@tbox.cn/app-module-promotion 0.2.0 → 0.9.4
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/AGENTS.md +16 -0
- package/README.md +90 -11
- package/dist/chunk-QOTX4XDS.js +1745 -0
- package/dist/chunk-S7CVFCML.js +1330 -0
- package/dist/client/index.d.ts +21 -3
- package/dist/client/index.js +4 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js +16 -4
- package/dist/promotion-6L7HLRC2.css +2135 -0
- package/dist/server/index.d.ts +2481 -41
- package/dist/server/index.js +13 -3
- package/package.json +28 -15
- package/skills/promotion/SKILL.md +137 -0
- package/skills/promotion/references/claim-loop.md +18 -0
- package/src/client/cards/index.ts +10 -0
- package/src/client/cards/promotion-activity-category-list/index.tsx +34 -0
- package/src/client/cards/promotion-activity-detail/index.tsx +84 -0
- package/src/client/cards/promotion-activity-list/index.tsx +56 -0
- package/src/client/cards/promotion-best-deal/index.tsx +18 -0
- package/src/client/cards/promotion-entitlement-list/index.tsx +161 -0
- package/src/client/cards/promotion-offer-detail/index.tsx +116 -0
- package/src/client/cards/promotion-offer-list/index.tsx +283 -0
- package/src/client/cards/view.ts +72 -0
- package/src/client/components/CouponQrCode.tsx +48 -0
- package/src/client/components/CouponSheet.tsx +124 -0
- package/src/client/components/ImageWithFallback.tsx +39 -0
- package/src/client/index.ts +23 -4
- package/src/client/styles/promotion.css +2135 -0
- package/src/client/types/css.d.ts +2 -0
- package/src/client/utils/sanitize-activity-html.ts +48 -0
- package/src/client/utils/scroll-card-bottom.ts +40 -0
- package/src/server/actions.ts +217 -0
- package/src/server/cards/index.ts +19 -0
- package/src/server/cards/promotion-activity-category-list/meta.ts +13 -0
- package/src/server/cards/promotion-activity-detail/meta.ts +29 -0
- package/src/server/cards/promotion-activity-list/meta.ts +13 -0
- package/src/server/cards/promotion-best-deal/meta.ts +20 -0
- package/src/server/cards/promotion-entitlement-list/meta.ts +17 -0
- package/src/server/cards/promotion-entitlement-list/samples.ts +51 -0
- package/src/server/cards/promotion-offer-detail/meta.ts +25 -0
- package/src/server/cards/promotion-offer-list/meta.ts +20 -0
- package/src/server/cards/promotion-offer-list/samples.ts +154 -0
- package/src/server/handler.ts +378 -16
- package/src/server/index.ts +117 -22
- package/src/server/navigation.ts +23 -0
- package/src/server/ports.ts +56 -0
- package/src/server/service.ts +243 -24
- package/src/server/tools.ts +789 -0
- package/tbox.module.json +126 -0
- package/tests/cards-render.test.tsx +656 -0
- package/tests/ports-resolve.test.ts +96 -0
- package/tests/pretool-coupons.test.ts +63 -0
- package/tests/promotion.test.ts +976 -0
- package/tests/samples.test.ts +42 -0
- package/tests/view.test.ts +61 -0
- package/tsup.config.ts +9 -1
- package/dist/chunk-AD6OLHSM.js +0 -86
- package/dist/chunk-LQGF6337.js +0 -32
- package/src/client/cards/coupon/index.tsx +0 -12
- package/src/server/cards/coupon/meta.ts +0 -23
- package/tbox.component.json +0 -20
- package/tests/service.test.ts +0 -31
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 图片 + 加载失败占位(0.4.0 D6:模块自持 ~20 行,禁跨模块依赖/基元封顶不破)。
|
|
3
|
+
* 源:POC shopping-guide 占位语义。src 缺省或加载失败 → 图标占位。
|
|
4
|
+
*/
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { ImageSquare } from '@phosphor-icons/react';
|
|
7
|
+
|
|
8
|
+
export function ImageWithFallback(props: {
|
|
9
|
+
src?: string;
|
|
10
|
+
alt: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
/** 占位区尺寸(px,图标随比例缩小) */
|
|
13
|
+
size?: number;
|
|
14
|
+
}) {
|
|
15
|
+
const { src, alt, className, size = 40 } = props;
|
|
16
|
+
const [failed, setFailed] = useState(false);
|
|
17
|
+
if (!src || failed) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={`img-fallback promotion-image--fallback ${className ?? ''}`.trim()}
|
|
21
|
+
aria-label={alt}
|
|
22
|
+
role="img"
|
|
23
|
+
>
|
|
24
|
+
<ImageSquare weight="duotone" size={Math.round(size * 0.45)} />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
<img
|
|
30
|
+
className={className}
|
|
31
|
+
src={src}
|
|
32
|
+
alt={alt}
|
|
33
|
+
loading="eager"
|
|
34
|
+
decoding="async"
|
|
35
|
+
referrerPolicy="no-referrer"
|
|
36
|
+
onError={() => setFailed(true)}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* module-promotion 客户端入口:9 个稳定传输卡型,renderer 内覆盖多个展示语义。
|
|
3
|
+
*/
|
|
4
|
+
import './styles/promotion.css'; // 0.4.0 D1:模块自持 CSS(副作用 import,首行保证先行加载)
|
|
5
|
+
|
|
1
6
|
import type { CardComponent } from '@tbox.cn/app-contracts';
|
|
2
7
|
import type { ClientContext, ClientModule } from '@tbox.cn/app-sdk/client';
|
|
3
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
PromotionOfferListCard,
|
|
10
|
+
PromotionOfferDetailCard,
|
|
11
|
+
PromotionEntitlementListCard,
|
|
12
|
+
PromotionActivityListCard,
|
|
13
|
+
PromotionActivityDetailCard,
|
|
14
|
+
PromotionActivityCategoryListCard,
|
|
15
|
+
PromotionBestDealCard,
|
|
16
|
+
} from './cards';
|
|
4
17
|
|
|
5
|
-
/** 客户端卡片组件 map(key 约定 = cardType;CLI sync 装配读取) */
|
|
6
18
|
const cards = {
|
|
7
|
-
|
|
19
|
+
'promotion-offer-list': PromotionOfferListCard as CardComponent,
|
|
20
|
+
'promotion-offer-detail': PromotionOfferDetailCard as CardComponent,
|
|
21
|
+
'promotion-entitlement-list': PromotionEntitlementListCard as CardComponent,
|
|
22
|
+
'promotion-activity-list': PromotionActivityListCard as CardComponent,
|
|
23
|
+
'promotion-activity-detail': PromotionActivityDetailCard as CardComponent,
|
|
24
|
+
'promotion-activity-category-list': PromotionActivityCategoryListCard as CardComponent,
|
|
25
|
+
'promotion-best-deal': PromotionBestDealCard as CardComponent,
|
|
8
26
|
} as const;
|
|
9
27
|
|
|
10
|
-
/** 模块注册入口:自注册闭环(与服务端 serverModule 对称) */
|
|
11
28
|
export const clientModule = {
|
|
12
29
|
cards,
|
|
13
30
|
register(ctx: ClientContext): void {
|
|
14
31
|
ctx.cards.registerMap(cards);
|
|
15
32
|
},
|
|
16
33
|
} satisfies ClientModule;
|
|
34
|
+
|
|
35
|
+
export { cards as promotionClientCards };
|