@webiny/website-builder-sdk 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e
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/BindingsApi.js +29 -36
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +82 -78
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.d.ts +4 -1
- package/BindingsResolver.js +99 -119
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +399 -363
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.js +32 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.js +20 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +9 -0
- package/ComponentRegistry.js +30 -44
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +3 -2
- package/ComponentResolver.js +39 -29
- package/ComponentResolver.js.map +1 -1
- package/ComponentResolver.test.d.ts +1 -0
- package/ComponentResolver.test.js +81 -0
- package/ComponentResolver.test.js.map +1 -0
- package/ConstraintEvaluator.js +246 -353
- package/ConstraintEvaluator.js.map +1 -1
- package/ConstraintEvaluator.test.js +1616 -1438
- package/ConstraintEvaluator.test.js.map +1 -1
- package/ContentSdk.d.ts +14 -0
- package/ContentSdk.js +113 -90
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.js +47 -59
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.js +17 -16
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.js +92 -121
- package/EditingSdk.js.map +1 -1
- package/ElementFactory.js +164 -172
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.objectListDefaults.test.d.ts +1 -0
- package/ElementFactory.objectListDefaults.test.js +423 -0
- package/ElementFactory.objectListDefaults.test.js.map +1 -0
- package/ElementFactory.test.js +335 -262
- package/ElementFactory.test.js.map +1 -1
- package/Environment.js +18 -19
- package/Environment.js.map +1 -1
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/HashObject.js +11 -26
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +40 -47
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.js +0 -3
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +178 -179
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +18 -1
- package/InheritedValueResolver.js +18 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.d.ts +23 -2
- package/InputBindingsProcessor.js +200 -307
- package/InputBindingsProcessor.js.map +1 -1
- package/InputBindingsProcessorTokens.test.d.ts +1 -0
- package/InputBindingsProcessorTokens.test.js +400 -0
- package/InputBindingsProcessorTokens.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +334 -315
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.js +23 -26
- package/InputsUpdater.js.map +1 -1
- package/LiveSdk.js +12 -13
- package/LiveSdk.js.map +1 -1
- package/Logger.js +9 -8
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.js +22 -21
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +1 -0
- package/PreviewDocument.js +30 -30
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +2 -1
- package/PreviewSdk.js +19 -17
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.js +51 -63
- package/PreviewViewport.js.map +1 -1
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.d.ts +12 -2
- package/StylesBindingsProcessor.js +62 -79
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.js +20 -25
- package/StylesUpdater.js.map +1 -1
- package/Theme.js +30 -25
- package/Theme.js.map +1 -1
- package/ViewportManager.js +89 -101
- package/ViewportManager.js.map +1 -1
- package/assertBindingShapes.d.ts +31 -0
- package/assertBindingShapes.js +64 -0
- package/assertBindingShapes.js.map +1 -0
- package/assertBindingShapes.test.d.ts +1 -0
- package/assertBindingShapes.test.js +131 -0
- package/assertBindingShapes.test.js.map +1 -0
- 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/constants.js +7 -6
- package/constants.js.map +1 -1
- package/contentEntry/ContentEntryBindingsResolver.d.ts +30 -0
- package/contentEntry/ContentEntryBindingsResolver.js +45 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +46 -0
- package/contentEntry/ContentEntryCache.js +50 -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/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createInput.d.ts +10 -2
- package/createInput.js +92 -143
- package/createInput.js.map +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +10 -5
- package/dataProviders/ApiClient.js +40 -49
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/DefaultDataProvider.d.ts +4 -0
- package/dataProviders/DefaultDataProvider.js +91 -58
- 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.js +2 -1
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +2 -1
- 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/LIST_PUBLISHED_PAGES.js +2 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +4 -0
- package/dataProviders/NullDataProvider.js +30 -20
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.js +24 -27
- package/dataProviders/RedirectsProvider.js.map +1 -1
- package/defaultBreakpoints.js +43 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.js +29 -32
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.js +9 -15
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.js +9 -8
- package/documentOperations/index.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 +79 -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/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.js +2 -1
- package/generateElementId.js.map +1 -1
- package/headersProvider.js +4 -3
- 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 +10 -0
- package/index.js +10 -2
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.js +12 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +58 -69
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +12 -9
- package/registerComponentGroup.js +5 -6
- package/registerComponentGroup.js.map +1 -1
- package/tokenBinding.d.ts +26 -0
- package/tokenBinding.js +15 -0
- package/tokenBinding.js.map +1 -0
- package/tokenBinding.test.d.ts +1 -0
- package/tokenBinding.test.js +165 -0
- package/tokenBinding.test.js.map +1 -0
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.d.ts +12 -0
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +96 -1
- package/types.js +0 -3
- package/IBindingsUpdater.js.map +0 -1
- package/IRedirects.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
package/image/types.d.ts
ADDED
package/image/types.js
ADDED
|
File without changes
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ export * from "./DocumentStore.js";
|
|
|
8
8
|
export * from "./Logger.js";
|
|
9
9
|
export * from "./FunctionConverter.js";
|
|
10
10
|
export * from "./createInput.js";
|
|
11
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
12
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
14
|
+
export * from "./createComponent.js";
|
|
15
|
+
export * from "./image/index.js";
|
|
16
|
+
export * from "./asset/index.js";
|
|
11
17
|
export * from "./MouseTracker.js";
|
|
12
18
|
export * from "./ViewportManager.js";
|
|
13
19
|
export * from "./messenger/Messenger.js";
|
|
@@ -21,11 +27,15 @@ export * from "./createElement.js";
|
|
|
21
27
|
export * from "./registerComponentGroup.js";
|
|
22
28
|
export * from "./jsonPatch.js";
|
|
23
29
|
export * from "./headersProvider.js";
|
|
30
|
+
export * from "./experiments/index.js";
|
|
24
31
|
export * from "./ComponentManifestToAstConverter.js";
|
|
25
32
|
export * from "./findMatchingAstNode.js";
|
|
26
33
|
export * from "./InheritanceProcessor.js";
|
|
27
34
|
export * from "./InputBindingsProcessor.js";
|
|
28
35
|
export * from "./StylesBindingsProcessor.js";
|
|
36
|
+
export * from "./tokenBinding.js";
|
|
29
37
|
export * from "./ElementFactory.js";
|
|
30
38
|
export * from "./ConstraintEvaluator.js";
|
|
39
|
+
export * from "./generateElementId.js";
|
|
31
40
|
export { StyleSettings } from "./constants.js";
|
|
41
|
+
export * from "./assertBindingShapes.js";
|
package/index.js
CHANGED
|
@@ -8,6 +8,12 @@ export * from "./DocumentStore.js";
|
|
|
8
8
|
export * from "./Logger.js";
|
|
9
9
|
export * from "./FunctionConverter.js";
|
|
10
10
|
export * from "./createInput.js";
|
|
11
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
12
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
14
|
+
export * from "./createComponent.js";
|
|
15
|
+
export * from "./image/index.js";
|
|
16
|
+
export * from "./asset/index.js";
|
|
11
17
|
export * from "./MouseTracker.js";
|
|
12
18
|
export * from "./ViewportManager.js";
|
|
13
19
|
export * from "./messenger/Messenger.js";
|
|
@@ -20,13 +26,15 @@ export * from "./createElement.js";
|
|
|
20
26
|
export * from "./registerComponentGroup.js";
|
|
21
27
|
export * from "./jsonPatch.js";
|
|
22
28
|
export * from "./headersProvider.js";
|
|
29
|
+
export * from "./experiments/index.js";
|
|
23
30
|
export * from "./ComponentManifestToAstConverter.js";
|
|
24
31
|
export * from "./findMatchingAstNode.js";
|
|
25
32
|
export * from "./InheritanceProcessor.js";
|
|
26
33
|
export * from "./InputBindingsProcessor.js";
|
|
27
34
|
export * from "./StylesBindingsProcessor.js";
|
|
35
|
+
export * from "./tokenBinding.js";
|
|
28
36
|
export * from "./ElementFactory.js";
|
|
29
37
|
export * from "./ConstraintEvaluator.js";
|
|
38
|
+
export * from "./generateElementId.js";
|
|
39
|
+
export * from "./assertBindingShapes.js";
|
|
30
40
|
export { StyleSettings } from "./constants.js";
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
package/jsonPatch.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return fjp.compare(tree1, tree2, invertible);
|
|
6
|
-
},
|
|
7
|
-
applyPatch: (document, patch, validateOperation, mutateDocument, banPrototypeModifications) => {
|
|
8
|
-
return fjp.applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications);
|
|
9
|
-
}
|
|
1
|
+
import * as __rspack_external_fast_json_patch_index_mjs_25f05694 from "fast-json-patch/index.mjs";
|
|
2
|
+
const jsonPatch = {
|
|
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)
|
|
10
5
|
};
|
|
6
|
+
export { jsonPatch };
|
|
11
7
|
|
|
12
8
|
//# sourceMappingURL=jsonPatch.js.map
|
package/jsonPatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"jsonPatch.js","sources":["../src/jsonPatch.ts"],"sourcesContent":["import type { Operation, Validator, PatchResult } from \"fast-json-patch\";\n// @ts-expect-error We need this hack.\nimport * as fjp from \"fast-json-patch/index.mjs\";\n\nexport type { Operation as JsonPatchOperation, PatchResult as JsonPatchResult };\n\nexport const jsonPatch = {\n compare: (tree1: object | any[], tree2: object | any[], invertible?: boolean): Operation[] => {\n return fjp.compare(tree1, tree2, invertible);\n },\n applyPatch: <T>(\n document: T,\n patch: Operation[],\n validateOperation?: boolean | Validator<T>,\n mutateDocument?: boolean,\n banPrototypeModifications?: boolean\n ): PatchResult<T> => {\n return fjp.applyPatch(\n document,\n patch,\n validateOperation,\n mutateDocument,\n banPrototypeModifications\n );\n }\n};\n"],"names":["jsonPatch","tree1","tree2","invertible","fjp","document","patch","validateOperation","mutateDocument","banPrototypeModifications"],"mappings":";AAMO,MAAMA,YAAY;IACrB,SAAS,CAACC,OAAuBC,OAAuBC,aAC7CC,qDAAAA,OAAW,CAACH,OAAOC,OAAOC;IAErC,YAAY,CACRE,UACAC,OACAC,mBACAC,gBACAC,4BAEOL,qDAAAA,UAAc,CACjBC,UACAC,OACAC,mBACAC,gBACAC;AAGZ"}
|
package/messages.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
const DOCUMENT_SET = "document.set";
|
|
2
|
+
const DOCUMENT_PATCH = "document.patch";
|
|
3
|
+
const PREVIEW_COMPONENT_REGISTER = "preview.component.register";
|
|
4
|
+
const PREVIEW_READY = "preview.ready";
|
|
5
|
+
const PREVIEW_COMPONENTGROUP_REGISTER = "preview.componentGroup.register";
|
|
6
|
+
const PREVIEW_VIEWPORT_CHANGE_START = "preview.viewport.change.start";
|
|
7
|
+
const PREVIEW_VIEWPORT_CHANGE_END = "preview.viewport.change.end";
|
|
8
|
+
const PREVIEW_ELEMENT_POSITIONS = "preview.element.positions";
|
|
9
|
+
const PREVIEW_ELEMENT_CLICK = "preview.element.click";
|
|
10
|
+
const PREVIEW_ELEMENT_ENTER = "preview.element.enter";
|
|
11
|
+
const PREVIEW_ELEMENT_LEAVE = "preview.element.leave";
|
|
12
|
+
export { DOCUMENT_PATCH, DOCUMENT_SET, PREVIEW_COMPONENTGROUP_REGISTER, PREVIEW_COMPONENT_REGISTER, PREVIEW_ELEMENT_CLICK, PREVIEW_ELEMENT_ENTER, PREVIEW_ELEMENT_LEAVE, PREVIEW_ELEMENT_POSITIONS, PREVIEW_READY, PREVIEW_VIEWPORT_CHANGE_END, PREVIEW_VIEWPORT_CHANGE_START };
|
|
12
13
|
|
|
13
14
|
//# sourceMappingURL=messages.js.map
|
package/messages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../src/messages.ts"],"sourcesContent":["export const DOCUMENT_SET = \"document.set\";\nexport const DOCUMENT_PATCH = \"document.patch\";\nexport const PREVIEW_COMPONENT_REGISTER = \"preview.component.register\";\nexport const PREVIEW_READY = \"preview.ready\";\nexport const PREVIEW_COMPONENTGROUP_REGISTER = \"preview.componentGroup.register\";\nexport const PREVIEW_VIEWPORT_CHANGE_START = \"preview.viewport.change.start\";\nexport const PREVIEW_VIEWPORT_CHANGE_END = \"preview.viewport.change.end\";\nexport const PREVIEW_ELEMENT_POSITIONS = \"preview.element.positions\";\nexport const PREVIEW_ELEMENT_CLICK = \"preview.element.click\";\nexport const PREVIEW_ELEMENT_ENTER = \"preview.element.enter\";\nexport const PREVIEW_ELEMENT_LEAVE = \"preview.element.leave\";\n"],"names":["DOCUMENT_SET","DOCUMENT_PATCH","PREVIEW_COMPONENT_REGISTER","PREVIEW_READY","PREVIEW_COMPONENTGROUP_REGISTER","PREVIEW_VIEWPORT_CHANGE_START","PREVIEW_VIEWPORT_CHANGE_END","PREVIEW_ELEMENT_POSITIONS","PREVIEW_ELEMENT_CLICK","PREVIEW_ELEMENT_ENTER","PREVIEW_ELEMENT_LEAVE"],"mappings":"AAAO,MAAMA,eAAe;AACrB,MAAMC,iBAAiB;AACvB,MAAMC,6BAA6B;AACnC,MAAMC,gBAAgB;AACtB,MAAMC,kCAAkC;AACxC,MAAMC,gCAAgC;AACtC,MAAMC,8BAA8B;AACpC,MAAMC,4BAA4B;AAClC,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
class MessageOrigin {
|
|
2
|
+
constructor(getWindow, origin){
|
|
3
|
+
this.getWindow = getWindow;
|
|
4
|
+
this.origin = origin;
|
|
5
|
+
}
|
|
6
|
+
matches(event) {
|
|
7
|
+
return event.origin === this.origin;
|
|
8
|
+
}
|
|
9
|
+
get window() {
|
|
10
|
+
return this.getWindow();
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
|
+
export { MessageOrigin };
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=MessageOrigin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"messenger/MessageOrigin.js","sources":["../../src/messenger/MessageOrigin.ts"],"sourcesContent":["export class MessageOrigin {\n private readonly getWindow: () => Window;\n public readonly origin: string;\n\n constructor(getWindow: () => Window, origin: string) {\n this.getWindow = getWindow;\n this.origin = origin;\n }\n\n matches(event: MessageEvent): boolean {\n return event.origin === this.origin;\n }\n\n get window() {\n return this.getWindow();\n }\n}\n"],"names":["MessageOrigin","getWindow","origin","event"],"mappings":"AAAO,MAAMA;IAIT,YAAYC,SAAuB,EAAEC,MAAc,CAAE;QACjD,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,MAAM,GAAGC;IAClB;IAEA,QAAQC,KAAmB,EAAW;QAClC,OAAOA,MAAM,MAAM,KAAK,IAAI,CAAC,MAAM;IACvC;IAEA,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,SAAS;IACzB;AACJ"}
|
package/messenger/Messenger.js
CHANGED
|
@@ -1,80 +1,69 @@
|
|
|
1
1
|
import { isMatch } from "matcher";
|
|
2
2
|
import { logger } from "../Logger.js";
|
|
3
|
-
const ignored = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = event.data || {};
|
|
21
|
-
if (!this.target.matches(event)) {
|
|
22
|
-
return;
|
|
3
|
+
const ignored = [
|
|
4
|
+
"preview.mouse.move",
|
|
5
|
+
"preview.component.register",
|
|
6
|
+
"preview.scroll",
|
|
7
|
+
"preview.viewport",
|
|
8
|
+
"preview.viewport.change.start",
|
|
9
|
+
"preview.viewport.change.end"
|
|
10
|
+
];
|
|
11
|
+
class Messenger {
|
|
12
|
+
constructor(source, target, pattern){
|
|
13
|
+
this.source = source;
|
|
14
|
+
this.target = target;
|
|
15
|
+
this.listeners = new Map();
|
|
16
|
+
this.pattern = pattern;
|
|
17
|
+
this.prefixGlob = pattern.replace(/\*+$/, "");
|
|
18
|
+
this.handleMessage = this.handleMessage.bind(this);
|
|
19
|
+
this.source.window.addEventListener("message", this.handleMessage);
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
handleMessage(event) {
|
|
22
|
+
const { type, payload } = event.data || {};
|
|
23
|
+
if (!this.target.matches(event)) return;
|
|
24
|
+
if (!type || !isMatch(type, this.pattern)) return;
|
|
25
|
+
const logicalType = this.stripPrefix(type);
|
|
26
|
+
if (!this.isIgnored(logicalType)) logger.debug({
|
|
27
|
+
type,
|
|
28
|
+
payload
|
|
29
|
+
}, `${this.getTime()} --> [${this.source.origin}][${logicalType}]`);
|
|
30
|
+
const handlers = this.listeners.get(logicalType);
|
|
31
|
+
if (handlers) handlers.forEach((fn)=>fn(payload, logicalType));
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
logger.debug({
|
|
30
|
-
type,
|
|
31
|
-
payload
|
|
32
|
-
}, `${this.getTime()} --> [${this.source.origin}][${logicalType}]`);
|
|
33
|
+
stripPrefix(fullType) {
|
|
34
|
+
return fullType.startsWith(this.prefixGlob) ? fullType.slice(this.prefixGlob.length) : fullType;
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
handlers.forEach(fn => fn(payload, logicalType));
|
|
36
|
+
isIgnored(logicalType) {
|
|
37
|
+
return ignored.includes(logicalType);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
on(logicalType, handler) {
|
|
46
|
-
if (!this.listeners.has(logicalType)) {
|
|
47
|
-
this.listeners.set(logicalType, new Set());
|
|
39
|
+
on(logicalType, handler) {
|
|
40
|
+
if (!this.listeners.has(logicalType)) this.listeners.set(logicalType, new Set());
|
|
41
|
+
this.listeners.get(logicalType).add(handler);
|
|
42
|
+
return ()=>{
|
|
43
|
+
const listeners = this.listeners.get(logicalType);
|
|
44
|
+
if (listeners) listeners.delete(handler);
|
|
45
|
+
};
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
send(logicalType, payload) {
|
|
48
|
+
const fullType = this.prefixGlob + logicalType;
|
|
49
|
+
if (!this.isIgnored(logicalType)) logger.debug({
|
|
50
|
+
type: fullType,
|
|
51
|
+
payload
|
|
52
|
+
}, `${this.getTime()} <-- [${this.source.origin}][${logicalType}]`);
|
|
53
|
+
this.target.window.postMessage({
|
|
54
|
+
type: fullType,
|
|
55
|
+
payload
|
|
56
|
+
}, this.target.origin);
|
|
57
|
+
}
|
|
58
|
+
dispose() {
|
|
59
|
+
this.source.window.removeEventListener("message", this.handleMessage);
|
|
60
|
+
this.listeners.clear();
|
|
61
|
+
}
|
|
62
|
+
getTime() {
|
|
63
|
+
const date = new Date();
|
|
64
|
+
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;
|
|
64
65
|
}
|
|
65
|
-
this.target.window.postMessage({
|
|
66
|
-
type: fullType,
|
|
67
|
-
payload
|
|
68
|
-
}, this.target.origin);
|
|
69
|
-
}
|
|
70
|
-
dispose() {
|
|
71
|
-
this.source.window.removeEventListener("message", this.handleMessage);
|
|
72
|
-
this.listeners.clear();
|
|
73
|
-
}
|
|
74
|
-
getTime() {
|
|
75
|
-
const date = new Date();
|
|
76
|
-
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;
|
|
77
|
-
}
|
|
78
66
|
}
|
|
67
|
+
export { Messenger };
|
|
79
68
|
|
|
80
69
|
//# sourceMappingURL=Messenger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"messenger/Messenger.js","sources":["../../src/messenger/Messenger.ts"],"sourcesContent":["import { isMatch } from \"matcher\";\nimport type { MessageOrigin } from \"./MessageOrigin.js\";\nimport { logger } from \"../Logger.js\";\n\nexport type Message<T = any> = {\n type: string;\n payload: T;\n};\n\ntype Handler<T = any> = (payload: T, logicalType: string, wildcardMatch?: string) => void;\n\nconst ignored = [\n \"preview.mouse.move\",\n \"preview.component.register\",\n \"preview.scroll\",\n \"preview.viewport\",\n \"preview.viewport.change.start\",\n \"preview.viewport.change.end\"\n];\n\nexport class Messenger {\n private listeners = new Map<string, Set<Handler>>();\n private readonly pattern: string;\n private readonly prefixGlob: string;\n\n constructor(\n private source: MessageOrigin,\n private target: MessageOrigin,\n // Pattern to filter events this Messenger handles.\n pattern: string\n ) {\n this.pattern = pattern;\n this.prefixGlob = pattern.replace(/\\*+$/, \"\");\n this.handleMessage = this.handleMessage.bind(this);\n this.source.window.addEventListener(\"message\", this.handleMessage);\n }\n\n private handleMessage(event: MessageEvent) {\n const { type, payload } = event.data || {};\n if (!this.target.matches(event)) {\n return;\n }\n\n if (!type || !isMatch(type, this.pattern)) {\n return;\n }\n\n const logicalType = this.stripPrefix(type);\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type,\n payload\n },\n `${this.getTime()} --> [${this.source.origin}][${logicalType}]`\n );\n }\n\n const handlers = this.listeners.get(logicalType);\n if (handlers) {\n handlers.forEach(fn => fn(payload, logicalType));\n }\n }\n\n private stripPrefix(fullType: string): string {\n return fullType.startsWith(this.prefixGlob)\n ? fullType.slice(this.prefixGlob.length)\n : fullType;\n }\n\n private isIgnored(logicalType: string): boolean {\n return ignored.includes(logicalType);\n }\n\n on<T = any>(logicalType: string, handler: Handler<T>) {\n if (!this.listeners.has(logicalType)) {\n this.listeners.set(logicalType, new Set());\n }\n this.listeners.get(logicalType)!.add(handler);\n return () => {\n const listeners = this.listeners.get(logicalType);\n if (listeners) {\n listeners.delete(handler);\n }\n };\n }\n\n send<T = any>(logicalType: string, payload?: T) {\n const fullType = this.prefixGlob + logicalType;\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type: fullType,\n payload\n },\n `${this.getTime()} <-- [${this.source.origin}][${logicalType}]`\n );\n }\n\n this.target.window.postMessage({ type: fullType, payload }, this.target.origin);\n }\n\n dispose() {\n this.source.window.removeEventListener(\"message\", this.handleMessage);\n this.listeners.clear();\n }\n\n getTime() {\n const date = new Date();\n return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;\n }\n}\n"],"names":["ignored","Messenger","source","target","pattern","Map","event","type","payload","isMatch","logicalType","logger","handlers","fn","fullType","handler","Set","listeners","date","Date"],"mappings":";;AAWA,MAAMA,UAAU;IACZ;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC;IAKT,YACYC,MAAqB,EACrBC,MAAqB,EAE7BC,OAAe,CACjB;aAJUF,MAAM,GAANA;aACAC,MAAM,GAANA;aANJ,SAAS,GAAG,IAAIE;QAUpB,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,UAAU,GAAGA,QAAQ,OAAO,CAAC,QAAQ;QAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI;QACjD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,IAAI,CAAC,aAAa;IACrE;IAEQ,cAAcE,KAAmB,EAAE;QACvC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGF,MAAM,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAACA,QACrB;QAGJ,IAAI,CAACC,QAAQ,CAACE,QAAQF,MAAM,IAAI,CAAC,OAAO,GACpC;QAGJ,MAAMG,cAAc,IAAI,CAAC,WAAW,CAACH;QAErC,IAAI,CAAC,IAAI,CAAC,SAAS,CAACG,cAChBC,OAAO,KAAK,CACR;YACIJ;YACAC;QACJ,GACA,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAEE,YAAY,CAAC,CAAC;QAIvE,MAAME,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CAACF;QACpC,IAAIE,UACAA,SAAS,OAAO,CAACC,CAAAA,KAAMA,GAAGL,SAASE;IAE3C;IAEQ,YAAYI,QAAgB,EAAU;QAC1C,OAAOA,SAAS,UAAU,CAAC,IAAI,CAAC,UAAU,IACpCA,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,IACrCA;IACV;IAEQ,UAAUJ,WAAmB,EAAW;QAC5C,OAAOV,QAAQ,QAAQ,CAACU;IAC5B;IAEA,GAAYA,WAAmB,EAAEK,OAAmB,EAAE;QAClD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACL,cACpB,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,aAAa,IAAIM;QAExC,IAAI,CAAC,SAAS,CAAC,GAAG,CAACN,aAAc,GAAG,CAACK;QACrC,OAAO;YACH,MAAME,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,CAACP;YACrC,IAAIO,WACAA,UAAU,MAAM,CAACF;QAEzB;IACJ;IAEA,KAAcL,WAAmB,EAAEF,OAAW,EAAE;QAC5C,MAAMM,WAAW,IAAI,CAAC,UAAU,GAAGJ;QAEnC,IAAI,CAAC,IAAI,CAAC,SAAS,CAACA,cAChBC,OAAO,KAAK,CACR;YACI,MAAMG;YACNN;QACJ,GACA,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAEE,YAAY,CAAC,CAAC;QAIvE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;YAAE,MAAMI;YAAUN;QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM;IAClF;IAEA,UAAU;QACN,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,IAAI,CAAC,aAAa;QACpE,IAAI,CAAC,SAAS,CAAC,KAAK;IACxB;IAEA,UAAU;QACN,MAAMU,OAAO,IAAIC;QACjB,OAAO,GAAGD,KAAK,QAAQ,GAAG,CAAC,EAAEA,KAAK,UAAU,GAAG,CAAC,EAAEA,KAAK,UAAU,GAAG,CAAC,EAAEA,KAAK,eAAe,IAAI;IACnG;AACJ"}
|
package/messenger/index.js
CHANGED
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.eb81deee7e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"author": "Pavel Denisjuk",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@webiny/sdk": "0.0.0-unstable.eb81deee7e",
|
|
16
|
+
"@webiny/theme-common": "0.0.0-unstable.eb81deee7e",
|
|
15
17
|
"csstype": "3.2.3",
|
|
16
18
|
"deep-equal": "2.2.3",
|
|
17
19
|
"deepmerge": "4.3.1",
|
|
@@ -20,8 +22,8 @@
|
|
|
20
22
|
"is-hotkey": "0.2.0",
|
|
21
23
|
"lodash": "4.18.1",
|
|
22
24
|
"matcher": "6.0.0",
|
|
23
|
-
"mobx": "
|
|
24
|
-
"nanoid": "
|
|
25
|
+
"mobx": "7.0.3",
|
|
26
|
+
"nanoid": "6.0.1",
|
|
25
27
|
"nanoid-dictionary": "5.0.0",
|
|
26
28
|
"pino": "10.3.1",
|
|
27
29
|
"pino-pretty": "13.1.3"
|
|
@@ -29,13 +31,12 @@
|
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@types/deep-equal": "1.0.4",
|
|
31
33
|
"@types/is-hotkey": "0.1.10",
|
|
32
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
33
|
-
"typescript": "
|
|
34
|
-
"vitest": "4.1.
|
|
34
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
35
|
+
"typescript": "7.0.2",
|
|
36
|
+
"vitest": "4.1.11"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
"directory": "dist"
|
|
39
|
+
"access": "public"
|
|
39
40
|
},
|
|
40
41
|
"adio": {
|
|
41
42
|
"ignore": {
|
|
@@ -44,5 +45,7 @@
|
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
|
-
"
|
|
48
|
+
"webiny": {
|
|
49
|
+
"publishFrom": "dist"
|
|
50
|
+
}
|
|
48
51
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { contentSdk } from "./ContentSdk.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
editingSdk.registerComponentGroup(group);
|
|
2
|
+
const registerComponentGroup = (group)=>{
|
|
3
|
+
const editingSdk = contentSdk.getEditingSdk();
|
|
4
|
+
if (!editingSdk) return;
|
|
5
|
+
editingSdk.registerComponentGroup(group);
|
|
8
6
|
};
|
|
7
|
+
export { registerComponentGroup };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=registerComponentGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"registerComponentGroup.js","sources":["../src/registerComponentGroup.ts"],"sourcesContent":["import type { ComponentGroup } from \"./types.js\";\nimport { contentSdk } from \"./ContentSdk.js\";\n\nexport const registerComponentGroup = (group: ComponentGroup) => {\n const editingSdk = contentSdk.getEditingSdk();\n\n if (!editingSdk) {\n return;\n }\n\n editingSdk.registerComponentGroup(group);\n};\n"],"names":["registerComponentGroup","group","editingSdk","contentSdk"],"mappings":";AAGO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,aAAaC,WAAW,aAAa;IAE3C,IAAI,CAACD,YACD;IAGJA,WAAW,sBAAsB,CAACD;AACtC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TokenReference, ValueBinding } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Design token references in element styles — see the Theme design brief, section 7.1.
|
|
4
|
+
*
|
|
5
|
+
* Content stores a *structured* reference, never a resolved value and never a raw CSS variable
|
|
6
|
+
* string. Storing `var(--wby-color-surface-page)` would bake the naming convention into customer
|
|
7
|
+
* data, making a prefix change a data migration; and Admin needs the structured form to show which
|
|
8
|
+
* token is selected when a picker is reopened.
|
|
9
|
+
*
|
|
10
|
+
* The renderer converts a reference to `var(--wby-…)` at output time. That conversion lives here so
|
|
11
|
+
* there is exactly one place that knows the mapping.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isTokenBinding: (binding: ValueBinding | undefined) => binding is ValueBinding & {
|
|
14
|
+
token: TokenReference;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Emits the CSS value for a reference.
|
|
18
|
+
*
|
|
19
|
+
* The stored fallback is emitted as the `var()` second argument. That matters when no theme is
|
|
20
|
+
* active — a variable that resolves to nothing makes the browser drop the whole declaration, so
|
|
21
|
+
* content authored under a theme would visibly lose its colour the moment the theme is deactivated.
|
|
22
|
+
* With a fallback it keeps rendering the value it had when it was picked.
|
|
23
|
+
*/
|
|
24
|
+
export declare const tokenToCssValue: (reference: TokenReference) => string;
|
|
25
|
+
/** Builds a reference, capturing the currently resolved value as the fallback. */
|
|
26
|
+
export declare const createTokenReference: (path: string, fallback?: string) => TokenReference;
|
package/tokenBinding.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toCssVariableName } from "@webiny/theme-common/naming/cssVariable.js";
|
|
2
|
+
const isTokenBinding = (binding)=>Boolean(binding?.token?.path);
|
|
3
|
+
const tokenToCssValue = (reference)=>{
|
|
4
|
+
const variable = toCssVariableName(reference.path);
|
|
5
|
+
return reference.fallback ? `var(${variable}, ${reference.fallback})` : `var(${variable})`;
|
|
6
|
+
};
|
|
7
|
+
const createTokenReference = (path, fallback)=>fallback ? {
|
|
8
|
+
path,
|
|
9
|
+
fallback
|
|
10
|
+
} : {
|
|
11
|
+
path
|
|
12
|
+
};
|
|
13
|
+
export { createTokenReference, isTokenBinding, tokenToCssValue };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=tokenBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenBinding.js","sources":["../src/tokenBinding.ts"],"sourcesContent":["import { toCssVariableName } from \"@webiny/theme-common/naming/cssVariable.js\";\nimport type { TokenReference, ValueBinding } from \"~/types.js\";\n\n/**\n * Design token references in element styles — see the Theme design brief, section 7.1.\n *\n * Content stores a *structured* reference, never a resolved value and never a raw CSS variable\n * string. Storing `var(--wby-color-surface-page)` would bake the naming convention into customer\n * data, making a prefix change a data migration; and Admin needs the structured form to show which\n * token is selected when a picker is reopened.\n *\n * The renderer converts a reference to `var(--wby-…)` at output time. That conversion lives here so\n * there is exactly one place that knows the mapping.\n */\n\nexport const isTokenBinding = (\n binding: ValueBinding | undefined\n): binding is ValueBinding & { token: TokenReference } => {\n return Boolean(binding?.token?.path);\n};\n\n/**\n * Emits the CSS value for a reference.\n *\n * The stored fallback is emitted as the `var()` second argument. That matters when no theme is\n * active — a variable that resolves to nothing makes the browser drop the whole declaration, so\n * content authored under a theme would visibly lose its colour the moment the theme is deactivated.\n * With a fallback it keeps rendering the value it had when it was picked.\n */\nexport const tokenToCssValue = (reference: TokenReference): string => {\n const variable = toCssVariableName(reference.path);\n\n return reference.fallback ? `var(${variable}, ${reference.fallback})` : `var(${variable})`;\n};\n\n/** Builds a reference, capturing the currently resolved value as the fallback. */\nexport const createTokenReference = (path: string, fallback?: string): TokenReference => {\n return fallback ? { path, fallback } : { path };\n};\n"],"names":["isTokenBinding","binding","Boolean","tokenToCssValue","reference","variable","toCssVariableName","createTokenReference","path","fallback"],"mappings":";AAeO,MAAMA,iBAAiB,CAC1BC,UAEOC,QAAQD,SAAS,OAAO;AAW5B,MAAME,kBAAkB,CAACC;IAC5B,MAAMC,WAAWC,kBAAkBF,UAAU,IAAI;IAEjD,OAAOA,UAAU,QAAQ,GAAG,CAAC,IAAI,EAAEC,SAAS,EAAE,EAAED,UAAU,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAEC,SAAS,CAAC,CAAC;AAC9F;AAGO,MAAME,uBAAuB,CAACC,MAAcC,WACxCA,WAAW;QAAED;QAAMC;IAAS,IAAI;QAAED;IAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|