forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
584 changed files
with
241,425 additions
and
4,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
src/core/helpers/html-parser.js | ||
src/core/helpers/html-parser.js | ||
src/platforms/app-plus-nvue/runtime | ||
build/rollup-plugin-require-context | ||
packages/*/packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
.project | ||
unpackage/ | ||
.vscode/ | ||
.vscode/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
module.exports = { | ||
ignore: [ | ||
"./packages", | ||
], | ||
presets: [ | ||
["@vue/app", { | ||
useBuiltIns: "entry" | ||
}] | ||
] | ||
const config = { | ||
ignore: [ | ||
"./packages", | ||
], | ||
presets: [ | ||
["@vue/app", { | ||
useBuiltIns: "entry" | ||
}] | ||
], | ||
plugins: [require('./lib/babel-plugin-uni-api/index.js')] | ||
} | ||
|
||
if (process.env.NODE_ENV === 'test') { | ||
delete config.ignore | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const apis = require('../lib/apis') | ||
|
||
const AUTO_LOADS = [ | ||
'upx2px', | ||
'canIUse', | ||
|
||
'getSystemInfo', | ||
'getSystemInfoSync', | ||
|
||
'navigateTo', | ||
'redirectTo', | ||
'switchTab', | ||
'reLaunch', | ||
'navigateBack' | ||
] | ||
|
||
const TOAST_DEPS = [ | ||
['/platforms/h5/components/app/popup/toast.vue', 'Toast'], | ||
['/platforms/h5/components/app/popup/mixins/toast.js', 'ToastMixin'] | ||
] | ||
|
||
// TODO 暂不考虑 head,tabBar 的动态拆分 | ||
const DEPS = { | ||
'chooseLocation': [ | ||
['/platforms/h5/components/system-routes/choose-location/index.vue', 'ChooseLocation'] | ||
], | ||
'openLocation': [ | ||
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation'] | ||
], | ||
'previewImage': [ | ||
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage'] | ||
], | ||
'showToast': TOAST_DEPS, | ||
'hideToast': TOAST_DEPS, | ||
'showLoading': TOAST_DEPS, | ||
'hideLoading': TOAST_DEPS, | ||
'showModal': [ | ||
['/platforms/h5/components/app/popup/modal.vue', 'Modal'], | ||
['/platforms/h5/components/app/popup/mixins/modal.js', 'ModalMixin'] | ||
], | ||
'showActionSheet': [ | ||
['/platforms/h5/components/app/popup/actionSheet.vue', 'ActionSheet'], | ||
['/platforms/h5/components/app/popup/mixins/action-sheet.js', 'ActionSheetMixin'] | ||
], | ||
'createSelectorQuery': [ | ||
['/core/view/bridge/subscribe/api/request-component-info.js', 'requestComponentInfo'] | ||
], | ||
'createIntersectionObserver': [ | ||
['/core/view/bridge/subscribe/api/request-component-observer.js', 'requestComponentObserver'], | ||
['/core/view/bridge/subscribe/api/request-component-observer.js', 'destroyComponentObserver'] | ||
] | ||
} | ||
|
||
// 检查依赖文件是否存在 | ||
Object.keys(DEPS).reduce(function (depFiles, name) { | ||
DEPS[name].forEach(function (dep) { | ||
depFiles.add(dep[0]) | ||
}) | ||
return depFiles | ||
}, new Set()).forEach(file => { | ||
if (!fs.existsSync(path.join(__dirname, '../src', file))) { | ||
console.error(file + ' 不存在') | ||
process.exit(0) | ||
} | ||
}) | ||
|
||
function parseApiManifestDeps (manifest, protocol) { | ||
// 解析 platform 依赖 | ||
Object.keys(manifest).forEach(name => { | ||
const deps = manifest[name][1] | ||
if (deps.length) { | ||
deps.forEach(dep => { | ||
if (manifest[dep[1]]) { | ||
dep[0] = manifest[dep[1]][0] | ||
} else { | ||
console.error(`依赖模块[${dep[1]}]不存在,删除 ${name} 接口\n`) | ||
delete manifest[name] | ||
} | ||
}) | ||
} | ||
}) | ||
// 解析 protocol 依赖 | ||
Object.keys(manifest).forEach(name => { | ||
const deps = manifest[name][1] | ||
if (protocol[name]) { | ||
deps.push([protocol[name], name]) | ||
} else { | ||
console.warn(`${name} 缺少 protocol`) | ||
} | ||
}) | ||
// 追加默认依赖 | ||
Object.keys(DEPS).forEach(name => { | ||
if (manifest[name]) { | ||
manifest[name][1].push(...DEPS[name]) | ||
} else { | ||
console.error(`缺少 ${name}`) | ||
} | ||
}) | ||
// 设置自动加载标记 | ||
AUTO_LOADS.forEach(name => { | ||
if (manifest[name]) { | ||
manifest[name][2] = true | ||
} else { | ||
console.error(`缺少 ${name}`) | ||
} | ||
}) | ||
} | ||
|
||
module.exports = { | ||
generateApiManifest (manifest, protocol) { | ||
if (!Object.keys(manifest).length) { | ||
throw new Error('api manifest.json 生成失败') | ||
} | ||
parseApiManifestDeps(manifest, protocol) | ||
|
||
const manifestJson = Object.create(null) | ||
const todoApis = [] | ||
apis.forEach(name => { | ||
if (manifest[name]) { | ||
manifestJson[name] = manifest[name] | ||
} else { | ||
todoApis.push(name) | ||
} | ||
}) | ||
|
||
if (todoApis.length) { | ||
console.log('\n') | ||
console.warn(`${process.env.UNI_PLATFORM} 平台缺少以下 API 实现(共 ${todoApis.length} 个)`) | ||
todoApis.forEach(name => { | ||
console.warn(name) | ||
}) | ||
} | ||
|
||
fs.writeFileSync(path.resolve(__dirname, '../packages/uni-' + process.env.UNI_PLATFORM + '/manifest.json'), | ||
JSON.stringify(manifestJson, null, 4) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const path = require('path') | ||
const alias = require('rollup-plugin-alias') | ||
const replace = require('rollup-plugin-replace') | ||
const nodeResolve = require('rollup-plugin-node-resolve') | ||
const commonjs = require('rollup-plugin-commonjs') | ||
const requireContext = require('../lib/rollup-plugin-require-context') | ||
|
||
let input = 'src/platforms/app-plus/service/framework/create-instance-context.js' | ||
|
||
const output = { | ||
file: 'packages/uni-app-plus-nvue/dist/index.js', | ||
format: 'es' | ||
} | ||
|
||
const external = [] | ||
|
||
if (process.env.UNI_SERVICE === 'legacy') { | ||
input = 'src/platforms/app-plus-nvue/services/index.legacy.js' | ||
output.file = 'packages/uni-app-plus-nvue/dist/index.legacy.js' | ||
} else { | ||
input = 'src/platforms/app-plus/service/index.js' | ||
output.file = 'packages/uni-app-plus-nvue/dist/index.js' | ||
output.format = 'iife' | ||
output.name = 'serviceContext' | ||
output.banner = | ||
`export function createServiceContext(Vue, weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge,instanceContext){ | ||
var localStorage = plus.storage | ||
var setTimeout = instanceContext.setTimeout | ||
var clearTimeout = instanceContext.clearTimeout | ||
var setInterval = instanceContext.setInterval | ||
var clearInterval = instanceContext.clearInterval | ||
` | ||
output.footer = | ||
` | ||
var uni = serviceContext.uni | ||
var getApp = serviceContext.getApp | ||
var getCurrentPages = serviceContext.getCurrentPages | ||
var __registerPage = serviceContext.__registerPage | ||
return serviceContext \n} | ||
` | ||
} | ||
|
||
const resolve = dir => path.resolve(__dirname, '../', dir) | ||
|
||
module.exports = { | ||
input, | ||
output, | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs(), | ||
requireContext(), | ||
alias({ | ||
'uni-core': resolve('src/core'), | ||
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM), | ||
'uni-platforms': resolve('src/platforms'), | ||
'uni-shared': resolve('src/shared/index.js'), | ||
'uni-helpers': resolve('src/core/helpers'), | ||
'uni-invoke-api': resolve('src/platforms/app-plus/service/api'), | ||
'uni-service-api': resolve('src/core/service/platform-api'), | ||
'uni-api-protocol': resolve('src/core/helpers/protocol') | ||
}), | ||
replace({ | ||
__GLOBAL__: 'getGlobalUni()', | ||
__PLATFORM__: JSON.stringify('app-plus'), | ||
__PLATFORM_TITLE__: 'app-plus-nvue' | ||
}) | ||
], | ||
external | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
input: 'packages/uni-stat/src/index.js', | ||
output: { | ||
file: 'packages/uni-stat/dist/index.js', | ||
format: 'es' | ||
}, | ||
external: ['vue', '../package.json'], | ||
plugins: [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.