@webstudio-is/react-sdk 0.0.0-5844e28 → 0.0.0-7cb4145
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 +191 -553
- package/lib/runtime.js +14 -7
- package/lib/types/__generated__/standard-attributes.d.ts +2 -0
- package/lib/types/component-generator.d.ts +16 -6
- package/lib/types/context.d.ts +6 -0
- package/lib/types/hook.d.ts +2 -2
- package/lib/types/index.d.ts +1 -3
- package/lib/types/page-settings-meta.d.ts +2 -1
- package/lib/types/props.d.ts +1337 -8
- package/lib/types/runtime.d.ts +0 -1
- package/package.json +11 -11
- package/placeholder.d.ts +14 -11
- package/lib/types/css/css.d.ts +0 -20
- package/lib/types/css/css.test.d.ts +0 -1
- package/lib/types/css/global-rules.d.ts +0 -6
- package/lib/types/css/index.d.ts +0 -2
- package/lib/types/embed-template.d.ts +0 -54
- package/lib/types/embed-template.test.d.ts +0 -1
- package/lib/types/instance-utils.d.ts +0 -3
- package/lib/types/instance-utils.test.d.ts +0 -1
package/lib/runtime.js
CHANGED
|
@@ -7,7 +7,11 @@ import {
|
|
|
7
7
|
var ReactSdkContext = createContext({
|
|
8
8
|
assetBaseUrl: "/",
|
|
9
9
|
imageLoader: ({ src }) => src,
|
|
10
|
-
resources: {}
|
|
10
|
+
resources: {},
|
|
11
|
+
breakpoints: [],
|
|
12
|
+
onError: (error) => {
|
|
13
|
+
console.error(error);
|
|
14
|
+
}
|
|
11
15
|
});
|
|
12
16
|
var useResource = (name) => {
|
|
13
17
|
const { resources } = useContext(ReactSdkContext);
|
|
@@ -82,7 +86,8 @@ var PageSettingsMeta = ({
|
|
|
82
86
|
host,
|
|
83
87
|
siteName,
|
|
84
88
|
pageMeta,
|
|
85
|
-
imageLoader
|
|
89
|
+
imageLoader,
|
|
90
|
+
assetBaseUrl
|
|
86
91
|
}) => {
|
|
87
92
|
const metas = [];
|
|
88
93
|
if (url !== void 0) {
|
|
@@ -124,7 +129,7 @@ var PageSettingsMeta = ({
|
|
|
124
129
|
metas.push({
|
|
125
130
|
property: "og:image",
|
|
126
131
|
content: `https://${host}${imageLoader({
|
|
127
|
-
src: pageMeta.socialImageAssetName
|
|
132
|
+
src: `${assetBaseUrl}${pageMeta.socialImageAssetName}`,
|
|
128
133
|
// Do not transform social image (not enough information do we need to do this)
|
|
129
134
|
format: "raw"
|
|
130
135
|
})}`
|
|
@@ -136,6 +141,12 @@ var PageSettingsMeta = ({
|
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
143
|
metas.push(...pageMeta.custom);
|
|
144
|
+
const isTwitterCardSizeDefined = pageMeta.custom.some(
|
|
145
|
+
(meta) => meta.property === "twitter:card"
|
|
146
|
+
);
|
|
147
|
+
if ((pageMeta.socialImageAssetName !== void 0 || pageMeta.socialImageUrl !== void 0) && isTwitterCardSizeDefined === false) {
|
|
148
|
+
metas.push({ property: "twitter:card", content: "summary_large_image" });
|
|
149
|
+
}
|
|
139
150
|
return metas.map((meta, index) => /* @__PURE__ */ jsx(Meta, { ...meta }, index));
|
|
140
151
|
};
|
|
141
152
|
|
|
@@ -197,16 +208,12 @@ var PageSettingsCanonicalLink = (props) => {
|
|
|
197
208
|
|
|
198
209
|
// src/runtime.ts
|
|
199
210
|
var xmlNodeTagSuffix = "-ws-xml-node-fb77f896-8e96-40b9-b8f8-90a4e70d724a";
|
|
200
|
-
var getIndexWithinAncestorFromComponentProps = (props) => {
|
|
201
|
-
return props["data-ws-index"];
|
|
202
|
-
};
|
|
203
211
|
export {
|
|
204
212
|
PageSettingsCanonicalLink,
|
|
205
213
|
PageSettingsMeta,
|
|
206
214
|
PageSettingsTitle,
|
|
207
215
|
ReactSdkContext,
|
|
208
216
|
getClosestInstance,
|
|
209
|
-
getIndexWithinAncestorFromComponentProps,
|
|
210
217
|
useResource,
|
|
211
218
|
useVariableState,
|
|
212
219
|
xmlNodeTagSuffix
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { Instances, Instance, Props, Scope, DataSources, Prop } from "@webstudio-is/sdk";
|
|
2
|
-
|
|
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,
|
|
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;
|
package/lib/types/context.d.ts
CHANGED
|
@@ -22,5 +22,11 @@ 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
|
+
}[];
|
|
30
|
+
onError: (error: unknown) => void;
|
|
25
31
|
}>;
|
|
26
32
|
export declare const useResource: (name: string) => any;
|
package/lib/types/hook.d.ts
CHANGED
|
@@ -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
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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[];
|