@webstudio-is/react-sdk 0.206.0 → 0.208.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.
package/lib/index.js CHANGED
@@ -156,6 +156,7 @@ var showAttribute = "data-ws-show";
156
156
  var indexAttribute = "data-ws-index";
157
157
  var collapsedAttribute = "data-ws-collapsed";
158
158
  var textContentAttribute = "data-ws-text-content";
159
+ var animationCanPlayOnCanvasAttribute = "data-ws-animation-can-play-on-canvas";
159
160
  var attributeNameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
160
161
  var attributeNameChar = attributeNameStartChar + ":\\-0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
161
162
  var validAttributeNameRegex = new RegExp(
@@ -779,33 +780,33 @@ var generateWebstudioComponent = ({
779
780
  classesMap
780
781
  }) => {
781
782
  const instance = instances.get(rootInstanceId);
782
- if (instance === void 0) {
783
- return "";
784
- }
785
783
  const indexesWithinAncestors = getIndexesWithinAncestors(metas, instances, [
786
784
  rootInstanceId
787
785
  ]);
788
786
  const usedDataSources = /* @__PURE__ */ new Map();
789
- const generatedJsx = generateJsxElement({
790
- context: "expression",
791
- scope,
792
- instance,
793
- props,
794
- dataSources,
795
- usedDataSources,
796
- indexesWithinAncestors,
797
- classesMap,
798
- children: generateJsxChildren({
787
+ let generatedJsx = "<></>\n";
788
+ if (instance) {
789
+ generatedJsx = generateJsxElement({
790
+ context: "expression",
799
791
  scope,
800
- children: instance.children,
801
- instances,
792
+ instance,
802
793
  props,
803
794
  dataSources,
804
795
  usedDataSources,
805
796
  indexesWithinAncestors,
806
- classesMap
807
- })
808
- });
797
+ classesMap,
798
+ children: generateJsxChildren({
799
+ scope,
800
+ children: instance.children,
801
+ instances,
802
+ props,
803
+ dataSources,
804
+ usedDataSources,
805
+ indexesWithinAncestors,
806
+ classesMap
807
+ })
808
+ });
809
+ }
809
810
  let generatedProps = "";
810
811
  let generatedParameters = "";
811
812
  const uniqueParameters = new Set(
@@ -861,6 +862,7 @@ var generateWebstudioComponent = ({
861
862
  return generatedComponent;
862
863
  };
863
864
  export {
865
+ animationCanPlayOnCanvasAttribute,
864
866
  collapsedAttribute,
865
867
  componentAttribute,
866
868
  generateDataFromEmbedTemplate,
package/lib/runtime.js CHANGED
@@ -7,7 +7,8 @@ import {
7
7
  var ReactSdkContext = createContext({
8
8
  assetBaseUrl: "/",
9
9
  imageLoader: ({ src }) => src,
10
- resources: {}
10
+ resources: {},
11
+ breakpoints: []
11
12
  });
12
13
  var useResource = (name) => {
13
14
  const { resources } = useContext(ReactSdkContext);
@@ -22,5 +22,10 @@ export type Params = {
22
22
  export declare const ReactSdkContext: import("react").Context<Params & {
23
23
  imageLoader: ImageLoader;
24
24
  resources: Record<string, any>;
25
+ breakpoints: {
26
+ id: string;
27
+ minWidth?: number;
28
+ maxWidth?: number;
29
+ }[];
25
30
  }>;
26
31
  export declare const useResource: (name: string) => any;
@@ -394,6 +394,7 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
394
394
  };
395
395
  name?: string | undefined;
396
396
  description?: string | undefined;
397
+ enabled?: [string, boolean][] | undefined;
397
398
  }[];
398
399
  source?: "closest" | "nearest" | "root" | undefined;
399
400
  axis?: "block" | "x" | "inline" | "y" | undefined;
@@ -699,6 +700,7 @@ export declare const normalizeProps: ({ props, assetBaseUrl, assets, uploadingIm
699
700
  };
700
701
  name?: string | undefined;
701
702
  description?: string | undefined;
703
+ enabled?: [string, boolean][] | undefined;
702
704
  }[];
703
705
  subject?: string | undefined;
704
706
  axis?: "block" | "x" | "inline" | "y" | undefined;
@@ -740,4 +742,5 @@ export declare const showAttribute: "data-ws-show";
740
742
  export declare const indexAttribute: "data-ws-index";
741
743
  export declare const collapsedAttribute: "data-ws-collapsed";
742
744
  export declare const textContentAttribute: "data-ws-text-content";
745
+ export declare const animationCanPlayOnCanvasAttribute = "data-ws-animation-can-play-on-canvas";
743
746
  export declare const isAttributeNameSafe: (attributeName: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.206.0",
3
+ "version": "0.208.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -11,10 +11,10 @@
11
11
  "react": "18.3.0-canary-14898b6a9-20240318",
12
12
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
13
13
  "strip-indent": "^4.0.0",
14
- "type-fest": "^4.32.0",
15
- "vitest": "^3.0.4",
14
+ "type-fest": "^4.37.0",
15
+ "vitest": "^3.0.8",
16
16
  "zod": "^3.22.4",
17
- "@webstudio-is/template": "0.206.0",
17
+ "@webstudio-is/template": "0.208.0",
18
18
  "@webstudio-is/tsconfig": "1.0.7"
19
19
  },
20
20
  "peerDependencies": {
@@ -26,11 +26,11 @@
26
26
  "change-case": "^5.4.4",
27
27
  "html-tags": "^4.0.0",
28
28
  "nanoid": "^5.0.9",
29
- "@webstudio-is/css-engine": "0.206.0",
30
- "@webstudio-is/fonts": "0.206.0",
31
- "@webstudio-is/icons": "^0.206.0",
32
- "@webstudio-is/image": "0.206.0",
33
- "@webstudio-is/sdk": "0.206.0"
29
+ "@webstudio-is/css-engine": "0.208.0",
30
+ "@webstudio-is/fonts": "0.208.0",
31
+ "@webstudio-is/icons": "^0.208.0",
32
+ "@webstudio-is/image": "0.208.0",
33
+ "@webstudio-is/sdk": "0.208.0"
34
34
  },
35
35
  "exports": {
36
36
  ".": {
package/placeholder.d.ts CHANGED
@@ -11,6 +11,12 @@ declare module "__CLIENT__" {
11
11
 
12
12
  export const favIconAsset: string | undefined;
13
13
 
14
+ export const breakpoints: {
15
+ id: string;
16
+ minWidth?: number;
17
+ maxWidth?: number;
18
+ }[];
19
+
14
20
  // Font assets on current page (can be preloaded)
15
21
  export const pageFontAssets: string[];
16
22