@webiny/website-builder-sdk 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7
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/BindingsResolver.d.ts +4 -1
- package/BindingsResolver.js.map +1 -1
- package/ComponentInputTraverser.js +4 -0
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentResolver.d.ts +6 -3
- package/ComponentResolver.js +9 -4
- package/ComponentResolver.js.map +1 -1
- package/ContentSdk.d.ts +67 -1
- package/ContentSdk.js +90 -8
- package/ContentSdk.js.map +1 -1
- package/DocumentStoreManager.d.ts +9 -2
- package/DocumentStoreManager.js +24 -5
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +7 -1
- package/EditingSdk.js +5 -3
- package/EditingSdk.js.map +1 -1
- package/ElementFactory.js +7 -2
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.js +102 -0
- package/ElementFactory.test.js.map +1 -1
- package/LiveSdk.d.ts +3 -1
- package/LiveSdk.js +3 -2
- package/LiveSdk.js.map +1 -1
- package/PreviewDocument.d.ts +3 -1
- package/PreviewDocument.js +5 -2
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +4 -1
- package/PreviewSdk.js +6 -2
- package/PreviewSdk.js.map +1 -1
- package/ResizeObserver.js +1 -1
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.js +3 -2
- package/StylesBindingsProcessor.js.map +1 -1
- package/Theme.js +2 -1
- package/Theme.js.map +1 -1
- package/asset/deliveryUrl.d.ts +41 -0
- package/asset/deliveryUrl.js +34 -0
- package/asset/deliveryUrl.js.map +1 -0
- package/asset/deliveryUrl.test.d.ts +1 -0
- package/asset/deliveryUrl.test.js +127 -0
- package/asset/deliveryUrl.test.js.map +1 -0
- package/asset/geometry.d.ts +7 -0
- package/asset/geometry.js +10 -0
- package/asset/geometry.js.map +1 -0
- package/asset/imageSrcSet.d.ts +63 -0
- package/asset/imageSrcSet.js +98 -0
- package/asset/imageSrcSet.js.map +1 -0
- package/asset/imageSrcSet.test.d.ts +1 -0
- package/asset/imageSrcSet.test.js +103 -0
- package/asset/imageSrcSet.test.js.map +1 -0
- package/asset/index.d.ts +5 -0
- package/asset/index.js +5 -0
- package/asset/normalize.d.ts +24 -0
- package/asset/normalize.js +106 -0
- package/asset/normalize.js.map +1 -0
- package/asset/normalize.test.d.ts +1 -0
- package/asset/normalize.test.js +263 -0
- package/asset/normalize.test.js.map +1 -0
- package/asset/types.d.ts +2 -0
- package/asset/types.js +0 -0
- package/componentLoader/ComponentLoader.d.ts +16 -0
- package/componentLoader/ComponentLoader.js +0 -0
- package/componentLoader/RegistryOnlyComponentLoader.d.ts +9 -0
- package/componentLoader/RegistryOnlyComponentLoader.js +8 -0
- package/componentLoader/RegistryOnlyComponentLoader.js.map +1 -0
- package/componentLoader/createComponentLoader.d.ts +7 -0
- package/componentLoader/createComponentLoader.js +10 -0
- package/componentLoader/createComponentLoader.js.map +1 -0
- package/componentLoader/defaultComponentLoader.d.ts +7 -0
- package/componentLoader/defaultComponentLoader.js +8 -0
- package/componentLoader/defaultComponentLoader.js.map +1 -0
- package/componentLoader/index.d.ts +3 -0
- package/componentLoader/index.js +3 -0
- package/contentClientState.test.d.ts +1 -0
- package/contentClientState.test.js +384 -0
- package/contentClientState.test.js.map +1 -0
- package/contentEntry/ContentEntryBindingsResolver.d.ts +33 -0
- package/contentEntry/ContentEntryBindingsResolver.js +52 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +49 -0
- package/contentEntry/ContentEntryCache.js +51 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createComponent.d.ts +5 -0
- package/createComponent.js +32 -0
- package/createComponent.js.map +1 -0
- package/createContentClient.d.ts +17 -0
- package/createContentClient.js +16 -0
- package/createContentClient.js.map +1 -0
- package/createContentClient.test.d.ts +1 -0
- package/createContentClient.test.js +165 -0
- package/createContentClient.test.js.map +1 -0
- package/createInput.d.ts +10 -2
- package/createInput.js +8 -1
- package/createInput.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +10 -5
- package/dataProviders/ApiClient.js +10 -10
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/DefaultDataProvider.d.ts +4 -0
- package/dataProviders/DefaultDataProvider.js +35 -0
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +2 -0
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +2 -0
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
- package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
- package/dataProviders/NullDataProvider.d.ts +4 -0
- package/dataProviders/NullDataProvider.js +9 -0
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/queries.test.d.ts +1 -0
- package/dataProviders/queries.test.js +45 -0
- package/dataProviders/queries.test.js.map +1 -0
- package/defaultBreakpoints.js +23 -3
- package/defaultBreakpoints.js.map +1 -1
- package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
- package/experiments/PostHogAnalyticsProvider.js +28 -0
- package/experiments/PostHogAnalyticsProvider.js.map +1 -0
- package/experiments/analyticsProvider.d.ts +4 -0
- package/experiments/analyticsProvider.js +11 -0
- package/experiments/analyticsProvider.js.map +1 -0
- package/experiments/bucketing.d.ts +27 -0
- package/experiments/bucketing.js +91 -0
- package/experiments/bucketing.js.map +1 -0
- package/experiments/bucketing.test.d.ts +1 -0
- package/experiments/bucketing.test.js +183 -0
- package/experiments/bucketing.test.js.map +1 -0
- package/experiments/index.d.ts +5 -0
- package/experiments/index.js +5 -0
- package/experiments/render.d.ts +82 -0
- package/experiments/render.js +149 -0
- package/experiments/render.js.map +1 -0
- package/experiments/types.d.ts +108 -0
- package/experiments/types.js +4 -0
- package/experiments/types.js.map +1 -0
- package/headersProvider.d.ts +1 -2
- package/headersProvider.js.map +1 -1
- package/image/geometry.d.ts +54 -0
- package/image/geometry.js +112 -0
- package/image/geometry.js.map +1 -0
- package/image/geometry.test.d.ts +1 -0
- package/image/geometry.test.js +190 -0
- package/image/geometry.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/image/presets.d.ts +6 -0
- package/image/presets.js +20 -0
- package/image/presets.js.map +1 -0
- package/image/types.d.ts +10 -0
- package/image/types.js +0 -0
- package/index.d.ts +12 -0
- package/index.js +12 -0
- package/jsonPatch.js +3 -3
- package/package.json +7 -6
- package/types/WebsiteBuilderTheme.d.ts +5 -0
- package/types.d.ts +75 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { getCropRect, getImageRenderData, getVisibleRect, resolveAssetImage } from "./geometry.js";
|
|
3
|
+
const geometry_test_image = (overrides)=>({
|
|
4
|
+
width: 1000,
|
|
5
|
+
height: 1000,
|
|
6
|
+
...overrides
|
|
7
|
+
});
|
|
8
|
+
describe("resolveAssetImage", ()=>{
|
|
9
|
+
it("prefers the override per property, falling back to the asset default", ()=>{
|
|
10
|
+
const assetDefault = {
|
|
11
|
+
crop: {
|
|
12
|
+
top: 0.1,
|
|
13
|
+
left: 0.1,
|
|
14
|
+
bottom: 0.1,
|
|
15
|
+
right: 0.1
|
|
16
|
+
},
|
|
17
|
+
focalPoint: {
|
|
18
|
+
x: 0.2,
|
|
19
|
+
y: 0.2
|
|
20
|
+
},
|
|
21
|
+
alt: "default alt",
|
|
22
|
+
caption: "default caption"
|
|
23
|
+
};
|
|
24
|
+
const override = {
|
|
25
|
+
focalPoint: {
|
|
26
|
+
x: 0.8,
|
|
27
|
+
y: 0.8
|
|
28
|
+
},
|
|
29
|
+
alt: "override alt"
|
|
30
|
+
};
|
|
31
|
+
const result = resolveAssetImage(override, assetDefault);
|
|
32
|
+
expect(result.crop).toEqual(assetDefault.crop);
|
|
33
|
+
expect(result.caption).toBe("default caption");
|
|
34
|
+
expect(result.focalPoint).toEqual(override.focalPoint);
|
|
35
|
+
expect(result.alt).toBe("override alt");
|
|
36
|
+
});
|
|
37
|
+
it("handles null/undefined inputs", ()=>{
|
|
38
|
+
expect(resolveAssetImage(null, null)).toEqual({
|
|
39
|
+
crop: void 0,
|
|
40
|
+
focalPoint: void 0,
|
|
41
|
+
alt: void 0,
|
|
42
|
+
caption: void 0
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("getCropRect", ()=>{
|
|
47
|
+
it("returns the full image when no crop is set", ()=>{
|
|
48
|
+
expect(getCropRect()).toEqual({
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0,
|
|
51
|
+
width: 1,
|
|
52
|
+
height: 1
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it("converts edge insets into a rectangle", ()=>{
|
|
56
|
+
const rect = getCropRect({
|
|
57
|
+
top: 0.1,
|
|
58
|
+
left: 0.2,
|
|
59
|
+
bottom: 0.3,
|
|
60
|
+
right: 0.05
|
|
61
|
+
});
|
|
62
|
+
expect(rect.x).toBeCloseTo(0.2, 10);
|
|
63
|
+
expect(rect.y).toBeCloseTo(0.1, 10);
|
|
64
|
+
expect(rect.width).toBeCloseTo(0.75, 10);
|
|
65
|
+
expect(rect.height).toBeCloseTo(0.6, 10);
|
|
66
|
+
});
|
|
67
|
+
it("does not produce negative dimensions when insets overlap", ()=>{
|
|
68
|
+
const rect = getCropRect({
|
|
69
|
+
top: 0.7,
|
|
70
|
+
left: 0.7,
|
|
71
|
+
bottom: 0.7,
|
|
72
|
+
right: 0.7
|
|
73
|
+
});
|
|
74
|
+
expect(rect.width).toBe(0);
|
|
75
|
+
expect(rect.height).toBe(0);
|
|
76
|
+
});
|
|
77
|
+
it("clamps out-of-range values", ()=>{
|
|
78
|
+
const rect = getCropRect({
|
|
79
|
+
top: -1,
|
|
80
|
+
left: 2,
|
|
81
|
+
bottom: 0,
|
|
82
|
+
right: 0
|
|
83
|
+
});
|
|
84
|
+
expect(rect.x).toBe(1);
|
|
85
|
+
expect(rect.y).toBe(0);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe("getVisibleRect", ()=>{
|
|
89
|
+
it("returns the crop rect when no aspect ratio is requested", ()=>{
|
|
90
|
+
const rect = getVisibleRect(geometry_test_image({
|
|
91
|
+
crop: {
|
|
92
|
+
top: 0.1,
|
|
93
|
+
left: 0.1,
|
|
94
|
+
bottom: 0.1,
|
|
95
|
+
right: 0.1
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
expect(rect).toEqual({
|
|
99
|
+
x: 0.1,
|
|
100
|
+
y: 0.1,
|
|
101
|
+
width: 0.8,
|
|
102
|
+
height: 0.8
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
it("fits a 16:9 rect inside a square image, centered by default", ()=>{
|
|
106
|
+
const rect = getVisibleRect(geometry_test_image(), 16 / 9);
|
|
107
|
+
expect(rect.width).toBeCloseTo(1, 5);
|
|
108
|
+
expect(rect.height).toBeCloseTo(0.5625, 5);
|
|
109
|
+
expect(rect.y).toBeCloseTo(0.21875, 5);
|
|
110
|
+
expect(rect.x).toBeCloseTo(0, 5);
|
|
111
|
+
});
|
|
112
|
+
it("shifts the visible rect toward the focal point and clamps to bounds", ()=>{
|
|
113
|
+
const rect = getVisibleRect(geometry_test_image({
|
|
114
|
+
focalPoint: {
|
|
115
|
+
x: 0.5,
|
|
116
|
+
y: 0.05
|
|
117
|
+
}
|
|
118
|
+
}), 16 / 9);
|
|
119
|
+
expect(rect.y).toBeCloseTo(0, 5);
|
|
120
|
+
});
|
|
121
|
+
it("keeps the visible rect within the crop rectangle", ()=>{
|
|
122
|
+
const rect = getVisibleRect(geometry_test_image({
|
|
123
|
+
crop: {
|
|
124
|
+
top: 0.25,
|
|
125
|
+
left: 0,
|
|
126
|
+
bottom: 0.25,
|
|
127
|
+
right: 0
|
|
128
|
+
},
|
|
129
|
+
focalPoint: {
|
|
130
|
+
x: 0.5,
|
|
131
|
+
y: 0.9
|
|
132
|
+
}
|
|
133
|
+
}), 1);
|
|
134
|
+
expect(rect.y).toBeGreaterThanOrEqual(0.25 - 1e-9);
|
|
135
|
+
expect(rect.y + rect.height).toBeLessThanOrEqual(0.75 + 1e-9);
|
|
136
|
+
});
|
|
137
|
+
it("accepts an explicit width/height aspect ratio", ()=>{
|
|
138
|
+
const byObject = getVisibleRect(geometry_test_image(), {
|
|
139
|
+
width: 16,
|
|
140
|
+
height: 9
|
|
141
|
+
});
|
|
142
|
+
const byNumber = getVisibleRect(geometry_test_image(), 16 / 9);
|
|
143
|
+
expect(byObject).toEqual(byNumber);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe("getImageRenderData", ()=>{
|
|
147
|
+
it("derives objectPosition from the focal point", ()=>{
|
|
148
|
+
const data = getImageRenderData(geometry_test_image({
|
|
149
|
+
focalPoint: {
|
|
150
|
+
x: 0.25,
|
|
151
|
+
y: 0.75
|
|
152
|
+
}
|
|
153
|
+
}), 1);
|
|
154
|
+
expect(data.objectPosition).toBe("25% 75%");
|
|
155
|
+
});
|
|
156
|
+
it("produces an overflow-hidden container with the requested aspect ratio", ()=>{
|
|
157
|
+
const data = getImageRenderData(geometry_test_image(), 16 / 9);
|
|
158
|
+
expect(data.container.overflow).toBe("hidden");
|
|
159
|
+
expect(data.container.aspectRatio).toBe(`${Math.round(16 / 9 * 1000) / 1000}`);
|
|
160
|
+
});
|
|
161
|
+
it("scales and offsets the image so the visible rect fills the container", ()=>{
|
|
162
|
+
const data = getImageRenderData(geometry_test_image(), 16 / 9);
|
|
163
|
+
expect(data.image.width).toBe("100%");
|
|
164
|
+
expect(data.image.height).toBe(`${Math.round(100 / 0.5625 * 1000) / 1000}%`);
|
|
165
|
+
expect(parseFloat(data.image.left)).toBe(0);
|
|
166
|
+
expect(parseFloat(data.image.top)).toBeLessThan(0);
|
|
167
|
+
});
|
|
168
|
+
it("stays finite for a degenerate (collapsed) crop", ()=>{
|
|
169
|
+
const data = getImageRenderData(geometry_test_image({
|
|
170
|
+
crop: {
|
|
171
|
+
top: 0.7,
|
|
172
|
+
left: 0.7,
|
|
173
|
+
bottom: 0.7,
|
|
174
|
+
right: 0.7
|
|
175
|
+
}
|
|
176
|
+
}), 1);
|
|
177
|
+
expect(Number.isFinite(parseFloat(data.image.width))).toBe(true);
|
|
178
|
+
expect(Number.isFinite(parseFloat(data.image.height))).toBe(true);
|
|
179
|
+
});
|
|
180
|
+
it("passes through intrinsic dimensions", ()=>{
|
|
181
|
+
const data = getImageRenderData(geometry_test_image({
|
|
182
|
+
width: 1920,
|
|
183
|
+
height: 1080
|
|
184
|
+
}), 16 / 9);
|
|
185
|
+
expect(data.intrinsicWidth).toBe(1920);
|
|
186
|
+
expect(data.intrinsicHeight).toBe(1080);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=geometry.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image/geometry.test.js","sources":["../../src/image/geometry.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { getCropRect, getImageRenderData, getVisibleRect, resolveAssetImage } from \"./geometry.js\";\nimport type { AssetImage } from \"@webiny/sdk\";\n\nconst image = (overrides?: Partial<AssetImage>): AssetImage => ({\n width: 1000,\n height: 1000,\n ...overrides\n});\n\ndescribe(\"resolveAssetImage\", () => {\n it(\"prefers the override per property, falling back to the asset default\", () => {\n const assetDefault: AssetImage = {\n crop: { top: 0.1, left: 0.1, bottom: 0.1, right: 0.1 },\n focalPoint: { x: 0.2, y: 0.2 },\n alt: \"default alt\",\n caption: \"default caption\"\n };\n const override: AssetImage = {\n focalPoint: { x: 0.8, y: 0.8 },\n alt: \"override alt\"\n };\n\n const result = resolveAssetImage(override, assetDefault);\n\n expect(result.crop).toEqual(assetDefault.crop);\n expect(result.caption).toBe(\"default caption\");\n expect(result.focalPoint).toEqual(override.focalPoint);\n expect(result.alt).toBe(\"override alt\");\n });\n\n it(\"handles null/undefined inputs\", () => {\n expect(resolveAssetImage(null, null)).toEqual({\n crop: undefined,\n focalPoint: undefined,\n alt: undefined,\n caption: undefined\n });\n });\n});\n\ndescribe(\"getCropRect\", () => {\n it(\"returns the full image when no crop is set\", () => {\n expect(getCropRect()).toEqual({ x: 0, y: 0, width: 1, height: 1 });\n });\n\n it(\"converts edge insets into a rectangle\", () => {\n const rect = getCropRect({ top: 0.1, left: 0.2, bottom: 0.3, right: 0.05 });\n expect(rect.x).toBeCloseTo(0.2, 10);\n expect(rect.y).toBeCloseTo(0.1, 10);\n expect(rect.width).toBeCloseTo(0.75, 10);\n expect(rect.height).toBeCloseTo(0.6, 10);\n });\n\n it(\"does not produce negative dimensions when insets overlap\", () => {\n const rect = getCropRect({ top: 0.7, left: 0.7, bottom: 0.7, right: 0.7 });\n expect(rect.width).toBe(0);\n expect(rect.height).toBe(0);\n });\n\n it(\"clamps out-of-range values\", () => {\n const rect = getCropRect({ top: -1, left: 2, bottom: 0, right: 0 });\n expect(rect.x).toBe(1);\n expect(rect.y).toBe(0);\n });\n});\n\ndescribe(\"getVisibleRect\", () => {\n it(\"returns the crop rect when no aspect ratio is requested\", () => {\n const rect = getVisibleRect(\n image({ crop: { top: 0.1, left: 0.1, bottom: 0.1, right: 0.1 } })\n );\n expect(rect).toEqual({ x: 0.1, y: 0.1, width: 0.8, height: 0.8 });\n });\n\n it(\"fits a 16:9 rect inside a square image, centered by default\", () => {\n const rect = getVisibleRect(image(), 16 / 9);\n expect(rect.width).toBeCloseTo(1, 5);\n expect(rect.height).toBeCloseTo(0.5625, 5);\n expect(rect.y).toBeCloseTo((1 - 0.5625) / 2, 5);\n expect(rect.x).toBeCloseTo(0, 5);\n });\n\n it(\"shifts the visible rect toward the focal point and clamps to bounds\", () => {\n const rect = getVisibleRect(image({ focalPoint: { x: 0.5, y: 0.05 } }), 16 / 9);\n expect(rect.y).toBeCloseTo(0, 5);\n });\n\n it(\"keeps the visible rect within the crop rectangle\", () => {\n const rect = getVisibleRect(\n image({\n crop: { top: 0.25, left: 0, bottom: 0.25, right: 0 },\n focalPoint: { x: 0.5, y: 0.9 }\n }),\n 1\n );\n expect(rect.y).toBeGreaterThanOrEqual(0.25 - 1e-9);\n expect(rect.y + rect.height).toBeLessThanOrEqual(0.75 + 1e-9);\n });\n\n it(\"accepts an explicit width/height aspect ratio\", () => {\n const byObject = getVisibleRect(image(), { width: 16, height: 9 });\n const byNumber = getVisibleRect(image(), 16 / 9);\n expect(byObject).toEqual(byNumber);\n });\n});\n\ndescribe(\"getImageRenderData\", () => {\n it(\"derives objectPosition from the focal point\", () => {\n const data = getImageRenderData(image({ focalPoint: { x: 0.25, y: 0.75 } }), 1);\n expect(data.objectPosition).toBe(\"25% 75%\");\n });\n\n it(\"produces an overflow-hidden container with the requested aspect ratio\", () => {\n const data = getImageRenderData(image(), 16 / 9);\n expect(data.container.overflow).toBe(\"hidden\");\n expect(data.container.aspectRatio).toBe(`${Math.round((16 / 9) * 1000) / 1000}`);\n });\n\n it(\"scales and offsets the image so the visible rect fills the container\", () => {\n const data = getImageRenderData(image(), 16 / 9);\n expect(data.image.width).toBe(\"100%\");\n expect(data.image.height).toBe(`${Math.round((100 / 0.5625) * 1000) / 1000}%`);\n expect(parseFloat(data.image.left)).toBe(0);\n expect(parseFloat(data.image.top)).toBeLessThan(0);\n });\n\n it(\"stays finite for a degenerate (collapsed) crop\", () => {\n const data = getImageRenderData(\n image({ crop: { top: 0.7, left: 0.7, bottom: 0.7, right: 0.7 } }),\n 1\n );\n expect(Number.isFinite(parseFloat(data.image.width))).toBe(true);\n expect(Number.isFinite(parseFloat(data.image.height))).toBe(true);\n });\n\n it(\"passes through intrinsic dimensions\", () => {\n const data = getImageRenderData(image({ width: 1920, height: 1080 }), 16 / 9);\n expect(data.intrinsicWidth).toBe(1920);\n expect(data.intrinsicHeight).toBe(1080);\n });\n});\n"],"names":["image","overrides","describe","it","assetDefault","override","result","resolveAssetImage","expect","undefined","getCropRect","rect","getVisibleRect","byObject","byNumber","data","getImageRenderData","Math","parseFloat","Number"],"mappings":";;AAIA,MAAMA,sBAAQ,CAACC,YAAiD;QAC5D,OAAO;QACP,QAAQ;QACR,GAAGA,SAAS;IAChB;AAEAC,SAAS,qBAAqB;IAC1BC,GAAG,wEAAwE;QACvE,MAAMC,eAA2B;YAC7B,MAAM;gBAAE,KAAK;gBAAK,MAAM;gBAAK,QAAQ;gBAAK,OAAO;YAAI;YACrD,YAAY;gBAAE,GAAG;gBAAK,GAAG;YAAI;YAC7B,KAAK;YACL,SAAS;QACb;QACA,MAAMC,WAAuB;YACzB,YAAY;gBAAE,GAAG;gBAAK,GAAG;YAAI;YAC7B,KAAK;QACT;QAEA,MAAMC,SAASC,kBAAkBF,UAAUD;QAE3CI,OAAOF,OAAO,IAAI,EAAE,OAAO,CAACF,aAAa,IAAI;QAC7CI,OAAOF,OAAO,OAAO,EAAE,IAAI,CAAC;QAC5BE,OAAOF,OAAO,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
|
|
|
1
|
+
import type { AspectRatioPreset } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default aspect ratios shown in the image editor's preview strip.
|
|
4
|
+
* A later phase will let a field lock to one of these (or a custom ratio).
|
|
5
|
+
*/
|
|
6
|
+
export declare const ASPECT_RATIO_PRESETS: AspectRatioPreset[];
|
package/image/presets.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const ASPECT_RATIO_PRESETS = [
|
|
2
|
+
{
|
|
3
|
+
id: "square",
|
|
4
|
+
label: "Square",
|
|
5
|
+
ratio: 1
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "4:3",
|
|
9
|
+
label: "4:3",
|
|
10
|
+
ratio: 4 / 3
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "16:9",
|
|
14
|
+
label: "16:9",
|
|
15
|
+
ratio: 16 / 9
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
export { ASPECT_RATIO_PRESETS };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image/presets.js","sources":["../../src/image/presets.ts"],"sourcesContent":["import type { AspectRatioPreset } from \"./types.js\";\n\n/**\n * Default aspect ratios shown in the image editor's preview strip.\n * A later phase will let a field lock to one of these (or a custom ratio).\n */\nexport const ASPECT_RATIO_PRESETS: AspectRatioPreset[] = [\n { id: \"square\", label: \"Square\", ratio: 1 },\n { id: \"4:3\", label: \"4:3\", ratio: 4 / 3 },\n { id: \"16:9\", label: \"16:9\", ratio: 16 / 9 }\n];\n"],"names":["ASPECT_RATIO_PRESETS"],"mappings":"AAMO,MAAMA,uBAA4C;IACrD;QAAE,IAAI;QAAU,OAAO;QAAU,OAAO;IAAE;IAC1C;QAAE,IAAI;QAAO,OAAO;QAAO,OAAO,IAAI;IAAE;IACxC;QAAE,IAAI;QAAQ,OAAO;QAAQ,OAAO,KAAK;IAAE;CAC9C"}
|
package/image/types.d.ts
ADDED
package/image/types.js
ADDED
|
File without changes
|
package/index.d.ts
CHANGED
|
@@ -3,17 +3,27 @@ export * from "./EditingSdk.js";
|
|
|
3
3
|
export * from "./LiveSdk.js";
|
|
4
4
|
export * from "./NullSdk.js";
|
|
5
5
|
export * from "./ContentSdk.js";
|
|
6
|
+
export * from "./createContentClient.js";
|
|
6
7
|
export * from "./Environment.js";
|
|
7
8
|
export * from "./DocumentStore.js";
|
|
8
9
|
export * from "./Logger.js";
|
|
9
10
|
export * from "./FunctionConverter.js";
|
|
10
11
|
export * from "./createInput.js";
|
|
12
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
14
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
15
|
+
export * from "./createComponent.js";
|
|
16
|
+
export * from "./image/index.js";
|
|
17
|
+
export * from "./asset/index.js";
|
|
11
18
|
export * from "./MouseTracker.js";
|
|
12
19
|
export * from "./ViewportManager.js";
|
|
13
20
|
export * from "./messenger/Messenger.js";
|
|
14
21
|
export * from "./messenger/MessageOrigin.js";
|
|
15
22
|
export type * from "./types.js";
|
|
16
23
|
export * from "./DocumentStoreManager.js";
|
|
24
|
+
export * from "./ComponentRegistry.js";
|
|
25
|
+
export * from "./componentLoader/index.js";
|
|
26
|
+
export * from "./dataProviders/ApiClient.js";
|
|
17
27
|
export * from "./BindingsProcessor.js";
|
|
18
28
|
export * from "./ResizeObserver.js";
|
|
19
29
|
export * from "./BindingsResolver.js";
|
|
@@ -21,6 +31,7 @@ export * from "./createElement.js";
|
|
|
21
31
|
export * from "./registerComponentGroup.js";
|
|
22
32
|
export * from "./jsonPatch.js";
|
|
23
33
|
export * from "./headersProvider.js";
|
|
34
|
+
export * from "./experiments/index.js";
|
|
24
35
|
export * from "./ComponentManifestToAstConverter.js";
|
|
25
36
|
export * from "./findMatchingAstNode.js";
|
|
26
37
|
export * from "./InheritanceProcessor.js";
|
|
@@ -28,4 +39,5 @@ export * from "./InputBindingsProcessor.js";
|
|
|
28
39
|
export * from "./StylesBindingsProcessor.js";
|
|
29
40
|
export * from "./ElementFactory.js";
|
|
30
41
|
export * from "./ConstraintEvaluator.js";
|
|
42
|
+
export * from "./generateElementId.js";
|
|
31
43
|
export { StyleSettings } from "./constants.js";
|
package/index.js
CHANGED
|
@@ -3,16 +3,26 @@ export * from "./EditingSdk.js";
|
|
|
3
3
|
export * from "./LiveSdk.js";
|
|
4
4
|
export * from "./NullSdk.js";
|
|
5
5
|
export * from "./ContentSdk.js";
|
|
6
|
+
export * from "./createContentClient.js";
|
|
6
7
|
export * from "./Environment.js";
|
|
7
8
|
export * from "./DocumentStore.js";
|
|
8
9
|
export * from "./Logger.js";
|
|
9
10
|
export * from "./FunctionConverter.js";
|
|
10
11
|
export * from "./createInput.js";
|
|
12
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
14
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
15
|
+
export * from "./createComponent.js";
|
|
16
|
+
export * from "./image/index.js";
|
|
17
|
+
export * from "./asset/index.js";
|
|
11
18
|
export * from "./MouseTracker.js";
|
|
12
19
|
export * from "./ViewportManager.js";
|
|
13
20
|
export * from "./messenger/Messenger.js";
|
|
14
21
|
export * from "./messenger/MessageOrigin.js";
|
|
15
22
|
export * from "./DocumentStoreManager.js";
|
|
23
|
+
export * from "./ComponentRegistry.js";
|
|
24
|
+
export * from "./componentLoader/index.js";
|
|
25
|
+
export * from "./dataProviders/ApiClient.js";
|
|
16
26
|
export * from "./BindingsProcessor.js";
|
|
17
27
|
export * from "./ResizeObserver.js";
|
|
18
28
|
export * from "./BindingsResolver.js";
|
|
@@ -20,6 +30,7 @@ export * from "./createElement.js";
|
|
|
20
30
|
export * from "./registerComponentGroup.js";
|
|
21
31
|
export * from "./jsonPatch.js";
|
|
22
32
|
export * from "./headersProvider.js";
|
|
33
|
+
export * from "./experiments/index.js";
|
|
23
34
|
export * from "./ComponentManifestToAstConverter.js";
|
|
24
35
|
export * from "./findMatchingAstNode.js";
|
|
25
36
|
export * from "./InheritanceProcessor.js";
|
|
@@ -27,4 +38,5 @@ export * from "./InputBindingsProcessor.js";
|
|
|
27
38
|
export * from "./StylesBindingsProcessor.js";
|
|
28
39
|
export * from "./ElementFactory.js";
|
|
29
40
|
export * from "./ConstraintEvaluator.js";
|
|
41
|
+
export * from "./generateElementId.js";
|
|
30
42
|
export { StyleSettings } from "./constants.js";
|
package/jsonPatch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __rspack_external_fast_json_patch_index_mjs_25f05694 from "fast-json-patch/index.mjs";
|
|
2
2
|
const jsonPatch = {
|
|
3
|
-
compare: (tree1, tree2, invertible)=>
|
|
4
|
-
applyPatch: (document, patch, validateOperation, mutateDocument, banPrototypeModifications)=>
|
|
3
|
+
compare: (tree1, tree2, invertible)=>__rspack_external_fast_json_patch_index_mjs_25f05694.compare(tree1, tree2, invertible),
|
|
4
|
+
applyPatch: (document, patch, validateOperation, mutateDocument, banPrototypeModifications)=>__rspack_external_fast_json_patch_index_mjs_25f05694.applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications)
|
|
5
5
|
};
|
|
6
6
|
export { jsonPatch };
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7c2def32a7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"author": "Pavel Denisjuk",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@webiny/sdk": "0.0.0-unstable.7c2def32a7",
|
|
15
16
|
"csstype": "3.2.3",
|
|
16
17
|
"deep-equal": "2.2.3",
|
|
17
18
|
"deepmerge": "4.3.1",
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
"is-hotkey": "0.2.0",
|
|
21
22
|
"lodash": "4.18.1",
|
|
22
23
|
"matcher": "6.0.0",
|
|
23
|
-
"mobx": "
|
|
24
|
-
"nanoid": "
|
|
24
|
+
"mobx": "7.0.3",
|
|
25
|
+
"nanoid": "6.0.1",
|
|
25
26
|
"nanoid-dictionary": "5.0.0",
|
|
26
27
|
"pino": "10.3.1",
|
|
27
28
|
"pino-pretty": "13.1.3"
|
|
@@ -29,9 +30,9 @@
|
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/deep-equal": "1.0.4",
|
|
31
32
|
"@types/is-hotkey": "0.1.10",
|
|
32
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
33
|
-
"typescript": "
|
|
34
|
-
"vitest": "4.1.
|
|
33
|
+
"@webiny/build-tools": "0.0.0-unstable.7c2def32a7",
|
|
34
|
+
"typescript": "7.0.2",
|
|
35
|
+
"vitest": "4.1.11"
|
|
35
36
|
},
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
|
@@ -13,6 +13,7 @@ export type WebsiteBuilderTheme = {
|
|
|
13
13
|
colors: ColorStyle[];
|
|
14
14
|
fontSizes?: FontSizes;
|
|
15
15
|
typography: Typography;
|
|
16
|
+
allowCustomColors?: boolean;
|
|
16
17
|
};
|
|
17
18
|
type KnownKeys = "desktop" | "tablet" | "mobile";
|
|
18
19
|
type BreakpointBase = Omit<Breakpoint, "name">;
|
|
@@ -92,5 +93,9 @@ export type WebsiteBuilderThemeInput = {
|
|
|
92
93
|
* ]
|
|
93
94
|
*/
|
|
94
95
|
typography?: Typography;
|
|
96
|
+
/**
|
|
97
|
+
* Allow custom color selection (ChromePicker) in the Lexical editor's font color toolbar action.
|
|
98
|
+
*/
|
|
99
|
+
allowCustomColors?: boolean;
|
|
95
100
|
};
|
|
96
101
|
export {};
|
package/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { BindingsApi } from "./BindingsApi.js";
|
|
|
3
3
|
import type { ShorthandCssProperties } from "./types/ShorthandCssProperties.js";
|
|
4
4
|
import type { InputFactory } from "./createInput.js";
|
|
5
5
|
import type { Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
6
|
+
import type { ActiveExperiment, VariantContent } from "./experiments/types.js";
|
|
6
7
|
export type { WebsiteBuilderTheme, Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
7
8
|
type CSSProperties = CSS.Properties<string | number>;
|
|
8
9
|
export type ElementMap = Record<string, DocumentElement>;
|
|
@@ -77,6 +78,7 @@ export type ComponentGroup = {
|
|
|
77
78
|
name: string;
|
|
78
79
|
label: string;
|
|
79
80
|
description?: string;
|
|
81
|
+
icon?: string;
|
|
80
82
|
filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;
|
|
81
83
|
};
|
|
82
84
|
export type ResponsiveStyles = {
|
|
@@ -197,6 +199,7 @@ export type ComponentManifest = {
|
|
|
197
199
|
hideFromToolbar?: boolean;
|
|
198
200
|
hideStyleSettings?: string[];
|
|
199
201
|
autoApplyStyles?: boolean;
|
|
202
|
+
applyDefaultStyles?: boolean;
|
|
200
203
|
tags: string[];
|
|
201
204
|
constraints?: ComponentConstraint[];
|
|
202
205
|
descendantConstraints?: ComponentConstraint[];
|
|
@@ -230,6 +233,7 @@ export type DocumentElement = {
|
|
|
230
233
|
export type SerializableCSSStyleDeclaration = {
|
|
231
234
|
[K in keyof CssProperties]?: CssProperties[K];
|
|
232
235
|
};
|
|
236
|
+
export type DocumentCache = Record<string, unknown>;
|
|
233
237
|
export type Document = {
|
|
234
238
|
id: string;
|
|
235
239
|
state: DocumentState;
|
|
@@ -239,6 +243,7 @@ export type Document = {
|
|
|
239
243
|
metadata: DocumentMetadata;
|
|
240
244
|
bindings: DocumentBindings;
|
|
241
245
|
elements: ElementMap;
|
|
246
|
+
__cache?: DocumentCache;
|
|
242
247
|
};
|
|
243
248
|
export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "extensions" | "metadata" | "state"> & {
|
|
244
249
|
languagePaths: Record<string, string>;
|
|
@@ -372,6 +377,9 @@ export interface IDataProvider {
|
|
|
372
377
|
getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
373
378
|
getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
374
379
|
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
380
|
+
getPageExperiment(path: string): Promise<ActiveExperiment | null>;
|
|
381
|
+
getVariantContent(variantId: string): Promise<VariantContent | null>;
|
|
382
|
+
getExperimentPaused(experimentId: string): Promise<boolean>;
|
|
375
383
|
}
|
|
376
384
|
export interface IEnvironment {
|
|
377
385
|
isClient(): boolean;
|
|
@@ -447,6 +455,72 @@ export type RadioInput = BaseInput<string> & {
|
|
|
447
455
|
value: string;
|
|
448
456
|
}[];
|
|
449
457
|
};
|
|
458
|
+
export interface ContentEntryReference {
|
|
459
|
+
id: string;
|
|
460
|
+
modelId: string;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Query-mode configuration, declared by the component author. The editor then
|
|
464
|
+
* builds a query within these bounds (see `ContentEntryQueryValue`).
|
|
465
|
+
*/
|
|
466
|
+
/**
|
|
467
|
+
* A field the editor may sort by: a bare read-API sort key, or a key paired with
|
|
468
|
+
* a display label shown in the editor.
|
|
469
|
+
*/
|
|
470
|
+
export type ContentEntrySortField = string | {
|
|
471
|
+
field: string;
|
|
472
|
+
label?: string;
|
|
473
|
+
};
|
|
474
|
+
export interface ContentEntryQueryConfig {
|
|
475
|
+
/**
|
|
476
|
+
* Fields the editor may sort by (one at a time). Each `field` is a CMS read-API
|
|
477
|
+
* sort key — value fields as `values_<fieldId>` (e.g. `values_title`), meta
|
|
478
|
+
* fields bare (e.g. `createdOn`). Provide a `label` for a friendlier UI; a bare
|
|
479
|
+
* string uses the key as its label.
|
|
480
|
+
*/
|
|
481
|
+
sort?: {
|
|
482
|
+
fields: ContentEntrySortField[];
|
|
483
|
+
};
|
|
484
|
+
/** Editor-configurable result limit, with an optional default and hard cap. */
|
|
485
|
+
limit?: {
|
|
486
|
+
default?: number;
|
|
487
|
+
max?: number;
|
|
488
|
+
};
|
|
489
|
+
/** Show a free-text search box (matches fullTextSearch-enabled fields). */
|
|
490
|
+
search?: boolean;
|
|
491
|
+
/** Enable "load more" pagination in the rendered component. */
|
|
492
|
+
pagination?: boolean;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* The value stored for a query-mode input: the editor's chosen query.
|
|
496
|
+
* `modelId` identifies the CMS model so the frontend SDK can resolve the
|
|
497
|
+
* query without component manifests.
|
|
498
|
+
*/
|
|
499
|
+
export interface ContentEntryQueryValue {
|
|
500
|
+
modelId: string;
|
|
501
|
+
sort?: {
|
|
502
|
+
field: string;
|
|
503
|
+
order: "asc" | "desc";
|
|
504
|
+
};
|
|
505
|
+
limit?: number;
|
|
506
|
+
search?: string;
|
|
507
|
+
}
|
|
508
|
+
export type ContentEntryInput = BaseInput<ContentEntryReference | ContentEntryReference[] | ContentEntryQueryValue> & {
|
|
509
|
+
type: "contentEntry";
|
|
510
|
+
/**
|
|
511
|
+
* The content model(s) the editor may pick entries from. Author-fixed.
|
|
512
|
+
*/
|
|
513
|
+
models: string[];
|
|
514
|
+
/**
|
|
515
|
+
* "manual" (default): the editor hand-picks entries (stored as references).
|
|
516
|
+
* "query": the editor configures a dynamic query on the fixed model.
|
|
517
|
+
*/
|
|
518
|
+
mode?: "manual" | "query";
|
|
519
|
+
/**
|
|
520
|
+
* Query-mode configuration. Only used when `mode` is "query".
|
|
521
|
+
*/
|
|
522
|
+
query?: ContentEntryQueryConfig;
|
|
523
|
+
};
|
|
450
524
|
export type ObjectInput = BaseInput<Record<string, any>> & {
|
|
451
525
|
type: "object";
|
|
452
526
|
fields: ComponentInput[];
|
|
@@ -455,7 +529,7 @@ export type CustomInput = BaseInput<any> & {
|
|
|
455
529
|
type: string;
|
|
456
530
|
fields: ComponentInput[];
|
|
457
531
|
};
|
|
458
|
-
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | CustomInput;
|
|
532
|
+
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | ContentEntryInput | CustomInput;
|
|
459
533
|
export type ManifestInputsArray<TInputs, TAllowChildren extends boolean> = TAllowChildren extends true ? {
|
|
460
534
|
[K in Exclude<keyof TInputs, "children">]: InputFactory<K & string>;
|
|
461
535
|
}[Exclude<keyof TInputs, "children">][] : {
|