vite-plugin-react-shopify 1.1.0 → 2.1.0

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.d.ts CHANGED
@@ -6,7 +6,6 @@ interface Options {
6
6
  snippetFile?: string;
7
7
  buildDir?: string;
8
8
  debug?: boolean;
9
- hash?: boolean;
10
9
  ssg?: SSGOptions;
11
10
  importMap?: ImportMapOptions;
12
11
  }
@@ -16,21 +15,23 @@ interface SSGOptions {
16
15
  template?: string;
17
16
  section?: string;
18
17
  block?: string;
18
+ snippet?: string;
19
19
  };
20
20
  outputName?: string;
21
+ cssPrefix?: string;
21
22
  }
22
23
  interface ImportMapOptions {
23
24
  react?: string;
24
25
  reactDomClient?: string;
25
26
  }
26
- type ShopifyBlockType = "template" | "section" | "block";
27
- type SettingValue = string | number | boolean;
28
- type InputSettings = Record<string, SettingValue>;
27
+
29
28
  interface BaseSettingSchema {
30
29
  id: string;
31
30
  label: string;
32
31
  info?: string;
33
32
  }
33
+ type SettingValue = string | number | boolean;
34
+ type InputSettings = Record<string, SettingValue>;
34
35
  interface CheckboxSetting extends BaseSettingSchema {
35
36
  type: "checkbox";
36
37
  default?: boolean;
@@ -211,9 +212,36 @@ type SidebarSetting = HeaderSetting | ParagraphSetting | LineBreakSetting;
211
212
  type SettingSchema = InputSettingSchema | SidebarSetting;
212
213
  /** @deprecated Use {@link SettingSchema} instead */
213
214
  type SchemaSetting = SettingSchema;
215
+ /**
216
+ * Type-level assertion: prevents settings with empty-string defaults.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const settings = [...] as const satisfies SettingSchema[];
221
+ * type __noEmptyCheck = AssertNoEmptyDefaults<typeof settings>;
222
+ * // TypeScript will show `never` if any setting has `default: ""`
223
+ * declare const __assert: __noEmptyCheck;
224
+ * ```
225
+ */
226
+ type IsEmptyStringDefault<T> = T extends {
227
+ default: "";
228
+ } ? true : false;
229
+ type EmptyDefaultsExist<T extends readonly any[]> = true extends {
230
+ [K in keyof T]: IsEmptyStringDefault<T[K]>;
231
+ }[number] ? true : false;
232
+ type AssertNoEmptyDefaults<T extends readonly SettingSchema[]> = EmptyDefaultsExist<T> extends true ? never : true;
233
+ type ValueForType<T extends string> = T extends "checkbox" ? boolean : T extends "number" | "range" ? number : string;
234
+ type InferSettings<T extends readonly {
235
+ type: string;
236
+ id: string;
237
+ }[]> = {
238
+ [K in T[number] as K["id"]]: ValueForType<K["type"]>;
239
+ };
240
+
241
+ type ShopifyBlockType = "template" | "section" | "block" | "snippet";
214
242
  interface ShopifyMeta {
215
243
  type?: ShopifyBlockType;
216
- name: string;
244
+ name?: string;
217
245
  tag?: string;
218
246
  class?: string;
219
247
  limit?: number;
@@ -243,6 +271,7 @@ interface PresetBlock {
243
271
  settings?: InputSettings;
244
272
  blocks?: PresetBlock[];
245
273
  }
274
+
246
275
  interface SSGEntry {
247
276
  filePath: string;
248
277
  componentName: string;
@@ -250,14 +279,7 @@ interface SSGEntry {
250
279
  targetType: ShopifyBlockType;
251
280
  meta: Required<Pick<ShopifyMeta, "name">> & ShopifyMeta;
252
281
  }
253
- type ValueForType<T extends string> = T extends "checkbox" ? boolean : T extends "number" | "range" ? number : string;
254
- type InferSettings<T extends readonly {
255
- type: string;
256
- id: string;
257
- }[]> = {
258
- [K in T[number] as K["id"]]: ValueForType<K["type"]>;
259
- };
260
282
 
261
283
  declare const vitePluginShopify: (options?: Options) => Plugin[];
262
284
 
263
- export { type ArticleListSetting, type ArticleSetting, type BlogSetting, type CheckboxSetting, type CollectionListSetting, type CollectionSetting, type ColorBackgroundSetting, type ColorSchemeGroupSetting, type ColorSchemeRole, type ColorSchemeSetting, type ColorSetting, type FontPickerSetting, type HeaderSetting, type HtmlSetting, type ImagePickerSetting, type ImportMapOptions, type InferSettings, type InlineRichtextSetting, type InputSettingSchema, type InputSettings, type LineBreakSetting, type LinkListSetting, type LiquidSetting, type MetaobjectListSetting, type MetaobjectSetting, type NumberSetting, type Options, type PageSetting, type ParagraphSetting, type PresetBlock, type PresetDefinition, type ProductListSetting, type ProductSetting, type RadioSetting, type RangeSetting, type RichtextSetting, type SSGEntry, type SSGOptions, type SchemaSetting, type SelectSetting, type SettingSchema, type SettingType, type SettingValue, type ShopifyBlockType, type ShopifyMeta, type SidebarSetting, type TextAlignmentSetting, type TextSetting, type TextareaSetting, type UrlSetting, type VideoSetting, type VideoUrlSetting, vitePluginShopify as default };
285
+ export { type ArticleListSetting, type ArticleSetting, type AssertNoEmptyDefaults, type BlogSetting, type CheckboxSetting, type CollectionListSetting, type CollectionSetting, type ColorBackgroundSetting, type ColorSchemeGroupSetting, type ColorSchemeRole, type ColorSchemeSetting, type ColorSetting, type FontPickerSetting, type HeaderSetting, type HtmlSetting, type ImagePickerSetting, type ImportMapOptions, type InferSettings, type InlineRichtextSetting, type InputSettingSchema, type InputSettings, type LineBreakSetting, type LinkListSetting, type LiquidSetting, type MetaobjectListSetting, type MetaobjectSetting, type NumberSetting, type Options, type PageSetting, type ParagraphSetting, type PresetBlock, type PresetDefinition, type ProductListSetting, type ProductSetting, type RadioSetting, type RangeSetting, type RichtextSetting, type SSGEntry, type SSGOptions, type SchemaSetting, type SelectSetting, type SettingSchema, type SettingType, type SettingValue, type ShopifyBlockType, type ShopifyMeta, type SidebarSetting, type TextAlignmentSetting, type TextSetting, type TextareaSetting, type UrlSetting, type VideoSetting, type VideoUrlSetting, vitePluginShopify as default };