@webiny/website-builder-sdk 6.0.0-rc.2 → 6.0.0-rc.3
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/ContentSdk.d.ts +3 -3
- package/ContentSdk.js +4 -4
- package/ContentSdk.js.map +1 -1
- package/EditingSdk.d.ts +2 -2
- package/EditingSdk.js +2 -2
- package/EditingSdk.js.map +1 -1
- package/LiveSdk.d.ts +2 -2
- package/LiveSdk.js.map +1 -1
- package/NullSdk.d.ts +2 -2
- package/NullSdk.js +8 -1
- package/NullSdk.js.map +1 -1
- package/PreviewSdk.d.ts +2 -2
- package/PreviewSdk.js +2 -2
- package/PreviewSdk.js.map +1 -1
- package/dataProviders/DefaultDataProvider.d.ts +2 -2
- package/dataProviders/DefaultDataProvider.js +16 -3
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +13 -2
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +8 -1
- package/dataProviders/NullDataProvider.js +8 -1
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/package.json +3 -3
- package/types.d.ts +18 -3
- package/types.js.map +1 -1
package/ContentSdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component, IContentSdk, PublicPage, PublicRedirect, ResolvedComponent } from "./types.js";
|
|
1
|
+
import type { Component, IContentSdk, ListPagesOptions, ListPagesResult, PublicPage, PublicRedirect, ResolvedComponent } from "./types.js";
|
|
2
2
|
import { LiveSdk } from "./LiveSdk.js";
|
|
3
3
|
import { EditingSdk } from "./EditingSdk.js";
|
|
4
4
|
import { type ResolveElementParams } from "./ComponentResolver.js";
|
|
@@ -20,7 +20,7 @@ declare class InternalContentSdk implements IContentSdk, IRedirects {
|
|
|
20
20
|
constructor(redirectsProvider: IRedirects, liveSdk: LiveSdk, editingSdk?: EditingSdk);
|
|
21
21
|
getEditingSdk(): EditingSdk | undefined;
|
|
22
22
|
getPage(path: string): Promise<PublicPage | null>;
|
|
23
|
-
listPages(): Promise<
|
|
23
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
24
24
|
getAllRedirects(): Promise<Map<string, PublicRedirect>>;
|
|
25
25
|
getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;
|
|
26
26
|
}
|
|
@@ -31,7 +31,7 @@ export declare class ContentSdk implements IContentSdk, IRedirects {
|
|
|
31
31
|
init(config: ContentSDKConfig, afterInit?: () => void): void;
|
|
32
32
|
getEditingSdk(): EditingSdk | undefined;
|
|
33
33
|
getPage(path: string): Promise<PublicPage | null>;
|
|
34
|
-
listPages(): Promise<
|
|
34
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
35
35
|
getAllRedirects(): Promise<Map<string, PublicRedirect>>;
|
|
36
36
|
getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;
|
|
37
37
|
registerComponent(blueprint: Component): void;
|
package/ContentSdk.js
CHANGED
|
@@ -21,8 +21,8 @@ class InternalContentSdk {
|
|
|
21
21
|
async getPage(path) {
|
|
22
22
|
return this.activeSdk.getPage(path);
|
|
23
23
|
}
|
|
24
|
-
listPages() {
|
|
25
|
-
return this.activeSdk.listPages();
|
|
24
|
+
listPages(options) {
|
|
25
|
+
return this.activeSdk.listPages(options);
|
|
26
26
|
}
|
|
27
27
|
getAllRedirects() {
|
|
28
28
|
return this.redirectsProvider.getAllRedirects();
|
|
@@ -69,9 +69,9 @@ export class ContentSdk {
|
|
|
69
69
|
this.assertInitialized();
|
|
70
70
|
return this.sdk.getPage(path);
|
|
71
71
|
}
|
|
72
|
-
listPages() {
|
|
72
|
+
listPages(options) {
|
|
73
73
|
this.assertInitialized();
|
|
74
|
-
return this.sdk.listPages();
|
|
74
|
+
return this.sdk.listPages(options);
|
|
75
75
|
}
|
|
76
76
|
async getAllRedirects() {
|
|
77
77
|
this.assertInitialized();
|
package/ContentSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["environment","LiveSdk","EditingSdk","ComponentResolver","PreviewSdk","componentRegistry","ApiClient","DefaultDataProvider","Theme","viewportManager","RedirectsProvider","InternalContentSdk","constructor","redirectsProvider","liveSdk","editingSdk","activeSdk","getEditingSdk","getPage","path","listPages","getAllRedirects","getRedirectByPath","ContentSdk","isPreview","init","config","afterInit","configHash","JSON","stringify","lastConfig","apiClient","apiHost","apiKey","apiTenant","dataProvider","preview","isEditing","theme","from","isClient","setBreakpoints","breakpoints","sdk","assertInitialized","registerComponent","blueprint","register","resolveElement","params","resolve","isPreviewing","Error","contentSdk"],"sources":["ContentSdk.ts"],"sourcesContent":["import type {\n Component,\n IContentSdk,\n PublicPage,\n PublicRedirect,\n ResolvedComponent\n} from \"~/types.js\";\nimport { environment } from \"./Environment.js\";\nimport { LiveSdk } from \"./LiveSdk.js\";\nimport { EditingSdk } from \"./EditingSdk.js\";\nimport { ComponentResolver, type ResolveElementParams } from \"~/ComponentResolver.js\";\nimport { PreviewSdk } from \"./PreviewSdk.js\";\nimport { componentRegistry } from \"~/ComponentRegistry.js\";\nimport { ApiClient } from \"~/dataProviders/ApiClient.js\";\nimport { DefaultDataProvider } from \"~/dataProviders/DefaultDataProvider.js\";\nimport type { WebsiteBuilderThemeInput } from \"./types/WebsiteBuilderTheme.js\";\nimport { Theme } from \"./Theme.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\nimport type { IRedirects } from \"~/IRedirects.js\";\nimport { RedirectsProvider } from \"~/dataProviders/RedirectsProvider.js\";\n\nexport type ApiConfig = {\n apiKey: string;\n apiHost: string;\n apiTenant: string;\n};\n\nexport type ContentSDKConfig = ApiConfig & {\n preview?: boolean;\n theme?: WebsiteBuilderThemeInput;\n};\n\nclass InternalContentSdk implements IContentSdk, IRedirects {\n private activeSdk: IContentSdk;\n private editingSdk: EditingSdk | undefined;\n private redirectsProvider: IRedirects;\n\n constructor(redirectsProvider: IRedirects, liveSdk: LiveSdk, editingSdk?: EditingSdk) {\n this.redirectsProvider = redirectsProvider;\n this.activeSdk = editingSdk ?? liveSdk;\n this.editingSdk = editingSdk;\n }\n\n getEditingSdk() {\n return this.editingSdk;\n }\n\n async getPage(path: string): Promise<PublicPage | null> {\n return this.activeSdk.getPage(path);\n }\n\n listPages(): Promise<
|
|
1
|
+
{"version":3,"names":["environment","LiveSdk","EditingSdk","ComponentResolver","PreviewSdk","componentRegistry","ApiClient","DefaultDataProvider","Theme","viewportManager","RedirectsProvider","InternalContentSdk","constructor","redirectsProvider","liveSdk","editingSdk","activeSdk","getEditingSdk","getPage","path","listPages","options","getAllRedirects","getRedirectByPath","ContentSdk","isPreview","init","config","afterInit","configHash","JSON","stringify","lastConfig","apiClient","apiHost","apiKey","apiTenant","dataProvider","preview","isEditing","theme","from","isClient","setBreakpoints","breakpoints","sdk","assertInitialized","registerComponent","blueprint","register","resolveElement","params","resolve","isPreviewing","Error","contentSdk"],"sources":["ContentSdk.ts"],"sourcesContent":["import type {\n Component,\n IContentSdk,\n ListPagesOptions,\n ListPagesResult,\n PublicPage,\n PublicRedirect,\n ResolvedComponent\n} from \"~/types.js\";\nimport { environment } from \"./Environment.js\";\nimport { LiveSdk } from \"./LiveSdk.js\";\nimport { EditingSdk } from \"./EditingSdk.js\";\nimport { ComponentResolver, type ResolveElementParams } from \"~/ComponentResolver.js\";\nimport { PreviewSdk } from \"./PreviewSdk.js\";\nimport { componentRegistry } from \"~/ComponentRegistry.js\";\nimport { ApiClient } from \"~/dataProviders/ApiClient.js\";\nimport { DefaultDataProvider } from \"~/dataProviders/DefaultDataProvider.js\";\nimport type { WebsiteBuilderThemeInput } from \"./types/WebsiteBuilderTheme.js\";\nimport { Theme } from \"./Theme.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\nimport type { IRedirects } from \"~/IRedirects.js\";\nimport { RedirectsProvider } from \"~/dataProviders/RedirectsProvider.js\";\n\nexport type ApiConfig = {\n apiKey: string;\n apiHost: string;\n apiTenant: string;\n};\n\nexport type ContentSDKConfig = ApiConfig & {\n preview?: boolean;\n theme?: WebsiteBuilderThemeInput;\n};\n\nclass InternalContentSdk implements IContentSdk, IRedirects {\n private activeSdk: IContentSdk;\n private editingSdk: EditingSdk | undefined;\n private redirectsProvider: IRedirects;\n\n constructor(redirectsProvider: IRedirects, liveSdk: LiveSdk, editingSdk?: EditingSdk) {\n this.redirectsProvider = redirectsProvider;\n this.activeSdk = editingSdk ?? liveSdk;\n this.editingSdk = editingSdk;\n }\n\n getEditingSdk() {\n return this.editingSdk;\n }\n\n async getPage(path: string): Promise<PublicPage | null> {\n return this.activeSdk.getPage(path);\n }\n\n listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n return this.activeSdk.listPages(options);\n }\n\n getAllRedirects(): Promise<Map<string, PublicRedirect>> {\n return this.redirectsProvider.getAllRedirects();\n }\n\n getRedirectByPath(path: string): Promise<PublicRedirect | undefined> {\n return this.redirectsProvider.getRedirectByPath(path);\n }\n}\n\nexport class ContentSdk implements IContentSdk, IRedirects {\n protected sdk?: InternalContentSdk;\n private isPreview = false;\n private lastConfig: any;\n\n public init(config: ContentSDKConfig, afterInit?: () => void): void {\n const configHash = JSON.stringify(config);\n if (this.lastConfig && this.lastConfig === configHash) {\n return;\n }\n\n this.lastConfig = configHash;\n const apiClient = new ApiClient(config.apiHost, config.apiKey, config.apiTenant);\n\n const dataProvider = new DefaultDataProvider({ apiClient });\n\n let liveSdk: IContentSdk = new LiveSdk(dataProvider);\n\n if (config.preview && !environment.isEditing()) {\n this.isPreview = true;\n liveSdk = new PreviewSdk(dataProvider, liveSdk);\n }\n\n const theme = Theme.from(config.theme ?? {});\n\n if (environment.isClient()) {\n viewportManager.setBreakpoints(theme.breakpoints);\n }\n\n let editingSdk;\n if (environment.isEditing()) {\n editingSdk = new EditingSdk(liveSdk, theme);\n }\n\n this.sdk = new InternalContentSdk(\n new RedirectsProvider(apiClient),\n liveSdk as LiveSdk,\n editingSdk\n );\n\n if (typeof afterInit === \"function\") {\n afterInit();\n }\n }\n\n public getEditingSdk() {\n this.assertInitialized();\n return this.sdk.getEditingSdk();\n }\n\n public getPage(path: string) {\n this.assertInitialized();\n return this.sdk.getPage(path);\n }\n\n public listPages(options?: ListPagesOptions) {\n this.assertInitialized();\n return this.sdk.listPages(options);\n }\n\n public async getAllRedirects() {\n this.assertInitialized();\n return this.sdk.getAllRedirects();\n }\n\n getRedirectByPath(path: string): Promise<PublicRedirect | undefined> {\n this.assertInitialized();\n return this.sdk.getRedirectByPath(path);\n }\n\n registerComponent(blueprint: Component): void {\n this.assertInitialized();\n componentRegistry.register(blueprint);\n }\n\n resolveElement(params: ResolveElementParams): ResolvedComponent[] | null {\n this.assertInitialized();\n return new ComponentResolver(componentRegistry).resolve(params);\n }\n\n isEditing() {\n return environment.isEditing();\n }\n\n isPreviewing() {\n return this.isPreview;\n }\n\n private assertInitialized(): asserts this is this & {\n sdk: IContentSdk;\n } {\n if (!this.sdk) {\n throw new Error(`ContentSdk has not been initialized!`);\n }\n }\n}\n\nexport const contentSdk = new ContentSdk();\n"],"mappings":"AASA,SAASA,WAAW;AACpB,SAASC,OAAO;AAChB,SAASC,UAAU;AACnB,SAASC,iBAAiB;AAC1B,SAASC,UAAU;AACnB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,mBAAmB;AAE5B,SAASC,KAAK;AACd,SAASC,eAAe;AAExB,SAASC,iBAAiB;AAa1B,MAAMC,kBAAkB,CAAoC;EAKxDC,WAAWA,CAACC,iBAA6B,EAAEC,OAAgB,EAAEC,UAAuB,EAAE;IAClF,IAAI,CAACF,iBAAiB,GAAGA,iBAAiB;IAC1C,IAAI,CAACG,SAAS,GAAGD,UAAU,IAAID,OAAO;IACtC,IAAI,CAACC,UAAU,GAAGA,UAAU;EAChC;EAEAE,aAAaA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACF,UAAU;EAC1B;EAEA,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F,iBAAiB,CAAC,CAAC;IACxBzC,iBAAiB,CAAC4C,QAAQ,CAACD,SAAS,CAAC;EACzC;EAEAE,cAAcA,CAACC,MAA4B,EAA8B;IACrE,IAAI,CAACL,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI3C,iBAAiB,CAACE,iBAAiB,CAAC,CAAC+C,OAAO,CAACD,MAAM,CAAC;EACnE;EAEAZ,SAASA,CAAA,EAAG;IACR,OAAOvC,WAAW,CAACuC,SAAS,CAAC,CAAC;EAClC;EAEAc,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAAC5B,SAAS;EACzB;EAEQqB,iBAAiBA,CAAA,EAEvB;IACE,IAAI,CAAC,IAAI,CAACD,GAAG,EAAE;MACX,MAAM,IAAIS,KAAK,CAAC,sCAAsC,CAAC;IAC3D;EACJ;AACJ;AAEA,OAAO,MAAMC,UAAU,GAAG,IAAI/B,UAAU,CAAC,CAAC","ignoreList":[]}
|
package/EditingSdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentGroup, IContentSdk, PublicPage } from "./types.js";
|
|
1
|
+
import type { ComponentGroup, IContentSdk, ListPagesOptions, ListPagesResult, PublicPage } from "./types.js";
|
|
2
2
|
import { Messenger } from "./messenger/index.js";
|
|
3
3
|
import type { WebsiteBuilderTheme } from "./types/WebsiteBuilderTheme.js";
|
|
4
4
|
export declare class EditingSdk implements IContentSdk {
|
|
@@ -11,7 +11,7 @@ export declare class EditingSdk implements IContentSdk {
|
|
|
11
11
|
private lastBoxesHash;
|
|
12
12
|
constructor(liveSdk: IContentSdk, theme: WebsiteBuilderTheme);
|
|
13
13
|
getPage(path: string): Promise<PublicPage | null>;
|
|
14
|
-
listPages(): Promise<
|
|
14
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
15
15
|
registerComponentGroup(group: ComponentGroup): void;
|
|
16
16
|
private getReferrerOrigin;
|
|
17
17
|
private setupListeners;
|
package/EditingSdk.js
CHANGED
|
@@ -42,8 +42,8 @@ export class EditingSdk {
|
|
|
42
42
|
await this.documentStore.waitForDocument();
|
|
43
43
|
return this.documentStore.getDocument();
|
|
44
44
|
}
|
|
45
|
-
async listPages() {
|
|
46
|
-
return this.liveSdk.listPages();
|
|
45
|
+
async listPages(options) {
|
|
46
|
+
return this.liveSdk.listPages(options);
|
|
47
47
|
}
|
|
48
48
|
registerComponentGroup(group) {
|
|
49
49
|
this.messenger.send("preview.componentGroup.register", {
|
package/EditingSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Messenger","MessageOrigin","logger","PreviewViewport","viewportManager","componentRegistry","functionConverter","documentStoreManager","PreviewDocument","hashObject","EditingSdk","positionReportingEnabled","previewViewport","lastBoxesHash","constructor","liveSdk","theme","source","window","location","origin","target","parent","getReferrerOrigin","previewDocument","createFromWindow","documentStore","getStore","getId","messenger","onRegister","reg","send","component","manifest","setupListeners","disableLinks","getPage","path","matches","type","waitForDocument","getDocument","listPages","registerComponentGroup","group","filter","serialize","undefined","searchParams","URLSearchParams","search","get","on","data","setDocument","initPositionReporting","updateElement","id","patch","applyPatch","onViewportChangeStart","onViewportChangeEnd","setInterval","reportBoxes","warn","newBoxes","getBoxes","hash","boxes","viewport","getViewport","document","addEventListener","event","anchor","closest","href","preventDefault","stopPropagation"],"sources":["EditingSdk.ts"],"sourcesContent":["\"use client\";\nimport type { ComponentGroup, IContentSdk, PublicPage } from \"./types.js\";\nimport { Messenger, MessageOrigin } from \"./messenger/index.js\";\nimport { logger } from \"./Logger.js\";\nimport { PreviewViewport } from \"./PreviewViewport.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\nimport { componentRegistry } from \"./ComponentRegistry.js\";\nimport { functionConverter } from \"./FunctionConverter.js\";\nimport { documentStoreManager } from \"~/DocumentStoreManager.js\";\nimport type { DocumentStore } from \"~/DocumentStore.js\";\nimport { PreviewDocument } from \"./PreviewDocument.js\";\nimport { hashObject } from \"~/HashObject.js\";\nimport type { WebsiteBuilderTheme } from \"~/types/WebsiteBuilderTheme.js\";\n\nexport class EditingSdk implements IContentSdk {\n public readonly messenger: Messenger;\n private positionReportingEnabled = false;\n private previewViewport: PreviewViewport | null = null;\n private liveSdk: IContentSdk;\n private documentStore: DocumentStore<PublicPage>;\n private previewDocument: PreviewDocument;\n private lastBoxesHash = 0;\n\n constructor(liveSdk: IContentSdk, theme: WebsiteBuilderTheme) {\n this.liveSdk = liveSdk;\n\n const source = new MessageOrigin(() => window, window.location.origin);\n const target = new MessageOrigin(() => window.parent, this.getReferrerOrigin());\n\n this.previewDocument = PreviewDocument.createFromWindow();\n\n this.documentStore = documentStoreManager.getStore<PublicPage>(\n this.previewDocument.getId()\n );\n\n this.messenger = new Messenger(source, target, \"wb.editor.*\");\n\n componentRegistry.onRegister(reg => {\n this.messenger.send(\"preview.component.register\", reg.component.manifest);\n });\n\n this.setupListeners();\n\n this.messenger.send(\"preview.ready\", true);\n\n if (theme) {\n this.messenger.send(\"preview.theme\", { theme });\n }\n\n this.disableLinks();\n }\n\n public async getPage(path: string): Promise<PublicPage | null> {\n if (!this.previewDocument.matches({ type: \"page\", path })) {\n return this.liveSdk.getPage(path);\n }\n\n await this.documentStore.waitForDocument();\n return this.documentStore.getDocument();\n }\n\n public async listPages(): Promise<PublicPage[]> {\n return this.liveSdk.listPages();\n }\n\n registerComponentGroup(group: ComponentGroup) {\n this.messenger.send(\"preview.componentGroup.register\", {\n ...group,\n filter: group.filter ? functionConverter.serialize(group.filter) : undefined\n });\n }\n\n private getReferrerOrigin(): string {\n try {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(\"wb.referrer\")!;\n } catch {\n return \"\";\n }\n }\n\n private setupListeners() {\n if (!this.messenger) {\n return;\n }\n\n this.messenger.on(\"document.set\", data => {\n this.documentStore.setDocument(data);\n\n if (!this.positionReportingEnabled) {\n // Initialize position reporting\n this.initPositionReporting();\n }\n });\n\n this.messenger.on(\"element.set\", data => {\n this.documentStore.updateElement(data.id, data.patch);\n });\n\n this.messenger.on(\"document.patch\", patch => {\n this.documentStore.applyPatch(patch);\n });\n }\n\n private initPositionReporting(): void {\n if (this.positionReportingEnabled) {\n return;\n }\n\n // Initialize element positions tracker\n this.previewViewport = new PreviewViewport();\n\n // Add event listeners\n viewportManager.onViewportChangeStart(() => {\n if (this.messenger) {\n this.messenger.send(\"preview.viewport.change.start\");\n }\n });\n\n viewportManager.onViewportChangeEnd(() => {\n if (this.messenger) {\n this.messenger.send(\"preview.viewport.change.end\");\n }\n });\n\n // Enable position reporting by default\n this.positionReportingEnabled = true;\n\n // Report positions periodically\n setInterval(() => this.reportBoxes(), 300);\n }\n\n private reportBoxes(): void {\n if (!this.messenger || !this.previewViewport) {\n logger.warn(\"No messenger or preview viewport. Skipping position reporting.\");\n return;\n }\n\n const newBoxes = this.previewViewport.getBoxes();\n const hash = hashObject.hash(newBoxes);\n if (hash === this.lastBoxesHash) {\n return;\n }\n\n this.lastBoxesHash = hash;\n // Send positions to the editor\n this.messenger.send(\"preview.viewport\", {\n boxes: this.previewViewport.getBoxes(),\n viewport: this.previewViewport.getViewport()\n });\n }\n\n private disableLinks() {\n // Intercept link clicks when we're in the editing mode (loaded via iframe from the editor).\n document.addEventListener(\n \"click\",\n event => {\n const target = event.target as HTMLElement;\n\n // Check if the clicked element or any of its ancestors is a link\n const anchor = target.closest(\"a\");\n\n if (anchor && anchor.href) {\n event.preventDefault();\n event.stopPropagation();\n }\n },\n // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#usecapture\n true\n );\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,EAAEC,aAAa;AACjC,SAASC,MAAM;AACf,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAE7B,SAASC,eAAe;AACxB,SAASC,UAAU;AAGnB,OAAO,MAAMC,UAAU,CAAwB;EAEnCC,wBAAwB,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C,kBAAkB,EAAE;MACpCqC,KAAK,EAAE,IAAI,CAACzD,eAAe,CAACuD,QAAQ,CAAC,CAAC;MACtCG,QAAQ,EAAE,IAAI,CAAC1D,eAAe,CAAC2D,WAAW,CAAC;IAC/C,CAAC,CAAC;EACN;EAEQnC,YAAYA,CAAA,EAAG;IACnB;IACAoC,QAAQ,CAACC,gBAAgB,CACrB,OAAO,EACPC,KAAK,IAAI;MACL,MAAMrD,MAAM,GAAGqD,KAAK,CAACrD,MAAqB;;MAE1C;MACA,MAAMsD,MAAM,GAAGtD,MAAM,CAACuD,OAAO,CAAC,GAAG,CAAC;MAElC,IAAID,MAAM,IAAIA,MAAM,CAACE,IAAI,EAAE;QACvBH,KAAK,CAACI,cAAc,CAAC,CAAC;QACtBJ,KAAK,CAACK,eAAe,CAAC,CAAC;MAC3B;IACJ,CAAC;IACD;IACA,IACJ,CAAC;EACL;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Messenger","MessageOrigin","logger","PreviewViewport","viewportManager","componentRegistry","functionConverter","documentStoreManager","PreviewDocument","hashObject","EditingSdk","positionReportingEnabled","previewViewport","lastBoxesHash","constructor","liveSdk","theme","source","window","location","origin","target","parent","getReferrerOrigin","previewDocument","createFromWindow","documentStore","getStore","getId","messenger","onRegister","reg","send","component","manifest","setupListeners","disableLinks","getPage","path","matches","type","waitForDocument","getDocument","listPages","options","registerComponentGroup","group","filter","serialize","undefined","searchParams","URLSearchParams","search","get","on","data","setDocument","initPositionReporting","updateElement","id","patch","applyPatch","onViewportChangeStart","onViewportChangeEnd","setInterval","reportBoxes","warn","newBoxes","getBoxes","hash","boxes","viewport","getViewport","document","addEventListener","event","anchor","closest","href","preventDefault","stopPropagation"],"sources":["EditingSdk.ts"],"sourcesContent":["\"use client\";\nimport type {\n ComponentGroup,\n IContentSdk,\n ListPagesOptions,\n ListPagesResult,\n PublicPage\n} from \"./types.js\";\nimport { Messenger, MessageOrigin } from \"./messenger/index.js\";\nimport { logger } from \"./Logger.js\";\nimport { PreviewViewport } from \"./PreviewViewport.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\nimport { componentRegistry } from \"./ComponentRegistry.js\";\nimport { functionConverter } from \"./FunctionConverter.js\";\nimport { documentStoreManager } from \"~/DocumentStoreManager.js\";\nimport type { DocumentStore } from \"~/DocumentStore.js\";\nimport { PreviewDocument } from \"./PreviewDocument.js\";\nimport { hashObject } from \"~/HashObject.js\";\nimport type { WebsiteBuilderTheme } from \"~/types/WebsiteBuilderTheme.js\";\n\nexport class EditingSdk implements IContentSdk {\n public readonly messenger: Messenger;\n private positionReportingEnabled = false;\n private previewViewport: PreviewViewport | null = null;\n private liveSdk: IContentSdk;\n private documentStore: DocumentStore<PublicPage>;\n private previewDocument: PreviewDocument;\n private lastBoxesHash = 0;\n\n constructor(liveSdk: IContentSdk, theme: WebsiteBuilderTheme) {\n this.liveSdk = liveSdk;\n\n const source = new MessageOrigin(() => window, window.location.origin);\n const target = new MessageOrigin(() => window.parent, this.getReferrerOrigin());\n\n this.previewDocument = PreviewDocument.createFromWindow();\n\n this.documentStore = documentStoreManager.getStore<PublicPage>(\n this.previewDocument.getId()\n );\n\n this.messenger = new Messenger(source, target, \"wb.editor.*\");\n\n componentRegistry.onRegister(reg => {\n this.messenger.send(\"preview.component.register\", reg.component.manifest);\n });\n\n this.setupListeners();\n\n this.messenger.send(\"preview.ready\", true);\n\n if (theme) {\n this.messenger.send(\"preview.theme\", { theme });\n }\n\n this.disableLinks();\n }\n\n public async getPage(path: string): Promise<PublicPage | null> {\n if (!this.previewDocument.matches({ type: \"page\", path })) {\n return this.liveSdk.getPage(path);\n }\n\n await this.documentStore.waitForDocument();\n return this.documentStore.getDocument();\n }\n\n public async listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n return this.liveSdk.listPages(options);\n }\n\n registerComponentGroup(group: ComponentGroup) {\n this.messenger.send(\"preview.componentGroup.register\", {\n ...group,\n filter: group.filter ? functionConverter.serialize(group.filter) : undefined\n });\n }\n\n private getReferrerOrigin(): string {\n try {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get(\"wb.referrer\")!;\n } catch {\n return \"\";\n }\n }\n\n private setupListeners() {\n if (!this.messenger) {\n return;\n }\n\n this.messenger.on(\"document.set\", data => {\n this.documentStore.setDocument(data);\n\n if (!this.positionReportingEnabled) {\n // Initialize position reporting\n this.initPositionReporting();\n }\n });\n\n this.messenger.on(\"element.set\", data => {\n this.documentStore.updateElement(data.id, data.patch);\n });\n\n this.messenger.on(\"document.patch\", patch => {\n this.documentStore.applyPatch(patch);\n });\n }\n\n private initPositionReporting(): void {\n if (this.positionReportingEnabled) {\n return;\n }\n\n // Initialize element positions tracker\n this.previewViewport = new PreviewViewport();\n\n // Add event listeners\n viewportManager.onViewportChangeStart(() => {\n if (this.messenger) {\n this.messenger.send(\"preview.viewport.change.start\");\n }\n });\n\n viewportManager.onViewportChangeEnd(() => {\n if (this.messenger) {\n this.messenger.send(\"preview.viewport.change.end\");\n }\n });\n\n // Enable position reporting by default\n this.positionReportingEnabled = true;\n\n // Report positions periodically\n setInterval(() => this.reportBoxes(), 300);\n }\n\n private reportBoxes(): void {\n if (!this.messenger || !this.previewViewport) {\n logger.warn(\"No messenger or preview viewport. Skipping position reporting.\");\n return;\n }\n\n const newBoxes = this.previewViewport.getBoxes();\n const hash = hashObject.hash(newBoxes);\n if (hash === this.lastBoxesHash) {\n return;\n }\n\n this.lastBoxesHash = hash;\n // Send positions to the editor\n this.messenger.send(\"preview.viewport\", {\n boxes: this.previewViewport.getBoxes(),\n viewport: this.previewViewport.getViewport()\n });\n }\n\n private disableLinks() {\n // Intercept link clicks when we're in the editing mode (loaded via iframe from the editor).\n document.addEventListener(\n \"click\",\n event => {\n const target = event.target as HTMLElement;\n\n // Check if the clicked element or any of its ancestors is a link\n const anchor = target.closest(\"a\");\n\n if (anchor && anchor.href) {\n event.preventDefault();\n event.stopPropagation();\n }\n },\n // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener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7E;IACJ;IAEA,MAAMC,QAAQ,GAAG,IAAI,CAACvD,eAAe,CAACwD,QAAQ,CAAC,CAAC;IAChD,MAAMC,IAAI,GAAG5D,UAAU,CAAC4D,IAAI,CAACF,QAAQ,CAAC;IACtC,IAAIE,IAAI,KAAK,IAAI,CAACxD,aAAa,EAAE;MAC7B;IACJ;IAEA,IAAI,CAACA,aAAa,GAAGwD,IAAI;IACzB;IACA,IAAI,CAACxC,SAAS,CAACG,IAAI,CAAC,kBAAkB,EAAE;MACpCsC,KAAK,EAAE,IAAI,CAAC1D,eAAe,CAACwD,QAAQ,CAAC,CAAC;MACtCG,QAAQ,EAAE,IAAI,CAAC3D,eAAe,CAAC4D,WAAW,CAAC;IAC/C,CAAC,CAAC;EACN;EAEQpC,YAAYA,CAAA,EAAG;IACnB;IACAqC,QAAQ,CAACC,gBAAgB,CACrB,OAAO,EACPC,KAAK,IAAI;MACL,MAAMtD,MAAM,GAAGsD,KAAK,CAACtD,MAAqB;;MAE1C;MACA,MAAMuD,MAAM,GAAGvD,MAAM,CAACwD,OAAO,CAAC,GAAG,CAAC;MAElC,IAAID,MAAM,IAAIA,MAAM,CAACE,IAAI,EAAE;QACvBH,KAAK,CAACI,cAAc,CAAC,CAAC;QACtBJ,KAAK,CAACK,eAAe,CAAC,CAAC;MAC3B;IACJ,CAAC;IACD;IACA,IACJ,CAAC;EACL;AACJ","ignoreList":[]}
|
package/LiveSdk.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GetPageOptions, IContentSdk, IDataProvider, ListPagesOptions, PublicPage } from "./types.js";
|
|
1
|
+
import type { GetPageOptions, IContentSdk, IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "./types.js";
|
|
2
2
|
export declare class LiveSdk implements IContentSdk {
|
|
3
3
|
private dataProvider;
|
|
4
4
|
constructor(dataProvider: IDataProvider);
|
|
5
5
|
getPage(path: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
6
|
-
listPages(options?: ListPagesOptions): Promise<
|
|
6
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
7
7
|
}
|
package/LiveSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["documentStoreManager","LiveSdk","constructor","dataProvider","getPage","path","options","page","getPageByPath","getStore","properties","id","setDocument","listPages"],"sources":["LiveSdk.ts"],"sourcesContent":["import type {\n GetPageOptions,\n IContentSdk,\n IDataProvider,\n ListPagesOptions,\n PublicPage\n} from \"~/types.js\";\nimport { documentStoreManager } from \"~/DocumentStoreManager.js\";\n\nexport class LiveSdk implements IContentSdk {\n private dataProvider: IDataProvider;\n\n constructor(dataProvider: IDataProvider) {\n this.dataProvider = dataProvider;\n }\n\n async getPage(path: string, options?: GetPageOptions): Promise<PublicPage | null> {\n const page = await this.dataProvider.getPageByPath(path, options);\n if (page) {\n documentStoreManager.getStore<PublicPage>(page.properties.id).setDocument(page);\n }\n return page;\n }\n\n listPages(options?: ListPagesOptions): Promise<
|
|
1
|
+
{"version":3,"names":["documentStoreManager","LiveSdk","constructor","dataProvider","getPage","path","options","page","getPageByPath","getStore","properties","id","setDocument","listPages"],"sources":["LiveSdk.ts"],"sourcesContent":["import type {\n GetPageOptions,\n IContentSdk,\n IDataProvider,\n ListPagesOptions,\n ListPagesResult,\n PublicPage\n} from \"~/types.js\";\nimport { documentStoreManager } from \"~/DocumentStoreManager.js\";\n\nexport class LiveSdk implements IContentSdk {\n private dataProvider: IDataProvider;\n\n constructor(dataProvider: IDataProvider) {\n this.dataProvider = dataProvider;\n }\n\n async getPage(path: string, options?: GetPageOptions): Promise<PublicPage | null> {\n const page = await this.dataProvider.getPageByPath(path, options);\n if (page) {\n documentStoreManager.getStore<PublicPage>(page.properties.id).setDocument(page);\n }\n return page;\n }\n\n listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n return this.dataProvider.listPages(options);\n }\n}\n"],"mappings":"AAQA,SAASA,oBAAoB;AAE7B,OAAO,MAAMC,OAAO,CAAwB;EAGxCC,WAAWA,CAACC,YAA2B,EAAE;IACrC,IAAI,CAACA,YAAY,GAAGA,YAAY;EACpC;EAEA,MAAMC,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAA8B;IAC9E,MAAMC,IAAI,GAAG,MAAM,IAAI,CAACJ,YAAY,CAACK,aAAa,CAACH,IAAI,EAAEC,OAAO,CAAC;IACjE,IAAIC,IAAI,EAAE;MACNP,oBAAoB,CAACS,QAAQ,CAAaF,IAAI,CAACG,UAAU,CAACC,EAAE,CAAC,CAACC,WAAW,CAACL,IAAI,CAAC;IACnF;IACA,OAAOA,IAAI;EACf;EAEAM,SAASA,CAACP,OAA0B,EAA4B;IAC5D,OAAO,IAAI,CAACH,YAAY,CAACU,SAAS,CAACP,OAAO,CAAC;EAC/C;AACJ","ignoreList":[]}
|
package/NullSdk.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IContentSdk, Page, PublicRedirect, ResolvedComponent } from "./types.js";
|
|
1
|
+
import type { IContentSdk, ListPagesResult, Page, PublicRedirect, ResolvedComponent } from "./types.js";
|
|
2
2
|
export declare class NullSdk implements IContentSdk {
|
|
3
3
|
getPage(): Promise<Page | null>;
|
|
4
|
-
listPages(): Promise<
|
|
4
|
+
listPages(): Promise<ListPagesResult>;
|
|
5
5
|
listRedirects(): Promise<PublicRedirect[]>;
|
|
6
6
|
registerComponent(): void;
|
|
7
7
|
resolveElement(): ResolvedComponent[] | null;
|
package/NullSdk.js
CHANGED
|
@@ -3,7 +3,14 @@ export class NullSdk {
|
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
5
|
listPages() {
|
|
6
|
-
return Promise.resolve(
|
|
6
|
+
return Promise.resolve({
|
|
7
|
+
data: [],
|
|
8
|
+
meta: {
|
|
9
|
+
hasMoreItems: false,
|
|
10
|
+
totalCount: 0,
|
|
11
|
+
cursor: null
|
|
12
|
+
}
|
|
13
|
+
});
|
|
7
14
|
}
|
|
8
15
|
listRedirects() {
|
|
9
16
|
return Promise.resolve([]);
|
package/NullSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NullSdk","getPage","listPages","Promise","resolve","listRedirects","registerComponent","resolveElement"],"sources":["NullSdk.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["NullSdk","getPage","listPages","Promise","resolve","data","meta","hasMoreItems","totalCount","cursor","listRedirects","registerComponent","resolveElement"],"sources":["NullSdk.ts"],"sourcesContent":["import type {\n IContentSdk,\n ListPagesResult,\n Page,\n PublicRedirect,\n ResolvedComponent\n} from \"./types.js\";\n\nexport class NullSdk implements IContentSdk {\n async getPage(): Promise<Page | null> {\n return null;\n }\n\n listPages(): Promise<ListPagesResult> {\n return Promise.resolve({\n data: [],\n meta: { hasMoreItems: false, totalCount: 0, cursor: null }\n });\n }\n\n listRedirects(): Promise<PublicRedirect[]> {\n return Promise.resolve([]);\n }\n\n registerComponent(): void {}\n\n resolveElement(): ResolvedComponent[] | null {\n return null;\n }\n}\n"],"mappings":"AAQA,OAAO,MAAMA,OAAO,CAAwB;EACxC,MAAMC,OAAOA,CAAA,EAAyB;IAClC,OAAO,IAAI;EACf;EAEAC,SAASA,CAAA,EAA6B;IAClC,OAAOC,OAAO,CAACC,OAAO,CAAC;MACnBC,IAAI,EAAE,EAAE;MACRC,IAAI,EAAE;QAAEC,YAAY,EAAE,KAAK;QAAEC,UAAU,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAK;IAC7D,CAAC,CAAC;EACN;EAEAC,aAAaA,CAAA,EAA8B;IACvC,OAAOP,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;EAEAO,iBAAiBA,CAAA,EAAS,CAAC;EAE3BC,cAAcA,CAAA,EAA+B;IACzC,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
|
package/PreviewSdk.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IContentSdk, IDataProvider, PublicPage } from "./types.js";
|
|
1
|
+
import type { IContentSdk, IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "./types.js";
|
|
2
2
|
export declare class PreviewSdk implements IContentSdk {
|
|
3
3
|
private liveSdk;
|
|
4
4
|
private dataProvider;
|
|
5
5
|
constructor(dataProvider: IDataProvider, liveSdk: IContentSdk);
|
|
6
6
|
getPage(path: string): Promise<PublicPage | null>;
|
|
7
|
-
listPages(): Promise<
|
|
7
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
8
8
|
}
|
package/PreviewSdk.js
CHANGED
package/PreviewSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PreviewDocument","PreviewSdk","constructor","dataProvider","liveSdk","getPage","path","previewDocument","createFromHeaders","matches","type","getPageById","getId","listPages"],"sources":["PreviewSdk.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["PreviewDocument","PreviewSdk","constructor","dataProvider","liveSdk","getPage","path","previewDocument","createFromHeaders","matches","type","getPageById","getId","listPages","options"],"sources":["PreviewSdk.ts"],"sourcesContent":["import type {\n IContentSdk,\n IDataProvider,\n ListPagesOptions,\n ListPagesResult,\n PublicPage\n} from \"~/types.js\";\nimport { PreviewDocument } from \"~/PreviewDocument.js\";\n\nexport class PreviewSdk implements IContentSdk {\n private liveSdk: IContentSdk;\n private dataProvider: IDataProvider;\n\n constructor(dataProvider: IDataProvider, liveSdk: IContentSdk) {\n this.liveSdk = liveSdk;\n this.dataProvider = dataProvider;\n }\n\n async getPage(path: string): Promise<PublicPage | null> {\n const previewDocument = await PreviewDocument.createFromHeaders();\n if (!previewDocument.matches({ type: \"page\", path })) {\n return this.liveSdk.getPage(path);\n }\n return this.dataProvider.getPageById(previewDocument.getId());\n }\n\n async listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n return this.liveSdk.listPages(options);\n }\n}\n"],"mappings":"AAOA,SAASA,eAAe;AAExB,OAAO,MAAMC,UAAU,CAAwB;EAI3CC,WAAWA,CAACC,YAA2B,EAAEC,OAAoB,EAAE;IAC3D,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACD,YAAY,GAAGA,YAAY;EACpC;EAEA,MAAME,OAAOA,CAACC,IAAY,EAA8B;IACpD,MAAMC,eAAe,GAAG,MAAMP,eAAe,CAACQ,iBAAiB,CAAC,CAAC;IACjE,IAAI,CAACD,eAAe,CAACE,OAAO,CAAC;MAAEC,IAAI,EAAE,MAAM;MAAEJ;IAAK,CAAC,CAAC,EAAE;MAClD,OAAO,IAAI,CAACF,OAAO,CAACC,OAAO,CAACC,IAAI,CAAC;IACrC;IACA,OAAO,IAAI,CAACH,YAAY,CAACQ,WAAW,CAACJ,eAAe,CAACK,KAAK,CAAC,CAAC,CAAC;EACjE;EAEA,MAAMC,SAASA,CAACC,OAA0B,EAA4B;IAClE,OAAO,IAAI,CAACV,OAAO,CAACS,SAAS,CAACC,OAAO,CAAC;EAC1C;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IDataProvider, PublicPage } from "../types.js";
|
|
1
|
+
import type { IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "../types.js";
|
|
2
2
|
import type { ApiClient } from "../dataProviders/ApiClient.js";
|
|
3
3
|
interface DefaultDataProviderConfig {
|
|
4
4
|
apiClient: ApiClient;
|
|
@@ -8,7 +8,7 @@ export declare class DefaultDataProvider implements IDataProvider {
|
|
|
8
8
|
constructor(config: DefaultDataProviderConfig);
|
|
9
9
|
getPageByPath(path: string): Promise<PublicPage | null>;
|
|
10
10
|
getPageById(id: string): Promise<PublicPage | null>;
|
|
11
|
-
listPages(): Promise<
|
|
11
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
12
12
|
private checkForErrors;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -26,17 +26,30 @@ export class DefaultDataProvider {
|
|
|
26
26
|
this.checkForErrors("getPageById", result.websiteBuilder.getPageById);
|
|
27
27
|
return result.websiteBuilder.getPageById.data;
|
|
28
28
|
}
|
|
29
|
-
async listPages() {
|
|
29
|
+
async listPages(options) {
|
|
30
|
+
const {
|
|
31
|
+
where,
|
|
32
|
+
...rest
|
|
33
|
+
} = options ?? {};
|
|
30
34
|
const result = await this.config.apiClient.query({
|
|
31
35
|
query: LIST_PUBLISHED_PAGES,
|
|
32
36
|
variables: {
|
|
33
37
|
where: {
|
|
38
|
+
...where,
|
|
34
39
|
published: true
|
|
35
|
-
}
|
|
40
|
+
},
|
|
41
|
+
...rest
|
|
36
42
|
}
|
|
37
43
|
});
|
|
38
44
|
this.checkForErrors("listPages", result.websiteBuilder.listPages);
|
|
39
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
data: result.websiteBuilder.listPages.data ?? [],
|
|
47
|
+
meta: result.websiteBuilder.listPages.meta ?? {
|
|
48
|
+
hasMoreItems: false,
|
|
49
|
+
totalCount: 0,
|
|
50
|
+
cursor: null
|
|
51
|
+
}
|
|
52
|
+
};
|
|
40
53
|
}
|
|
41
54
|
checkForErrors(action, data) {
|
|
42
55
|
if (data.error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GET_PAGE_BY_PATH","GET_PAGE_BY_ID","LIST_PUBLISHED_PAGES","ignoreActions","DefaultDataProvider","constructor","config","getPageByPath","path","result","apiClient","query","variables","checkForErrors","websiteBuilder","data","getPageById","id","listPages","where","published","action","error","some","item","includes","console","message"],"sources":["DefaultDataProvider.ts"],"sourcesContent":["import type { IDataProvider, PublicPage } from \"~/types.js\";\nimport type { ApiClient } from \"~/dataProviders/ApiClient.js\";\nimport { GET_PAGE_BY_PATH } from \"./GET_PAGE_BY_PATH.js\";\nimport { GET_PAGE_BY_ID } from \"./GET_PAGE_BY_ID.js\";\nimport { LIST_PUBLISHED_PAGES } from \"./LIST_PUBLISHED_PAGES.js\";\n\ninterface DefaultDataProviderConfig {\n apiClient: ApiClient;\n}\n\nconst ignoreActions = [\".well-known\", \"_next\"];\n\nexport class DefaultDataProvider implements IDataProvider {\n private config: DefaultDataProviderConfig;\n\n constructor(config: DefaultDataProviderConfig) {\n this.config = config;\n }\n\n public async getPageByPath(path: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_PATH,\n variables: {\n path\n }\n });\n\n this.checkForErrors(`getPageByPath:${path}`, result.websiteBuilder.getPageByPath);\n\n return result.websiteBuilder.getPageByPath.data;\n }\n\n public async getPageById(id: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_ID,\n variables: {\n id\n }\n });\n\n this.checkForErrors(\"getPageById\", result.websiteBuilder.getPageById);\n\n return result.websiteBuilder.getPageById.data;\n }\n\n public async listPages() {\n const result = await this.config.apiClient.query({\n query: LIST_PUBLISHED_PAGES,\n variables: {\n where: {\n published: true\n }\n }\n });\n\n this.checkForErrors(\"listPages\", result.websiteBuilder.listPages);\n\n return result.websiteBuilder.listPages.data ?? [];\n }\n\n private checkForErrors(action: string, data: any) {\n if (data.error) {\n // TODO: investigate how these ignored actions make their way to the SDK.\n if (ignoreActions.some(item => action.includes(item))) {\n return;\n }\n console.error(`Could not execute \"${action}\". Reason: ${data.error.message}`);\n }\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAM7B,MAAMC,aAAa,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC;AAE9C,OAAO,MAAMC,mBAAmB,CAA0B;EAGtDC,WAAWA,CAACC,MAAiC,EAAE;IAC3C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,aAAaA,CAACC,IAAY,EAA8B;IACjE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,MAAM,CAACI,SAAS,CAACC,KAAK,CAAC;MAC7CA,KAAK,EAAEX,gBAAgB;MACvBY,SAAS,EAAE;QACPJ;MACJ;IACJ,CAAC,CAAC;IAEF,IAAI,CAACK,cAAc,CAAC,iBAAiBL,IAAI,EAAE,EAAEC,MAAM,CAACK,cAAc,CAACP,aAAa,CAAC;IAEjF,OAAOE,MAAM,CAACK,cAAc,CAACP,aAAa,CAACQ,IAAI;EACnD;EAEA,MAAaC,WAAWA,CAACC,EAAU,EAA8B;IAC7D,MAAMR,MAAM,GAAG,MAAM,IAAI,CAACH,MAAM,CAACI,SAAS,CAACC,KAAK,CAAC;MAC7CA,KAAK,EAAEV,cAAc;MACrBW,SAAS,EAAE;QACPK;MACJ;IACJ,CAAC,CAAC;IAEF,IAAI,CAACJ,cAAc,CAAC,aAAa,EAAEJ,MAAM,CAACK,cAAc,CAACE,WAAW,CAAC;IAErE,OAAOP,MAAM,CAACK,cAAc,CAACE,WAAW,CAACD,IAAI;EACjD;EAEA,MAAaG,SAASA,
|
|
1
|
+
{"version":3,"names":["GET_PAGE_BY_PATH","GET_PAGE_BY_ID","LIST_PUBLISHED_PAGES","ignoreActions","DefaultDataProvider","constructor","config","getPageByPath","path","result","apiClient","query","variables","checkForErrors","websiteBuilder","data","getPageById","id","listPages","options","where","rest","published","meta","hasMoreItems","totalCount","cursor","action","error","some","item","includes","console","message"],"sources":["DefaultDataProvider.ts"],"sourcesContent":["import type { IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from \"~/types.js\";\nimport type { ApiClient } from \"~/dataProviders/ApiClient.js\";\nimport { GET_PAGE_BY_PATH } from \"./GET_PAGE_BY_PATH.js\";\nimport { GET_PAGE_BY_ID } from \"./GET_PAGE_BY_ID.js\";\nimport { LIST_PUBLISHED_PAGES } from \"./LIST_PUBLISHED_PAGES.js\";\n\ninterface DefaultDataProviderConfig {\n apiClient: ApiClient;\n}\n\nconst ignoreActions = [\".well-known\", \"_next\"];\n\nexport class DefaultDataProvider implements IDataProvider {\n private config: DefaultDataProviderConfig;\n\n constructor(config: DefaultDataProviderConfig) {\n this.config = config;\n }\n\n public async getPageByPath(path: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_PATH,\n variables: {\n path\n }\n });\n\n this.checkForErrors(`getPageByPath:${path}`, result.websiteBuilder.getPageByPath);\n\n return result.websiteBuilder.getPageByPath.data;\n }\n\n public async getPageById(id: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_ID,\n variables: {\n id\n }\n });\n\n this.checkForErrors(\"getPageById\", result.websiteBuilder.getPageById);\n\n return result.websiteBuilder.getPageById.data;\n }\n\n public async listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n const { where, ...rest } = options ?? {};\n\n const result = await this.config.apiClient.query({\n query: LIST_PUBLISHED_PAGES,\n variables: {\n where: {\n ...where,\n published: true\n },\n ...rest\n }\n });\n\n this.checkForErrors(\"listPages\", result.websiteBuilder.listPages);\n\n return {\n data: result.websiteBuilder.listPages.data ?? [],\n meta: result.websiteBuilder.listPages.meta ?? {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null\n }\n };\n }\n\n private checkForErrors(action: string, data: any) {\n if (data.error) {\n // TODO: investigate how these ignored actions make their way to the SDK.\n if (ignoreActions.some(item => action.includes(item))) {\n return;\n }\n console.error(`Could not execute \"${action}\". Reason: ${data.error.message}`);\n }\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAM7B,MAAMC,aAAa,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC;AAE9C,OAAO,MAAMC,mBAAmB,CAA0B;EAGtDC,WAAWA,CAACC,MAAiC,EAAE;IAC3C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,aAAaA,CAACC,IAAY,EAA8B;IACjE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,MAAM,CAACI,SAAS,CAACC,KAAK,CAAC;MAC7CA,KAAK,EAAEX,gBAAgB;MACvBY,SAAS,EAAE;QACPJ;MACJ;IACJ,CAAC,CAAC;IAEF,IAAI,CAACK,cAAc,CAAC,iBAAiBL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;MACA,IAAIzB,aAAa,CAAC0B,IAAI,CAACC,IAAI,IAAIH,MAAM,CAACI,QAAQ,CAACD,IAAI,CAAC,CAAC,EAAE;QACnD;MACJ;MACAE,OAAO,CAACJ,KAAK,CAAC,sBAAsBD,MAAM,cAAcZ,IAAI,CAACa,KAAK,CAACK,OAAO,EAAE,CAAC;IACjF;EACJ;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIST_PUBLISHED_PAGES = "\n query ListPublishedPages($where: WbPagesListWhereInput) {\n websiteBuilder {\n listPages(where: $where) {\n data {\n id\n properties\n elements\n bindings\n extensions\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
|
|
1
|
+
export declare const LIST_PUBLISHED_PAGES = "\n query ListPublishedPages(\n $where: WbPagesListWhereInput\n $limit: Int\n $after: String\n $sort: [WbPageListSorter]\n $search: String\n ) {\n websiteBuilder {\n listPages(where: $where, limit: $limit, after: $after, sort: $sort, search: $search) {\n data {\n id\n properties\n elements\n bindings\n extensions\n }\n meta {\n hasMoreItems\n totalCount\n cursor\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export const LIST_PUBLISHED_PAGES = /* GraphQL*/`
|
|
2
|
-
query ListPublishedPages(
|
|
2
|
+
query ListPublishedPages(
|
|
3
|
+
$where: WbPagesListWhereInput
|
|
4
|
+
$limit: Int
|
|
5
|
+
$after: String
|
|
6
|
+
$sort: [WbPageListSorter]
|
|
7
|
+
$search: String
|
|
8
|
+
) {
|
|
3
9
|
websiteBuilder {
|
|
4
|
-
listPages(where: $where) {
|
|
10
|
+
listPages(where: $where, limit: $limit, after: $after, sort: $sort, search: $search) {
|
|
5
11
|
data {
|
|
6
12
|
id
|
|
7
13
|
properties
|
|
@@ -9,6 +15,11 @@ export const LIST_PUBLISHED_PAGES = /* GraphQL*/`
|
|
|
9
15
|
bindings
|
|
10
16
|
extensions
|
|
11
17
|
}
|
|
18
|
+
meta {
|
|
19
|
+
hasMoreItems
|
|
20
|
+
totalCount
|
|
21
|
+
cursor
|
|
22
|
+
}
|
|
12
23
|
error {
|
|
13
24
|
code
|
|
14
25
|
message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LIST_PUBLISHED_PAGES"],"sources":["LIST_PUBLISHED_PAGES.ts"],"sourcesContent":["export const LIST_PUBLISHED_PAGES = /* GraphQL*/ `\n query ListPublishedPages($where: WbPagesListWhereInput) {\n websiteBuilder {\n listPages(where: $where) {\n data {\n id\n properties\n elements\n bindings\n extensions\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,YAAa;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["LIST_PUBLISHED_PAGES"],"sources":["LIST_PUBLISHED_PAGES.ts"],"sourcesContent":["export const LIST_PUBLISHED_PAGES = /* GraphQL*/ `\n query ListPublishedPages(\n $where: WbPagesListWhereInput\n $limit: Int\n $after: String\n $sort: [WbPageListSorter]\n $search: String\n ) {\n websiteBuilder {\n listPages(where: $where, limit: $limit, after: $after, sort: $sort, search: $search) {\n data {\n id\n properties\n elements\n bindings\n extensions\n }\n meta {\n hasMoreItems\n totalCount\n cursor\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,YAAa;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,13 @@ import type { IDataProvider, Page, PublicRedirect } from "../types.js";
|
|
|
2
2
|
export declare class NullDataProvider implements IDataProvider {
|
|
3
3
|
getPageById(): Promise<Page | null>;
|
|
4
4
|
getPageByPath(): Promise<Page | null>;
|
|
5
|
-
listPages(): Promise<
|
|
5
|
+
listPages(): Promise<{
|
|
6
|
+
data: never[];
|
|
7
|
+
meta: {
|
|
8
|
+
hasMoreItems: boolean;
|
|
9
|
+
totalCount: number;
|
|
10
|
+
cursor: null;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
6
13
|
listRedirects(): Promise<PublicRedirect[]>;
|
|
7
14
|
}
|
|
@@ -6,7 +6,14 @@ export class NullDataProvider {
|
|
|
6
6
|
return Promise.resolve(null);
|
|
7
7
|
}
|
|
8
8
|
async listPages() {
|
|
9
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
data: [],
|
|
11
|
+
meta: {
|
|
12
|
+
hasMoreItems: false,
|
|
13
|
+
totalCount: 0,
|
|
14
|
+
cursor: null
|
|
15
|
+
}
|
|
16
|
+
};
|
|
10
17
|
}
|
|
11
18
|
listRedirects() {
|
|
12
19
|
return Promise.resolve([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NullDataProvider","getPageById","Promise","resolve","getPageByPath","listPages","listRedirects"],"sources":["NullDataProvider.ts"],"sourcesContent":["import type { IDataProvider, Page, PublicRedirect } from \"~/types.js\";\n\nexport class NullDataProvider implements IDataProvider {\n getPageById(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n getPageByPath(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n public async listPages() {\n return [];\n }\n\n listRedirects(): Promise<PublicRedirect[]> {\n return Promise.resolve([]);\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAA0B;EACnDC,WAAWA,CAAA,EAAyB;IAChC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEAC,aAAaA,CAAA,EAAyB;IAClC,OAAOF,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEA,MAAaE,SAASA,CAAA,EAAG;IACrB,OAAO,EAAE;
|
|
1
|
+
{"version":3,"names":["NullDataProvider","getPageById","Promise","resolve","getPageByPath","listPages","data","meta","hasMoreItems","totalCount","cursor","listRedirects"],"sources":["NullDataProvider.ts"],"sourcesContent":["import type { IDataProvider, Page, PublicRedirect } from \"~/types.js\";\n\nexport class NullDataProvider implements IDataProvider {\n getPageById(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n getPageByPath(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n public async listPages() {\n return { data: [], meta: { hasMoreItems: false, totalCount: 0, cursor: null } };\n }\n\n listRedirects(): Promise<PublicRedirect[]> {\n return Promise.resolve([]);\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAA0B;EACnDC,WAAWA,CAAA,EAAyB;IAChC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEAC,aAAaA,CAAA,EAAyB;IAClC,OAAOF,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEA,MAAaE,SAASA,CAAA,EAAG;IACrB,OAAO;MAAEC,IAAI,EAAE,EAAE;MAAEC,IAAI,EAAE;QAAEC,YAAY,EAAE,KAAK;QAAEC,UAAU,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAK;IAAE,CAAC;EACnF;EAEAC,aAAaA,CAAA,EAA8B;IACvC,OAAOT,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;AACJ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/deep-equal": "1.0.4",
|
|
32
32
|
"@types/is-hotkey": "0.1.10",
|
|
33
|
-
"@webiny/build-tools": "6.0.0-rc.
|
|
33
|
+
"@webiny/build-tools": "6.0.0-rc.3",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
35
|
"vitest": "4.0.18"
|
|
36
36
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "228fe25e1a17f248d566bce1c33d11c291955513"
|
|
49
49
|
}
|
package/types.d.ts
CHANGED
|
@@ -211,11 +211,26 @@ export type PreviewViewportData = {
|
|
|
211
211
|
};
|
|
212
212
|
export type ApiOptions = Record<string, any>;
|
|
213
213
|
export type GetPageOptions = ApiOptions;
|
|
214
|
-
export
|
|
214
|
+
export interface ListPagesOptions {
|
|
215
|
+
where?: Record<string, any>;
|
|
216
|
+
limit?: number;
|
|
217
|
+
after?: string;
|
|
218
|
+
sort?: string[];
|
|
219
|
+
search?: string;
|
|
220
|
+
}
|
|
221
|
+
export interface ListPagesMeta {
|
|
222
|
+
hasMoreItems: boolean;
|
|
223
|
+
totalCount: number;
|
|
224
|
+
cursor: string | null;
|
|
225
|
+
}
|
|
226
|
+
export interface ListPagesResult {
|
|
227
|
+
data: PublicPage[];
|
|
228
|
+
meta: ListPagesMeta;
|
|
229
|
+
}
|
|
215
230
|
export interface IDataProvider {
|
|
216
231
|
getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
217
232
|
getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
218
|
-
listPages(options?: ListPagesOptions): Promise<
|
|
233
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
219
234
|
}
|
|
220
235
|
export interface IEnvironment {
|
|
221
236
|
isClient(): boolean;
|
|
@@ -224,7 +239,7 @@ export interface IEnvironment {
|
|
|
224
239
|
}
|
|
225
240
|
export interface IContentSdk {
|
|
226
241
|
getPage(path: string): Promise<PublicPage | null>;
|
|
227
|
-
listPages(options?: ListPagesOptions): Promise<
|
|
242
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
228
243
|
}
|
|
229
244
|
export type BaseInput<T = any> = {
|
|
230
245
|
name: string;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi.js\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties.js\";\nimport type { InputFactory } from \"~/createInput.js\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme.js\";\n\ntype CSSProperties = CSS.Properties<string | number>;\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentBlueprint<TComponent = any, TManifest = any> = {\n component: TComponent;\n manifest: TManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags?: string[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"extensions\" | \"state\"\n>;\n\nexport type PublicRedirect = {\n id: string;\n from: string;\n to: string;\n permanent: boolean;\n};\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document & {\n metadata: Record<string, any>;\n};\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n extensions: Record<string, any>;\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n};\n\nexport type PreviewViewportInfo = {\n // Viewport width (only the visible part)\n width: number;\n // Viewport height (only the visible part)\n height: number;\n // Full iframe width\n scrollWidth: number;\n // Full iframe height\n scrollHeight: number;\n // Iframe horizontal scroll offset\n scrollX: number;\n // Iframe vertical scroll offest\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\nexport type ListPagesOptions = ApiOptions;\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n\nexport type ManifestInputsArray<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? {\n [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string>;\n }[Exclude<keyof TInputs, \"children\">][]\n : {\n [K in keyof TInputs]: InputFactory<K & string>;\n }[keyof TInputs][];\n\nexport type ManifestInputsObject<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? { [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string> }\n : { [K in keyof TInputs]: InputFactory<K & string> };\n\nexport type ComponentManifestInput<TInputs> =\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren: true;\n inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;\n })\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren?: false;\n inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;\n });\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi.js\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties.js\";\nimport type { InputFactory } from \"~/createInput.js\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme.js\";\n\ntype CSSProperties = CSS.Properties<string | number>;\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentBlueprint<TComponent = any, TManifest = any> = {\n component: TComponent;\n manifest: TManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags?: string[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"extensions\" | \"state\"\n>;\n\nexport type PublicRedirect = {\n id: string;\n from: string;\n to: string;\n permanent: boolean;\n};\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document & {\n metadata: Record<string, any>;\n};\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n extensions: Record<string, any>;\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n};\n\nexport type PreviewViewportInfo = {\n // Viewport width (only the visible part)\n width: number;\n // Viewport height (only the visible part)\n height: number;\n // Full iframe width\n scrollWidth: number;\n // Full iframe height\n scrollHeight: number;\n // Iframe horizontal scroll offset\n scrollX: number;\n // Iframe vertical scroll offest\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\n\nexport interface ListPagesOptions {\n where?: Record<string, any>;\n limit?: number;\n after?: string;\n sort?: string[];\n search?: string;\n}\n\nexport interface ListPagesMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\n\nexport interface ListPagesResult {\n data: PublicPage[];\n meta: ListPagesMeta;\n}\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n\nexport type ManifestInputsArray<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? {\n [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string>;\n }[Exclude<keyof TInputs, \"children\">][]\n : {\n [K in keyof TInputs]: InputFactory<K & string>;\n }[keyof TInputs][];\n\nexport type ManifestInputsObject<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? { [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string> }\n : { [K in keyof TInputs]: InputFactory<K & string> };\n\nexport type ComponentManifestInput<TInputs> =\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren: true;\n inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;\n })\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren?: false;\n inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;\n });\n"],"mappings":"","ignoreList":[]}
|