Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum PLATFORM_TYPE {
RN = 'rn',
HARMONY = 'harmony',
QUICK = 'quickapp',
ASCF = 'ascf',
}

export const PLATFORM_CONFIG_MAP = {
Expand All @@ -22,4 +23,7 @@ export const PLATFORM_CONFIG_MAP = {
quickapp: {
type: PLATFORM_TYPE.QUICK
},
ascf: {
type: PLATFORM_TYPE.ASCF
},
}
3 changes: 3 additions & 0 deletions packages/taro-api/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ENV_TYPE = {
HARMONY: 'HARMONY',
QUICKAPP: 'QUICKAPP',
HARMONYHYBRID: 'HARMONYHYBRID',
ASCF: 'ASCF',
}

export function getEnv () {
Expand All @@ -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
3 changes: 2 additions & 1 deletion packages/taro-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default class CLI {
case 'qq':
case 'jd':
case 'h5':
case 'ascf':
case 'harmony-hybrid':
kernel.optsPlugins.push(`@tarojs/plugin-platform-${platform}`)
break
Expand Down Expand Up @@ -153,7 +154,7 @@ export default class CLI {
plugin = args.plugin
platform = 'plugin'
kernel.optsPlugins.push(path.resolve(platformsPath, 'plugin.js'))
if (plugin === 'weapp' || plugin === 'alipay' || plugin === 'jd') {
if (plugin === 'ascf' || plugin === 'weapp' || plugin === 'alipay' || plugin === 'jd') {
kernel.optsPlugins.push(`@tarojs/plugin-platform-${plugin}`)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/src/presets/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default (ctx: IPluginContext) => {
ctx.registerCommand({
name: 'build',
optionsMap: {
'--type [typeName]': 'Build type, weapp/swan/alipay/tt/qq/jd/h5/rn',
'--type [typeName]': 'Build type, ascf/weapp/swan/alipay/tt/qq/jd/h5/rn',
'--watch': 'Watch mode',
'--env [env]': 'Value for process.env.NODE_ENV',
'--mode [mode]': 'Value of dotenv extname',
Expand Down
9 changes: 5 additions & 4 deletions packages/taro-cli/src/presets/platforms/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ export default (ctx: IPluginContext) => {
_
} = ctx.runOpts
const { chalk, PLATFORMS } = ctx.helper
const { WEAPP, ALIPAY, JD } = PLATFORMS
const { WEAPP, ALIPAY, JD, ASCF } = PLATFORMS
const typeMap = {
[JD]: '京东',
[WEAPP]: '微信',
[ALIPAY]: '支付宝'
[ALIPAY]: '支付宝',
[ASCF]: '元服务'
}
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
2 changes: 1 addition & 1 deletion packages/taro-cli/templates/default/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare namespace NodeJS {
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
NODE_ENV: 'development' | 'production',
/** 当前构建的平台 */
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
TARO_ENV: 'ascf' | 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
/**
* 当前构建的小程序 appid
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/scripts/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'

export const MINI_APP_TYPES = ['weapp', 'alipay', 'swan', 'tt', 'qq', 'jd'] as const
export const MINI_APP_TYPES = ['ascf', 'weapp', 'alipay', 'swan', 'tt', 'qq', 'jd'] as const
export const TYPES_DIR = path.join(process.cwd(), 'types')
35 changes: 35 additions & 0 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,43 @@ declare namespace ButtonProps {
| keyof openTypeKeys['alipay']
| keyof openTypeKeys['qq']
| keyof openTypeKeys['tt']
| keyof openTypeKeys['ascf']
/** open-type 的合法值 */
interface openTypeKeys {
ascf: {
/** 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从回调中获得具体信息
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html
*/
contact

/** 触发用户转发,使用前建议先阅读使用指引
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95
*/
share

/** 获取用户手机号,可以从回调中获取到用户信息
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
*/
getPhoneNumber

/** 获取用户信息,可以从回调中获取到用户信息 */
getUserInfo

/** 打开APP,可以通过 app-parameter 属性设定向APP传的参数
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html
*/
launchApp

/** 打开授权设置页 */
openSetting

/** 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容 */
feedback

/** 获取用户头像,可以从回调中获得具体信息 */
chooseAvatar
}

weapp: {
/** 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从回调中获得具体信息
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html
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
export const CSS_IMPORT_REG = /@import (["'])(.+?)\1;/g
Expand Down Expand Up @@ -171,6 +171,7 @@ export const UPDATE_PACKAGE_LIST = [
'@tarojs/with-weapp',
'@tarojs/taroize',
'@tarojs/plugin-platform-weapp',
'@tarojs/plugin-platform-ascf',
'@tarojs/plugin-platform-alipay',
'@tarojs/plugin-platform-swan',
'@tarojs/plugin-platform-tt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare module '*.styl';
// @ts-ignore
declare const process: {
env: {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
TARO_ENV: 'ascf' | 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
[key: string]: any;
}
}
2 changes: 2 additions & 0 deletions packages/taro-platform-ascf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
types
!types/shims-ascf.d.ts
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
43 changes: 43 additions & 0 deletions packages/taro-platform-ascf/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@tarojs/plugin-platform-ascf",
"version": "3.6.37",
"description": "微信小程序平台插件",
"author": "drchan",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-ascf#readme",
"license": "MIT",
"main": "index.js",
"keywords": [
"taro"
],
"files": [
"index.js",
"dist",
"types"
],
"types": "types/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w"
},
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
"dependencies": {
"@tarojs/service": "workspace:*"
},
"devDependencies": {
"@tarojs/components": "workspace:*",
"@tarojs/shared": "workspace:*",
"rollup": "^2.79.0",
"rollup-plugin-ts": "^3.0.2",
"typescript": "^4.7.4"
},
"peerDependencies": {
"@tarojs/components": "workspace:~",
"@tarojs/shared": "workspace:~"
}
}
56 changes: 56 additions & 0 deletions packages/taro-platform-ascf/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as path from 'path'
import ts from 'rollup-plugin-ts'

const cwd = __dirname

const base = {
external: ['@tarojs/shared', '@tarojs/service'],
plugins: [ts()]
}

// 供 CLI 编译时使用的 Taro 插件入口
const compileConfig = {
input: path.join(cwd, 'src/index.ts'),
output: {
file: path.join(cwd, 'dist/index.js'),
format: 'cjs',
sourcemap: true,
exports: 'named'
},
...base
}

// 供 Loader 使用的运行时入口
const runtimeConfig = {
input: path.join(cwd, 'src/runtime.ts'),
output: {
file: path.join(cwd, 'dist/runtime.js'),
format: 'es',
sourcemap: true
},
...base
}

// 供继承的包使用,为了能 tree-shaking
const runtimeUtilsConfig = {
input: path.join(cwd, 'src/runtime-utils.ts'),
output: {
file: path.join(cwd, 'dist/runtime-utils.js'),
format: 'es',
sourcemap: true
},
...base
}

// React 下 webpack 会 alias @tarojs/components 为此文件
const otherConfig = {
input: path.join(cwd, 'src/components-react.ts'),
output: {
file: path.join(cwd, 'dist/components-react.js'),
format: 'es',
sourcemap: true
},
...base
}

module.exports = [compileConfig, runtimeConfig, runtimeUtilsConfig, otherConfig]
24 changes: 24 additions & 0 deletions packages/taro-platform-ascf/src/apis-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const needPromiseApis = new Set([
'authPrivateMessage',
'chooseContact',
'cropImage',
'disableAlertBeforeUnload',
'editImage',
'enableAlertBeforeUnload',
'getBackgroundFetchData',
'getFuzzyLocation',
'getGroupEnterInfo',
'getLocalIPAddress',
'getShareInfo',
'getUserProfile',
'getWeRunData',
'join1v1Chat',
'openCustomerServiceChat',
'openVideoEditor',
'saveFileToDisk',
'scanItem',
'setEnable1v1Chat',
'setWindowSize',
'sendBizRedPacket',
'startFacialRecognitionVerify',
])
31 changes: 31 additions & 0 deletions packages/taro-platform-ascf/src/apis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { processApis } from '@tarojs/shared'

import { needPromiseApis } from './apis-list'

declare const has: any

export function initNativeApi (taro) {
processApis(taro, has, {
needPromiseApis,
modifyApis (apis) {
// fix https://github.com/NervJS/taro/issues/9899
apis.delete('lanDebug')
},
transformMeta (api: string, options: Record<string, any>) {
if (api === 'showShareMenu') {
options.menus = options.showShareItems?.map(item => item === 'wechatFriends' ? 'shareAppMessage' : item === 'wechatMoment' ? 'shareTimeline' : item)
}

return {
key: api,
options
}
}
})
taro.cloud = has.cloud
taro.getTabBar = function (pageCtx) {
if (typeof pageCtx?.getTabBar === 'function') {
return pageCtx.getTabBar()?.$taroInstances
}
}
}
17 changes: 17 additions & 0 deletions packages/taro-platform-ascf/src/components-react.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For React.createElement's type
export * from '@tarojs/components/mini'
export const Editor = 'editor'
export const MatchMedia = 'match-media'
export const FunctionalPageNavigator = 'functional-page-navigator'
export const LivePusher = 'live-pusher'
export const OfficialAccount = 'official-account'
export const OpenData = 'open-data'
export const NavigationBar = 'navigation-bar'
export const PageMeta = 'page-meta'
export const VoipRoom = 'voip-room'
export const AdCustom = 'ad-custom'
export const PageContainer = 'page-container'
export const ShareElement = 'share-element'
export const KeyboardAccessory = 'keyboard-accessory'
export const RootPortal = 'root-portal'
export const ChannelLive = 'channel-live'
Loading
Loading