Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
"stylelint-order": "^6.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
"typescript": "~5.4.5",
"tslib": "^2.6.2",
"typescript": "~5.4.5",
"vitest": "^1.6.0"
},
"pnpm": {
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum PLATFORM_TYPE {
MINI = 'mini',
ASCF = 'ascf',
WEB = 'web',
RN = 'rn',
HARMONY = 'harmony',
Expand All @@ -17,6 +18,9 @@ export const PLATFORM_CONFIG_MAP = {
harmony: {
type: PLATFORM_TYPE.HARMONY
},
ascf: {
type: PLATFORM_TYPE.ASCF
},
mini: {
type: PLATFORM_TYPE.MINI
},
Expand Down
64 changes: 64 additions & 0 deletions packages/taro-api/src/ascf-bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as ASCF from '@ascf/native-api'

import Taro from '../../../../../taroo/taro/packages/taro/types'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

修复导入路径

这个导入路径看起来不正确,包含了 taroo 而不是 taro,并且相对路径层级过深。请确认正确的导入路径。

建议修复为:

-import Taro from '../../../../../taroo/taro/packages/taro/types'
+import Taro from '@tarojs/taro'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import Taro from '../../../../../taroo/taro/packages/taro/types'
import Taro from '@tarojs/taro'
🤖 Prompt for AI Agents
In packages/taro-api/src/ascf-bridge.ts at line 3, the import path for Taro is
incorrect because it uses 'taroo' instead of 'taro' and has an overly deep
relative path. Correct the import path to use the proper 'taro' directory and
simplify the relative path to accurately point to the Taro types module.

import networkMappings from './ascf-mappings/network.json'


const transformers = {
normalizeHeaders: (headers: Record<string, any>) => {
const normalized: Record<string, any> = {}
Object.keys(headers).forEach(key => {
normalized[key.toLowerCase()] = headers[key]
})
return normalized
}
}

export function ascRequest(options: Taro.request.Option): Promise<Taro.request.SuccessCallbackResult> {
const mapping = networkMappings.request
Comment on lines +17 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

验证映射配置结构

建议验证 networkMappings.request 的结构,确保映射配置包含必要的字段。

运行以下脚本来验证映射配置文件的存在和结构:


🏁 Script executed:

#!/bin/bash
# 描述:验证 ASCF 网络映射配置文件的存在和结构
# 预期:文件存在且包含 request 字段

# 检查映射文件是否存在
if [ -f "packages/taro-api/src/ascf-mappings/network.json" ]; then
    echo "✓ 映射文件存在"
    # 检查文件内容结构
    cat packages/taro-api/src/ascf-mappings/network.json | jq '.request'
else
    echo "✗ 映射文件不存在"
fi

Length of output: 712


验证网络映射配置结构并添加运行时校验

经过验证,packages/taro-api/src/ascf-mappings/network.json 文件存在且其 .request 段包含以下字段:

  • url(ascfParam、type、required、docLink)
  • method(ascfParam、valueMap、default、docLink)
  • header(ascfParam、type、transform、docLink)

为提升健壮性,建议在 packages/taro-api/src/ascf-bridge.tsascRequest 函数(第 17–18 行)中引入对映射结构的运行时校验,例如:

  • 检查 mapping.urlmapping.methodmapping.header 等必填节点是否存在且类型符合预期
  • 对可选字段(如 defaulttransform)提供安全默认值或在缺失时抛出明确异常
  • 考虑使用 zodajv 等 schema 验证库统一管理校验逻辑

这样可确保未来对映射文件的修改不会导致调用异常。

🤖 Prompt for AI Agents
In packages/taro-api/src/ascf-bridge.ts around lines 17 to 18, add runtime
validation for the networkMappings.request structure by checking that required
fields like url, method, and header exist and have the correct types. Implement
default values or throw clear errors for optional fields such as default and
transform if missing. Use a schema validation library like zod or ajv to define
and enforce this validation to prevent runtime errors from future changes to the
mapping file.

const ascfParams: Record<string, any> = {}


Object.entries(mapping).forEach(([taroKey, config]) => {
const value = (options as any)[taroKey]

if (value === undefined) {
if (config.required) {
throw new Error(`[ASCF] Missing required parameter: ${taroKey}`)
}
if (config.default !== undefined) {
ascfParams[config.ascfParam] = config.default
}
return
}

let transformedValue = value
if (config.valueMap) {
transformedValue = config.valueMap[value] ?? value
}
if (config.transform && transformers[config.transform]) {
transformedValue = transformers[config.transform](value)
}

ascfParams[config.ascfParam] = transformedValue
})

return ASCF.Network.request(ascfParams).then(res => {
return {
data: res.body,
statusCode: res.status,
header: res.headers,
errMsg: 'request:ok'
}
})
}
Comment on lines +46 to +54
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

添加错误处理和响应验证

当前实现缺少对 ASCF.Network.request 调用的错误处理,并且假设响应结构固定。建议添加错误处理和响应验证。

-  return ASCF.Network.request(ascfParams).then(res => {
-    return {
-      data: res.body,
-      statusCode: res.status,
-      header: res.headers,
-      errMsg: 'request:ok'
-    }
-  })
+  return ASCF.Network.request(ascfParams).then(res => {
+    if (!res) {
+      throw new Error('[ASCF] Invalid response from ASCF.Network.request')
+    }
+    return {
+      data: res.body,
+      statusCode: res.status || 200,
+      header: res.headers || {},
+      errMsg: 'request:ok'
+    }
+  }).catch(error => {
+    throw new Error(`[ASCF] Network request failed: ${error.message || error}`)
+  })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return ASCF.Network.request(ascfParams).then(res => {
return {
data: res.body,
statusCode: res.status,
header: res.headers,
errMsg: 'request:ok'
}
})
}
return ASCF.Network.request(ascfParams)
.then(res => {
if (!res) {
throw new Error('[ASCF] Invalid response from ASCF.Network.request')
}
return {
data: res.body,
statusCode: res.status || 200,
header: res.headers || {},
errMsg: 'request:ok'
}
})
.catch(error => {
throw new Error(`[ASCF] Network request failed: ${error.message || error}`)
})
}
🤖 Prompt for AI Agents
In packages/taro-api/src/ascf-bridge.ts around lines 46 to 54, the current code
lacks error handling and assumes a fixed response structure from
ASCF.Network.request. Modify the code to add a catch block to handle any errors
from the request call, returning a proper error object or message. Also,
validate the response structure before accessing properties like body, status,
and headers to avoid runtime errors.



export const ascfApis = {
connectDevice: (options: { deviceId: string, timeout?: number }) => {
return ASCF.Device.connect({
deviceId: options.deviceId,
timeout: options.timeout || 5000
})
}
}
Comment on lines +57 to +64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

添加参数验证和错误处理

建议为 connectDevice 函数添加参数验证和错误处理,以提高代码健壮性。

 export const ascfApis = {
-  connectDevice: (options: { deviceId: string, timeout?: number }) => {
+  connectDevice: (options: { deviceId: string, timeout?: number }) => {
+    if (!options || !options.deviceId) {
+      throw new Error('[ASCF] deviceId is required for connectDevice')
+    }
+    if (options.timeout && (options.timeout < 0 || options.timeout > 60000)) {
+      throw new Error('[ASCF] timeout must be between 0 and 60000ms')
+    }
     return ASCF.Device.connect({
       deviceId: options.deviceId,
       timeout: options.timeout || 5000
-    })
+    }).catch(error => {
+      throw new Error(`[ASCF] Device connection failed: ${error.message || error}`)
+    })
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const ascfApis = {
connectDevice: (options: { deviceId: string, timeout?: number }) => {
return ASCF.Device.connect({
deviceId: options.deviceId,
timeout: options.timeout || 5000
})
}
}
export const ascfApis = {
connectDevice: (options: { deviceId: string, timeout?: number }) => {
if (!options || !options.deviceId) {
throw new Error('[ASCF] deviceId is required for connectDevice')
}
if (options.timeout && (options.timeout < 0 || options.timeout > 60000)) {
throw new Error('[ASCF] timeout must be between 0 and 60000ms')
}
return ASCF.Device.connect({
deviceId: options.deviceId,
timeout: options.timeout || 5000
}).catch(error => {
throw new Error(`[ASCF] Device connection failed: ${error.message || error}`)
})
}
}
🤖 Prompt for AI Agents
In packages/taro-api/src/ascf-bridge.ts around lines 57 to 64, the connectDevice
function lacks parameter validation and error handling. Add checks to ensure the
deviceId parameter is provided and valid before calling ASCF.Device.connect.
Wrap the connection call in a try-catch block to handle potential errors
gracefully, returning or throwing meaningful error messages to improve
robustness.

27 changes: 27 additions & 0 deletions packages/taro-api/src/ascf-mappings/network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"request": {
"url": {
"ascfParam": "endpoint",
"type": "string",
"required": true,
"docLink": "https://ascf.docs/apis/network#endpoint"
},
"method": {
"ascfParam": "httpMethod",
"valueMap": {
"GET": "GET",
"POST": "POST",
"PUT": "PUT",
"DELETE": "DELETE"
},
"default": "GET",
"docLink": "https://ascf.docs/apis/network#http-method"
},
"header": {
"ascfParam": "headers",
"type": "object",
"transform": "normalizeHeaders",
"docLink": "https://ascf.docs/apis/network#headers"
}
}
}
3 changes: 3 additions & 0 deletions packages/taro-api/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const ENV_TYPE = {
ASCF: 'ASCF',
WEAPP: 'WEAPP',
SWAN: 'SWAN',
ALIPAY: 'ALIPAY',
Expand Down Expand Up @@ -35,6 +36,8 @@ export function getEnv () {
return ENV_TYPE.HARMONY
} else if (process.env.TARO_ENV === 'quickapp') {
return ENV_TYPE.QUICKAPP
} else if (process.env.TARO_ENV === 'ascf') {
return ENV_TYPE.ASCF
} else {
return process.env.TARO_ENV || 'Unknown'
}
Expand Down
1 change: 1 addition & 0 deletions packages/taro-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default class CLI {
// 针对不同的内置平台注册对应的端平台插件
switch (platform) {
case 'weapp':
case 'ascf':
case 'alipay':
case 'swan':
case 'tt':
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-cli/src/presets/platforms/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ export default (ctx: IPluginContext) => {
_
} = ctx.runOpts
const { chalk, PLATFORMS } = ctx.helper
const { WEAPP, ALIPAY, JD } = PLATFORMS
const { ASCF, WEAPP, ALIPAY, JD } = PLATFORMS
const typeMap = {
[ASCF]: 'ASCF',
[JD]: '京东',
[WEAPP]: '微信',
[ALIPAY]: '支付宝'
}
const { plugin, isWatch } = options
if (plugin !== WEAPP && plugin !== ALIPAY && plugin !== JD) {
console.log(chalk.red('目前插件编译仅支持 微信/支付宝/京东 小程序!'))
if (plugin !== ASCF && plugin !== WEAPP && plugin !== ALIPAY && plugin !== JD) {
console.log(chalk.red('目前插件编译仅支持 ASCF/微信/支付宝/京东 小程序!'))
return
}
console.log(chalk.green(`开始编译${typeMap[plugin]}小程序插件`))
Expand Down
32 changes: 32 additions & 0 deletions packages/taro-components/ascf-mappings/core.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"Button": {
"size": {
"ascfProp": "dimension",
"valueMap": {
"mini": "XS",
"small": "S",
"default": "M",
"large": "L"
},
"required": false,
"default": "M",
"docLink": "https://ascf.docs/components/button#dimension"
},
"loading": {
"ascfProp": "isLoading",
"type": "boolean",
"required": false,
"default": false,
"docLink": "https://ascf.docs/components/button#isloading"
}
},
"Input": {
"password": {
"ascfProp": "secretInput",
"type": "boolean",
"required": false,
"default": false,
"docLink": "https://ascf.docs/components/input#secretinput"
}
}
}
43 changes: 43 additions & 0 deletions packages/taro-components/src/common/ascf-adapter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { h } from '@stencil/core'
import React from 'react'

import coreMappings from '../../ascf-mappings/core.json'

const ASCF_MAPPINGS = {
...coreMappings
}

export function withAscfAdapter<T extends IntrinsicAttributes & T>(WrappedComponent: React.ComponentType<T>) {
const componentName = WrappedComponent.name
const mapping = ASCF_MAPPINGS[componentName] || {}

// eslint-disable-next-line react/display-name
return (props: T) => {
if (process.env.TARO_ENV !== 'ascf') {
return <WrappedComponent {...props} />
}

const ascfProps: any = {}

Object.entries(props).forEach(([key, value]) => {
const propMapping = mapping[key]

if (propMapping) {
ascfProps[propMapping.ascfProp] = propMapping.valueMap
? propMapping.valueMap[value] ?? value
: value
} else {
ascfProps[key] = value
}
})

Object.entries(mapping).forEach(([, config]) => {
const ascfKey = config.ascfProp
if (ascfProps[ascfKey] === undefined && config.default !== undefined) {
ascfProps[ascfKey] = config.default
}
})

return <WrappedComponent {...ascfProps} />
}
}
5 changes: 5 additions & 0 deletions packages/taro-components/src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Component, h, Prop, State, ComponentInterface, Event, EventEmitter, Listen, Element, Host } from '@stencil/core'
import classNames from 'classnames'
import { withAscfAdapter } from 'src/common/ascf-adapter'


@Component({
tag: 'taro-button-core',
Expand Down Expand Up @@ -104,3 +106,6 @@ export class Button implements ComponentInterface {
)
}
}



27 changes: 27 additions & 0 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,33 @@ declare namespace ButtonProps {
authorizePrivateMessage
}
}

declare namespace TaroGeneral {
interface ENV_TYPE {
ascf: boolean
}
}

type ASCFAdaptedProps<Props, Mapping> = {
[K in keyof Props]:
K extends keyof Mapping
? Mapping[K]['ascfProp'] extends string
? Props[K]
: never
: Props[K]
} & {
[K in keyof Mapping as Mapping[K]['ascfProp']]?: any
};
interface ButtonProps {
size?: 'mini' | 'small' | 'default' | 'large'
loading?: boolean
}
Comment on lines +460 to +463
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

接口重复声明导致编译错误

ButtonProps 接口已在第4行声明,此处重复声明会导致 TypeScript 编译错误。应使用不同的名称,如 SimplifiedButtonPropsASCFButtonProps

-  interface ButtonProps {
+  interface SimplifiedButtonProps {
     size?: 'mini' | 'small' | 'default' | 'large'
     loading?: boolean
   }

同时更新第467行的引用:

-      ? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
-      : ButtonProps;
+      ? ASCFAdaptedProps<SimplifiedButtonProps, typeof coreMappings.Button>
+      : SimplifiedButtonProps;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
interface ButtonProps {
size?: 'mini' | 'small' | 'default' | 'large'
loading?: boolean
}
// Rename to avoid duplicate declaration
interface SimplifiedButtonProps {
size?: 'mini' | 'small' | 'default' | 'large'
loading?: boolean
}
// …later in the same file, update the conditional type reference…
? ASCFAdaptedProps<SimplifiedButtonProps, typeof coreMappings.Button>
: SimplifiedButtonProps;
🤖 Prompt for AI Agents
In packages/taro-components/types/Button.d.ts around lines 460 to 463, the
ButtonProps interface is being redeclared, causing a TypeScript compilation
error. Rename this interface to a unique name such as SimplifiedButtonProps or
ASCFButtonProps to avoid duplication, and update all references to this
interface accordingly, including the one at line 467.


type TaroButtonProps =
TaroGeneral.ENV_TYPE['ascf'] extends true
? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

缺少 coreMappings 导入

代码引用了 coreMappings.Button 但未导入该模块。根据 AI 摘要,此映射定义在 packages/taro-components/ascf-mappings/core.json 中。

在文件顶部添加导入语句:

import coreMappings from '../ascf-mappings/core.json'
🤖 Prompt for AI Agents
In packages/taro-components/types/Button.d.ts at line 467, the code references
coreMappings.Button but coreMappings is not imported. Fix this by adding the
import statement "import coreMappings from '../ascf-mappings/core.json'" at the
top of the file to properly import the coreMappings module.

: ButtonProps;

Comment on lines +465 to +469
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

条件类型实现可能存在问题

当前条件类型检查 TaroGeneral.ENV_TYPE['ascf'] extends true 可能无法正常工作。TypeScript 中的条件类型通常不应直接检查布尔值属性。

建议重新考虑类型设计,可能需要使用不同的方法来实现平台特定的类型切换。请验证当前实现是否能正确工作:


🏁 Script executed:

#!/bin/bash
# 检查其他文件中是否有类似的条件类型实现模式
ast-grep --pattern 'type $_ = $_["$_"] extends true ? $_ : $_'

# 查找 ENV_TYPE 的使用方式
rg -A 3 "ENV_TYPE\['ascf'\]"

Length of output: 408


🏁 Script executed:

#!/bin/bash
# 查找 TaroGeneral 接口定义及 ENV_TYPE 的声明
rg -n "interface TaroGeneral" -C 5 .
rg -n "type TaroGeneral" -C 5 .
rg -n "ENV_TYPE" -C 5 .

Length of output: 23498


修复 Button.d.ts 中 TaroGeneral.ENV_TYPE['ascf'] 条件类型判断

当前实现

// packages/taro-components/types/Button.d.ts:445-447
declare namespace TaroGeneral {
  interface ENV_TYPE {
    ascf: boolean
  }
}

// packages/taro-components/types/Button.d.ts:465-469
type TaroButtonProps = 
  TaroGeneral.ENV_TYPE['ascf'] extends true 
    ? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
    : ButtonProps;

问题
TaroGeneral.ENV_TYPE['ascf'] 的类型是 boolean,在 TypeScript 中 boolean extends true 永远为 false,导致条件类型始终走到 : ButtonProps 分支。

请在以下位置进行修正:

  • packages/taro-components/types/Button.d.ts
    • 修改 ENV_TYPE['ascf'] 的声明为字面量类型(true/false
    • 或者将条件类型改为接收类型参数,再在不同环境下传入具体的布尔值
    • 或者重新设计为映射类型,根据环境字符串(如 ENV_TYPE.ASCF)来分发不同 Props

示例(仅供参考):

- type TaroButtonProps =
-   TaroGeneral.ENV_TYPE['ascf'] extends true
-     ? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
-     : ButtonProps;
+ // 方式一:字面量化 ENV_TYPE 定义
+ declare namespace TaroGeneral {
+   interface ENV_TYPE {
+     ascf: true
+     // ...其他平台字段同理
+   }
+ }
+ type TaroButtonProps =
+   TaroGeneral.ENV_TYPE['ascf'] extends true
+     ? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
+     : ButtonProps;
+
+ // 或 方式二:使用类型参数
+ type TaroButtonProps<IsASCF extends boolean> =
+   IsASCF extends true
+     ? ASCFAdaptedProps<ButtonProps, typeof coreMappings.Button>
+     : ButtonProps;
+ // 使用处:TaroButtonProps<typeof TaroGeneral.ENV_TYPE['ascf']>

请根据项目实际需求选择合适方案并修复,确保 ASCF 环境下能正确生成 ASCFAdaptedProps

🤖 Prompt for AI Agents
In packages/taro-components/types/Button.d.ts around lines 465 to 469, the
conditional type uses TaroGeneral.ENV_TYPE['ascf'] which is declared as boolean,
causing the condition to always evaluate to false. To fix this, change the
declaration of ENV_TYPE['ascf'] from boolean to a literal type true or false, or
refactor the conditional type to accept a type parameter representing the
environment boolean value, ensuring the condition can correctly discriminate and
select ASCFAdaptedProps when appropriate.

/** lang 的合法值 */
interface Lang {
/** 英文 */
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-helper/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const REG_IMAGE = /\.(png|jpe?g|gif|bpm|svg|webp)(\?.*)?$/
export const REG_FONT = /\.(woff2?|eot|ttf|otf)(\?.*)?$/
export const REG_JSON = /\.json(\?.*)?$/
export const REG_UX = /\.ux(\?.*)?$/
export const REG_TEMPLATE = /\.(wxml|axml|ttml|qml|swan|jxml)(\?.*)?$/
export const REG_TEMPLATE = /\.(hxml|wxml|axml|ttml|qml|swan|jxml)(\?.*)?$/
export const REG_WXML_IMPORT = /<import(.*)?src=(?:(?:'([^']*)')|(?:"([^"]*)"))/gi
export const REG_URL =
/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i
Expand Down Expand Up @@ -177,6 +177,7 @@ export const UPDATE_PACKAGE_LIST = [
'@tarojs/taroize',
'@tarojs/plugin-inject',
'@tarojs/plugin-platform-weapp',
'@tarojs/plugin-platform-ascf',
'@tarojs/plugin-platform-alipay',
'@tarojs/plugin-platform-swan',
'@tarojs/plugin-platform-tt',
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-platform-ascf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@tarojs/plugin-platform-ascf`

Taro 插件。用于支持编译为ascf。
4 changes: 4 additions & 0 deletions packages/taro-platform-ascf/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = require('./dist/index.js').default

module.exports.default = module.exports
module.exports.AscfApp = require('./dist/index.js').AscfApp
Comment on lines +1 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

模块导出结构符合约定

导出文件遵循了 Taro 平台包的标准模式,确保了 CommonJS 和 ES 模块的兼容性。

建议验证编译后的分发文件是否正确导出了预期的内容:


🏁 Script executed:

#!/bin/bash
# 检查 dist 目录和导出文件是否存在
fd "dist" --type d packages/taro-platform-ascf/ --exec ls -la {}/index.js \;

Length of output: 79


脚本未返回任何结果,可能是目录不存在或命令路径有误。请使用更直接的方式验证 packages/taro-platform-ascf/dist/index.js 是否存在并导出预期内容:


🏁 Script executed:

#!/bin/bash
# 查找并列出 dist 目录下的 index.js
find packages/taro-platform-ascf/dist -maxdepth 1 -type f -name index.js -exec ls -la {} \;

# 如存在,则检查默认和 AscfApp 导出
if [ -f packages/taro-platform-ascf/dist/index.js ]; then
  grep -E "export default|export (\\{[^}]*\\}|AscfApp)" -n packages/taro-platform-ascf/dist/index.js || echo "未找到预期的导出"
fi

Length of output: 219


缺少 dist 构建产物

packages/taro-platform-ascf 中未能找到 dist/index.js,请确认已生成并提交该构建产物,或将导出路径调整为实际存在的文件:

– 确认 packages/taro-platform-ascf/dist/index.js 已被生成并纳入版本控制
– 若 dist 目录由 CI/构建流程动态生成,请在发布包时确保包含该目录或改用正确的入口文件
– 如路径不同,请在 packages/taro-platform-ascf/index.js 中更新 require('./dist/index.js') 为有效路径

🤖 Prompt for AI Agents
In packages/taro-platform-ascf/index.js lines 1 to 4, the require statement
points to './dist/index.js' which is missing. Ensure that the dist/index.js file
is generated and included in version control if it is a build artifact. If the
dist directory is created dynamically during CI or build, update the package
publishing process to include it or change the require path in index.js to point
to an existing file that can serve as the module entry point.

40 changes: 40 additions & 0 deletions packages/taro-platform-ascf/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@tarojs/plugin-platform-ascf",
"version": "4.0.12",
"description": "ascf平台插件",
"author": "ascf",
"license": "MIT",
"main": "index.js",
"types": "dist/types/index.d.ts",
"keywords": [
"taro"
],
"files": [
"index.js",
"dist"
],
"scripts": {
"prod": "pnpm run build",
"build": "rollup -c",
"dev": "rollup -c -w"
},
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"engines": {
"node": ">= 18"
},
"devDependencies": {
"@tarojs/components": "workspace:*",
"@tarojs/service": "workspace:*",
"@tarojs/shared": "workspace:*"
},
"peerDependencies": {
"@tarojs/service": "workspace:*",
"@tarojs/shared": "workspace:*"
}
}
Loading