@swell/apps-sdk 1.0.138 → 1.0.139

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.
@@ -1,6 +1,6 @@
1
- import { Swell } from '@/api';
2
1
  import { ThemeCache } from '../cache';
3
- import type { SwellThemeConfig, SwellThemeVersion } from 'types/swell';
2
+ import type { Swell } from '@/api';
3
+ import type { SwellThemeConfig, SwellThemePreload } from 'types/swell';
4
4
  /**
5
5
  * Responsible for loading a theme.
6
6
  */
@@ -27,7 +27,7 @@ export declare class ThemeLoader {
27
27
  /**
28
28
  * Preloads a theme version and configs. This is used to optimize initial theme load.
29
29
  */
30
- preloadTheme(version: SwellThemeVersion, configs: SwellThemeConfig[]): Promise<void>;
30
+ preloadTheme(payload: SwellThemePreload): Promise<void>;
31
31
  /**
32
32
  * Fetches a theme config by file path.
33
33
  */
@@ -53,6 +53,10 @@ export declare class ThemeLoader {
53
53
  * Caches a theme config by hash.
54
54
  */
55
55
  private cacheThemeConfig;
56
+ /**
57
+ * Caches a CDN file url by config hash.
58
+ */
59
+ private cacheThemeFileUrl;
56
60
  /**
57
61
  * Fetches the manifest (set of config hashes) for a theme version.
58
62
  */
@@ -68,6 +72,7 @@ export declare class ThemeLoader {
68
72
  * but we probably need to find why that happens in the first place (TODO).
69
73
  */
70
74
  private fetchThemeConfigsFromSourceByPath;
75
+ private getThemeId;
71
76
  /**
72
77
  * Generates a Swell API query filter for this theme version.
73
78
  */
@@ -3,7 +3,7 @@ import { ShopifyCompatibility } from './compatibility/shopify';
3
3
  import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
4
4
  import { ThemeLoader } from './theme/theme-loader';
5
5
  import type { FormatInput } from 'swell-js';
6
- import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemeLocaleConfig, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellThemeVersion, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig, ThemePage, SwellPageRequest, SwellSettingsGeo } from '../types/swell';
6
+ import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemeLocaleConfig, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellThemePreload, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig, ThemePage, SwellPageRequest, SwellSettingsGeo } from '../types/swell';
7
7
  export declare class SwellTheme {
8
8
  swell: Swell;
9
9
  props: SwellAppStorefrontThemeProps;
@@ -109,7 +109,7 @@ export declare class SwellTheme {
109
109
  /**
110
110
  * Preloads updated theme configs. Used to optimize initial theme load.
111
111
  */
112
- preloadThemeConfigs(version: SwellThemeVersion, configs: SwellThemeConfig[]): Promise<void>;
112
+ preloadThemeConfigs(payload: SwellThemePreload): Promise<void>;
113
113
  getPageConfigPath(pageId: string, altTemplate?: string): string | null;
114
114
  getThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
115
115
  getThemeConfigsByPath(pathPrefix: string, pathSuffix?: string): Promise<Map<string, SwellThemeConfig>>;
@@ -175,18 +175,33 @@ export interface SwellCollectionPage {
175
175
  end: number;
176
176
  }
177
177
  export type SwellCollectionPages = Record<string, SwellCollectionPage>;
178
- export interface SwellThemeConfig extends SwellRecord {
178
+ export interface SwellFile {
179
+ id: string;
180
+ md5: string;
181
+ url: string;
182
+ length: number;
183
+ filename: string | null;
184
+ content_type: string;
185
+ date_uploaded: string;
186
+ }
187
+ export interface SwellThemeConfig {
179
188
  id: string;
180
189
  type: string;
190
+ name: string;
191
+ hash: string;
192
+ file: SwellFile;
181
193
  file_data: string;
182
194
  file_path: string;
183
195
  }
196
+ export type SwellThemeManifest = Record<string, string>;
184
197
  export interface SwellThemeVersion extends SwellRecord {
185
198
  manifest: SwellThemeManifest;
186
199
  hash: string;
187
200
  }
188
- export interface SwellThemeManifest {
189
- [key: string]: string;
201
+ export interface SwellThemePreload {
202
+ api: number;
203
+ version?: SwellThemeVersion;
204
+ configs?: SwellThemeConfig[];
190
205
  }
191
206
  export interface SwellMenu {
192
207
  id: string;
@@ -509,7 +524,7 @@ export interface ThemeFormConfig {
509
524
  url: string;
510
525
  return_url?: string;
511
526
  params?: ThemeFormConfigParam[];
512
- handler?: () => void;
527
+ handler?: (...args: any[]) => any;
513
528
  }
514
529
  export interface ThemeFormErrorMessage {
515
530
  code?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swell/apps-sdk",
3
3
  "type": "module",
4
- "version": "1.0.138",
4
+ "version": "1.0.139",
5
5
  "description": "Swell SDK for building isomorphic apps.",
6
6
  "author": "Swell",
7
7
  "license": "MIT",