@slidejs/runner-swiper 0.1.4 → 0.1.5

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/src/runner.ts CHANGED
@@ -10,9 +10,7 @@ import type { SlideContext } from '@slidejs/context';
10
10
  import { SwiperAdapter } from './adapter';
11
11
  import type { SwiperAdapterOptions } from './types';
12
12
  // 导入 CSS 内容用于注入
13
- import swiperCSS from 'swiper/css?inline';
14
- import swiperNavigationCSS from 'swiper/css/navigation?inline';
15
- import swiperPaginationCSS from 'swiper/css/pagination?inline';
13
+ import swiperBundleCSS from 'swiper/css/bundle?inline';
16
14
  import customCSS from './style.css?inline';
17
15
 
18
16
  /**
@@ -70,31 +68,13 @@ export async function createSlideRunner<TContext extends SlideContext = SlideCon
70
68
  // 2. 编译为 SlideDSL
71
69
  const slideDSL = compile<TContext>(ast);
72
70
 
73
- // 2.1 注入 Swiper CSS 到 document.head(全局,如果尚未注入)
74
- // 注入基础 CSS
75
- const baseStyleId = 'swiper-styles';
76
- if (!document.head.querySelector(`#${baseStyleId}`)) {
71
+ // 2.1 注入 Swiper Bundle CSS 到 document.head(全局,如果尚未注入)
72
+ // Bundle CSS 包含所有模块(核心、Navigation、Pagination 等)
73
+ const swiperStyleId = 'swiper-bundle-styles';
74
+ if (!document.head.querySelector(`#${swiperStyleId}`)) {
77
75
  const style = document.createElement('style');
78
- style.id = baseStyleId;
79
- style.textContent = swiperCSS;
80
- document.head.appendChild(style);
81
- }
82
-
83
- // 注入 Navigation CSS
84
- const navigationStyleId = 'swiper-navigation-styles';
85
- if (!document.head.querySelector(`#${navigationStyleId}`)) {
86
- const style = document.createElement('style');
87
- style.id = navigationStyleId;
88
- style.textContent = swiperNavigationCSS;
89
- document.head.appendChild(style);
90
- }
91
-
92
- // 注入 Pagination CSS
93
- const paginationStyleId = 'swiper-pagination-styles';
94
- if (!document.head.querySelector(`#${paginationStyleId}`)) {
95
- const style = document.createElement('style');
96
- style.id = paginationStyleId;
97
- style.textContent = swiperPaginationCSS;
76
+ style.id = swiperStyleId;
77
+ style.textContent = swiperBundleCSS;
98
78
  document.head.appendChild(style);
99
79
  }
100
80
 
package/src/types.ts CHANGED
@@ -13,8 +13,8 @@ type SwiperOptions = ConstructorParameters<typeof Swiper>[1];
13
13
  /**
14
14
  * SwiperAdapter 选项
15
15
  *
16
- * 注意:所有必需的 Swiper CSS(包括核心 CSS、Navigation CSS Pagination CSS)
17
- * 都会在创建 runner 时自动注入,无需手动导入。
16
+ * 注意:Swiper Bundle CSS(包含所有模块的 CSS)会在创建 runner 时自动注入,
17
+ * 无需手动导入。
18
18
  *
19
19
  * Keyboard、Navigation 和 Pagination 模块已在适配器中自动注册,
20
20
  * 无需在配置中再次指定 modules。