@swell/apps-sdk 1.0.95 → 1.0.96

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.
Files changed (41) hide show
  1. package/dist/index.cjs +49 -49
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/index.js +49 -49
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +49 -49
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/src/compatibility/drops/object-handles.d.ts +1 -1
  8. package/dist/src/compatibility/shopify-configs.d.ts +4 -8
  9. package/dist/src/compatibility/shopify-objects/resource.d.ts +1 -1
  10. package/dist/src/compatibility/shopify.d.ts +6 -2
  11. package/dist/src/constants.d.ts +2 -2
  12. package/dist/src/easyblocks/config.d.ts +9 -3
  13. package/dist/src/liquid/filters/asset_url.d.ts +3 -2
  14. package/dist/src/liquid/filters/default_errors.d.ts +3 -2
  15. package/dist/src/liquid/filters/index.d.ts +4 -2
  16. package/dist/src/liquid/filters/json.d.ts +3 -2
  17. package/dist/src/liquid/filters/json_pretty.d.ts +3 -2
  18. package/dist/src/liquid/filters/script_tag.d.ts +3 -0
  19. package/dist/src/liquid/filters/stylesheet_tag.d.ts +3 -2
  20. package/dist/src/liquid/filters/translate.d.ts +3 -2
  21. package/dist/src/liquid/index.d.ts +15 -19
  22. package/dist/src/liquid/tags/case.d.ts +1 -1
  23. package/dist/src/liquid/tags/for.d.ts +1 -1
  24. package/dist/src/liquid/tags/form.d.ts +1 -1
  25. package/dist/src/liquid/tags/inline_editable.d.ts +1 -1
  26. package/dist/src/liquid/tags/javascript.d.ts +1 -1
  27. package/dist/src/liquid/tags/layout.d.ts +1 -1
  28. package/dist/src/liquid/tags/paginate.d.ts +1 -1
  29. package/dist/src/liquid/tags/render.d.ts +1 -1
  30. package/dist/src/liquid/tags/section.d.ts +1 -1
  31. package/dist/src/liquid/tags/sections.d.ts +1 -1
  32. package/dist/src/liquid/tags/shopify/include.d.ts +1 -1
  33. package/dist/src/liquid/tags/style.d.ts +1 -1
  34. package/dist/src/liquid/test-helpers.d.ts +2 -0
  35. package/dist/src/liquid/utils.d.ts +6 -14
  36. package/dist/src/menus.d.ts +1 -1
  37. package/dist/src/theme.d.ts +15 -15
  38. package/dist/src/utils/index.d.ts +1 -1
  39. package/dist/types/shopify.d.ts +19 -15
  40. package/dist/types/swell.d.ts +14 -5
  41. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import { Drop } from 'liquidjs';
2
2
  export default class ObjectHandlesDrop<T> extends Drop {
3
3
  #private;
4
- constructor(map?: Record<string, T> | Map<string, T>);
4
+ constructor(map?: Record<string, T | undefined> | Map<string, T>);
5
5
  liquidMethodMissing(key: unknown): T | undefined;
6
6
  }
@@ -1,10 +1,6 @@
1
- import type { ShopifySectionBlockSchema, ShopifySectionPresetSchema, ShopifySectionSchema, ShopifySettingSchema, ShopifySettingsData, ShopifySettingSection, ShopifySettingsSchema } from 'types/shopify';
2
- import type { ThemeBlockSchema, ThemeEditorSchema, ThemePresetSchema, ThemeSectionSchemaData, ThemeSettingFieldSchema, ThemeSettings, ThemeSettingSectionSchema } from 'types/swell';
3
- export declare function convertShopifySettingsSchema(settingsSchema: ShopifySettingsSchema): ThemeEditorSchema;
1
+ import type { ShopifySectionSchema, ShopifySettingsData, ShopifySettingsSchema } from 'types/shopify';
2
+ import type { ThemeEditorSchema, ThemePresetSchema, ThemeSectionSchemaData, ThemeSettings } from 'types/swell';
3
+ export declare function convertShopifySettingsSchema(settingsSchema: ShopifySettingsSchema, locale: string): ThemeEditorSchema;
4
4
  export declare function convertShopifySettingsData(settingsData: ShopifySettingsData): ThemeSettings;
5
5
  export declare function convertShopifySettingsPresets(settingsData: ShopifySettingsData): ThemePresetSchema[];
6
- export declare function convertShopifySectionSchema(sectionSchema: ShopifySectionSchema): ThemeSectionSchemaData;
7
- export declare function shopifySchemaBlockToSwellBlockSchema(block: ShopifySectionBlockSchema): ThemeBlockSchema;
8
- export declare function shopifySchemaPresetToSwellPresetSchema(preset: ShopifySectionPresetSchema): ThemePresetSchema;
9
- export declare function shopifySchemaSectionToSwellSettingSection(section: ShopifySettingSection): ThemeSettingSectionSchema;
10
- export declare function shopifySchemaSettingToSwellSettingField(setting: ShopifySettingSchema): ThemeSettingFieldSchema;
6
+ export declare function convertShopifySectionSchema(sectionSchema: ShopifySectionSchema, locale: string): ThemeSectionSchemaData;
@@ -20,4 +20,4 @@ export declare function isResolvable(asyncProp: unknown): boolean;
20
20
  export declare function resolveAsyncProp<R extends SwellData>(asyncProp: unknown): Promise<R | R[] | null | undefined>;
21
21
  export declare function handleDeferredProp<T, R extends SwellData>(asyncProp: unknown, handler: (...value: R[]) => T): Promise<T | null>;
22
22
  export declare function deferWith<T, R extends SwellData = SwellData>(asyncProp: unknown, handler: (...value: R[]) => T): DeferredShopifyResource<T | null>;
23
- export declare function deferSwellCollectionWithShopifyResults<T extends Record<string, SwellStorefrontCollection>, R extends ShopifyResource>(instance: ShopifyCompatibility, asyncProp: unknown, key: string, ShopifyObject: (instance: ShopifyCompatibility, result: SwellRecord) => R, handler?: (shopifyResult: R, result: SwellRecord) => void): DeferredShopifyResource<SwellStorefrontCollection<import("types/swell").SwellCollection<SwellRecord>> | null>;
23
+ export declare function deferSwellCollectionWithShopifyResults<T extends Record<string, SwellStorefrontCollection>, R extends ShopifyResource>(instance: ShopifyCompatibility, asyncProp: unknown, key: string, ShopifyObject: (instance: ShopifyCompatibility, result: SwellRecord) => R, handler?: (shopifyResult: R, result: SwellRecord) => void): DeferredShopifyResource<SwellStorefrontCollection | null>;
@@ -5,6 +5,9 @@ import { SwellTheme } from '@/theme';
5
5
  import { ShopifyResource } from './shopify-objects';
6
6
  import type { ThemeGlobals, ThemeSettings, ThemePresetSchema, ThemeEditorSchema, ThemeSectionSchemaData, SwellData, SwellMenu, SwellAppShopifyCompatibilityConfig, SwellSettingsGeo } from '../../types/swell';
7
7
  import type { ShopifySettingsData, ShopifySettingsSchema, ShopifySectionSchema, ShopifyPageResourceMap, ShopifyObjectResourceMap, ShopifyFormResourceMap, ShopifyQueryParamsMap, ShopifyLocalizationConfig } from '../../types/shopify';
8
+ /**
9
+ * This class is meant to be extended by a storefront app to provide compatibility with Shopify's Liquid
10
+ */
8
11
  export declare class ShopifyCompatibility {
9
12
  theme: SwellTheme;
10
13
  swell: Swell;
@@ -16,7 +19,8 @@ export declare class ShopifyCompatibility {
16
19
  shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
17
20
  editorLocaleConfig?: Record<string, ShopifyLocalizationConfig | undefined>;
18
21
  constructor(theme: SwellTheme);
19
- adaptGlobals(globals: ThemeGlobals): void;
22
+ initGlobals(globals: ThemeGlobals): void;
23
+ adaptGlobals(globals: Partial<ThemeGlobals>, prevGlobals: ThemeGlobals): void;
20
24
  /**
21
25
  * Extracts values from the form according to the passed settings config
22
26
  *
@@ -71,7 +75,7 @@ export declare class ShopifyCompatibility {
71
75
  getAdaptedFormClientHtml(formType: string, scope: SwellData, arg?: any): Promise<string | undefined>;
72
76
  getAdaptedFormServerParams(formType: string, context: SwellData): Promise<SwellData | undefined>;
73
77
  getAdaptedFormServerResponse(formType: string, context: SwellData): Promise<SwellData | undefined>;
74
- getShopData({ store }: ThemeGlobals): {};
78
+ getShopData(store: SwellData): {};
75
79
  getContentForHeader(): string;
76
80
  getMenuData(menu: SwellMenu): SwellData;
77
81
  getFontData(font: ThemeFont): SwellData;
@@ -1,4 +1,4 @@
1
- import type { SwellData } from 'types/swell';
1
+ import type { SwellData, SwellSettingsGeo } from 'types/swell';
2
2
  export declare const FILE_DATA_INCLUDE_QUERY: SwellData;
3
- export declare const GEO_DATA: SwellData;
3
+ export declare const GEO_DATA: SwellSettingsGeo;
4
4
  export declare const LANG_TO_COUNTRY_CODES: Record<string, string | undefined>;
@@ -1,13 +1,13 @@
1
1
  import type { Backend, InternalTemplate, NoCodeComponentDefinition } from '@swell/easyblocks-core';
2
- import { SwellTheme } from '../theme';
2
+ import type { SwellTheme } from '../theme';
3
3
  import type { SwellThemeConfig, ThemeGlobals, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup } from 'types/swell';
4
4
  export declare function getEasyblocksPropsFromThemeConfigs(theme: SwellTheme, themeConfigs: SwellThemeConfig[], pageId: string): Promise<{
5
- pageTemplate: ThemeSectionGroup | undefined;
5
+ pageTemplate: string | ThemeSectionGroup | undefined;
6
6
  allSections: import("types/swell").ThemeSectionSchema[];
7
7
  pageSections: ThemeSectionConfig[];
8
8
  layoutSectionGroups: ThemeLayoutSectionGroupConfig[];
9
9
  }>;
10
- export declare function getEasyblocksPageTemplate<T>(theme: SwellTheme, pageId: string): Promise<T | undefined>;
10
+ export declare function getEasyblocksPageTemplate<T>(theme: SwellTheme, pageId: string): Promise<T | string | undefined>;
11
11
  export declare function getEasyblocksPagePropsWithConfigs(themeGlobals: ThemeGlobals, allSections: ThemePageSectionSchema[], pageSections: ThemeSectionConfig[], layoutSectionGroups: ThemeLayoutSectionGroupConfig[], pageId: string): {
12
12
  easyblocksConfig: {
13
13
  components: NoCodeComponentDefinition<Record<string, any>, Record<string, any>>[];
@@ -105,6 +105,12 @@ export declare function getEasyblocksPagePropsWithConfigs(themeGlobals: ThemeGlo
105
105
  id: string;
106
106
  };
107
107
  };
108
+ swell_radio: {
109
+ type: string;
110
+ widget: {
111
+ id: string;
112
+ };
113
+ };
108
114
  swell_short_text: {
109
115
  type: string;
110
116
  widget: {
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from "..";
2
- export default function bind(liquidSwell: LiquidSwell): (assetPath: string) => Promise<string | null>;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(liquidSwell: LiquidSwell): FilterHandler;
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from '..';
2
- export default function bind(_liquidSwell: LiquidSwell): (errors: any) => Promise<string>;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(_liquidSwell: LiquidSwell): FilterHandler;
@@ -1,4 +1,3 @@
1
- import { LiquidSwell } from '..';
2
1
  import asset_url from './asset_url';
3
2
  import brightness_difference from './brightness_difference';
4
3
  import color_brightness from './color_brightness';
@@ -29,6 +28,7 @@ import money from './money';
29
28
  import money_with_currency from './money_with_currency';
30
29
  import money_without_currency from './money_without_currency';
31
30
  import money_without_trailing_zeros from './money_without_trailing_zeros';
31
+ import script_tag from './script_tag';
32
32
  import stylesheet_tag from './stylesheet_tag';
33
33
  import time_tag from './time_tag';
34
34
  import translate from './translate';
@@ -38,6 +38,7 @@ import payment_button from './shopify/payment_button';
38
38
  import payment_terms from './shopify/payment_terms';
39
39
  import placeholder_svg_tag from './shopify/placeholder_svg_tag';
40
40
  import inline_editable from './inline_editable';
41
+ import type { LiquidSwell } from '..';
41
42
  export declare const filters: {
42
43
  asset_url: typeof asset_url;
43
44
  brightness_difference: typeof brightness_difference;
@@ -77,6 +78,7 @@ export declare const filters: {
77
78
  money_with_currency: typeof money_with_currency;
78
79
  money_without_currency: typeof money_without_currency;
79
80
  money_without_trailing_zeros: typeof money_without_trailing_zeros;
81
+ script_tag: typeof script_tag;
80
82
  stylesheet_tag: typeof stylesheet_tag;
81
83
  time_tag: typeof time_tag;
82
84
  translate: typeof translate;
@@ -93,4 +95,4 @@ export declare const filters: {
93
95
  inline_editable: typeof inline_editable;
94
96
  };
95
97
  export declare function bindFilters(liquidSwell: LiquidSwell): void;
96
- export declare function resolveAsyncProps(propArg: any, resolveProps: boolean | Array<string>): Promise<any>;
98
+ export declare function resolveAsyncProps(propArg: unknown, resolveProps: boolean | string[]): Promise<unknown>;
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from '..';
2
- export default function bind(_liquidSwell: LiquidSwell): (input: unknown, space?: number) => Promise<string>;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(_liquidSwell: LiquidSwell): FilterHandler;
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from '..';
2
- export default function bind(_liquidSwell: LiquidSwell): (input: any, space?: number) => Promise<string>;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(_liquidSwell: LiquidSwell): FilterHandler;
@@ -0,0 +1,3 @@
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(_liquidSwell: LiquidSwell): FilterHandler;
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from "..";
2
- export default function bind(_liquidSwell: LiquidSwell): (assetUrl: string) => string;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(_liquidSwell: LiquidSwell): FilterHandler;
@@ -1,2 +1,3 @@
1
- import { LiquidSwell } from '..';
2
- export default function bind(liquidSwell: LiquidSwell): (key: string, params?: any[]) => Promise<string>;
1
+ import type { FilterHandler } from 'liquidjs/dist/template';
2
+ import type { LiquidSwell } from '..';
3
+ export default function bind(liquidSwell: LiquidSwell): FilterHandler;
@@ -1,4 +1,4 @@
1
- import { Liquid, type FS } from 'liquidjs';
1
+ import { Liquid } from 'liquidjs';
2
2
  import { SwellTheme } from '../theme';
3
3
  import type { GetAssetUrl, GetThemeConfig, GetThemeTemplateConfigByType, RenderCurrency, RenderTemplate, RenderPageSections, RenderTemplateString, RenderTranslation, ThemeSectionSchema } from 'types/swell';
4
4
  export * from './color';
@@ -6,14 +6,14 @@ export * from './form';
6
6
  export * from './font';
7
7
  interface LiquidSwellOptions {
8
8
  theme: SwellTheme;
9
- getThemeConfig: GetThemeConfig;
9
+ getThemeConfig?: GetThemeConfig;
10
10
  getThemeTemplateConfigByType?: GetThemeTemplateConfigByType;
11
- getAssetUrl: GetAssetUrl;
12
- renderTemplate: RenderTemplate;
13
- renderTemplateString: RenderTemplateString;
14
- renderPageSections: RenderPageSections;
15
- renderTranslation: RenderTranslation;
16
- renderCurrency: RenderCurrency;
11
+ getAssetUrl?: GetAssetUrl;
12
+ renderTemplate?: RenderTemplate;
13
+ renderTemplateString?: RenderTemplateString;
14
+ renderPageSections?: RenderPageSections;
15
+ renderTranslation?: RenderTranslation;
16
+ renderCurrency?: RenderCurrency;
17
17
  isEditor: boolean;
18
18
  locale?: string;
19
19
  currency?: string;
@@ -25,27 +25,23 @@ interface LiquidSwellOptions {
25
25
  export declare class LiquidSwell extends Liquid {
26
26
  theme: SwellTheme;
27
27
  getThemeConfig: GetThemeConfig;
28
- getThemeTemplateConfigByType: GetThemeTemplateConfigByType | undefined;
28
+ getThemeTemplateConfigByType: GetThemeTemplateConfigByType;
29
29
  getAssetUrl: GetAssetUrl;
30
30
  renderTemplate: RenderTemplate;
31
31
  renderTemplateString: RenderTemplateString;
32
32
  renderPageSections: RenderPageSections;
33
33
  renderTranslation: RenderTranslation;
34
34
  renderCurrency: RenderCurrency;
35
- engine: Liquid;
36
35
  isEditor: boolean;
37
- locale: string | undefined;
38
- currency: string | undefined;
39
- layoutName: string | undefined;
40
- extName: string | undefined;
41
- componentsDir: string | undefined;
42
- sectionsDir: string | undefined;
36
+ locale: string;
37
+ currency: string;
38
+ layoutName: string;
39
+ extName: string;
40
+ componentsDir: string;
41
+ sectionsDir: string;
43
42
  lastSchema: ThemeSectionSchema | undefined;
44
43
  constructor({ theme, getThemeConfig, getThemeTemplateConfigByType, getAssetUrl, renderTemplate, renderTemplateString, renderPageSections, renderTranslation, renderCurrency, isEditor, locale, currency, layoutName, extName, componentsDir, sectionsDir, }: LiquidSwellOptions);
45
- initLiquidEngine(): Liquid;
46
- getLiquidFS(): FS;
47
44
  parseAndRender(template: string, data: any): Promise<string>;
48
- resolveFilePath(fileName: string, extName?: string): string;
49
45
  resolveFilePathByType(type: string, name: string): Promise<string | undefined>;
50
46
  getComponentPath(componentName: string): Promise<string>;
51
47
  getSectionPath(sectionName: string): Promise<string>;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(_liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(_liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(_liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '../..';
1
+ import type { LiquidSwell } from '../..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(liquidSwell: LiquidSwell): TagClass;
@@ -1,3 +1,3 @@
1
- import { LiquidSwell } from '..';
1
+ import type { LiquidSwell } from '..';
2
2
  import type { TagClass } from 'liquidjs/dist/template';
3
3
  export default function bind(_liquidSwell: LiquidSwell): TagClass;
@@ -1,6 +1,8 @@
1
1
  import { LiquidSwell } from './';
2
+ import type { Swell } from '@/api';
2
3
  type DescribeLiquidCallbackType = (render: (template: string, data?: any) => Promise<string>, liquid: LiquidSwell) => void;
3
4
  export declare function describeFilter(name: string, callback: DescribeLiquidCallbackType): void;
4
5
  export declare function describeTag(name: string, callback: DescribeLiquidCallbackType): void;
5
6
  export declare function removeSpaces(value: string): string;
7
+ export declare function setStorefrontLocalization(swell: Swell, locale: string, currency: string): void;
6
8
  export {};
@@ -1,12 +1,4 @@
1
- import { Context } from 'liquidjs';
2
- export declare const toString: () => string;
3
- export declare const hasOwnProperty: (v: PropertyKey) => boolean;
4
- /**
5
- * Utils used by liquidjs tags and filters
6
- */
7
- export declare class Drop {
8
- liquidMethodMissing(key: string): undefined;
9
- }
1
+ import { Context, Drop } from 'liquidjs';
10
2
  export declare class ForloopDrop extends Drop {
11
3
  i: number;
12
4
  length: number;
@@ -22,10 +14,10 @@ export declare class ForloopDrop extends Drop {
22
14
  next(): void;
23
15
  valueOf(): string;
24
16
  }
25
- export declare function toValue(value: any): any;
17
+ export declare function toValue(value: unknown): unknown;
26
18
  export declare function isString(value: unknown): value is string;
27
19
  export declare function isNumber(value: unknown): value is number;
28
- export declare function isFunction(value: unknown): value is Function;
20
+ export declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
29
21
  export declare function toLiquid(value: unknown): unknown;
30
22
  export declare function isNil(value: unknown): value is undefined | null;
31
23
  export declare function isUndefined(value: unknown): value is undefined;
@@ -33,8 +25,8 @@ export declare function isArray<T>(value: unknown): value is Array<T>;
33
25
  export declare function isObject(value: unknown): value is Record<string, unknown>;
34
26
  export declare function isIterable<T>(value: unknown): value is Iterable<T>;
35
27
  export declare function isLikePromise(value: unknown): value is Promise<unknown>;
36
- export declare function isTruthy(val: any, ctx: Context): boolean;
37
- export declare function isFalsy(val: any, ctx: Context): boolean;
28
+ export declare function isTruthy(val: unknown, ctx: Context): boolean;
29
+ export declare function isFalsy(val: unknown, ctx: Context): boolean;
38
30
  export interface Comparable {
39
31
  equals(rhs: unknown): boolean;
40
32
  gt(rhs: unknown): boolean;
@@ -46,5 +38,5 @@ export declare function isComparable(arg: unknown): arg is Comparable;
46
38
  export declare function toArray<T>(val: unknown): T[];
47
39
  export declare function toEnumerable<T>(val: unknown): T[];
48
40
  export declare function stringify(value: unknown): string;
49
- export declare function paramsToProps(params: string[] | Record<string, string>): Record<string, unknown>;
41
+ export declare function paramsToProps(params: (string | [string, unknown])[] | Record<string, string>): Record<string, unknown>;
50
42
  export declare function jsonStringifyAsync(input: unknown, space?: number): Promise<string>;
@@ -3,7 +3,7 @@ import { SwellStorefrontRecord, SwellStorefrontCollection } from './api';
3
3
  import { type SwellMenu, type SwellMenuItem } from '../types/swell';
4
4
  export declare function resolveMenuSettings(theme: SwellTheme, menus: SwellMenu[], options?: {
5
5
  currentUrl?: string;
6
- }): Promise<Record<string, SwellMenu>>;
6
+ }): Promise<Record<string, SwellMenu | undefined>>;
7
7
  export declare function resolveMenuItems(theme: SwellTheme, menuItems: SwellMenuItem[], options?: {
8
8
  currentUrl?: string;
9
9
  }): Promise<SwellMenuItem[]>;
@@ -2,7 +2,8 @@ import { Swell, StorefrontResource, SwellStorefrontCollection, SwellStorefrontRe
2
2
  import { ShopifyCompatibility } from './compatibility/shopify';
3
3
  import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
4
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';
5
+ import type { FormatInput } from 'swell-js';
6
+ 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, ThemePage, SwellPageRequest, SwellSettingsGeo } from 'types/swell';
6
7
  export declare class SwellTheme {
7
8
  swell: Swell;
8
9
  props: SwellAppStorefrontThemeProps;
@@ -12,7 +13,7 @@ export declare class SwellTheme {
12
13
  liquidSwell: LiquidSwell;
13
14
  themeLoader: ThemeLoader;
14
15
  themeConfigs: Map<string, SwellThemeConfig> | null;
15
- page: any;
16
+ page?: ThemeSettings;
16
17
  pageId: string | undefined;
17
18
  shopifyCompatibility: ShopifyCompatibility | null;
18
19
  shopifyCompatibilityClass: typeof ShopifyCompatibility;
@@ -27,18 +28,18 @@ export declare class SwellTheme {
27
28
  });
28
29
  getSwellAppThemeProps(swellConfig?: SwellAppConfig): SwellAppStorefrontThemeProps;
29
30
  initGlobals(pageId: string): Promise<void>;
30
- setGlobals(globals: SwellData): void;
31
+ setGlobals(globals: Partial<ThemeGlobals>): void;
31
32
  getSettingsAndConfigs(): Promise<{
32
33
  store: SwellData;
33
34
  session: SwellData;
34
- menus: Record<string, SwellMenu>;
35
- geo: SwellData;
35
+ menus: Record<string, SwellMenu | undefined>;
36
+ geo: SwellSettingsGeo;
36
37
  configs: ThemeConfigs;
37
38
  }>;
38
- resolvePageData(store: SwellData, configs: SwellData, pageId?: string): Promise<{
39
+ resolvePageData(store: SwellData, configs: ThemeConfigs, pageId?: string): Promise<{
39
40
  settings: ThemeSettings;
40
- request: ThemeSettings;
41
- page: ThemeSettings;
41
+ request: SwellPageRequest;
42
+ page: ThemePage;
42
43
  cart: SwellStorefrontSingleton | {};
43
44
  account: SwellStorefrontSingleton | null;
44
45
  customer?: SwellStorefrontSingleton | null;
@@ -95,7 +96,7 @@ export declare class SwellTheme {
95
96
  setCompatibilityData(pageData: SwellData): void;
96
97
  resolveLookupSetting(setting: ThemeSettingFieldSchema, value: any): SwellData | SwellStorefrontRecord | SwellStorefrontCollection | null;
97
98
  resolveLookupResource(collection: string, id: string): StorefrontResource<SwellRecord>;
98
- resolveMenuSettings(): Promise<Record<string, SwellMenu>>;
99
+ resolveMenuSettings(): Promise<Record<string, SwellMenu | undefined>>;
99
100
  resolveMenuSetting(value: string): SwellMenu | null;
100
101
  lang(key: string, data?: any, fallback?: string): Promise<string>;
101
102
  resolveFontSetting(value: string): ThemeFont;
@@ -116,13 +117,13 @@ export declare class SwellTheme {
116
117
  renderTemplateString(templateString: string, data?: SwellData): Promise<string>;
117
118
  getSectionSchema(sectionName: string): Promise<Partial<ThemeSectionSchema> | undefined>;
118
119
  getSectionConfigWithSchemaTagOnly(config: SwellThemeConfig): SwellThemeConfig | null;
120
+ renderThemeTemplate(filePath: `${string}.liquid`, data?: SwellData): Promise<string>;
121
+ renderThemeTemplate(filePath: `${string}.json`, data?: SwellData): Promise<ThemePageTemplateConfig>;
119
122
  renderThemeTemplate(filePath: string, data?: SwellData): Promise<string | ThemePageTemplateConfig>;
120
123
  renderLayoutTemplate(name: string, data?: SwellData): Promise<string>;
121
124
  renderPageTemplate(name: string, data?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
122
125
  renderPage(pageData?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
123
- renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<{
124
- [key: string]: string;
125
- }>;
126
+ renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<Record<string, string | undefined>>;
126
127
  renderSection(sectionId: string, pageData?: SwellData): Promise<string | ThemePageTemplateConfig>;
127
128
  renderLayout(data?: SwellData): Promise<string>;
128
129
  getContentForHeader(): string;
@@ -147,12 +148,11 @@ export declare class SwellTheme {
147
148
  renderSectionConfigs(sectionConfigs: ThemeSectionConfig[], data?: SwellData): Promise<ThemeSectionConfig[]>;
148
149
  renderTranslation(key: string, data?: unknown, fallback?: string): Promise<string>;
149
150
  renderTranslationValue(localeCode: string, langConfig: any, key: string, data?: any, fallback?: string): Promise<string>;
150
- renderCurrency(amount: number, params: any): string;
151
+ renderCurrency(amount: number, params?: FormatInput): string;
151
152
  }
152
- export declare class PageError {
153
+ export declare class PageError extends Error {
153
154
  title: string;
154
155
  status: number;
155
- message: string;
156
156
  description?: string;
157
157
  constructor(title?: string | Error, status?: number, description?: string);
158
158
  toString(): string;
@@ -8,7 +8,7 @@ export declare function isObject(value: unknown): value is Record<string, unknow
8
8
  export declare function toBase64(inputString: string): string;
9
9
  export declare function arrayToObject<T extends {
10
10
  [I in keyof T | K]?: T[I];
11
- }, K extends string = 'id'>(arr: T[], key?: K): Record<string, T>;
11
+ }, K extends string = 'id'>(arr: T[], key?: K): Record<string, T | undefined>;
12
12
  export declare function getCountryCodeFromLocale(locale: string): string;
13
13
  export declare function forEachKeyDeep(obj: Record<string, unknown>, fn: (key: string, value: unknown) => boolean | void): void;
14
14
  export declare function findCircularReferences(value: object): unknown[];
@@ -1,4 +1,4 @@
1
- import type { SwellData, OptionItem, ThemeSectionEnabledDisabled } from './swell';
1
+ import type { SwellData, ThemeSectionEnabledDisabled } from './swell';
2
2
  import type { ShopifyResource } from '../src/compatibility/shopify-objects/resource';
3
3
  import type { ShopifyCompatibility } from '../src/compatibility/shopify';
4
4
  import type { StorefrontResource } from '../src/resources';
@@ -20,6 +20,10 @@ export interface ShopifySettingRoleSchema {
20
20
  icons: string;
21
21
  links: string;
22
22
  }
23
+ export interface ShopifyOptionItem {
24
+ label: string | Record<string, string | undefined>;
25
+ value: string;
26
+ }
23
27
  export interface ShopifySettingDefinitionSchema {
24
28
  type: 'header' | 'color' | 'color_background';
25
29
  label: string;
@@ -30,28 +34,28 @@ export interface ShopifySettingDefinitionSchema {
30
34
  }
31
35
  export interface ShopifySettingSchema {
32
36
  type: ShopifyBasicInputType | ShopifySpecializedInputType;
33
- label: string;
37
+ label: string | Record<string, string | undefined>;
34
38
  id?: string;
35
- info?: string;
36
- default?: any;
39
+ info?: string | Record<string, string | undefined>;
40
+ default?: string | Record<string, string | undefined>;
37
41
  placeholder?: string;
38
- content?: string;
39
- options?: Array<OptionItem>;
42
+ content?: string | Record<string, string | undefined>;
43
+ options?: ShopifyOptionItem[];
40
44
  group?: string;
41
45
  min?: number;
42
46
  max?: number;
43
47
  step?: number;
44
48
  unit?: string;
45
49
  limit?: number;
46
- definition?: Array<ShopifySettingDefinitionSchema>;
50
+ definition?: ShopifySettingDefinitionSchema[];
47
51
  role?: ShopifySettingRoleSchema;
48
- accept?: Array<string>;
52
+ accept?: string[];
49
53
  }
50
54
  export interface ShopifySettingSection {
51
55
  name: string;
52
- settings?: Array<ShopifySettingSchema>;
56
+ settings?: ShopifySettingSchema[];
53
57
  }
54
- export type ShopifySettingsSchema = Array<ShopifySettingSection>;
58
+ export type ShopifySettingsSchema = ShopifySettingSection[];
55
59
  export interface ShopifySettingsData {
56
60
  current: Record<string, any> | string;
57
61
  presets: Record<string, Record<string, any>>;
@@ -69,7 +73,7 @@ export interface ShopifySectionPresetSchema {
69
73
  }
70
74
  export interface ShopifySettingSection {
71
75
  name: string;
72
- settings?: Array<ShopifySettingSchema>;
76
+ settings?: ShopifySettingSchema[];
73
77
  }
74
78
  export interface ShopifySectionGroupItem {
75
79
  type: string;
@@ -93,7 +97,7 @@ export interface ShopifySectionSchema {
93
97
  settings: ShopifySettingSchema[];
94
98
  blocks?: ShopifySectionBlockSchema[];
95
99
  presets?: ShopifySectionPresetSchema[];
96
- default?: ShopifySettingSchema;
100
+ default?: ShopifySectionPresetSchema;
97
101
  }
98
102
  export interface ShopifyPageResource {
99
103
  from: string;
@@ -102,7 +106,7 @@ export interface ShopifyPageResource {
102
106
  }
103
107
  export interface ShopifyPage {
104
108
  page: string;
105
- resources: Array<ShopifyPageResource>;
109
+ resources: ShopifyPageResource[];
106
110
  }
107
111
  export type ShopifyPageResourceMap = Map<string, ShopifyPage>;
108
112
  interface ShopifyObject {
@@ -118,12 +122,12 @@ export interface ShopifyForm {
118
122
  serverParams?(context: SwellData): SwellData;
119
123
  serverResponse?(context: SwellData): SwellData;
120
124
  }
121
- export type ShopifyFormResourceMap = Array<ShopifyForm>;
125
+ export type ShopifyFormResourceMap = ShopifyForm[];
122
126
  export interface ShopifyQueryParams {
123
127
  from: string | ((param: string) => boolean);
124
128
  to: string | ((param: string, value: string) => SwellData);
125
129
  }
126
- export type ShopifyQueryParamsMap = Array<ShopifyQueryParams>;
130
+ export type ShopifyQueryParamsMap = ShopifyQueryParams[];
127
131
  export interface ShopifyLocalizationSection {
128
132
  [key: string]: string | ShopifyLocalizationSection;
129
133
  }