@webiny/website-builder-sdk 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea
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.d.ts +4 -4
- package/BindingsApi.js +32 -39
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.d.ts +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +83 -78
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.d.ts +6 -3
- package/BindingsResolver.js +92 -122
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +402 -365
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.d.ts +1 -1
- package/ComponentInputTraverser.js +29 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.d.ts +23 -1
- package/ComponentManifestToAstConverter.js +140 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +2 -1
- package/ComponentRegistry.js +40 -22
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +7 -4
- package/ComponentResolver.js +33 -32
- package/ComponentResolver.js.map +1 -1
- package/ConstraintEvaluator.d.ts +41 -0
- package/ConstraintEvaluator.js +304 -0
- package/ConstraintEvaluator.js.map +1 -0
- package/ConstraintEvaluator.test.d.ts +1 -0
- package/ConstraintEvaluator.test.js +1771 -0
- package/ConstraintEvaluator.test.js.map +1 -0
- package/ContentSdk.d.ts +90 -8
- package/ContentSdk.js +195 -78
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.d.ts +3 -3
- package/DocumentStore.js +48 -60
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.d.ts +11 -4
- package/DocumentStoreManager.js +37 -17
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +21 -5
- package/EditingSdk.js +119 -131
- package/EditingSdk.js.map +1 -1
- package/ElementBindings.d.ts +28 -0
- package/ElementBindings.js +88 -0
- package/ElementBindings.js.map +1 -0
- package/ElementBindings.test.d.ts +1 -0
- package/ElementBindings.test.js +127 -0
- package/ElementBindings.test.js.map +1 -0
- package/ElementFactory.d.ts +15 -7
- package/ElementFactory.js +165 -168
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.d.ts +1 -0
- package/ElementFactory.test.js +511 -0
- package/ElementFactory.test.js.map +1 -0
- package/ElementSelection.d.ts +20 -0
- package/ElementSelection.js +32 -0
- package/ElementSelection.js.map +1 -0
- package/ElementSelection.test.d.ts +1 -0
- package/ElementSelection.test.js +73 -0
- package/ElementSelection.test.js.map +1 -0
- package/Environment.d.ts +7 -0
- package/Environment.js +19 -19
- package/Environment.js.map +1 -1
- package/Environment.test.d.ts +1 -0
- package/Environment.test.js +39 -0
- package/Environment.test.js.map +1 -0
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/GlobalComponentLanguage.d.ts +31 -0
- package/GlobalComponentLanguage.js +37 -0
- package/GlobalComponentLanguage.js.map +1 -0
- package/HashObject.js +11 -12
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +41 -48
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.d.ts +2 -2
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.d.ts +5 -0
- package/IRedirects.js +0 -0
- package/InheritanceProcessor.d.ts +4 -4
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +185 -177
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +7 -1
- package/InheritedValueResolver.js +22 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.d.ts +4 -4
- package/InputBindingsProcessor.js +196 -294
- package/InputBindingsProcessor.js.map +1 -1
- package/InputRenderer.test.d.ts +1 -0
- package/InputRenderer.test.js +186 -0
- package/InputRenderer.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +466 -315
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.d.ts +5 -5
- package/InputsUpdater.js +26 -28
- package/InputsUpdater.js.map +1 -1
- package/LayoutContentArea.d.ts +68 -0
- package/LayoutContentArea.js +78 -0
- package/LayoutContentArea.js.map +1 -0
- package/LayoutContentArea.test.d.ts +1 -0
- package/LayoutContentArea.test.js +111 -0
- package/LayoutContentArea.test.js.map +1 -0
- package/LiveSdk.d.ts +6 -3
- package/LiveSdk.js +17 -14
- package/LiveSdk.js.map +1 -1
- package/Logger.d.ts +2 -1
- package/Logger.js +10 -6
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.d.ts +6 -3
- package/NullSdk.js +25 -11
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +3 -1
- package/PreviewDocument.js +31 -31
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +7 -3
- package/PreviewSdk.js +24 -18
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.d.ts +6 -2
- package/PreviewViewport.js +60 -83
- package/PreviewViewport.js.map +1 -1
- package/PreviewViewport.test.d.ts +1 -0
- package/PreviewViewport.test.js +27 -0
- package/PreviewViewport.test.js.map +1 -0
- package/README.md +10 -2
- package/RadioOptionInputs.test.d.ts +1 -0
- package/RadioOptionInputs.test.js +521 -0
- package/RadioOptionInputs.test.js.map +1 -0
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.d.ts +2 -2
- package/StylesBindingsProcessor.js +45 -83
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.d.ts +4 -4
- package/StylesUpdater.js +25 -27
- package/StylesUpdater.js.map +1 -1
- package/Theme.d.ts +1 -1
- package/Theme.js +31 -33
- package/Theme.js.map +1 -1
- package/ViewportManager.d.ts +3 -1
- package/ViewportManager.js +90 -95
- package/ViewportManager.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/constants.d.ts +1 -0
- package/constants.js +7 -5
- package/constants.js.map +1 -1
- package/contentClientState.test.d.ts +1 -0
- package/contentClientState.test.js +404 -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/createElement.d.ts +1 -1
- package/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createGlobalElementDocument.d.ts +6 -0
- package/createGlobalElementDocument.js +23 -0
- package/createGlobalElementDocument.js.map +1 -0
- package/createInput.d.ts +132 -16
- package/createInput.js +93 -112
- package/createInput.js.map +1 -1
- package/createTheme.d.ts +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +18 -5
- package/dataProviders/ApiClient.js +58 -38
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/ApiClient.test.d.ts +1 -0
- package/dataProviders/ApiClient.test.js +116 -0
- package/dataProviders/ApiClient.test.js.map +1 -0
- package/dataProviders/DefaultDataProvider.d.ts +9 -3
- package/dataProviders/DefaultDataProvider.js +106 -35
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/DefaultDataProvider.test.d.ts +1 -0
- package/dataProviders/DefaultDataProvider.test.js +81 -0
- package/dataProviders/DefaultDataProvider.test.js.map +1 -0
- 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_LAYOUT_BY_SLUG.d.ts +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js +27 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +11 -1
- 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 +11 -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.d.ts +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +17 -5
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +18 -4
- package/dataProviders/NullDataProvider.js +33 -10
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.d.ts +11 -0
- package/dataProviders/RedirectsProvider.js +29 -0
- package/dataProviders/RedirectsProvider.js.map +1 -0
- package/dataProviders/queries.test.d.ts +1 -0
- package/dataProviders/queries.test.js +53 -0
- package/dataProviders/queries.test.js.map +1 -0
- package/defaultBreakpoints.d.ts +1 -1
- package/defaultBreakpoints.js +43 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
- package/documentOperations/$addElementReferenceToParent.js +30 -26
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.d.ts +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.d.ts +3 -3
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.d.ts +1 -1
- package/documentOperations/RemoveElement.js +10 -7
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.d.ts +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.d.ts +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.d.ts +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.d.ts +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.d.ts +8 -8
- package/documentOperations/index.js +16 -15
- 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 +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/findMatchingAstNode.d.ts +1 -1
- package/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.d.ts +1 -1
- package/generateElementId.js +2 -2
- package/generateElementId.js.map +1 -1
- package/globalElements.d.ts +43 -0
- package/globalElements.js +79 -0
- package/globalElements.js.map +1 -0
- package/globalElements.test.d.ts +1 -0
- package/globalElements.test.js +343 -0
- package/globalElements.test.js.map +1 -0
- package/headersProvider.d.ts +1 -2
- 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 +22 -3
- package/index.js +21 -5
- package/jsonPatch.d.ts +1 -1
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.d.ts +3 -0
- package/messages.js +15 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +59 -70
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +19 -23
- package/radioOptionInputs.d.ts +24 -0
- package/radioOptionInputs.js +26 -0
- package/radioOptionInputs.js.map +1 -0
- package/registerComponentGroup.d.ts +1 -1
- package/registerComponentGroup.js +6 -7
- package/registerComponentGroup.js.map +1 -1
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.d.ts +54 -45
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +369 -24
- package/types.js +0 -3
- package/withGlobalElementDefaults.d.ts +8 -0
- package/withGlobalElementDefaults.js +60 -0
- package/withGlobalElementDefaults.js.map +1 -0
- package/IBindingsUpdater.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/lexical/createDefaultLexicalTheme.d.ts +0 -2
- package/lexical/createDefaultLexicalTheme.js +0 -84
- package/lexical/createDefaultLexicalTheme.js.map +0 -1
- package/lexical/createLexicalTheme.d.ts +0 -2
- package/lexical/createLexicalTheme.js +0 -7
- package/lexical/createLexicalTheme.js.map +0 -1
- package/lexical/deepMerge.d.ts +0 -1
- package/lexical/deepMerge.js +0 -23
- package/lexical/deepMerge.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/LexicalEditorTheme.d.ts +0 -2
- package/types/LexicalEditorTheme.js +0 -3
- package/types/LexicalEditorTheme.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ContentSdk } from "./ContentSdk.js";
|
|
2
|
+
import type { ContentSDKConfig } from "./ContentSdk.js";
|
|
3
|
+
/**
|
|
4
|
+
* A configured content client. It exposes the same methods as `contentSdk`,
|
|
5
|
+
* except `init()`: a client's configuration is fixed when it is created.
|
|
6
|
+
*/
|
|
7
|
+
export type ContentClient = Omit<ContentSdk, "init">;
|
|
8
|
+
/**
|
|
9
|
+
* Create a content client with its own configuration and its own API client, separate
|
|
10
|
+
* from the `contentSdk` singleton and from other clients. Use it when one process serves
|
|
11
|
+
* requests for different tenants or API hosts.
|
|
12
|
+
*
|
|
13
|
+
* Data fetching is per client, and so are the component registry, the content entry cache
|
|
14
|
+
* and the document store. The editing environment is module-level and shared by all
|
|
15
|
+
* clients and `contentSdk`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createContentClient(config: ContentSDKConfig): ContentClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ContentSdk } from "./ContentSdk.js";
|
|
2
|
+
import { ComponentRegistry } from "./ComponentRegistry.js";
|
|
3
|
+
import { ContentEntryCache } from "./contentEntry/ContentEntryCache.js";
|
|
4
|
+
import { DocumentStoreManager } from "./DocumentStoreManager.js";
|
|
5
|
+
function createContentClient(config) {
|
|
6
|
+
const client = new ContentSdk({
|
|
7
|
+
componentRegistry: new ComponentRegistry(),
|
|
8
|
+
contentEntryCache: new ContentEntryCache(),
|
|
9
|
+
documentStoreManager: new DocumentStoreManager()
|
|
10
|
+
});
|
|
11
|
+
client.init(config);
|
|
12
|
+
return client;
|
|
13
|
+
}
|
|
14
|
+
export { createContentClient };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=createContentClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContentClient.js","sources":["../src/createContentClient.ts"],"sourcesContent":["import { ContentSdk } from \"./ContentSdk.js\";\nimport type { ContentSDKConfig } from \"./ContentSdk.js\";\nimport { ComponentRegistry } from \"./ComponentRegistry.js\";\nimport { ContentEntryCache } from \"./contentEntry/ContentEntryCache.js\";\nimport { DocumentStoreManager } from \"./DocumentStoreManager.js\";\n\n/**\n * A configured content client. It exposes the same methods as `contentSdk`,\n * except `init()`: a client's configuration is fixed when it is created.\n */\nexport type ContentClient = Omit<ContentSdk, \"init\">;\n\n/**\n * Create a content client with its own configuration and its own API client, separate\n * from the `contentSdk` singleton and from other clients. Use it when one process serves\n * requests for different tenants or API hosts.\n *\n * Data fetching is per client, and so are the component registry, the content entry cache\n * and the document store. The editing environment is module-level and shared by all\n * clients and `contentSdk`.\n */\nexport function createContentClient(config: ContentSDKConfig): ContentClient {\n const client = new ContentSdk({\n componentRegistry: new ComponentRegistry(),\n contentEntryCache: new ContentEntryCache(),\n documentStoreManager: new DocumentStoreManager()\n });\n client.init(config);\n return client;\n}\n"],"names":["createContentClient","config","client","ContentSdk","ComponentRegistry","ContentEntryCache","DocumentStoreManager"],"mappings":";;;;AAqBO,SAASA,oBAAoBC,MAAwB;IACxD,MAAMC,SAAS,IAAIC,WAAW;QAC1B,mBAAmB,IAAIC;QACvB,mBAAmB,IAAIC;QACvB,sBAAsB,IAAIC;IAC9B;IACAJ,OAAO,IAAI,CAACD;IACZ,OAAOC;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createContentClient } from "./createContentClient.js";
|
|
3
|
+
import { contentSdk } from "./ContentSdk.js";
|
|
4
|
+
const pageResponse = (path)=>({
|
|
5
|
+
data: {
|
|
6
|
+
websiteBuilder: {
|
|
7
|
+
getPageByPath: {
|
|
8
|
+
data: {
|
|
9
|
+
id: `page:${path}`,
|
|
10
|
+
properties: {
|
|
11
|
+
id: `page:${path}`,
|
|
12
|
+
path
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
error: null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
describe("createContentClient", ()=>{
|
|
21
|
+
let requests;
|
|
22
|
+
let delays;
|
|
23
|
+
beforeEach(()=>{
|
|
24
|
+
requests = [];
|
|
25
|
+
delays = {};
|
|
26
|
+
const fetchMock = vi.fn(async (url, init)=>{
|
|
27
|
+
const headers = init.headers;
|
|
28
|
+
const body = JSON.parse(init.body);
|
|
29
|
+
const path = body.variables.path;
|
|
30
|
+
requests.push({
|
|
31
|
+
url,
|
|
32
|
+
tenant: headers["X-Tenant"],
|
|
33
|
+
authorization: headers["Authorization"],
|
|
34
|
+
path
|
|
35
|
+
});
|
|
36
|
+
const delay = delays[path] ?? 0;
|
|
37
|
+
await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
38
|
+
return {
|
|
39
|
+
json: async ()=>pageResponse(path)
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
43
|
+
});
|
|
44
|
+
afterEach(()=>{
|
|
45
|
+
vi.unstubAllGlobals();
|
|
46
|
+
});
|
|
47
|
+
it("sends each client's own tenant, host and key", async ()=>{
|
|
48
|
+
const clientA = createContentClient({
|
|
49
|
+
apiHost: "https://a.example.com",
|
|
50
|
+
apiKey: "key-a",
|
|
51
|
+
apiTenant: "tenant-a"
|
|
52
|
+
});
|
|
53
|
+
const clientB = createContentClient({
|
|
54
|
+
apiHost: "https://b.example.com",
|
|
55
|
+
apiKey: "key-b",
|
|
56
|
+
apiTenant: "tenant-b"
|
|
57
|
+
});
|
|
58
|
+
await clientA.getPage("/a");
|
|
59
|
+
await clientB.getPage("/b");
|
|
60
|
+
expect(requests).toEqual([
|
|
61
|
+
{
|
|
62
|
+
url: "https://a.example.com/graphql",
|
|
63
|
+
tenant: "tenant-a",
|
|
64
|
+
authorization: "Bearer key-a",
|
|
65
|
+
path: "/a"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
url: "https://b.example.com/graphql",
|
|
69
|
+
tenant: "tenant-b",
|
|
70
|
+
authorization: "Bearer key-b",
|
|
71
|
+
path: "/b"
|
|
72
|
+
}
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
it("keeps clients isolated when their calls interleave", async ()=>{
|
|
76
|
+
const clientA = createContentClient({
|
|
77
|
+
apiHost: "https://a.example.com",
|
|
78
|
+
apiKey: "key-a",
|
|
79
|
+
apiTenant: "tenant-a"
|
|
80
|
+
});
|
|
81
|
+
const clientB = createContentClient({
|
|
82
|
+
apiHost: "https://b.example.com",
|
|
83
|
+
apiKey: "key-b",
|
|
84
|
+
apiTenant: "tenant-b"
|
|
85
|
+
});
|
|
86
|
+
delays["/a"] = 20;
|
|
87
|
+
delays["/b"] = 0;
|
|
88
|
+
const [pageA, pageB] = await Promise.all([
|
|
89
|
+
clientA.getPage("/a"),
|
|
90
|
+
clientB.getPage("/b")
|
|
91
|
+
]);
|
|
92
|
+
expect(pageA?.properties.path).toBe("/a");
|
|
93
|
+
expect(pageB?.properties.path).toBe("/b");
|
|
94
|
+
const requestA = requests.find((request)=>"/a" === request.path);
|
|
95
|
+
const requestB = requests.find((request)=>"/b" === request.path);
|
|
96
|
+
expect(requestA).toMatchObject({
|
|
97
|
+
url: "https://a.example.com/graphql",
|
|
98
|
+
tenant: "tenant-a",
|
|
99
|
+
authorization: "Bearer key-a"
|
|
100
|
+
});
|
|
101
|
+
expect(requestB).toMatchObject({
|
|
102
|
+
url: "https://b.example.com/graphql",
|
|
103
|
+
tenant: "tenant-b",
|
|
104
|
+
authorization: "Bearer key-b"
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it("does not change what the contentSdk singleton sends, and init() does not change a client", async ()=>{
|
|
108
|
+
contentSdk.init({
|
|
109
|
+
apiHost: "https://singleton.example.com",
|
|
110
|
+
apiKey: "key-singleton",
|
|
111
|
+
apiTenant: "root"
|
|
112
|
+
});
|
|
113
|
+
const client = createContentClient({
|
|
114
|
+
apiHost: "https://client.example.com",
|
|
115
|
+
apiKey: "key-client",
|
|
116
|
+
apiTenant: "tenant-client"
|
|
117
|
+
});
|
|
118
|
+
await contentSdk.getPage("/singleton");
|
|
119
|
+
contentSdk.init({
|
|
120
|
+
apiHost: "https://singleton-2.example.com",
|
|
121
|
+
apiKey: "key-singleton-2",
|
|
122
|
+
apiTenant: "root-2"
|
|
123
|
+
});
|
|
124
|
+
await client.getPage("/client");
|
|
125
|
+
await contentSdk.getPage("/singleton-2");
|
|
126
|
+
expect(requests).toEqual([
|
|
127
|
+
{
|
|
128
|
+
url: "https://singleton.example.com/graphql",
|
|
129
|
+
tenant: "root",
|
|
130
|
+
authorization: "Bearer key-singleton",
|
|
131
|
+
path: "/singleton"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
url: "https://client.example.com/graphql",
|
|
135
|
+
tenant: "tenant-client",
|
|
136
|
+
authorization: "Bearer key-client",
|
|
137
|
+
path: "/client"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
url: "https://singleton-2.example.com/graphql",
|
|
141
|
+
tenant: "root-2",
|
|
142
|
+
authorization: "Bearer key-singleton-2",
|
|
143
|
+
path: "/singleton-2"
|
|
144
|
+
}
|
|
145
|
+
]);
|
|
146
|
+
});
|
|
147
|
+
it("keeps the preview flag per client", ()=>{
|
|
148
|
+
const live = createContentClient({
|
|
149
|
+
apiHost: "https://a.example.com",
|
|
150
|
+
apiKey: "key-a",
|
|
151
|
+
apiTenant: "tenant-a"
|
|
152
|
+
});
|
|
153
|
+
const preview = createContentClient({
|
|
154
|
+
apiHost: "https://a.example.com",
|
|
155
|
+
apiKey: "key-a",
|
|
156
|
+
apiTenant: "tenant-a",
|
|
157
|
+
preview: true,
|
|
158
|
+
previewParams: "wb.type=page&wb.path=/a&wb.id=page-1"
|
|
159
|
+
});
|
|
160
|
+
expect(live.isPreviewing()).toBe(false);
|
|
161
|
+
expect(preview.isPreviewing()).toBe(true);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=createContentClient.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContentClient.test.js","sources":["../src/createContentClient.test.ts"],"sourcesContent":["import { describe, it, expect, beforeEach, afterEach, vi } from \"vitest\";\nimport { createContentClient } from \"./createContentClient.js\";\nimport { contentSdk } from \"./ContentSdk.js\";\n\ninterface RecordedRequest {\n url: string;\n tenant: string;\n authorization: string;\n path: string;\n}\n\nconst pageResponse = (path: string) => {\n return {\n data: {\n websiteBuilder: {\n getPageByPath: {\n data: { id: `page:${path}`, properties: { id: `page:${path}`, path } },\n error: null\n }\n }\n }\n };\n};\n\ndescribe(\"createContentClient\", () => {\n let requests: RecordedRequest[];\n let delays: Record<string, number>;\n\n beforeEach(() => {\n requests = [];\n delays = {};\n\n const fetchMock = vi.fn(async (url: string, init: RequestInit) => {\n const headers = init.headers as Record<string, string>;\n const body = JSON.parse(init.body as string);\n const path: string = body.variables.path;\n requests.push({\n url,\n tenant: headers[\"X-Tenant\"],\n authorization: headers[\"Authorization\"],\n path\n });\n\n const delay = delays[path] ?? 0;\n await new Promise(resolve => setTimeout(resolve, delay));\n\n return { json: async () => pageResponse(path) };\n });\n\n vi.stubGlobal(\"fetch\", fetchMock);\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n });\n\n it(\"sends each client's own tenant, host and key\", async () => {\n const clientA = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\"\n });\n const clientB = createContentClient({\n apiHost: \"https://b.example.com\",\n apiKey: \"key-b\",\n apiTenant: \"tenant-b\"\n });\n\n await clientA.getPage(\"/a\");\n await clientB.getPage(\"/b\");\n\n expect(requests).toEqual([\n {\n url: \"https://a.example.com/graphql\",\n tenant: \"tenant-a\",\n authorization: \"Bearer key-a\",\n path: \"/a\"\n },\n {\n url: \"https://b.example.com/graphql\",\n tenant: \"tenant-b\",\n authorization: \"Bearer key-b\",\n path: \"/b\"\n }\n ]);\n });\n\n it(\"keeps clients isolated when their calls interleave\", async () => {\n const clientA = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\"\n });\n const clientB = createContentClient({\n apiHost: \"https://b.example.com\",\n apiKey: \"key-b\",\n apiTenant: \"tenant-b\"\n });\n\n // The first request to start is the last to finish.\n delays[\"/a\"] = 20;\n delays[\"/b\"] = 0;\n\n const [pageA, pageB] = await Promise.all([clientA.getPage(\"/a\"), clientB.getPage(\"/b\")]);\n\n expect(pageA?.properties.path).toBe(\"/a\");\n expect(pageB?.properties.path).toBe(\"/b\");\n\n const requestA = requests.find(request => request.path === \"/a\");\n const requestB = requests.find(request => request.path === \"/b\");\n\n expect(requestA).toMatchObject({\n url: \"https://a.example.com/graphql\",\n tenant: \"tenant-a\",\n authorization: \"Bearer key-a\"\n });\n expect(requestB).toMatchObject({\n url: \"https://b.example.com/graphql\",\n tenant: \"tenant-b\",\n authorization: \"Bearer key-b\"\n });\n });\n\n it(\"does not change what the contentSdk singleton sends, and init() does not change a client\", async () => {\n contentSdk.init({\n apiHost: \"https://singleton.example.com\",\n apiKey: \"key-singleton\",\n apiTenant: \"root\"\n });\n\n const client = createContentClient({\n apiHost: \"https://client.example.com\",\n apiKey: \"key-client\",\n apiTenant: \"tenant-client\"\n });\n\n await contentSdk.getPage(\"/singleton\");\n\n contentSdk.init({\n apiHost: \"https://singleton-2.example.com\",\n apiKey: \"key-singleton-2\",\n apiTenant: \"root-2\"\n });\n\n await client.getPage(\"/client\");\n await contentSdk.getPage(\"/singleton-2\");\n\n expect(requests).toEqual([\n {\n url: \"https://singleton.example.com/graphql\",\n tenant: \"root\",\n authorization: \"Bearer key-singleton\",\n path: \"/singleton\"\n },\n {\n url: \"https://client.example.com/graphql\",\n tenant: \"tenant-client\",\n authorization: \"Bearer key-client\",\n path: \"/client\"\n },\n {\n url: \"https://singleton-2.example.com/graphql\",\n tenant: \"root-2\",\n authorization: \"Bearer key-singleton-2\",\n path: \"/singleton-2\"\n }\n ]);\n });\n\n it(\"keeps the preview flag per client\", () => {\n const live = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\"\n });\n const preview = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\",\n preview: true,\n previewParams: \"wb.type=page&wb.path=/a&wb.id=page-1\"\n });\n\n expect(live.isPreviewing()).toBe(false);\n expect(preview.isPreviewing()).toBe(true);\n });\n});\n"],"names":["pageResponse","path","describe","requests","delays","beforeEach","fetchMock","vi","url","init","headers","body","JSON","delay","Promise","resolve","setTimeout","afterEach","it","clientA","createContentClient","clientB","expect","pageA","pageB","requestA","request","requestB","contentSdk","client","live","preview"],"mappings":";;;AAWA,MAAMA,eAAe,CAACC,OACX;QACH,MAAM;YACF,gBAAgB;gBACZ,eAAe;oBACX,MAAM;wBAAE,IAAI,CAAC,KAAK,EAAEA,MAAM;wBAAE,YAAY;4BAAE,IAAI,CAAC,KAAK,EAAEA,MAAM;4BAAEA;wBAAK;oBAAE;oBACrE,OAAO;gBACX;YACJ;QACJ;IACJ;AAGJC,SAAS,uBAAuB;IAC5B,IAAIC;IACJ,IAAIC;IAEJC,WAAW;QACPF,WAAW,EAAE;QACbC,SAAS,CAAC;QAEV,MAAME,YAAYC,GAAG,EAAE,CAAC,OAAOC,KAAaC;YACxC,MAAMC,UAAUD,KAAK,OAAO;YAC5B,MAAME,OAAOC,KAAK,KAAK,CAACH,KAAK,IAAI;YACjC,MAAMR,OAAeU,KAAK,SAAS,CAAC,IAAI;YACxCR,SAAS,IAAI,CAAC;gBACVK;gBACA,QAAQE,OAAO,CAAC,WAAW;gBAC3B,eAAeA,OAAO,CAAC,gBAAgB;gBACvCT;YACJ;YAEA,MAAMY,QAAQT,MAAM,CAACH,KAAK,IAAI;YAC9B,MAAM,IAAIa,QAAQC,CAAAA,UAAWC,WAAWD,SAASF;YAEjD,OAAO;gBAAE,MAAM,UAAYb,aAAaC;YAAM;QAClD;QAEAM,GAAG,UAAU,CAAC,SAASD;IAC3B;IAEAW,UAAU;QACNV,GAAG,gBAAgB;IACvB;IAEAW,GAAG,gDAAgD;QAC/C,MAAMC,UAAUC,oBAAoB;YAChC,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QACA,MAAMC,UAAUD,oBAAoB;YAChC,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QAEA,MAAMD,QAAQ,OAAO,CAAC;QACtB,MAAME,QAAQ,OAAO,CAAC;QAEtBC,OAAOnB,UAAU,OAAO,CAAC;YACrB;gBACI,KAAK;gBACL,QAAQ;gBACR,eAAe;gBACf,MAAM;YACV;YACA;gBACI,KAAK;gBACL,QAAQ;gBACR,eAAe;gBACf,MAAM;YACV;SACH;IACL;IAEAe,GAAG,sDAAsD;QACrD,MAAMC,UAAUC,oBAAoB;YAChC,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QACA,MAAMC,UAAUD,oBAAoB;YAChC,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QAGAhB,MAAM,CAAC,KAAK,GAAG;QACfA,MAAM,CAAC,KAAK,GAAG;QAEf,MAAM,CAACmB,OAAOC,MAAM,GAAG,MAAMV,QAAQ,GAAG,CAAC;YAACK,QAAQ,OAAO,CAAC;YAAOE,QAAQ,OAAO,CAAC;SAAM;QAEvFC,OAAOC,OAAO,WAAW,MAAM,IAAI,CAAC;QACpCD,OAAOE,OAAO,WAAW,MAAM,IAAI,CAAC;QAEpC,MAAMC,WAAWtB,SAAS,IAAI,CAACuB,CAAAA,UAAWA,AAAiB,SAAjBA,QAAQ,IAAI;QACtD,MAAMC,WAAWxB,SAAS,IAAI,CAACuB,CAAAA,UAAWA,AAAiB,SAAjBA,QAAQ,IAAI;QAEtDJ,OAAOG,UAAU,aAAa,CAAC;YAC3B,KAAK;YACL,QAAQ;YACR,eAAe;QACnB;QACAH,OAAOK,UAAU,aAAa,CAAC;YAC3B,KAAK;YACL,QAAQ;YACR,eAAe;QACnB;IACJ;IAEAT,GAAG,4FAA4F;QAC3FU,WAAW,IAAI,CAAC;YACZ,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QAEA,MAAMC,SAAST,oBAAoB;YAC/B,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QAEA,MAAMQ,WAAW,OAAO,CAAC;QAEzBA,WAAW,IAAI,CAAC;YACZ,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QAEA,MAAMC,OAAO,OAAO,CAAC;QACrB,MAAMD,WAAW,OAAO,CAAC;QAEzBN,OAAOnB,UAAU,OAAO,CAAC;YACrB;gBACI,KAAK;gBACL,QAAQ;gBACR,eAAe;gBACf,MAAM;YACV;YACA;gBACI,KAAK;gBACL,QAAQ;gBACR,eAAe;gBACf,MAAM;YACV;YACA;gBACI,KAAK;gBACL,QAAQ;gBACR,eAAe;gBACf,MAAM;YACV;SACH;IACL;IAEAe,GAAG,qCAAqC;QACpC,MAAMY,OAAOV,oBAAoB;YAC7B,SAAS;YACT,QAAQ;YACR,WAAW;QACf;QACA,MAAMW,UAAUX,oBAAoB;YAChC,SAAS;YACT,QAAQ;YACR,WAAW;YACX,SAAS;YACT,eAAe;QACnB;QAEAE,OAAOQ,KAAK,YAAY,IAAI,IAAI,CAAC;QACjCR,OAAOS,QAAQ,YAAY,IAAI,IAAI,CAAC;IACxC;AACJ"}
|
package/createElement.d.ts
CHANGED
package/createElement.js
CHANGED
package/createElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createElement.js","sources":["../src/createElement.ts"],"sourcesContent":["import type { ResponsiveStyles } from \"~/types.js\";\n\nexport interface CreateElementParams {\n component: string;\n inputs?: Record<string, any>;\n styles?: ResponsiveStyles;\n}\n\nexport const createElement = (params: CreateElementParams) => {\n return {\n action: \"CreateElement\",\n params\n };\n};\n"],"names":["createElement","params"],"mappings":"AAQO,MAAMA,gBAAgB,CAACC,SACnB;QACH,QAAQ;QACRA;IACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentManifest, GlobalDocument } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the default instance of a global component (element + bindings) from its manifest defaults.
|
|
4
|
+
* Used when a global exists in code but has no stored instance yet.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createGlobalElementDocument: (componentName: string, components: Record<string, ComponentManifest>) => GlobalDocument;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ElementFactory } from "./ElementFactory.js";
|
|
2
|
+
const createDefaultIdGenerator = (componentName)=>{
|
|
3
|
+
const name = componentName.replace(/[^a-zA-Z0-9]/gu, (char)=>`_${char.codePointAt(0).toString(16)}_`);
|
|
4
|
+
const prefix = `global-${name}`;
|
|
5
|
+
let counter = 0;
|
|
6
|
+
return ()=>`${prefix}-${++counter}`;
|
|
7
|
+
};
|
|
8
|
+
const createGlobalElementDocument = (componentName, components)=>{
|
|
9
|
+
const factory = new ElementFactory(components, createDefaultIdGenerator(componentName));
|
|
10
|
+
const { operations } = factory.createGlobalElement(componentName);
|
|
11
|
+
const document = {
|
|
12
|
+
elements: {},
|
|
13
|
+
bindings: {}
|
|
14
|
+
};
|
|
15
|
+
operations.forEach((operation)=>operation.apply(document));
|
|
16
|
+
return {
|
|
17
|
+
elements: document.elements,
|
|
18
|
+
bindings: document.bindings
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { createGlobalElementDocument };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=createGlobalElementDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGlobalElementDocument.js","sources":["../src/createGlobalElementDocument.ts"],"sourcesContent":["import type { ComponentManifest, Document, GlobalDocument } from \"./types.js\";\nimport { ElementFactory } from \"./ElementFactory.js\";\n\n/**\n * Ids for the elements and bindings of a default global instance. They are derived from the component\n * name, so every build of the same defaults yields the same ids: the server render and the client\n * hydration agree, and re-renders don't remount the global's children. The hyphens keep them apart\n * from generated ids, which use only lowercase letters and digits.\n * Every other character of the name is escaped as `_<hex code point>_`, so two different names never\n * share a prefix (`Demo/Header` and `Demo-Header` would both collapse to `Demo-Header` otherwise).\n */\nconst createDefaultIdGenerator = (componentName: string) => {\n const name = componentName.replace(/[^a-zA-Z0-9]/gu, char => {\n return `_${char.codePointAt(0)!.toString(16)}_`;\n });\n const prefix = `global-${name}`;\n let counter = 0;\n return () => `${prefix}-${++counter}`;\n};\n\n/**\n * Build the default instance of a global component (element + bindings) from its manifest defaults.\n * Used when a global exists in code but has no stored instance yet.\n */\nexport const createGlobalElementDocument = (\n componentName: string,\n components: Record<string, ComponentManifest>\n): GlobalDocument => {\n const factory = new ElementFactory(components, createDefaultIdGenerator(componentName));\n const { operations } = factory.createGlobalElement(componentName);\n\n const document = { elements: {}, bindings: {} } as Document;\n operations.forEach(operation => operation.apply(document));\n\n return { elements: document.elements, bindings: document.bindings };\n};\n"],"names":["createDefaultIdGenerator","componentName","name","char","prefix","counter","createGlobalElementDocument","components","factory","ElementFactory","operations","document","operation"],"mappings":";AAWA,MAAMA,2BAA2B,CAACC;IAC9B,MAAMC,OAAOD,cAAc,OAAO,CAAC,kBAAkBE,CAAAA,OAC1C,CAAC,CAAC,EAAEA,KAAK,WAAW,CAAC,GAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEnD,MAAMC,SAAS,CAAC,OAAO,EAAEF,MAAM;IAC/B,IAAIG,UAAU;IACd,OAAO,IAAM,GAAGD,OAAO,CAAC,EAAE,EAAEC,SAAS;AACzC;AAMO,MAAMC,8BAA8B,CACvCL,eACAM;IAEA,MAAMC,UAAU,IAAIC,eAAeF,YAAYP,yBAAyBC;IACxE,MAAM,EAAES,UAAU,EAAE,GAAGF,QAAQ,mBAAmB,CAACP;IAEnD,MAAMU,WAAW;QAAE,UAAU,CAAC;QAAG,UAAU,CAAC;IAAE;IAC9CD,WAAW,OAAO,CAACE,CAAAA,YAAaA,UAAU,KAAK,CAACD;IAEhD,OAAO;QAAE,UAAUA,SAAS,QAAQ;QAAE,UAAUA,SAAS,QAAQ;IAAC;AACtE"}
|
package/createInput.d.ts
CHANGED
|
@@ -1,17 +1,133 @@
|
|
|
1
|
-
import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput } from "./types";
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput, ContentEntryInput } from "./types.js";
|
|
2
|
+
export type InputFactory<Name extends string> = ReturnType<typeof createTextInput<Name>> | ReturnType<typeof createLongTextInput<Name>> | ReturnType<typeof createNumberInput<Name>> | ReturnType<typeof createBooleanInput<Name>> | ReturnType<typeof createColorInput<Name>> | ReturnType<typeof createFileInput<Name>> | ReturnType<typeof createDateInput<Name>> | ReturnType<typeof createLexicalInput<Name>> | ReturnType<typeof createSelectInput<Name>> | ReturnType<typeof createRadioInput<Name>> | ReturnType<typeof createObjectInput<Name>> | ReturnType<typeof createTagsInput<Name>> | ReturnType<typeof createSlotInput<Name>> | ReturnType<typeof createContentEntryInput<Name>>;
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript Overload Resolution and Input Factory Design
|
|
5
|
+
*
|
|
6
|
+
* Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:
|
|
7
|
+
* 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).
|
|
8
|
+
* 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).
|
|
9
|
+
*
|
|
10
|
+
* TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.
|
|
11
|
+
* The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.
|
|
12
|
+
*
|
|
13
|
+
* In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.
|
|
14
|
+
* In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)
|
|
15
|
+
* provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context
|
|
16
|
+
* to resolve the correct type for `TName` even when `name` is omitted from the input.
|
|
17
|
+
*
|
|
18
|
+
* This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,
|
|
19
|
+
* so consumers of these factories do not need to worry about the presence of the `name` property in the result.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTextInput<TName extends string>(input: {
|
|
22
|
+
name: TName;
|
|
23
|
+
} & Omit<TextInput, "type" | "name">): TextInput & {
|
|
24
|
+
name: TName;
|
|
25
|
+
};
|
|
26
|
+
export declare function createTextInput<TName extends string>(input: Omit<TextInput, "type" | "name">): TextInput & {
|
|
27
|
+
name: TName;
|
|
28
|
+
};
|
|
29
|
+
export declare function createLongTextInput<TName extends string>(input: {
|
|
30
|
+
name: TName;
|
|
31
|
+
} & Omit<LongTextInput, "type" | "name">): LongTextInput & {
|
|
32
|
+
name: TName;
|
|
33
|
+
};
|
|
34
|
+
export declare function createLongTextInput<TName extends string>(input: Omit<LongTextInput, "type" | "name">): LongTextInput & {
|
|
35
|
+
name: TName;
|
|
36
|
+
};
|
|
37
|
+
export declare function createNumberInput<TName extends string>(input: {
|
|
38
|
+
name: TName;
|
|
39
|
+
} & Omit<NumberInput, "type" | "name">): NumberInput & {
|
|
40
|
+
name: TName;
|
|
41
|
+
};
|
|
42
|
+
export declare function createNumberInput<TName extends string>(input: Omit<NumberInput, "type" | "name">): NumberInput & {
|
|
43
|
+
name: TName;
|
|
44
|
+
};
|
|
45
|
+
export declare function createBooleanInput<TName extends string>(input: {
|
|
46
|
+
name: TName;
|
|
47
|
+
} & Omit<BooleanInput, "type" | "name">): BooleanInput & {
|
|
48
|
+
name: TName;
|
|
49
|
+
};
|
|
50
|
+
export declare function createBooleanInput<TName extends string>(input: Omit<BooleanInput, "type" | "name">): BooleanInput & {
|
|
51
|
+
name: TName;
|
|
52
|
+
};
|
|
53
|
+
export declare function createColorInput<TName extends string>(input: {
|
|
54
|
+
name: TName;
|
|
55
|
+
} & Omit<ColorInput, "type" | "name">): ColorInput & {
|
|
56
|
+
name: TName;
|
|
57
|
+
};
|
|
58
|
+
export declare function createColorInput<TName extends string>(input: Omit<ColorInput, "type" | "name">): ColorInput & {
|
|
59
|
+
name: TName;
|
|
60
|
+
};
|
|
61
|
+
export declare function createFileInput<TName extends string>(input: {
|
|
62
|
+
name: TName;
|
|
63
|
+
} & Omit<FileInput, "type" | "name">): FileInput & {
|
|
64
|
+
name: TName;
|
|
65
|
+
};
|
|
66
|
+
export declare function createFileInput<TName extends string>(input: Omit<FileInput, "type" | "name">): FileInput & {
|
|
67
|
+
name: TName;
|
|
68
|
+
};
|
|
69
|
+
export declare function createDateInput<TName extends string>(input: {
|
|
70
|
+
name: TName;
|
|
71
|
+
} & Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
|
|
72
|
+
name: TName;
|
|
73
|
+
};
|
|
74
|
+
export declare function createDateInput<TName extends string>(input: Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
|
|
75
|
+
name: TName;
|
|
76
|
+
};
|
|
77
|
+
export declare function createLexicalInput<TName extends string>(input: {
|
|
78
|
+
name: TName;
|
|
79
|
+
} & Omit<LexicalInput, "type" | "name">): LexicalInput & {
|
|
80
|
+
name: TName;
|
|
81
|
+
};
|
|
82
|
+
export declare function createLexicalInput<TName extends string>(input: Omit<LexicalInput, "type" | "name">): LexicalInput & {
|
|
83
|
+
name: TName;
|
|
84
|
+
};
|
|
85
|
+
export declare function createSelectInput<TName extends string>(input: {
|
|
86
|
+
name: TName;
|
|
87
|
+
} & Omit<SelectInput, "type" | "name">): SelectInput & {
|
|
88
|
+
name: TName;
|
|
89
|
+
};
|
|
90
|
+
export declare function createSelectInput<TName extends string>(input: Omit<SelectInput, "type" | "name">): SelectInput & {
|
|
91
|
+
name: TName;
|
|
92
|
+
};
|
|
93
|
+
export declare function createRadioInput<TName extends string>(input: {
|
|
94
|
+
name: TName;
|
|
95
|
+
} & Omit<RadioInput, "type" | "name">): RadioInput & {
|
|
96
|
+
name: TName;
|
|
97
|
+
};
|
|
98
|
+
export declare function createRadioInput<TName extends string>(input: Omit<RadioInput, "type" | "name">): RadioInput & {
|
|
99
|
+
name: TName;
|
|
100
|
+
};
|
|
101
|
+
export declare function createObjectInput<TName extends string>(input: {
|
|
102
|
+
name: TName;
|
|
103
|
+
} & Omit<ObjectInput, "type" | "name">): ObjectInput & {
|
|
104
|
+
name: TName;
|
|
105
|
+
};
|
|
106
|
+
export declare function createObjectInput<TName extends string>(input: Omit<ObjectInput, "type" | "name">): ObjectInput & {
|
|
107
|
+
name: TName;
|
|
108
|
+
};
|
|
109
|
+
export declare function createTagsInput<TName extends string>(input: {
|
|
110
|
+
name: TName;
|
|
111
|
+
} & Omit<TagsInput, "type" | "name">): TagsInput & {
|
|
112
|
+
name: TName;
|
|
113
|
+
};
|
|
114
|
+
export declare function createTagsInput<TName extends string>(input: Omit<TagsInput, "type" | "name">): TagsInput & {
|
|
115
|
+
name: TName;
|
|
116
|
+
};
|
|
117
|
+
export declare function createSlotInput<TName extends string>(input: {
|
|
118
|
+
name: TName;
|
|
119
|
+
} & Omit<SlotInput, "type" | "name">): SlotInput & {
|
|
120
|
+
name: TName;
|
|
121
|
+
};
|
|
122
|
+
export declare function createSlotInput<TName extends string>(input: Omit<SlotInput, "type" | "name">): SlotInput & {
|
|
123
|
+
name: TName;
|
|
124
|
+
};
|
|
125
|
+
export declare function createContentEntryInput<TName extends string>(input: {
|
|
126
|
+
name: TName;
|
|
127
|
+
} & Omit<ContentEntryInput, "type" | "name">): ContentEntryInput & {
|
|
128
|
+
name: TName;
|
|
129
|
+
};
|
|
130
|
+
export declare function createContentEntryInput<TName extends string>(input: Omit<ContentEntryInput, "type" | "name">): ContentEntryInput & {
|
|
131
|
+
name: TName;
|
|
132
|
+
};
|
|
16
133
|
export declare function createInput(input: ComponentInput): ComponentInput;
|
|
17
|
-
export {};
|