@swell/apps-sdk 1.0.74 → 1.0.76
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/dist/index.cjs +16 -16
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +16 -16
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +3 -3
- package/dist/src/theme/theme-loader.d.ts +18 -1
- package/dist/src/theme.d.ts +17 -13
- package/dist/types/swell.d.ts +10 -3
- package/package.json +1 -1
|
@@ -6,15 +6,28 @@ import type { SwellThemeConfig, SwellThemeVersion } from 'types/swell';
|
|
|
6
6
|
export declare class ThemeLoader {
|
|
7
7
|
private static cache;
|
|
8
8
|
private swell;
|
|
9
|
+
private manifest;
|
|
10
|
+
private configs;
|
|
11
|
+
private configPaths;
|
|
9
12
|
constructor(swell: Swell);
|
|
13
|
+
init(themeConfigs?: Map<string, SwellThemeConfig>): Promise<void>;
|
|
10
14
|
/**
|
|
11
15
|
* Loads theme configs for this version.
|
|
12
16
|
*/
|
|
13
17
|
loadTheme(): Promise<SwellThemeConfig[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Load theme configs from internal data, typically in the editor.
|
|
20
|
+
*/
|
|
21
|
+
setConfigs(themeConfigs: Map<string, SwellThemeConfig>): void;
|
|
14
22
|
/**
|
|
15
23
|
* Preloads a theme version and configs. This is used to optimize initial theme load.
|
|
16
24
|
*/
|
|
17
25
|
preloadTheme(version: SwellThemeVersion, configs: SwellThemeConfig[]): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetches a theme config by file path.
|
|
28
|
+
*/
|
|
29
|
+
fetchThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
|
|
30
|
+
fetchThemeConfigsByPath(pathPrefix: string, pathSuffix?: string): Promise<SwellThemeConfig[]>;
|
|
18
31
|
/**
|
|
19
32
|
* Load all theme configs.
|
|
20
33
|
*/
|
|
@@ -40,9 +53,13 @@ export declare class ThemeLoader {
|
|
|
40
53
|
*/
|
|
41
54
|
private fetchManifest;
|
|
42
55
|
/**
|
|
43
|
-
* Fetches theme configs via Swell Backend API.
|
|
56
|
+
* Fetches many theme configs via Swell Backend API.
|
|
44
57
|
*/
|
|
45
58
|
private fetchThemeConfigsFromSource;
|
|
59
|
+
/**
|
|
60
|
+
* Fetches one theme config via Swell Backend API.
|
|
61
|
+
*/
|
|
62
|
+
private fetchThemeConfigsFromSourceByPath;
|
|
46
63
|
/**
|
|
47
64
|
* Generates a Swell API query filter for this theme version.
|
|
48
65
|
*/
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Swell, StorefrontResource, SwellStorefrontCollection, SwellStorefrontRecord, SwellStorefrontSingleton } from './api';
|
|
2
2
|
import { ShopifyCompatibility } from './compatibility/shopify';
|
|
3
3
|
import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
|
|
4
|
-
import
|
|
5
|
-
import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellThemeVersion, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig
|
|
4
|
+
import { ThemeLoader } from './theme/theme-loader';
|
|
5
|
+
import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellThemeVersion, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig } from 'types/swell';
|
|
6
6
|
export declare class SwellTheme {
|
|
7
7
|
swell: Swell;
|
|
8
8
|
props: SwellAppStorefrontThemeProps;
|
|
@@ -10,8 +10,9 @@ export declare class SwellTheme {
|
|
|
10
10
|
forms?: ThemeFormConfig[];
|
|
11
11
|
resources?: ThemeResources;
|
|
12
12
|
liquidSwell: LiquidSwell;
|
|
13
|
+
themeLoader: ThemeLoader;
|
|
13
14
|
themeConfigs: Map<string, SwellThemeConfig> | null;
|
|
14
|
-
page
|
|
15
|
+
page: any;
|
|
15
16
|
pageId: string | undefined;
|
|
16
17
|
shopifyCompatibility: ShopifyCompatibility | null;
|
|
17
18
|
shopifyCompatibilityClass: typeof ShopifyCompatibility;
|
|
@@ -34,11 +35,11 @@ export declare class SwellTheme {
|
|
|
34
35
|
geo: SwellData;
|
|
35
36
|
configs: ThemeConfigs;
|
|
36
37
|
}>;
|
|
37
|
-
resolvePageData(store: SwellData, configs:
|
|
38
|
+
resolvePageData(store: SwellData, configs: SwellData, session?: SwellData, pageId?: string): Promise<{
|
|
38
39
|
settings: ThemeSettings;
|
|
39
|
-
request:
|
|
40
|
-
page:
|
|
41
|
-
cart: SwellStorefrontSingleton |
|
|
40
|
+
request: ThemeSettings;
|
|
41
|
+
page: ThemeSettings;
|
|
42
|
+
cart: SwellStorefrontSingleton | {};
|
|
42
43
|
account: SwellStorefrontSingleton | null;
|
|
43
44
|
customer?: SwellStorefrontSingleton | null;
|
|
44
45
|
}>;
|
|
@@ -89,7 +90,7 @@ export declare class SwellTheme {
|
|
|
89
90
|
updateSettings(form: Record<string, {
|
|
90
91
|
value: unknown;
|
|
91
92
|
} | undefined>, config: object): ThemeSettings;
|
|
92
|
-
resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string):
|
|
93
|
+
resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string): any;
|
|
93
94
|
setCompatibilityConfigs(configs: ThemeConfigs, localeCode: string): Promise<void>;
|
|
94
95
|
setCompatibilityData(pageData: SwellData): void;
|
|
95
96
|
resolveLookupSetting(setting: ThemeSettingFieldSchema, value: any): SwellData | SwellStorefrontRecord | SwellStorefrontCollection | null;
|
|
@@ -101,6 +102,7 @@ export declare class SwellTheme {
|
|
|
101
102
|
lang(key: string, data?: any, fallback?: string): Promise<string>;
|
|
102
103
|
resolveFontSetting(value: string): ThemeFont | null;
|
|
103
104
|
resolveUrlSetting(value: string): string;
|
|
105
|
+
resolveImageSetting(value: string): string;
|
|
104
106
|
getAllThemeConfigs(): Promise<Map<string, SwellThemeConfig>>;
|
|
105
107
|
/**
|
|
106
108
|
* Preloads updated theme configs. Used to optimize initial theme load.
|
|
@@ -108,6 +110,7 @@ export declare class SwellTheme {
|
|
|
108
110
|
preloadThemeConfigs(version: SwellThemeVersion, configs: SwellThemeConfig[]): Promise<void>;
|
|
109
111
|
getPageConfigPath(pageId: string): string | null;
|
|
110
112
|
getThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
|
|
113
|
+
getThemeConfigsByPath(pathPrefix: string, pathSuffix?: string): Promise<Map<string, SwellThemeConfig>>;
|
|
111
114
|
getThemeTemplateConfig(filePath: string): Promise<SwellThemeConfig | null>;
|
|
112
115
|
getThemeTemplateConfigByType(type: string, name: string): Promise<SwellThemeConfig | null>;
|
|
113
116
|
getAssetUrl(filePath: string): Promise<string | null>;
|
|
@@ -115,13 +118,13 @@ export declare class SwellTheme {
|
|
|
115
118
|
renderTemplateString(templateString: string, data?: SwellData): Promise<string>;
|
|
116
119
|
getSectionSchema(sectionName: string): Promise<Partial<ThemeSectionSchema> | undefined>;
|
|
117
120
|
getSectionConfigWithSchemaTagOnly(config: SwellThemeConfig): SwellThemeConfig | null;
|
|
118
|
-
renderThemeTemplate(filePath: `${string}.liquid`, data?: SwellData): Promise<string>;
|
|
119
|
-
renderThemeTemplate(filePath: `${string}.json`, data?: SwellData): Promise<ThemePageTemplateConfig>;
|
|
120
121
|
renderThemeTemplate(filePath: string, data?: SwellData): Promise<string | ThemePageTemplateConfig>;
|
|
121
122
|
renderLayoutTemplate(name: string, data?: SwellData): Promise<string>;
|
|
122
123
|
renderPageTemplate(name: string, data?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
|
|
123
124
|
renderPage(pageData?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
|
|
124
|
-
renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<
|
|
125
|
+
renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<{
|
|
126
|
+
[key: string]: string;
|
|
127
|
+
}>;
|
|
125
128
|
renderSection(sectionId: string, pageData?: SwellData): Promise<string | ThemePageTemplateConfig>;
|
|
126
129
|
renderLayout(data?: SwellData): Promise<string>;
|
|
127
130
|
getContentForHeader(): string;
|
|
@@ -147,11 +150,12 @@ export declare class SwellTheme {
|
|
|
147
150
|
renderTemplateSections(sectionGroup: ThemeSectionGroup, data?: SwellData): Promise<string>;
|
|
148
151
|
renderTranslation(key: string, data?: any, fallback?: string): Promise<string>;
|
|
149
152
|
renderTranslationValue(localeCode: string, langConfig: any, key: string, data?: any, fallback?: string): Promise<string>;
|
|
150
|
-
renderCurrency(amount: number, params
|
|
153
|
+
renderCurrency(amount: number, params: any): string;
|
|
151
154
|
}
|
|
152
|
-
export declare class PageError
|
|
155
|
+
export declare class PageError {
|
|
153
156
|
title: string;
|
|
154
157
|
status: number;
|
|
158
|
+
message: string;
|
|
155
159
|
description?: string;
|
|
156
160
|
constructor(title?: string | Error, status?: number, description?: string);
|
|
157
161
|
toString(): string;
|
package/dist/types/swell.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormatInput } from 'swell-js';
|
|
2
|
-
import type { SwellStorefrontRecord, SwellStorefrontResource } from '../src/resources';
|
|
2
|
+
import type { SwellStorefrontRecord, SwellStorefrontResource, SwellStorefrontSingleton } from '../src/resources';
|
|
3
3
|
import type { Swell, SwellStorefrontCollection, StorefrontResource } from '../src/api';
|
|
4
4
|
import type { ShopifySettingSchema, ShopifySettingsData, ShopifySettingsSchema } from './shopify';
|
|
5
5
|
export interface SwellApiParams {
|
|
@@ -252,12 +252,19 @@ export interface ThemeSwellPage extends SwellAppStorefrontThemePage, ThemePageAd
|
|
|
252
252
|
export type ThemePage = ThemeSwellPage | ThemeCustomPage;
|
|
253
253
|
export interface ThemeGlobals extends SwellData {
|
|
254
254
|
store: SwellData;
|
|
255
|
-
request: SwellPageRequest;
|
|
256
255
|
settings: ThemeSettings;
|
|
256
|
+
session: SwellData;
|
|
257
|
+
request: SwellPageRequest;
|
|
258
|
+
menus?: Record<string, SwellMenu>;
|
|
257
259
|
page: ThemePage;
|
|
260
|
+
cart: SwellStorefrontSingleton | {};
|
|
261
|
+
account: SwellStorefrontSingleton | null;
|
|
262
|
+
customer?: SwellStorefrontSingleton | null;
|
|
263
|
+
geo: SwellSettingsGeo;
|
|
258
264
|
configs: ThemeConfigs;
|
|
259
|
-
menus?: Record<string, SwellMenu>;
|
|
260
265
|
translations: Record<string, unknown>;
|
|
266
|
+
canonical_url: string;
|
|
267
|
+
shopify_compatibility: boolean;
|
|
261
268
|
[key: string]: any;
|
|
262
269
|
}
|
|
263
270
|
export interface ThemeConfigs {
|