@open-dy/vibecoding-sdk-taro 0.0.1-beta.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 (239) hide show
  1. package/dist/adapters/interest-card/eslint/eslint-plugin-custom-navigation.mjs +290 -0
  2. package/dist/adapters/interest-card/eslint/taro.mjs +55 -0
  3. package/dist/adapters/interest-card/runtime/microapp.d.ts +7 -0
  4. package/dist/adapters/interest-card/runtime/microapp.js +8 -0
  5. package/dist/adapters/interest-card/runtime/microapp.js.map +1 -0
  6. package/dist/adapters/interest-card/types/taro.d.ts +28 -0
  7. package/dist/build/config-overrides.d.ts +19 -0
  8. package/dist/build/config-overrides.js +35 -0
  9. package/dist/build/config-overrides.js.map +1 -0
  10. package/dist/build/index.d.ts +1 -0
  11. package/dist/build/index.js +2 -0
  12. package/dist/build/index.js.map +1 -0
  13. package/dist/build/plugins/app-config.cjs +43 -0
  14. package/dist/build/plugins/vite-depend-card.d.ts +29 -0
  15. package/dist/build/plugins/vite-depend-card.js +250 -0
  16. package/dist/build/plugins/vite-depend-card.js.map +1 -0
  17. package/dist/build/plugins/vite-image-asset-import.d.ts +10 -0
  18. package/dist/build/plugins/vite-image-asset-import.js +150 -0
  19. package/dist/build/plugins/vite-image-asset-import.js.map +1 -0
  20. package/dist/build/plugins/vite-inline-json.d.ts +4 -0
  21. package/dist/build/plugins/vite-inline-json.js +129 -0
  22. package/dist/build/plugins/vite-inline-json.js.map +1 -0
  23. package/dist/build/plugins/vite-taro-source-location.d.ts +13 -0
  24. package/dist/build/plugins/vite-taro-source-location.js +159 -0
  25. package/dist/build/plugins/vite-taro-source-location.js.map +1 -0
  26. package/dist/build/taro.d.ts +53 -0
  27. package/dist/build/taro.js +729 -0
  28. package/dist/build/taro.js.map +1 -0
  29. package/dist/components/miniapp-open-card.d.ts +19 -0
  30. package/dist/components/miniapp-open-card.js +3 -0
  31. package/dist/components/miniapp-open-card.js.map +1 -0
  32. package/dist/eslint/eslint-plugin-microapp-pages.mjs +659 -0
  33. package/dist/eslint/server.mjs +69 -0
  34. package/dist/eslint/taro.mjs +553 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +3 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/internal/runtime/douyin-open-button.d.ts +29 -0
  39. package/dist/internal/runtime/iframe-auth/identity.d.ts +20 -0
  40. package/dist/internal/runtime/iframe-auth/identity.js +156 -0
  41. package/dist/internal/runtime/iframe-auth/identity.js.map +1 -0
  42. package/dist/internal/runtime/iframe-auth/index.d.ts +2 -0
  43. package/dist/internal/runtime/iframe-auth/index.js +3 -0
  44. package/dist/internal/runtime/iframe-auth/index.js.map +1 -0
  45. package/dist/internal/runtime/iframe-auth/sync.d.ts +2 -0
  46. package/dist/internal/runtime/iframe-auth/sync.js +23 -0
  47. package/dist/internal/runtime/iframe-auth/sync.js.map +1 -0
  48. package/dist/lib/measure.d.ts +21 -0
  49. package/dist/lib/measure.js +101 -0
  50. package/dist/lib/measure.js.map +1 -0
  51. package/dist/lib/platform.d.ts +2 -0
  52. package/dist/lib/platform.js +11 -0
  53. package/dist/lib/platform.js.map +1 -0
  54. package/dist/lib/utils.d.ts +2 -0
  55. package/dist/lib/utils.js +6 -0
  56. package/dist/lib/utils.js.map +1 -0
  57. package/dist/reference/llms.txt +36 -0
  58. package/dist/reference/sdk-api/build/taro/BuildContext.md +53 -0
  59. package/dist/reference/sdk-api/build/taro/CreateMicroappTaroConfigOptions.md +62 -0
  60. package/dist/reference/sdk-api/build/taro/createMicroappTaroConfig.md +66 -0
  61. package/dist/reference/sdk-api/build/taro/index.md +11 -0
  62. package/dist/reference/sdk-api/runtime/CreateMicroappClientOptions.md +47 -0
  63. package/dist/reference/sdk-api/runtime/createMicroappClient.md +378 -0
  64. package/dist/reference/sdk-api/runtime/index.md +10 -0
  65. package/dist/reference/sdk-api.json +1534 -0
  66. package/dist/reference/sdk-api.md +43 -0
  67. package/dist/runtime/client.d.ts +63 -0
  68. package/dist/runtime/client.js +194 -0
  69. package/dist/runtime/client.js.map +1 -0
  70. package/dist/runtime/closed-domain-request-header.d.ts +4 -0
  71. package/dist/runtime/closed-domain-request-header.js +8 -0
  72. package/dist/runtime/closed-domain-request-header.js.map +1 -0
  73. package/dist/runtime/default-client.d.ts +57 -0
  74. package/dist/runtime/default-client.js +21 -0
  75. package/dist/runtime/default-client.js.map +1 -0
  76. package/dist/runtime/default-iframe-auth.d.ts +8 -0
  77. package/dist/runtime/default-iframe-auth.js +10 -0
  78. package/dist/runtime/default-iframe-auth.js.map +1 -0
  79. package/dist/runtime/douyin-container-request.d.ts +11 -0
  80. package/dist/runtime/douyin-container-request.js +301 -0
  81. package/dist/runtime/douyin-container-request.js.map +1 -0
  82. package/dist/runtime/douyin-login-request.d.ts +32 -0
  83. package/dist/runtime/douyin-login-request.js +400 -0
  84. package/dist/runtime/douyin-login-request.js.map +1 -0
  85. package/dist/runtime/globals.d.ts +342 -0
  86. package/dist/runtime/index.d.ts +4 -0
  87. package/dist/runtime/index.js +4 -0
  88. package/dist/runtime/index.js.map +1 -0
  89. package/dist/runtime/network-url.d.ts +3 -0
  90. package/dist/runtime/network-url.js +53 -0
  91. package/dist/runtime/network-url.js.map +1 -0
  92. package/dist/types/taro.d.ts +1 -0
  93. package/dist/ui/accordion.d.ts +17 -0
  94. package/dist/ui/accordion.js +60 -0
  95. package/dist/ui/accordion.js.map +1 -0
  96. package/dist/ui/alert-dialog.d.ts +33 -0
  97. package/dist/ui/alert-dialog.js +96 -0
  98. package/dist/ui/alert-dialog.js.map +1 -0
  99. package/dist/ui/alert.d.ts +11 -0
  100. package/dist/ui/alert.js +49 -0
  101. package/dist/ui/alert.js.map +1 -0
  102. package/dist/ui/aspect-ratio.d.ts +5 -0
  103. package/dist/ui/aspect-ratio.js +10 -0
  104. package/dist/ui/aspect-ratio.js.map +1 -0
  105. package/dist/ui/avatar.d.ts +14 -0
  106. package/dist/ui/avatar.js +50 -0
  107. package/dist/ui/avatar.js.map +1 -0
  108. package/dist/ui/badge.d.ts +8 -0
  109. package/dist/ui/badge.js +27 -0
  110. package/dist/ui/badge.js.map +1 -0
  111. package/dist/ui/button-group.d.ts +14 -0
  112. package/dist/ui/button-group.js +52 -0
  113. package/dist/ui/button-group.js.map +1 -0
  114. package/dist/ui/button.d.ts +30 -0
  115. package/dist/ui/button.js +75 -0
  116. package/dist/ui/button.js.map +1 -0
  117. package/dist/ui/calendar.d.ts +29 -0
  118. package/dist/ui/calendar.js +141 -0
  119. package/dist/ui/calendar.js.map +1 -0
  120. package/dist/ui/card.d.ts +12 -0
  121. package/dist/ui/card.js +38 -0
  122. package/dist/ui/card.js.map +1 -0
  123. package/dist/ui/carousel.d.ts +30 -0
  124. package/dist/ui/carousel.js +60 -0
  125. package/dist/ui/carousel.js.map +1 -0
  126. package/dist/ui/checkbox.d.ts +9 -0
  127. package/dist/ui/checkbox.js +20 -0
  128. package/dist/ui/checkbox.js.map +1 -0
  129. package/dist/ui/collapsible.d.ts +18 -0
  130. package/dist/ui/collapsible.js +53 -0
  131. package/dist/ui/collapsible.js.map +1 -0
  132. package/dist/ui/combobox.d.ts +55 -0
  133. package/dist/ui/combobox.js +165 -0
  134. package/dist/ui/combobox.js.map +1 -0
  135. package/dist/ui/dialog.d.ts +26 -0
  136. package/dist/ui/dialog.js +54 -0
  137. package/dist/ui/dialog.js.map +1 -0
  138. package/dist/ui/drawer.d.ts +21 -0
  139. package/dist/ui/drawer.js +57 -0
  140. package/dist/ui/drawer.js.map +1 -0
  141. package/dist/ui/dropdown-menu.d.ts +52 -0
  142. package/dist/ui/dropdown-menu.js +112 -0
  143. package/dist/ui/dropdown-menu.js.map +1 -0
  144. package/dist/ui/empty.d.ts +12 -0
  145. package/dist/ui/empty.js +35 -0
  146. package/dist/ui/empty.js.map +1 -0
  147. package/dist/ui/field.d.ts +26 -0
  148. package/dist/ui/field.js +117 -0
  149. package/dist/ui/field.js.map +1 -0
  150. package/dist/ui/helpers.d.ts +6 -0
  151. package/dist/ui/helpers.js +23 -0
  152. package/dist/ui/helpers.js.map +1 -0
  153. package/dist/ui/index.d.ts +47 -0
  154. package/dist/ui/index.js +48 -0
  155. package/dist/ui/index.js.map +1 -0
  156. package/dist/ui/input-group.d.ts +17 -0
  157. package/dist/ui/input-group.js +122 -0
  158. package/dist/ui/input-group.js.map +1 -0
  159. package/dist/ui/input-otp.d.ts +18 -0
  160. package/dist/ui/input-otp.js +48 -0
  161. package/dist/ui/input-otp.js.map +1 -0
  162. package/dist/ui/input.d.ts +5 -0
  163. package/dist/ui/input.js +8 -0
  164. package/dist/ui/input.js.map +1 -0
  165. package/dist/ui/item.d.ts +22 -0
  166. package/dist/ui/item.js +83 -0
  167. package/dist/ui/item.js.map +1 -0
  168. package/dist/ui/label.d.ts +3 -0
  169. package/dist/ui/label.js +8 -0
  170. package/dist/ui/label.js.map +1 -0
  171. package/dist/ui/menubar.d.ts +65 -0
  172. package/dist/ui/menubar.js +244 -0
  173. package/dist/ui/menubar.js.map +1 -0
  174. package/dist/ui/navigation-menu.d.ts +27 -0
  175. package/dist/ui/navigation-menu.js +72 -0
  176. package/dist/ui/navigation-menu.js.map +1 -0
  177. package/dist/ui/pagination.d.ts +17 -0
  178. package/dist/ui/pagination.js +28 -0
  179. package/dist/ui/pagination.js.map +1 -0
  180. package/dist/ui/popover.d.ts +27 -0
  181. package/dist/ui/popover.js +139 -0
  182. package/dist/ui/popover.js.map +1 -0
  183. package/dist/ui/portal.d.ts +5 -0
  184. package/dist/ui/portal.js +18 -0
  185. package/dist/ui/portal.js.map +1 -0
  186. package/dist/ui/progress.d.ts +45 -0
  187. package/dist/ui/progress.js +67 -0
  188. package/dist/ui/progress.js.map +1 -0
  189. package/dist/ui/radio-group.d.ts +12 -0
  190. package/dist/ui/radio-group.js +29 -0
  191. package/dist/ui/radio-group.js.map +1 -0
  192. package/dist/ui/resizable.d.ts +20 -0
  193. package/dist/ui/resizable.js +244 -0
  194. package/dist/ui/resizable.js.map +1 -0
  195. package/dist/ui/scroll-area.d.ts +8 -0
  196. package/dist/ui/scroll-area.js +34 -0
  197. package/dist/ui/scroll-area.js.map +1 -0
  198. package/dist/ui/select.d.ts +35 -0
  199. package/dist/ui/select.js +136 -0
  200. package/dist/ui/select.js.map +1 -0
  201. package/dist/ui/separator.d.ts +5 -0
  202. package/dist/ui/separator.js +8 -0
  203. package/dist/ui/separator.js.map +1 -0
  204. package/dist/ui/sheet.d.ts +26 -0
  205. package/dist/ui/sheet.js +67 -0
  206. package/dist/ui/sheet.js.map +1 -0
  207. package/dist/ui/skeleton.d.ts +3 -0
  208. package/dist/ui/skeleton.js +8 -0
  209. package/dist/ui/skeleton.js.map +1 -0
  210. package/dist/ui/slider.d.ts +12 -0
  211. package/dist/ui/slider.js +94 -0
  212. package/dist/ui/slider.js.map +1 -0
  213. package/dist/ui/sonner.d.ts +6 -0
  214. package/dist/ui/sonner.js +13 -0
  215. package/dist/ui/sonner.js.map +1 -0
  216. package/dist/ui/spinner.d.ts +3 -0
  217. package/dist/ui/spinner.js +9 -0
  218. package/dist/ui/spinner.js.map +1 -0
  219. package/dist/ui/switch.d.ts +11 -0
  220. package/dist/ui/switch.js +33 -0
  221. package/dist/ui/switch.js.map +1 -0
  222. package/dist/ui/table.d.ts +13 -0
  223. package/dist/ui/table.js +54 -0
  224. package/dist/ui/table.js.map +1 -0
  225. package/dist/ui/tabs.d.ts +23 -0
  226. package/dist/ui/tabs.js +61 -0
  227. package/dist/ui/tabs.js.map +1 -0
  228. package/dist/ui/tailwind.css +2 -0
  229. package/dist/ui/textarea.d.ts +3 -0
  230. package/dist/ui/textarea.js +13 -0
  231. package/dist/ui/textarea.js.map +1 -0
  232. package/dist/ui/theme.css +234 -0
  233. package/dist/ui/toggle-group.d.ts +19 -0
  234. package/dist/ui/toggle-group.js +73 -0
  235. package/dist/ui/toggle-group.js.map +1 -0
  236. package/dist/ui/toggle.d.ts +14 -0
  237. package/dist/ui/toggle.js +41 -0
  238. package/dist/ui/toggle.js.map +1 -0
  239. package/package.json +97 -0
@@ -0,0 +1,290 @@
1
+ /**
2
+ * 强制兴趣卡落地页使用自定义导航栏:app config 必须声明 navigationStyle: 'custom',
3
+ * page config 若声明 navigationStyle 也只能是 custom,每个页面必须显式声明导航前景色,
4
+ * 且每个页面入口必须接入顶部避让。
5
+ */
6
+ import { createRequire } from 'node:module';
7
+
8
+ const ts = createRequire(import.meta.url)('typescript');
9
+
10
+ const CUSTOM = 'custom';
11
+ const NAVIGATION_TEXT_STYLES = new Set(['black', 'white']);
12
+
13
+ const CUSTOM_NAV_IMPORTS = new Set([
14
+ '@/components/custom-nav-space',
15
+ '@/hooks/use-custom-nav-layout',
16
+ '@/lib/custom-nav-layout',
17
+ ]);
18
+
19
+ const FORBIDDEN_NAVIGATION_APIS = new Map([
20
+ ['setNavigationBarTitle', '禁止修改导航栏标题'],
21
+ ['setNavigationBarColor', '禁止修改导航栏颜色、前景色或状态栏样式'],
22
+ ['showNavigationBarLoading', '禁止显示导航栏 loading'],
23
+ ['hideNavigationBarLoading', '禁止隐藏导航栏 loading'],
24
+ ['hideHomeButton', '禁止隐藏左上角首页或 logo 按钮'],
25
+ ]);
26
+
27
+ function getPropertyName(prop) {
28
+ if (!ts.isPropertyAssignment(prop)) return null;
29
+ if (ts.isIdentifier(prop.name)) return prop.name.text;
30
+ if (ts.isStringLiteral(prop.name)) return prop.name.text;
31
+ return null;
32
+ }
33
+
34
+ function getStringLiteral(node) {
35
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
36
+ return node.text;
37
+ }
38
+ return null;
39
+ }
40
+
41
+ function getStaticPropertyName(node) {
42
+ if (!node.computed && node.property.type === 'Identifier') {
43
+ return node.property.name;
44
+ }
45
+ if (
46
+ node.computed &&
47
+ node.property.type === 'Literal' &&
48
+ typeof node.property.value === 'string'
49
+ ) {
50
+ return node.property.value;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ function getPropertyKeyName(node) {
56
+ if (!node.computed && node.key.type === 'Identifier') {
57
+ return node.key.name;
58
+ }
59
+ if (node.key.type === 'Literal' && typeof node.key.value === 'string') {
60
+ return node.key.value;
61
+ }
62
+ return null;
63
+ }
64
+
65
+ /**
66
+ * @returns {{ windowStyle: string | null, pageStyle: string | null, windowTextStyle: string | null, pageTextStyle: string | null, invalid: Array<{ kind: string, value: string | null }> } | null}
67
+ */
68
+ function extractNavigationStyles(filePath, text) {
69
+ const sf = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
70
+ let result = null;
71
+
72
+ function fromObjectLiteral(obj) {
73
+ const out = {
74
+ windowStyle: null,
75
+ pageStyle: null,
76
+ windowTextStyle: null,
77
+ pageTextStyle: null,
78
+ invalid: [],
79
+ };
80
+
81
+ for (const prop of obj.properties) {
82
+ if (!ts.isPropertyAssignment(prop)) continue;
83
+ const key = getPropertyName(prop);
84
+
85
+ if (key === 'navigationStyle') {
86
+ const value = getStringLiteral(prop.initializer);
87
+ out.pageStyle = value;
88
+ if (value !== CUSTOM) {
89
+ out.invalid.push({ kind: 'page', value });
90
+ }
91
+ }
92
+
93
+ if (key === 'navigationBarTextStyle') {
94
+ out.pageTextStyle = getStringLiteral(prop.initializer);
95
+ }
96
+
97
+ if (key === 'window' && ts.isObjectLiteralExpression(prop.initializer)) {
98
+ for (const windowProp of prop.initializer.properties) {
99
+ if (!ts.isPropertyAssignment(windowProp)) continue;
100
+ const windowKey = getPropertyName(windowProp);
101
+ if (windowKey === 'navigationStyle') {
102
+ const value = getStringLiteral(windowProp.initializer);
103
+ out.windowStyle = value;
104
+ if (value !== CUSTOM) {
105
+ out.invalid.push({ kind: 'window', value });
106
+ }
107
+ }
108
+ if (windowKey === 'navigationBarTextStyle') {
109
+ out.windowTextStyle = getStringLiteral(windowProp.initializer);
110
+ }
111
+ }
112
+ }
113
+ }
114
+
115
+ return out;
116
+ }
117
+
118
+ function visit(node) {
119
+ if (result) return;
120
+ if (ts.isExportAssignment(node) && !node.isExportEquals && node.expression) {
121
+ const expr = node.expression;
122
+ if (
123
+ ts.isCallExpression(expr) &&
124
+ expr.arguments[0] &&
125
+ ts.isObjectLiteralExpression(expr.arguments[0])
126
+ ) {
127
+ result = fromObjectLiteral(expr.arguments[0]);
128
+ } else if (ts.isObjectLiteralExpression(expr)) {
129
+ result = fromObjectLiteral(expr);
130
+ }
131
+ }
132
+ ts.forEachChild(node, visit);
133
+ }
134
+
135
+ visit(sf);
136
+ return result;
137
+ }
138
+
139
+ const CONFIG_MESSAGE =
140
+ '兴趣卡落地页必须使用自定义导航栏:navigationStyle 只能是 "custom",禁止改成 default 或其他值。' +
141
+ '页面顶部请用 <CustomNavSpace /> 或 useCustomNavLayout() 避让状态栏与胶囊。';
142
+
143
+ const TEXT_STYLE_MESSAGE =
144
+ '请根据该页面首次进入时顶部区域的实际明暗,显式设置 navigationBarTextStyle:' +
145
+ '浅色顶部使用 "black",深色顶部使用 "white"。';
146
+
147
+ /** @type {import('eslint').Rule.RuleModule} */
148
+ const requireCustomNavigationStyle = {
149
+ meta: {
150
+ type: 'problem',
151
+ docs: {
152
+ description: '强制自定义导航,并要求 app fallback 与每个页面显式声明导航前景色',
153
+ },
154
+ schema: [],
155
+ },
156
+ create(context) {
157
+ const filePath = context.filename.replace(/\\/g, '/');
158
+ const isApp = filePath.endsWith('/src/app.config.ts') || filePath.endsWith('src/app.config.ts');
159
+ const isPageConfig = /\/src\/pages\/.+\.config\.ts$/.test(filePath);
160
+ if (!isApp && !isPageConfig) return {};
161
+
162
+ return {
163
+ Program(node) {
164
+ const sourceText = context.sourceCode.getText(node);
165
+ const parsed = extractNavigationStyles(filePath, sourceText);
166
+
167
+ if (!parsed) {
168
+ context.report({
169
+ node,
170
+ message: `无法解析 ${isApp ? 'defineAppConfig' : 'definePageConfig'},请使用对象字面量声明。${CONFIG_MESSAGE}`,
171
+ });
172
+ return;
173
+ }
174
+
175
+ if (isApp && parsed.windowStyle !== CUSTOM) {
176
+ context.report({
177
+ node,
178
+ message:
179
+ `src/app.config.ts 的 window.navigationStyle 必须为 "custom"(当前:${parsed.windowStyle ?? '未设置'})。${CONFIG_MESSAGE}`,
180
+ });
181
+ }
182
+
183
+ const textStyle = isApp ? parsed.windowTextStyle : parsed.pageTextStyle;
184
+ if (!NAVIGATION_TEXT_STYLES.has(textStyle)) {
185
+ context.report({
186
+ node,
187
+ message:
188
+ `${isApp ? 'src/app.config.ts 的 window' : '页面配置'}.navigationBarTextStyle ` +
189
+ `必须为 "black" 或 "white"(当前:${textStyle ?? '未设置'})。${TEXT_STYLE_MESSAGE}`,
190
+ });
191
+ }
192
+
193
+ for (const item of parsed.invalid) {
194
+ if (isApp && item.kind === 'window') continue;
195
+ context.report({
196
+ node,
197
+ message:
198
+ `禁止将 ${item.kind === 'window' ? 'window.' : ''}navigationStyle 设为 ${JSON.stringify(item.value)}。${CONFIG_MESSAGE}`,
199
+ });
200
+ }
201
+ },
202
+ };
203
+ },
204
+ };
205
+
206
+ /** @type {import('eslint').Rule.RuleModule} */
207
+ const pagesMustUseCustomNavSpace = {
208
+ meta: {
209
+ type: 'problem',
210
+ docs: {
211
+ description: '页面入口必须使用 CustomNavSpace 或 useCustomNavLayout 避让自定义导航栏区域',
212
+ },
213
+ schema: [],
214
+ },
215
+ create(context) {
216
+ const filePath = context.filename.replace(/\\/g, '/');
217
+ if (!/\/src\/pages\/.+\/index\.[jt]sx$/.test(filePath)) return {};
218
+
219
+ let used = false;
220
+
221
+ return {
222
+ ImportDeclaration(node) {
223
+ if (typeof node.source.value === 'string' && CUSTOM_NAV_IMPORTS.has(node.source.value)) {
224
+ used = true;
225
+ }
226
+ },
227
+ 'Program:exit'(node) {
228
+ if (used) return;
229
+ context.report({
230
+ node,
231
+ message:
232
+ '兴趣卡落地页必须 import <CustomNavSpace /> 或 useCustomNavLayout() 做顶部避让,' +
233
+ '禁止改回原生导航,也禁止只用固定 pt-* / safe-area 代替。',
234
+ });
235
+ },
236
+ };
237
+ },
238
+ };
239
+
240
+ /** @type {import('eslint').Rule.RuleModule} */
241
+ const noNavigationControlApis = {
242
+ meta: {
243
+ type: 'problem',
244
+ docs: {
245
+ description: '禁止兴趣卡落地页调用会修改宿主导航栏或左上角按钮的 API',
246
+ },
247
+ schema: [],
248
+ },
249
+ create(context) {
250
+ function report(node, apiName) {
251
+ const reason = FORBIDDEN_NAVIGATION_APIS.get(apiName);
252
+ if (!reason) return;
253
+
254
+ context.report({
255
+ node,
256
+ message:
257
+ `兴趣卡落地页禁止使用 ${apiName}:${reason}。` +
258
+ '导航栏和左上角按钮由宿主及自定义导航模板统一管理。',
259
+ });
260
+ }
261
+
262
+ return {
263
+ MemberExpression(node) {
264
+ report(node.property, getStaticPropertyName(node));
265
+ },
266
+ ImportSpecifier(node) {
267
+ const importedName = node.imported.type === 'Identifier'
268
+ ? node.imported.name
269
+ : node.imported.value;
270
+ report(node.imported, importedName);
271
+ },
272
+ Property(node) {
273
+ if (node.parent.type !== 'ObjectPattern') return;
274
+ report(node.key, getPropertyKeyName(node));
275
+ },
276
+ CallExpression(node) {
277
+ if (node.callee.type !== 'Identifier') return;
278
+ report(node.callee, node.callee.name);
279
+ },
280
+ };
281
+ },
282
+ };
283
+
284
+ export default {
285
+ rules: {
286
+ 'require-custom-navigation-style': requireCustomNavigationStyle,
287
+ 'pages-must-use-custom-nav-space': pagesMustUseCustomNavSpace,
288
+ 'no-navigation-control-apis': noNavigationControlApis,
289
+ },
290
+ };
@@ -0,0 +1,55 @@
1
+ import { createMicroappTaroEslintConfig } from '../../../eslint/taro.mjs'
2
+ import customNavigation from './eslint-plugin-custom-navigation.mjs'
3
+
4
+ const interestCardRules = [
5
+ {
6
+ files: ['src/**/*.{js,jsx,ts,tsx}'],
7
+ plugins: { customNavigation },
8
+ rules: {
9
+ 'customNavigation/no-navigation-control-apis': 'error',
10
+ },
11
+ },
12
+ {
13
+ files: ['src/**/*.{js,jsx,ts,tsx}'],
14
+ ignores: ['src/network.ts'],
15
+ plugins: { customNavigation },
16
+ rules: {
17
+ 'customNavigation/require-custom-navigation-style': 'error',
18
+ 'customNavigation/pages-must-use-custom-nav-space': 'error',
19
+ },
20
+ },
21
+ ]
22
+
23
+ /**
24
+ * 兴趣卡 Taro 的通用校验加上业务域导航约束。
25
+ *
26
+ * 公共规则仍由 `createMicroappTaroEslintConfig` 维护;这里只声明兴趣卡
27
+ * 独有的导航能力及其旧图标包来源,避免模板复制整份 ESLint 配置。
28
+ */
29
+ export function createInterestCardTaroEslintConfig(options = {}) {
30
+ const { overrides, ...baseOptions } = options
31
+ const additionalLucideSources = baseOptions.lucideImportSources === undefined
32
+ ? []
33
+ : Array.isArray(baseOptions.lucideImportSources)
34
+ ? baseOptions.lucideImportSources
35
+ : [baseOptions.lucideImportSources]
36
+
37
+ return createMicroappTaroEslintConfig({
38
+ ...baseOptions,
39
+ lucideImportSources: ['lucide-taro', ...additionalLucideSources],
40
+ preferredUiImportBase: '@/components/ui',
41
+ overrides(config) {
42
+ const withInterestCardRules = [...config, ...interestCardRules]
43
+ if (!overrides) return withInterestCardRules
44
+ if (typeof overrides === 'function') {
45
+ return overrides(withInterestCardRules) ?? withInterestCardRules
46
+ }
47
+ return [
48
+ ...withInterestCardRules,
49
+ ...(Array.isArray(overrides) ? overrides : [overrides]),
50
+ ]
51
+ },
52
+ })
53
+ }
54
+
55
+ export default createInterestCardTaroEslintConfig
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 兴趣卡落地页 Runtime 入口。
3
+ *
4
+ * 此适配层只提供稳定的兴趣卡导入路径;请求、登录和传输能力仍由通用
5
+ * microapp Runtime 实现,避免在业务域内复制基础逻辑。
6
+ */
7
+ export { clearDouyinLoginAuth, createMicroappClient, type CreateMicroappClientOptions, } from '../../../runtime/index.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 兴趣卡落地页 Runtime 入口。
3
+ *
4
+ * 此适配层只提供稳定的兴趣卡导入路径;请求、登录和传输能力仍由通用
5
+ * microapp Runtime 实现,避免在业务域内复制基础逻辑。
6
+ */
7
+ export { clearDouyinLoginAuth, createMicroappClient, } from '../../../runtime/index.js';
8
+ //# sourceMappingURL=microapp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microapp.js","sourceRoot":"","sources":["../../../../src/adapters/interest-card/runtime/microapp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,2BAA2B,CAAA"}
@@ -0,0 +1,28 @@
1
+ /// <reference path="../../../runtime/globals.d.ts" />
2
+
3
+ declare module '@tarojs/components' {
4
+ export * from '@tarojs/components/types/index'
5
+
6
+ import type { ComponentType } from 'react'
7
+ import type {
8
+ CommonEventFunction,
9
+ StandardProps,
10
+ } from '@tarojs/components/types/common'
11
+
12
+ export interface MiniappOpenCardProps extends StandardProps {
13
+ id?: string
14
+ appId: string
15
+ path: string
16
+ initData?: Record<string, unknown>
17
+ envVersion: 'current' | 'latest' | 'preview'
18
+ onLoad?: CommonEventFunction
19
+ onError?: CommonEventFunction<{
20
+ errMsg?: string
21
+ errNo?: number
22
+ errorCode?: number
23
+ errorType?: string
24
+ }>
25
+ }
26
+
27
+ export const MiniappOpenCard: ComponentType<MiniappOpenCardProps>
28
+ }
@@ -0,0 +1,19 @@
1
+ import type { UserConfigExport } from '@tarojs/cli';
2
+ import type { BuildContext, CreateMicroappTaroConfigOptions } from './taro.js';
3
+ /**
4
+ * @desc 递归合并 Taro 配置,数组按顺序拼接。
5
+ * @params {any} base 基础配置。
6
+ * @params {any} override 覆盖配置。
7
+ * @return {any} 合并后的配置。
8
+ * @example mergeConfigValue({ plugins: ['a'] }, { plugins: ['b'] })
9
+ */
10
+ export declare function mergeConfigValue(base: any, override: any): any;
11
+ /**
12
+ * @desc 将对象或函数形式的覆盖项应用到 Taro 配置。
13
+ * @params {UserConfigExport} config 当前配置。
14
+ * @params {CreateMicroappTaroConfigOptions['overrides']} overrides 覆盖项。
15
+ * @params {BuildContext} ctx 构建上下文。
16
+ * @return {UserConfigExport} 应用覆盖后的配置。
17
+ * @example applyConfigOverrides(config, { h5: { publicPath: '/' } }, ctx)
18
+ */
19
+ export declare function applyConfigOverrides(config: UserConfigExport, overrides: CreateMicroappTaroConfigOptions['overrides'], ctx: BuildContext): UserConfigExport;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @desc 递归合并 Taro 配置,数组按顺序拼接。
3
+ * @params {any} base 基础配置。
4
+ * @params {any} override 覆盖配置。
5
+ * @return {any} 合并后的配置。
6
+ * @example mergeConfigValue({ plugins: ['a'] }, { plugins: ['b'] })
7
+ */
8
+ export function mergeConfigValue(base, override) {
9
+ if (Array.isArray(base) && Array.isArray(override))
10
+ return [...base, ...override];
11
+ if (base && override && typeof base === 'object' && typeof override === 'object') {
12
+ const result = { ...base };
13
+ for (const [key, value] of Object.entries(override)) {
14
+ result[key] = key in result ? mergeConfigValue(result[key], value) : value;
15
+ }
16
+ return result;
17
+ }
18
+ return override;
19
+ }
20
+ /**
21
+ * @desc 将对象或函数形式的覆盖项应用到 Taro 配置。
22
+ * @params {UserConfigExport} config 当前配置。
23
+ * @params {CreateMicroappTaroConfigOptions['overrides']} overrides 覆盖项。
24
+ * @params {BuildContext} ctx 构建上下文。
25
+ * @return {UserConfigExport} 应用覆盖后的配置。
26
+ * @example applyConfigOverrides(config, { h5: { publicPath: '/' } }, ctx)
27
+ */
28
+ export function applyConfigOverrides(config, overrides, ctx) {
29
+ if (!overrides)
30
+ return config;
31
+ if (typeof overrides === 'function')
32
+ return overrides(config, ctx) ?? config;
33
+ return mergeConfigValue(config, overrides);
34
+ }
35
+ //# sourceMappingURL=config-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-overrides.js","sourceRoot":"","sources":["../../src/build/config-overrides.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAS,EAAE,QAAa;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;IACjF,IAAI,IAAI,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjF,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAA;QAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpD,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAC5E,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAwB,EACxB,SAAuD,EACvD,GAAiB;IAEjB,IAAI,CAAC,SAAS;QAAE,OAAO,MAAM,CAAA;IAC7B,IAAI,OAAO,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,MAAM,CAAA;IAC5E,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAqB,CAAA;AAChE,CAAC"}
@@ -0,0 +1 @@
1
+ export { createMicroappTaroConfig, type BuildContext, type CreateMicroappTaroConfigOptions, } from './taro.js';
@@ -0,0 +1,2 @@
1
+ export { createMicroappTaroConfig, } from './taro.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,QAAQ,CAAA"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = appConfigPlugin;
7
+ const path_1 = __importDefault(require("path"));
8
+ const withPreviewBasePath = (iconPath, previewBasePath) => {
9
+ if (!previewBasePath) {
10
+ return iconPath;
11
+ }
12
+ const previewPath = path_1.default.join(previewBasePath, iconPath);
13
+ if (previewPath.startsWith('./')) {
14
+ return previewPath;
15
+ }
16
+ if (previewPath.startsWith('/')) {
17
+ return `.${previewPath}`;
18
+ }
19
+ return `./${previewPath}`;
20
+ };
21
+ function appConfigPlugin(ctx, options = {}) {
22
+ const previewBasePath = options.previewBasePath ?? '';
23
+ ctx.modifyAppConfig(({ appConfig }) => {
24
+ if (typeof options.isClosedDomain === 'boolean') {
25
+ appConfig.isClosedDomain = options.isClosedDomain;
26
+ }
27
+ if (!(process.env.TARO_ENV === 'h5' && process.env.NODE_ENV === 'development')) {
28
+ return appConfig;
29
+ }
30
+ if (Array.isArray(appConfig.tabBar?.list) && appConfig.tabBar.list.length > 0) {
31
+ const list = appConfig.tabBar.list;
32
+ list.forEach(item => {
33
+ if (item.iconPath) {
34
+ item.iconPath = withPreviewBasePath(item.iconPath, previewBasePath);
35
+ }
36
+ if (item.selectedIconPath) {
37
+ item.selectedIconPath = withPreviewBasePath(item.selectedIconPath, previewBasePath);
38
+ }
39
+ });
40
+ }
41
+ return appConfig;
42
+ });
43
+ }
@@ -0,0 +1,29 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * @desc 通过 AST 检测卡片组件的 JSX 或 React.createElement 用法;仅导入或声明不算使用。
4
+ * 支持导入别名、命名空间及不可变局部别名;源码语法错误会向调用方抛出。
5
+ * @params {string} source 待分析的源码。
6
+ * @params {string} filename 用于按扩展名选择 TypeScript、JSX 解析语法的文件名。
7
+ * @return {boolean} 是否检测到卡片组件使用;不判断条件分支在运行时是否执行。
8
+ * @example usesCard("<Card />", "src/pages/index.tsx")
9
+ */
10
+ export declare function usesCard(source: string, filename: string): boolean;
11
+ /**
12
+ * @desc 递归扫描业务源码并收集监听路径,跳过依赖、测试、mock、声明和配置文件。
13
+ * 目录不存在时返回空结果;语法错误会中断扫描,避免将无法解析误判为不依赖卡片。
14
+ * @params {string} sourceDir Taro 编译上下文提供的源码目录,可为自定义 sourceRoot。
15
+ * @return {{ depends: boolean, files: string[], directories: string[] }} 检测结果及已扫描的文件、目录。
16
+ * @example scanSource("/workspace/project/src")
17
+ */
18
+ export declare function scanSource(sourceDir: string): {
19
+ depends: boolean;
20
+ files: string[];
21
+ directories: string[];
22
+ };
23
+ /**
24
+ * @desc 创建自动维护 isDependCard 的 Vite 插件,从 Taro 模块 metadata 获取编译上下文。
25
+ * 在入口配置序列化前完成扫描,并在开发期间处理文件修改、新增及删除。
26
+ * @return {Plugin} 注册到 compiler.vitePlugins 的插件实例。
27
+ * @example viteDependCardPlugin()
28
+ */
29
+ export declare function viteDependCardPlugin(): Plugin;