Skip to content

Commit 2a72e89

Browse files
ext.wuguorui1ext.wuguorui1
authored andcommitted
Taro-ascf
1 parent ac2dfa4 commit 2a72e89

File tree

20 files changed

+1028
-5
lines changed

20 files changed

+1028
-5
lines changed

packages/shared/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export enum PLATFORM_TYPE {
22
MINI = 'mini',
3+
ASCF = 'ascf',
34
WEB = 'web',
45
RN = 'rn',
56
HARMONY = 'harmony',
@@ -17,6 +18,9 @@ export const PLATFORM_CONFIG_MAP = {
1718
harmony: {
1819
type: PLATFORM_TYPE.HARMONY
1920
},
21+
ascf: {
22+
type: PLATFORM_TYPE.ASCF
23+
},
2024
mini: {
2125
type: PLATFORM_TYPE.MINI
2226
},

packages/taro-api/src/env.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const ENV_TYPE = {
2+
ASCF: 'ASCF',
23
WEAPP: 'WEAPP',
34
SWAN: 'SWAN',
45
ALIPAY: 'ALIPAY',
@@ -35,6 +36,8 @@ export function getEnv () {
3536
return ENV_TYPE.HARMONY
3637
} else if (process.env.TARO_ENV === 'quickapp') {
3738
return ENV_TYPE.QUICKAPP
39+
} else if (process.env.TARO_ENV === 'ascf') {
40+
return ENV_TYPE.ASCF
3841
} else {
3942
return process.env.TARO_ENV || 'Unknown'
4043
}

packages/taro-cli/src/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default class CLI {
118118
// 针对不同的内置平台注册对应的端平台插件
119119
switch (platform) {
120120
case 'weapp':
121+
case 'ascf':
121122
case 'alipay':
122123
case 'swan':
123124
case 'tt':
@@ -155,7 +156,7 @@ export default class CLI {
155156
plugin = args.plugin
156157
platform = 'plugin'
157158
kernel.optsPlugins.push(path.resolve(platformsPath, 'plugin.js'))
158-
if (plugin === 'weapp' || plugin === 'alipay' || plugin === 'jd') {
159+
if (plugin === 'ascf' || plugin === 'weapp' || plugin === 'alipay' || plugin === 'jd') {
159160
kernel.optsPlugins.push(`@tarojs/plugin-platform-${plugin}`)
160161
}
161162
}

packages/taro-cli/src/presets/platforms/plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ export default (ctx: IPluginContext) => {
1616
_
1717
} = ctx.runOpts
1818
const { chalk, PLATFORMS } = ctx.helper
19-
const { WEAPP, ALIPAY, JD } = PLATFORMS
19+
const { ASCF, WEAPP, ALIPAY, JD } = PLATFORMS
2020
const typeMap = {
21+
[ASCF]: 'ASCF',
2122
[JD]: '京东',
2223
[WEAPP]: '微信',
2324
[ALIPAY]: '支付宝'
2425
}
2526
const { plugin, isWatch } = options
26-
if (plugin !== WEAPP && plugin !== ALIPAY && plugin !== JD) {
27-
console.log(chalk.red('目前插件编译仅支持 微信/支付宝/京东 小程序!'))
27+
if (plugin !== ASCF && plugin !== WEAPP && plugin !== ALIPAY && plugin !== JD) {
28+
console.log(chalk.red('目前插件编译仅支持 ASCF/微信/支付宝/京东 小程序!'))
2829
return
2930
}
3031
console.log(chalk.green(`开始编译${typeMap[plugin]}小程序插件`))

packages/taro-helper/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const REG_IMAGE = /\.(png|jpe?g|gif|bpm|svg|webp)(\?.*)?$/
103103
export const REG_FONT = /\.(woff2?|eot|ttf|otf)(\?.*)?$/
104104
export const REG_JSON = /\.json(\?.*)?$/
105105
export const REG_UX = /\.ux(\?.*)?$/
106-
export const REG_TEMPLATE = /\.(wxml|axml|ttml|qml|swan|jxml)(\?.*)?$/
106+
export const REG_TEMPLATE = /\.(hxml|wxml|axml|ttml|qml|swan|jxml)(\?.*)?$/
107107
export const REG_WXML_IMPORT = /<import(.*)?src=(?:(?:'([^']*)')|(?:"([^"]*)"))/gi
108108
export const REG_URL =
109109
/^(?:(?:(?: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
@@ -177,6 +177,7 @@ export const UPDATE_PACKAGE_LIST = [
177177
'@tarojs/taroize',
178178
'@tarojs/plugin-inject',
179179
'@tarojs/plugin-platform-weapp',
180+
'@tarojs/plugin-platform-ascf',
180181
'@tarojs/plugin-platform-alipay',
181182
'@tarojs/plugin-platform-swan',
182183
'@tarojs/plugin-platform-tt',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@tarojs/plugin-platform-ascf`
2+
3+
Taro 插件。用于支持编译为ascf。
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = require('./dist/index.js').default
2+
3+
module.exports.default = module.exports
4+
module.exports.AscfApp = require('./dist/index.js').AscfApp
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@tarojs/plugin-platform-ascf",
3+
"version": "4.0.10",
4+
"description": "ascf平台插件",
5+
"author": "ascf",
6+
"license": "MIT",
7+
"main": "index.js",
8+
"types": "dist/types/index.d.ts",
9+
"keywords": [
10+
"taro"
11+
],
12+
"files": [
13+
"index.js",
14+
"dist"
15+
],
16+
"scripts": {
17+
"prod": "pnpm run build",
18+
"build": "rollup -c",
19+
"dev": "rollup -c -w"
20+
},
21+
"bugs": {
22+
"url": "https://github.com/NervJS/taro/issues"
23+
},
24+
"repository": {
25+
"type": "git",
26+
"url": "git+https://github.com/NervJS/taro.git"
27+
},
28+
"engines": {
29+
"node": ">= 18"
30+
},
31+
"devDependencies": {
32+
"@tarojs/components": "workspace:*",
33+
"@tarojs/service": "workspace:*",
34+
"@tarojs/shared": "workspace:*"
35+
},
36+
"peerDependencies": {
37+
"@tarojs/service": "workspace:*",
38+
"@tarojs/shared": "workspace:*"
39+
}
40+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import * as path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
4+
import { nodeResolve } from '@rollup/plugin-node-resolve'
5+
import typescript from '@rollup/plugin-typescript'
6+
import externals from 'rollup-plugin-node-externals'
7+
8+
const __filename = fileURLToPath(new URL(import.meta.url))
9+
const cwd = path.dirname(__filename)
10+
11+
const base = {
12+
plugins: [
13+
nodeResolve(),
14+
externals({
15+
peerDeps: true,
16+
}),
17+
typescript()
18+
]
19+
}
20+
21+
// 供 CLI 编译时使用的 Taro 插件入口
22+
const compileConfig = {
23+
input: path.join(cwd, 'src/index.ts'),
24+
output: {
25+
file: path.join(cwd, 'dist/index.js'),
26+
format: 'cjs',
27+
sourcemap: true,
28+
exports: 'named'
29+
},
30+
...base
31+
}
32+
33+
// 供 Loader 使用的运行时入口
34+
const runtimeConfig = {
35+
input: path.join(cwd, 'src/runtime.ts'),
36+
output: {
37+
file: path.join(cwd, 'dist/runtime.js'),
38+
format: 'es',
39+
sourcemap: true
40+
},
41+
...base
42+
}
43+
44+
// 供继承的包使用,为了能 tree-shaking
45+
const runtimeUtilsConfig = {
46+
input: path.join(cwd, 'src/runtime-utils.ts'),
47+
output: {
48+
file: path.join(cwd, 'dist/runtime-utils.js'),
49+
format: 'es',
50+
sourcemap: true
51+
},
52+
...base
53+
}
54+
55+
// React 下 webpack 会 alias @tarojs/components 为此文件
56+
const otherConfig = {
57+
input: path.join(cwd, 'src/components-react.ts'),
58+
output: {
59+
file: path.join(cwd, 'dist/components-react.js'),
60+
format: 'es',
61+
sourcemap: true
62+
},
63+
...base
64+
}
65+
66+
export default [compileConfig, runtimeConfig, runtimeUtilsConfig, otherConfig]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export const needPromiseApis = new Set([
2+
'addFileToFavorites',
3+
'addVideoToFavorites',
4+
'authPrivateMessage',
5+
'checkIsAddedToMyMiniProgram',
6+
'chooseContact',
7+
'cropImage',
8+
'disableAlertBeforeUnload',
9+
'editImage',
10+
'enableAlertBeforeUnload',
11+
'getBackgroundFetchData',
12+
'getChannelsLiveInfo',
13+
'getChannelsLiveNoticeInfo',
14+
'getFuzzyLocation',
15+
'getGroupEnterInfo',
16+
'getLocalIPAddress',
17+
'getShareInfo',
18+
'getUserProfile',
19+
'getWeRunData',
20+
'join1v1Chat',
21+
'openChannelsActivity',
22+
'openChannelsEvent',
23+
'openChannelsLive',
24+
'openChannelsUserProfile',
25+
'openCustomerServiceChat',
26+
'openVideoEditor',
27+
'saveFileToDisk',
28+
'scanItem',
29+
'setEnable1v1Chat',
30+
'setWindowSize',
31+
'sendBizRedPacket',
32+
'startFacialRecognitionVerify',
33+
])

0 commit comments

Comments
 (0)