@webstudio-is/react-sdk 0.0.0-588fe22 → 0.0.0-73cd6ea

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/runtime.js CHANGED
@@ -7,7 +7,12 @@ import {
7
7
  var ReactSdkContext = createContext({
8
8
  assetBaseUrl: "/",
9
9
  imageLoader: ({ src }) => src,
10
- resources: {}
10
+ videoLoader: ({ src }) => src,
11
+ resources: {},
12
+ breakpoints: [],
13
+ onError: (error) => {
14
+ console.error(error);
15
+ }
11
16
  });
12
17
  var useResource = (name) => {
13
18
  const { resources } = useContext(ReactSdkContext);
@@ -82,7 +87,8 @@ var PageSettingsMeta = ({
82
87
  host,
83
88
  siteName,
84
89
  pageMeta,
85
- imageLoader
90
+ imageLoader,
91
+ assetBaseUrl
86
92
  }) => {
87
93
  const metas = [];
88
94
  if (url !== void 0) {
@@ -124,7 +130,7 @@ var PageSettingsMeta = ({
124
130
  metas.push({
125
131
  property: "og:image",
126
132
  content: `https://${host}${imageLoader({
127
- src: pageMeta.socialImageAssetName,
133
+ src: `${assetBaseUrl}${pageMeta.socialImageAssetName}`,
128
134
  // Do not transform social image (not enough information do we need to do this)
129
135
  format: "raw"
130
136
  })}`
@@ -136,6 +142,12 @@ var PageSettingsMeta = ({
136
142
  });
137
143
  }
138
144
  metas.push(...pageMeta.custom);
145
+ const isTwitterCardSizeDefined = pageMeta.custom.some(
146
+ (meta) => meta.property === "twitter:card"
147
+ );
148
+ if ((pageMeta.socialImageAssetName !== void 0 || pageMeta.socialImageUrl !== void 0) && isTwitterCardSizeDefined === false) {
149
+ metas.push({ property: "twitter:card", content: "summary_large_image" });
150
+ }
139
151
  return metas.map((meta, index) => /* @__PURE__ */ jsx(Meta, { ...meta }, index));
140
152
  };
141
153
 
@@ -197,16 +209,12 @@ var PageSettingsCanonicalLink = (props) => {
197
209
 
198
210
  // src/runtime.ts
199
211
  var xmlNodeTagSuffix = "-ws-xml-node-fb77f896-8e96-40b9-b8f8-90a4e70d724a";
200
- var getIndexWithinAncestorFromComponentProps = (props) => {
201
- return props["data-ws-index"];
202
- };
203
212
  export {
204
213
  PageSettingsCanonicalLink,
205
214
  PageSettingsMeta,
206
215
  PageSettingsTitle,
207
216
  ReactSdkContext,
208
217
  getClosestInstance,
209
- getIndexWithinAncestorFromComponentProps,
210
218
  useResource,
211
219
  useVariableState,
212
220
  xmlNodeTagSuffix
@@ -0,0 +1,2 @@
1
+ export declare const standardAttributesToReactProps: Record<string, string>;
2
+ export declare const reactPropsToStandardAttributes: Record<string, string>;
@@ -1,8 +1,12 @@
1
- import type { Instances, Instance, Props, Scope, DataSources, Prop } from "@webstudio-is/sdk";
2
- import type { IndexesWithinAncestors } from "./instance-utils";
3
- export declare const generateJsxElement: ({ context, scope, instance, props, dataSources, usedDataSources, indexesWithinAncestors, children, classesMap, }: {
1
+ import type { Instances, Instance, Props, Scope, DataSources, Prop, WsComponentMeta, IndexesWithinAncestors } from "@webstudio-is/sdk";
2
+ export declare const generateJsxElement: ({ context, scope, metas, tagsOverrides, instance, props, dataSources, usedDataSources, indexesWithinAncestors, children, classesMap, }: {
4
3
  context?: "expression" | "jsx";
5
4
  scope: Scope;
5
+ metas: Map<Instance["component"], WsComponentMeta>;
6
+ /**
7
+ * Record<tag, componentDescriptor>
8
+ */
9
+ tagsOverrides?: Record<string, string>;
6
10
  instance: Instance;
7
11
  props: Props;
8
12
  dataSources: DataSources;
@@ -11,8 +15,10 @@ export declare const generateJsxElement: ({ context, scope, instance, props, dat
11
15
  children: string;
12
16
  classesMap?: Map<string, Array<string>>;
13
17
  }) => string;
14
- export declare const generateJsxChildren: ({ scope, children, instances, props, dataSources, usedDataSources, indexesWithinAncestors, classesMap, excludePlaceholders, }: {
18
+ export declare const generateJsxChildren: ({ scope, metas, tagsOverrides, children, instances, props, dataSources, usedDataSources, indexesWithinAncestors, classesMap, excludePlaceholders, }: {
15
19
  scope: Scope;
20
+ metas: Map<Instance["component"], WsComponentMeta>;
21
+ tagsOverrides?: Record<string, string>;
16
22
  children: Instance["children"];
17
23
  instances: Instances;
18
24
  props: Props;
@@ -22,7 +28,7 @@ export declare const generateJsxChildren: ({ scope, children, instances, props,
22
28
  classesMap?: Map<string, Array<string>>;
23
29
  excludePlaceholders?: boolean;
24
30
  }) => string;
25
- export declare const generateWebstudioComponent: ({ scope, name, rootInstanceId, parameters, instances, props, dataSources, indexesWithinAncestors, classesMap, }: {
31
+ export declare const generateWebstudioComponent: ({ scope, name, rootInstanceId, parameters, instances, props, dataSources, metas, tagsOverrides, classesMap, }: {
26
32
  scope: Scope;
27
33
  name: string;
28
34
  rootInstanceId: Instance["id"];
@@ -32,6 +38,10 @@ export declare const generateWebstudioComponent: ({ scope, name, rootInstanceId,
32
38
  instances: Instances;
33
39
  props: Props;
34
40
  dataSources: DataSources;
35
- indexesWithinAncestors: IndexesWithinAncestors;
36
41
  classesMap: Map<string, Array<string>>;
42
+ metas: Map<Instance["component"], WsComponentMeta>;
43
+ /**
44
+ * Record<tag, componentDescriptor>
45
+ */
46
+ tagsOverrides?: Record<string, string>;
37
47
  }) => string;
@@ -1,4 +1,4 @@
1
- import type { ImageLoader } from "@webstudio-is/image";
1
+ import type { ImageLoader, VideoLoader } from "@webstudio-is/image";
2
2
  export type Params = {
3
3
  /**
4
4
  * When rendering a published version, there is no renderer defined.
@@ -21,6 +21,13 @@ export type Params = {
21
21
  };
22
22
  export declare const ReactSdkContext: import("react").Context<Params & {
23
23
  imageLoader: ImageLoader;
24
+ videoLoader?: VideoLoader;
24
25
  resources: Record<string, any>;
26
+ breakpoints: {
27
+ id: string;
28
+ minWidth?: number;
29
+ maxWidth?: number;
30
+ }[];
31
+ onError: (error: unknown) => void;
25
32
  }>;
26
33
  export declare const useResource: (name: string) => any;
@@ -1,9 +1,9 @@
1
- import type { Instance, Prop } from "@webstudio-is/sdk";
2
- import type { IndexesWithinAncestors } from "./instance-utils";
1
+ import type { IndexesWithinAncestors, Instance, Prop } from "@webstudio-is/sdk";
3
2
  export type InstanceData = {
4
3
  id: Instance["id"];
5
4
  instanceKey: string;
6
5
  component: Instance["component"];
6
+ tag?: Instance["tag"];
7
7
  };
8
8
  /**
9
9
  * Hooks are subscriptions to builder events
@@ -1,9 +1,7 @@
1
1
  export * from "./remix";
2
- export * from "./css/index";
3
2
  export * from "./components/components-utils";
4
- export * from "./embed-template";
5
3
  export * from "./props";
6
4
  export type * from "./context";
7
- export { getIndexesWithinAncestors } from "./instance-utils";
8
5
  export type * from "./hook";
9
6
  export { generateWebstudioComponent, generateJsxElement, generateJsxChildren, } from "./component-generator";
7
+ export * from "./__generated__/standard-attributes";
@@ -1,10 +1,11 @@
1
1
  import type { ImageLoader } from "@webstudio-is/image";
2
2
  import type { PageMeta } from "@webstudio-is/sdk";
3
3
  export declare const isElementRenderedWithReact: (element: Element) => boolean;
4
- export declare const PageSettingsMeta: ({ url, host, siteName, pageMeta, imageLoader, }: {
4
+ export declare const PageSettingsMeta: ({ url, host, siteName, pageMeta, imageLoader, assetBaseUrl, }: {
5
5
  url?: string;
6
6
  host: string;
7
7
  siteName: string;
8
8
  pageMeta: PageMeta;
9
9
  imageLoader: ImageLoader;
10
+ assetBaseUrl: string;
10
11
  }) => import("react/jsx-runtime").JSX.Element[];