@swell/apps-sdk 1.0.50 → 1.0.51

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/src/api.d.ts CHANGED
@@ -7,7 +7,6 @@ export declare class Swell {
7
7
  swellHeaders: SwellData;
8
8
  queryParams: SwellData;
9
9
  workerEnv?: CFThemeEnv;
10
- private themeCache;
11
10
  config?: SwellAppConfig;
12
11
  shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
13
12
  backend?: SwellBackendAPI;
@@ -35,11 +34,6 @@ export declare class Swell {
35
34
  swellHeaders: SwellData;
36
35
  };
37
36
  static formatQueryParams(queryParams?: URLSearchParams | SwellData): SwellData;
38
- /**
39
- * Fetches a theme version resource
40
- * First attempts to fetch from cache.
41
- */
42
- getCachedThemeVersion<T>(key: string, version: string, handler: () => T | Promise<T>): Promise<T>;
43
37
  /**
44
38
  * Fetches a resource.
45
39
  * First attempts to fetch from cache.
@@ -0,0 +1,39 @@
1
+ import { Swell } from '../api';
2
+ import type { SwellThemeConfig } from 'types/swell';
3
+ /**
4
+ * Responsible for loading a theme.
5
+ */
6
+ export declare class ThemeLoader {
7
+ private static cache;
8
+ private swell;
9
+ constructor(swell: Swell);
10
+ /**
11
+ * Loads theme configs for this version.
12
+ */
13
+ loadTheme(): Promise<SwellThemeConfig[]>;
14
+ /**
15
+ * Load all theme configs.
16
+ */
17
+ private loadThemeAllConfigs;
18
+ /**
19
+ * Load theme configs via manifest.
20
+ *
21
+ * This approach has the following optimizations:
22
+ * - cached manifests and configs can be shared by other clients
23
+ * - when fetching from source, only fetch the missing records
24
+ */
25
+ private loadThemeFromManifest;
26
+ /**
27
+ * Fetches the manifest (list of hashes) for a theme version.
28
+ */
29
+ private fetchManifest;
30
+ /**
31
+ * Fetches theme configs via Swell Backend API.
32
+ */
33
+ private fetchThemeConfigsFromSource;
34
+ /**
35
+ * Generates a Swell API query filter for this theme version.
36
+ */
37
+ private themeVersionQueryFilter;
38
+ private getCache;
39
+ }
@@ -1,7 +1,7 @@
1
1
  import { Swell, StorefrontResource, SwellStorefrontCollection, SwellStorefrontRecord, SwellStorefrontSingleton } from './api';
2
- import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
3
2
  import { ShopifyCompatibility } from './compatibility/shopify';
4
- import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig } from '../types/swell';
3
+ import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
4
+ import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig } from 'types/swell';
5
5
  export declare class SwellTheme {
6
6
  swell: Swell;
7
7
  props: SwellAppStorefrontThemeProps;
@@ -96,7 +96,6 @@ export declare class SwellTheme {
96
96
  lang(key: string, data?: any, fallback?: string): Promise<string>;
97
97
  resolveFontSetting(value: string): ThemeFont | null;
98
98
  resolveUrlSetting(value: string): string;
99
- themeConfigQuery(): Record<string, unknown>;
100
99
  getAllThemeConfigs(): Promise<Map<string, SwellThemeConfig>>;
101
100
  getPageConfigPath(pageId: string): string | null;
102
101
  getThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
@@ -1,6 +1,5 @@
1
1
  import type { SwellData, SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema, ThemeSettings } from 'types/swell';
2
2
  export * from './md5';
3
- export declare function themeConfigQuery(swellHeaders: Record<string, unknown>): Record<string, unknown>;
4
3
  export declare function getAllSections(themeConfigs: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<ThemeSectionSchema | undefined>): Promise<ThemePageSectionSchema[]>;
5
4
  export declare function getLayoutSectionGroups(allSections: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeLayoutSectionGroupConfig[]>;
6
5
  export declare function getPageSections(sectionGroup: ThemeSectionGroup | SwellRecord, getSchema: (type: string) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeSectionConfig[]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swell/apps-sdk",
3
3
  "type": "module",
4
- "version": "1.0.50",
4
+ "version": "1.0.51",
5
5
  "description": "Swell SDK for building isomorphic apps.",
6
6
  "author": "Swell",
7
7
  "license": "MIT",
@@ -39,6 +39,7 @@
39
39
  "dependencies": {
40
40
  "@swell/easyblocks-core": "^1.0.10",
41
41
  "@types/lodash": "^4.17.5",
42
+ "bluebird": "^3.7.2",
42
43
  "cache-manager": "^6.3.2",
43
44
  "color": "^4.2.3",
44
45
  "keyv": "^5.2.3",
@@ -52,6 +53,7 @@
52
53
  "devDependencies": {
53
54
  "@eslint/js": "^9.18.0",
54
55
  "@kruining/waterlogged": "^1.1.45",
56
+ "@types/bluebird": "^3.5.42",
55
57
  "@types/color": "^3.0.6",
56
58
  "@types/jest": "29.5.14",
57
59
  "@types/lodash-es": "^4.17.12",