@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/.turbo/turbo-build.log +5 -19
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.mjs +380 -386
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/adapter.ts +21 -16
- package/src/index.ts +2 -2
- package/src/runner.ts +7 -6
- package/src/types.ts +7 -8
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
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
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 =
|
|
76
|
-
style.textContent =
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
19
|
+
* Keyboard、Navigation 和 Pagination 模块已在适配器中自动注册,
|
|
21
20
|
* 无需在配置中再次指定 modules。
|
|
22
21
|
*/
|
|
23
22
|
export interface SwiperAdapterOptions extends AdapterOptions {
|