@slidejs/runner-swiper 0.1.3 → 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,7 +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';
13
+ import swiperBundleCSS from 'swiper/css/bundle?inline';
14
14
  import customCSS from './style.css?inline';
15
15
 
16
16
  /**
@@ -68,12 +68,13 @@ export async function createSlideRunner<TContext extends SlideContext = SlideCon
68
68
  // 2. 编译为 SlideDSL
69
69
  const slideDSL = compile<TContext>(ast);
70
70
 
71
- // 2.1 Set to Global
72
- const globalStyles = document.head.querySelector('#swiper-styles');
73
- if (!globalStyles) {
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}`)) {
74
75
  const style = document.createElement('style');
75
- style.id = 'swiper-styles';
76
- style.textContent = swiperCSS;
76
+ style.id = swiperStyleId;
77
+ style.textContent = swiperBundleCSS;
77
78
  document.head.appendChild(style);
78
79
  }
79
80
 
package/src/types.ts CHANGED
@@ -4,20 +4,19 @@
4
4
  * 定义 Swiper 适配器的选项和配置
5
5
  */
6
6
 
7
- import type { SwiperOptions } from 'swiper';
7
+ import { Swiper } from 'swiper';
8
8
  import type { AdapterOptions } from '@slidejs/runner';
9
9
 
10
+ // Swiper 构造函数的第二个参数类型
11
+ type SwiperOptions = ConstructorParameters<typeof Swiper>[1];
12
+
10
13
  /**
11
14
  * SwiperAdapter 选项
12
15
  *
13
- * Swiper CSS 需要手动导入:
14
- * ```typescript
15
- * import 'swiper/css';
16
- * import 'swiper/css/navigation';
17
- * import 'swiper/css/pagination';
18
- * ```
16
+ * 注意:Swiper Bundle CSS(包含所有模块的 CSS)会在创建 runner 时自动注入,
17
+ * 无需手动导入。
19
18
  *
20
- * 注意:Keyboard、Navigation 和 Pagination 模块已在适配器中自动注册,
19
+ * Keyboard、Navigation 和 Pagination 模块已在适配器中自动注册,
21
20
  * 无需在配置中再次指定 modules。
22
21
  */
23
22
  export interface SwiperAdapterOptions extends AdapterOptions {