@antglobal/copilot-cards-mini-program 1.0.0 → 1.0.1

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.
Files changed (48) hide show
  1. package/README.md +127 -1
  2. package/dist/action-context/index.js +0 -1
  3. package/dist/adapter/alipay.js +0 -1
  4. package/dist/adapter/index.js +0 -1
  5. package/dist/adapter/wechat.js +0 -1
  6. package/dist/components/card-button/index.js +0 -1
  7. package/dist/components/card-divider/index.js +0 -1
  8. package/dist/components/card-icon/definition.d.ts +15 -0
  9. package/dist/components/card-icon/definition.js +17 -0
  10. package/dist/components/card-icon/index.acss +19 -0
  11. package/dist/components/card-icon/index.axml +16 -0
  12. package/dist/components/card-icon/index.d.ts +1 -0
  13. package/dist/components/card-icon/index.js +8 -0
  14. package/dist/components/card-icon/index.json +3 -0
  15. package/dist/components/card-icon/index.wxml +16 -0
  16. package/dist/components/card-icon/index.wxss +19 -0
  17. package/dist/components/card-image/index.js +0 -1
  18. package/dist/components/card-input/index.js +0 -1
  19. package/dist/components/card-node/index.axml +3 -0
  20. package/dist/components/card-node/index.js +0 -1
  21. package/dist/components/card-node/index.wxml +3 -0
  22. package/dist/components/card-root/index.js +0 -1
  23. package/dist/components/card-text/index.js +0 -1
  24. package/dist/events/index.js +0 -1
  25. package/dist/icons.d.ts +3 -0
  26. package/dist/icons.js +135 -0
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +1 -1
  29. package/dist/renderer/index.js +0 -1
  30. package/dist/renderer/transform.js +5 -2
  31. package/dist/streaming/index.js +0 -1
  32. package/package.json +14 -6
  33. package/dist/action-context/index.js.map +0 -1
  34. package/dist/adapter/alipay.js.map +0 -1
  35. package/dist/adapter/index.js.map +0 -1
  36. package/dist/adapter/wechat.js.map +0 -1
  37. package/dist/components/card-button/index.js.map +0 -1
  38. package/dist/components/card-divider/index.js.map +0 -1
  39. package/dist/components/card-image/index.js.map +0 -1
  40. package/dist/components/card-input/index.js.map +0 -1
  41. package/dist/components/card-node/index.js.map +0 -1
  42. package/dist/components/card-root/index.js.map +0 -1
  43. package/dist/components/card-text/index.js.map +0 -1
  44. package/dist/events/index.js.map +0 -1
  45. package/dist/index.js.map +0 -1
  46. package/dist/renderer/index.js.map +0 -1
  47. package/dist/renderer/transform.js.map +0 -1
  48. package/dist/streaming/index.js.map +0 -1
package/README.md CHANGED
@@ -1 +1,127 @@
1
- # Marmot NPM
1
+ # @antglobal/copilot-cards-mini-program
2
+
3
+ Native renderer for schema-driven cards in Alipay and WeChat mini-programs. It converts the same card schema used by the Web renderer into mini-program data trees and native component templates.
4
+
5
+ The package includes platform adapters, action integration, incremental streaming, and ready-to-register native components.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @antglobal/copilot-cards-mini-program
11
+ ```
12
+
13
+ `@antglobal/copilot-cards-core` is installed automatically.
14
+
15
+ ## Quick start
16
+
17
+ ```ts
18
+ import {
19
+ AlipayAdapter,
20
+ renderForMiniProgram,
21
+ } from "@antglobal/copilot-cards-mini-program";
22
+
23
+ const adapter = new AlipayAdapter();
24
+
25
+ const card = renderForMiniProgram(schema, {
26
+ adapter,
27
+ data: { userName: "Alice" },
28
+ onEmit: (eventName, payload) => {
29
+ console.log(eventName, payload);
30
+ },
31
+ });
32
+
33
+ this.setData(card.getData());
34
+
35
+ await card.handleEvent(nodeId, eventName, detail);
36
+ this.setData(card.getData());
37
+
38
+ card.dispose();
39
+ ```
40
+
41
+ Use `WeChatAdapter` instead of `AlipayAdapter` in WeChat mini-programs.
42
+
43
+ ## Register native components
44
+
45
+ Register the components used by your pages in `app.json` or the page-level JSON file:
46
+
47
+ ```json
48
+ {
49
+ "usingComponents": {
50
+ "card-root": "@antglobal/copilot-cards-mini-program/components/card-root/index",
51
+ "card-node": "@antglobal/copilot-cards-mini-program/components/card-node/index",
52
+ "card-text": "@antglobal/copilot-cards-mini-program/components/card-text/index",
53
+ "card-button": "@antglobal/copilot-cards-mini-program/components/card-button/index",
54
+ "card-image": "@antglobal/copilot-cards-mini-program/components/card-image/index",
55
+ "card-icon": "@antglobal/copilot-cards-mini-program/components/card-icon/index",
56
+ "card-input": "@antglobal/copilot-cards-mini-program/components/card-input/index",
57
+ "card-divider": "@antglobal/copilot-cards-mini-program/components/card-divider/index"
58
+ }
59
+ }
60
+ ```
61
+
62
+ The npm package contains both Alipay `.axml`/`.acss` assets and WeChat `.wxml`/`.wxss` assets.
63
+
64
+ ## Supported components
65
+
66
+ | Component | Schema type | Purpose |
67
+ | --- | --- | --- |
68
+ | `card-root` | Root | Owns the renderer instance and event bridge |
69
+ | `card-node` | Layout node | Recursively renders the card tree |
70
+ | `card-text` | `Text` | Styled text content |
71
+ | `card-button` | `Button` | Interactive button variants |
72
+ | `card-image` | `Image` | Images with fit modes |
73
+ | `card-icon` | `Icon` | Built-in SVG names, external sources, or emoji fallback |
74
+ | `card-input` | `Input` | Text input and variable synchronization |
75
+ | `card-divider` | `Divider` | Horizontal separators |
76
+
77
+ ## Platform adapters
78
+
79
+ `AlipayAdapter` and `WeChatAdapter` implement a shared interface for:
80
+
81
+ - HTTP requests
82
+ - toast notifications
83
+ - page navigation
84
+ - system information
85
+ - clipboard access
86
+
87
+ You can supply your own `MiniProgramAdapter` when integrating another compatible runtime.
88
+
89
+ ## Events and actions
90
+
91
+ `handleEvent(nodeId, eventName, detail)` maps native mini-program events back to schema actions. Supported action behavior is shared with `@antglobal/copilot-cards-core`, including requests, emitted events, variable updates, toast notifications, navigation, and copy actions.
92
+
93
+ The package exports event-name maps and `createEventDetail` for custom component integration.
94
+
95
+ ## Streaming
96
+
97
+ Use `createStreamingCardInstance` for incrementally generated cards:
98
+
99
+ ```ts
100
+ import {
101
+ createStreamingCardInstance,
102
+ WeChatAdapter,
103
+ } from "@antglobal/copilot-cards-mini-program";
104
+
105
+ const stream = createStreamingCardInstance({
106
+ adapter: new WeChatAdapter(),
107
+ });
108
+
109
+ for (const patch of stream.feed(chunk)) {
110
+ this.setData(patch.data);
111
+ }
112
+
113
+ for (const patch of stream.flush()) {
114
+ this.setData(patch.data);
115
+ }
116
+ ```
117
+
118
+ Streaming returns minimal `setData` patches instead of mutating a browser DOM.
119
+
120
+ ## Related packages
121
+
122
+ - `@antglobal/copilot-cards-core` — shared schema, expression, action, lifecycle, icon, and streaming logic.
123
+ - `@antglobal/copilot-cards-web` — browser and WebView renderer.
124
+
125
+ ## License
126
+
127
+ MIT
@@ -68,4 +68,3 @@ function createMiniProgramActionContext(adapter, options = {}) {
68
68
  }
69
69
 
70
70
  export { createMiniProgramActionContext };
71
- //# sourceMappingURL=index.js.map
@@ -63,4 +63,3 @@ class AlipayAdapter {
63
63
  }
64
64
 
65
65
  export { AlipayAdapter };
66
- //# sourceMappingURL=alipay.js.map
@@ -1,3 +1,2 @@
1
1
  export { AlipayAdapter } from './alipay.js';
2
2
  export { WeChatAdapter } from './wechat.js';
3
- //# sourceMappingURL=index.js.map
@@ -63,4 +63,3 @@ class WeChatAdapter {
63
63
  }
64
64
 
65
65
  export { WeChatAdapter };
66
- //# sourceMappingURL=wechat.js.map
@@ -24,4 +24,3 @@ function createCardButtonComponent() {
24
24
  }
25
25
 
26
26
  export { createCardButtonComponent };
27
- //# sourceMappingURL=index.js.map
@@ -11,4 +11,3 @@ function createCardDividerComponent() {
11
11
  }
12
12
 
13
13
  export { createCardDividerComponent };
14
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,15 @@
1
+ import { MiniProgramRenderNode } from '../../renderer/index.js';
2
+
3
+ declare function createCardIconComponent(): {
4
+ props: {
5
+ node: MiniProgramRenderNode | null;
6
+ };
7
+ properties: {
8
+ node: {
9
+ type: ObjectConstructor;
10
+ value: MiniProgramRenderNode | null;
11
+ };
12
+ };
13
+ };
14
+
15
+ export { createCardIconComponent };
@@ -0,0 +1,17 @@
1
+ function createCardIconComponent() {
2
+ return {
3
+ // Alipay mini program component input.
4
+ props: {
5
+ node: null,
6
+ },
7
+ // WeChat mini program component input.
8
+ properties: {
9
+ node: {
10
+ type: Object,
11
+ value: null,
12
+ },
13
+ },
14
+ };
15
+ }
16
+
17
+ export { createCardIconComponent };
@@ -0,0 +1,19 @@
1
+ .card-icon {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ box-sizing: border-box;
6
+ vertical-align: middle;
7
+ line-height: 0;
8
+ }
9
+
10
+ .card-icon__image {
11
+ display: block;
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+
16
+ .card-icon__text {
17
+ display: block;
18
+ line-height: 1;
19
+ }
@@ -0,0 +1,16 @@
1
+ <view
2
+ class="card-icon"
3
+ style="{{node.props._styleString || ''}}; width: {{node.props._iconSize}}px; height: {{node.props._iconSize}}px;"
4
+ >
5
+ <image
6
+ a:if="{{node.props._iconKind === 'image'}}"
7
+ class="card-icon__image"
8
+ src="{{node.props._iconSrc}}"
9
+ mode="aspectFit"
10
+ />
11
+ <text
12
+ a:else
13
+ class="card-icon__text"
14
+ style="font-size: {{node.props._iconSize}}px; color: {{node.props.color || 'currentColor'}};"
15
+ >{{node.props._iconText}}</text>
16
+ </view>
@@ -0,0 +1 @@
1
+ export { createCardIconComponent } from './definition.js';
@@ -0,0 +1,8 @@
1
+ import { createCardIconComponent } from './definition.js';
2
+
3
+ const componentRegistrar = globalThis.Component;
4
+ if (typeof componentRegistrar === 'function') {
5
+ componentRegistrar(createCardIconComponent());
6
+ }
7
+
8
+ export { createCardIconComponent };
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,16 @@
1
+ <view
2
+ class="card-icon"
3
+ style="{{node.props._styleString || ''}}; width: {{node.props._iconSize}}px; height: {{node.props._iconSize}}px;"
4
+ >
5
+ <image
6
+ wx:if="{{node.props._iconKind === 'image'}}"
7
+ class="card-icon__image"
8
+ src="{{node.props._iconSrc}}"
9
+ mode="aspectFit"
10
+ />
11
+ <text
12
+ wx:else
13
+ class="card-icon__text"
14
+ style="font-size: {{node.props._iconSize}}px; color: {{node.props.color || 'currentColor'}};"
15
+ >{{node.props._iconText}}</text>
16
+ </view>
@@ -0,0 +1,19 @@
1
+ .card-icon {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ box-sizing: border-box;
6
+ vertical-align: middle;
7
+ line-height: 0;
8
+ }
9
+
10
+ .card-icon__image {
11
+ display: block;
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+
16
+ .card-icon__text {
17
+ display: block;
18
+ line-height: 1;
19
+ }
@@ -20,4 +20,3 @@ function createCardImageComponent() {
20
20
  }
21
21
 
22
22
  export { createCardImageComponent };
23
- //# sourceMappingURL=index.js.map
@@ -43,4 +43,3 @@ function createCardInputComponent() {
43
43
  }
44
44
 
45
45
  export { createCardInputComponent };
46
- //# sourceMappingURL=index.js.map
@@ -9,6 +9,9 @@
9
9
  <!-- Image -->
10
10
  <card-image a:elif="{{node.type === 'Image'}}" node="{{node}}" onEvent="onEvent" />
11
11
 
12
+ <!-- Icon -->
13
+ <card-icon a:elif="{{node.type === 'Icon'}}" node="{{node}}" />
14
+
12
15
  <!-- Input -->
13
16
  <card-input a:elif="{{node.type === 'Input'}}" node="{{node}}" onEvent="onEvent" />
14
17
 
@@ -26,4 +26,3 @@ function createCardNodeComponent() {
26
26
  }
27
27
 
28
28
  export { createCardNodeComponent };
29
- //# sourceMappingURL=index.js.map
@@ -9,6 +9,9 @@
9
9
  <!-- Image -->
10
10
  <card-image wx:elif="{{node.type === 'Image'}}" node="{{node}}" bind:event="onEvent" />
11
11
 
12
+ <!-- Icon -->
13
+ <card-icon wx:elif="{{node.type === 'Icon'}}" node="{{node}}" />
14
+
12
15
  <!-- Input -->
13
16
  <card-input wx:elif="{{node.type === 'Input'}}" node="{{node}}" bind:event="onEvent" />
14
17
 
@@ -91,4 +91,3 @@ function createCardRootComponent() {
91
91
  }
92
92
 
93
93
  export { createCardRootComponent };
94
- //# sourceMappingURL=index.js.map
@@ -21,4 +21,3 @@ function createCardTextComponent() {
21
21
  }
22
22
 
23
23
  export { createCardTextComponent };
24
- //# sourceMappingURL=index.js.map
@@ -48,4 +48,3 @@ function createEventDetail(nodeId, eventName, extra) {
48
48
  }
49
49
 
50
50
  export { createEventDetail, nativeToSchemaEventMap, schemaToAlipayEventMap, schemaToWeChatEventMap };
51
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ declare function decorateMiniIconProps(props: Record<string, unknown>): Record<string, unknown>;
2
+
3
+ export { decorateMiniIconProps };
package/dist/icons.js ADDED
@@ -0,0 +1,135 @@
1
+ import { getBuiltinIcon } from '@antglobal/copilot-cards-core';
2
+
3
+ const DEFAULT_ICON_SIZE = 24;
4
+ const REPLACEMENT_CHARACTER = '\uFFFD';
5
+ function normalizeXmlText(value) {
6
+ let normalized = '';
7
+ for (let index = 0; index < value.length; index += 1) {
8
+ const codeUnit = value.charCodeAt(index);
9
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDBFF) {
10
+ const trailing = value.charCodeAt(index + 1);
11
+ if (trailing >= 0xDC00 && trailing <= 0xDFFF) {
12
+ normalized += value[index] + value[index + 1];
13
+ index += 1;
14
+ }
15
+ else {
16
+ normalized += REPLACEMENT_CHARACTER;
17
+ }
18
+ continue;
19
+ }
20
+ if (codeUnit >= 0xDC00 && codeUnit <= 0xDFFF) {
21
+ normalized += REPLACEMENT_CHARACTER;
22
+ continue;
23
+ }
24
+ const isAllowedXmlCharacter = codeUnit === 0x09 ||
25
+ codeUnit === 0x0A ||
26
+ codeUnit === 0x0D ||
27
+ (codeUnit >= 0x20 && codeUnit <= 0xD7FF) ||
28
+ (codeUnit >= 0xE000 && codeUnit <= 0xFFFD);
29
+ normalized += isAllowedXmlCharacter
30
+ ? value[index]
31
+ : REPLACEMENT_CHARACTER;
32
+ }
33
+ return normalized;
34
+ }
35
+ function escapeXmlAttr(value) {
36
+ return normalizeXmlText(value)
37
+ .replace(/&/g, '&amp;')
38
+ .replace(/"/g, '&quot;')
39
+ .replace(/</g, '&lt;')
40
+ .replace(/>/g, '&gt;');
41
+ }
42
+ function resolveIconSize(value) {
43
+ const size = Number(value);
44
+ return Number.isFinite(size) && size > 0 ? size : DEFAULT_ICON_SIZE;
45
+ }
46
+ function normalizeStyleKey(key) {
47
+ if (key.startsWith('--')) {
48
+ return /^--[A-Za-z0-9_-]+$/.test(key) ? key : undefined;
49
+ }
50
+ if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(key))
51
+ return undefined;
52
+ return key
53
+ .replace(/([A-Z])/g, '-$1')
54
+ .toLowerCase();
55
+ }
56
+ function normalizeStyleValue(value) {
57
+ if (typeof value === 'number') {
58
+ return Number.isFinite(value) ? String(value) : undefined;
59
+ }
60
+ if (typeof value !== 'string')
61
+ return undefined;
62
+ const normalized = normalizeXmlText(value);
63
+ if (/[;{}]/.test(normalized))
64
+ return undefined;
65
+ const compact = normalized.replace(/[\s\u0000-\u001f]/g, '').toLowerCase();
66
+ if (/expression\(/.test(compact) ||
67
+ /url\((?:['"]?)(?:javascript|vbscript|file|data:text\/html):/.test(compact)) {
68
+ return undefined;
69
+ }
70
+ return normalized;
71
+ }
72
+ function serializeIconStyle(value) {
73
+ if (!value || typeof value !== 'object' || Array.isArray(value))
74
+ return '';
75
+ const declarations = [];
76
+ for (const [rawKey, rawValue] of Object.entries(value)) {
77
+ const key = normalizeStyleKey(rawKey);
78
+ const styleValue = normalizeStyleValue(rawValue);
79
+ if (!key || styleValue === undefined)
80
+ continue;
81
+ declarations.push(`${key}: ${styleValue}`);
82
+ }
83
+ return declarations.join('; ');
84
+ }
85
+ function sanitizeExternalImageSrc(value) {
86
+ const src = String(value ?? '').trim();
87
+ if (!src)
88
+ return undefined;
89
+ const normalized = src.replace(/[\s\u0000-\u001f]/g, '').toLowerCase();
90
+ if (/^(javascript|vbscript|file):/.test(normalized))
91
+ return undefined;
92
+ if (/^data:/.test(normalized)) {
93
+ return /^data:image\/(?:png|jpeg|jpg|gif|webp);base64,/.test(normalized)
94
+ ? src
95
+ : undefined;
96
+ }
97
+ return src;
98
+ }
99
+ function decorateMiniIconProps(props) {
100
+ const size = resolveIconSize(props.size);
101
+ const name = props.name == null ? undefined : String(props.name);
102
+ const styleString = serializeIconStyle(props.style);
103
+ const decoratedProps = { ...props, _styleString: styleString };
104
+ if (props.src) {
105
+ const src = sanitizeExternalImageSrc(props.src);
106
+ if (src) {
107
+ return {
108
+ ...decoratedProps,
109
+ _iconKind: 'image',
110
+ _iconSrc: src,
111
+ _iconSize: size,
112
+ };
113
+ }
114
+ }
115
+ const icon = getBuiltinIcon(name);
116
+ if (icon) {
117
+ const color = escapeXmlAttr(String(props.color ?? 'currentColor'));
118
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" ` +
119
+ `viewBox="${icon.viewBox}" color="${color}">${icon.body}</svg>`;
120
+ return {
121
+ ...decoratedProps,
122
+ _iconKind: 'image',
123
+ _iconSrc: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`,
124
+ _iconSize: size,
125
+ };
126
+ }
127
+ return {
128
+ ...decoratedProps,
129
+ _iconKind: 'text',
130
+ _iconText: name ?? '?',
131
+ _iconSize: size,
132
+ };
133
+ }
134
+
135
+ export { decorateMiniIconProps };
package/dist/index.d.ts CHANGED
@@ -8,9 +8,10 @@ export { createCardNodeComponent } from './components/card-node/index.js';
8
8
  export { createCardTextComponent } from './components/card-text/index.js';
9
9
  export { createCardButtonComponent } from './components/card-button/index.js';
10
10
  export { createCardImageComponent } from './components/card-image/index.js';
11
+ export { createCardIconComponent } from './components/card-icon/definition.js';
11
12
  export { createCardInputComponent } from './components/card-input/index.js';
12
13
  export { createCardDividerComponent } from './components/card-divider/index.js';
13
14
  export { CardEventDetail, createEventDetail, nativeToSchemaEventMap, schemaToAlipayEventMap, schemaToWeChatEventMap } from './events/index.js';
14
15
  export { DataPatch, MiniProgramStreamingCardInstance, MiniProgramStreamingOptions, createStreamingCardInstance } from './streaming/index.js';
15
- export { ActionRunnerContext, ActionStep, CardSchema, CardSchemaInput, ElementNode, ExpressionContext, ExpressionValue, RenderTreeNode, convertLegacySchema, createLifecycleManager, hasExpression, isLegacySchema, normalizeSchema, parseSchema, registerActionHandler, resolveDeep, resolveExpression, runActionStep, runActionSteps, validateSchema } from '@antglobal/copilot-cards-core';
16
+ export { ActionRunnerContext, ActionStep, BuiltinIconName, CardSchema, CardSchemaInput, ElementNode, ExpressionContext, ExpressionValue, RenderTreeNode, convertLegacySchema, createLifecycleManager, hasExpression, isLegacySchema, normalizeSchema, parseSchema, registerActionHandler, resolveDeep, resolveExpression, runActionStep, runActionSteps, validateSchema } from '@antglobal/copilot-cards-core';
16
17
  export { transformNode, transformTree } from './renderer/transform.js';
package/dist/index.js CHANGED
@@ -7,10 +7,10 @@ export { createCardNodeComponent } from './components/card-node/index.js';
7
7
  export { createCardTextComponent } from './components/card-text/index.js';
8
8
  export { createCardButtonComponent } from './components/card-button/index.js';
9
9
  export { createCardImageComponent } from './components/card-image/index.js';
10
+ export { createCardIconComponent } from './components/card-icon/definition.js';
10
11
  export { createCardInputComponent } from './components/card-input/index.js';
11
12
  export { createCardDividerComponent } from './components/card-divider/index.js';
12
13
  export { createEventDetail, nativeToSchemaEventMap, schemaToAlipayEventMap, schemaToWeChatEventMap } from './events/index.js';
13
14
  export { createStreamingCardInstance } from './streaming/index.js';
14
15
  export { convertLegacySchema, createLifecycleManager, hasExpression, isLegacySchema, normalizeSchema, parseSchema, registerActionHandler, resolveDeep, resolveExpression, runActionStep, runActionSteps, validateSchema } from '@antglobal/copilot-cards-core';
15
16
  export { transformNode, transformTree } from './renderer/transform.js';
16
- //# sourceMappingURL=index.js.map
@@ -156,4 +156,3 @@ function registerLifecycles(tree, lifecycleManager, actionContext) {
156
156
  }
157
157
 
158
158
  export { renderForMiniProgram, transformTree };
159
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import { hasExpression, resolveExpression, resolveDeep, resolveExpressionValue } from '@antglobal/copilot-cards-core';
2
+ import { decorateMiniIconProps } from '../icons.js';
2
3
 
3
4
  /**
4
5
  * Transform — converts a RenderTreeNode into a MiniProgramRenderNode.
@@ -39,7 +40,7 @@ function transformNode(node, variables) {
39
40
  };
40
41
  }
41
42
  // 2. Resolve props with variable expressions
42
- const resolvedProps = resolveDeep(node.props, variables);
43
+ let resolvedProps = resolveDeep(node.props, variables);
43
44
  // Resolve content if it's an ExpressionValue object
44
45
  if (resolvedProps.content &&
45
46
  typeof resolvedProps.content === 'object' &&
@@ -47,6 +48,9 @@ function transformNode(node, variables) {
47
48
  'type' in resolvedProps.content) {
48
49
  resolvedProps.content = resolveExpressionValue(resolvedProps.content, variables);
49
50
  }
51
+ if (node.type === 'Icon') {
52
+ resolvedProps = decorateMiniIconProps(resolvedProps);
53
+ }
50
54
  // 3. Check directives.disabled
51
55
  let disabled = false;
52
56
  if (node.directives?.disabled) {
@@ -85,4 +89,3 @@ function transformTree(tree, variables) {
85
89
  }
86
90
 
87
91
  export { transformNode, transformTree };
88
- //# sourceMappingURL=transform.js.map
@@ -228,4 +228,3 @@ function createStreamingCardInstance(options) {
228
228
  }
229
229
 
230
230
  export { createStreamingCardInstance };
231
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,15 +1,24 @@
1
1
  {
2
2
  "name": "@antglobal/copilot-cards-mini-program",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Mini-program native renderer for copilot bot card SDK — adapts to WeChat / Alipay / DingTalk mini-program templates",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
7
15
  "miniprogram": "dist",
8
16
  "files": [
9
17
  "dist"
10
18
  ],
11
19
  "scripts": {
12
- "build": "rollup -c --forceExit && node scripts/postbuild.mjs"
20
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
21
+ "build": "npm run clean && tsc -p ../copilot-cards-mini-program/tsconfig.json --noEmit && rollup -c && node scripts/postbuild.mjs"
13
22
  },
14
23
  "keywords": [
15
24
  "copilot",
@@ -21,11 +30,10 @@
21
30
  ],
22
31
  "license": "MIT",
23
32
  "dependencies": {
24
- "@antglobal/copilot-cards-core": "^1.0.0",
33
+ "@antglobal/copilot-cards-core": "^1.0.1",
25
34
  "tslib": "^2.8.1"
26
35
  },
27
36
  "devDependencies": {
28
- "@rollup/plugin-typescript": "^11.1.0",
29
37
  "@types/node": "^20",
30
38
  "rollup": "^4.9.0",
31
39
  "rollup-plugin-dts": "^6.1.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"alipay.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wechat.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}