@dcloudio/uni-quickapp-webview 0.0.1-nvue3.3030820220125001
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.
- package/LICENSE +202 -0
- package/build.json +42 -0
- package/dist/uni.api.esm.js +902 -0
- package/dist/uni.compiler.js +128 -0
- package/dist/uni.mp.esm.js +1129 -0
- package/package.json +34 -0
- package/src/api/index.ts +4 -0
- package/src/api/protocols.ts +7 -0
- package/src/api/shims.ts +18 -0
- package/src/compiler/index.ts +21 -0
- package/src/compiler/jsconfig.json +6 -0
- package/src/compiler/options.ts +74 -0
- package/src/compiler/project.config.json +35 -0
- package/src/compiler/utils.ts +59 -0
- package/src/platform/index.ts +3 -0
- package/src/runtime/index.ts +22 -0
- package/src/runtime/parseComponentOptions.ts +91 -0
- package/src/runtime/parsePageOptions.ts +10 -0
- package/tsconfig.json +13 -0
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
+
"version": "0.0.1-nvue3.3030820220125001",
|
|
4
|
+
"description": "uni-app quickapp-webview",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/dcloudio/uni-app.git",
|
|
9
|
+
"directory": "packages/uni-quickapp-webview"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"uni-app": {
|
|
16
|
+
"name": "quickapp-webview",
|
|
17
|
+
"title": "快应用(Webview)版",
|
|
18
|
+
"apply": [
|
|
19
|
+
"quickapp-webview"
|
|
20
|
+
],
|
|
21
|
+
"main": "dist/uni.compiler.js"
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vue/compiler-core": "3.2.29"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@dcloudio/uni-cli-shared": "0.0.1-nvue3.3030820220125001",
|
|
29
|
+
"@dcloudio/uni-mp-vite": "0.0.1-nvue3.3030820220125001",
|
|
30
|
+
"@dcloudio/uni-mp-vue": "0.0.1-nvue3.3030820220125001",
|
|
31
|
+
"@dcloudio/uni-shared": "0.0.1-nvue3.3030820220125001",
|
|
32
|
+
"@vue/shared": "3.2.29"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/api/index.ts
ADDED
package/src/api/shims.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { initGetProvider } from '@dcloudio/uni-mp-core'
|
|
2
|
+
|
|
3
|
+
const providers = {
|
|
4
|
+
oauth: [] as string[],
|
|
5
|
+
share: [],
|
|
6
|
+
payment: [] as string[],
|
|
7
|
+
push: [],
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (qa.canIUse('getAccountProvider')) {
|
|
11
|
+
providers.oauth.push(qa.getAccountProvider() as string)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (qa.canIUse('getVendorPaymentProvider')) {
|
|
15
|
+
providers.payment.push(qa.getVendorPaymentProvider() as string)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const getProvider = initGetProvider(providers)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
import { ASSETS_INLINE_LIMIT } from '@dcloudio/uni-cli-shared'
|
|
3
|
+
import initMiniProgramPlugin from '@dcloudio/uni-mp-vite'
|
|
4
|
+
import { options } from './options'
|
|
5
|
+
|
|
6
|
+
const uniQuickappWebviewPlugin: Plugin = {
|
|
7
|
+
name: 'uni:quickapp-webview',
|
|
8
|
+
config() {
|
|
9
|
+
return {
|
|
10
|
+
define: {
|
|
11
|
+
__VUE_CREATED_DEFERRED__: true,
|
|
12
|
+
},
|
|
13
|
+
build: {
|
|
14
|
+
// css 中不支持引用本地资源
|
|
15
|
+
assetsInlineLimit: ASSETS_INLINE_LIMIT,
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default [uniQuickappWebviewPlugin, ...initMiniProgramPlugin(options)]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import type { CompilerOptions } from '@vue/compiler-core'
|
|
3
|
+
import {
|
|
4
|
+
MiniProgramCompilerOptions,
|
|
5
|
+
transformComponentLink,
|
|
6
|
+
transformRef,
|
|
7
|
+
} from '@dcloudio/uni-cli-shared'
|
|
8
|
+
import { UniMiniProgramPluginOptions } from '@dcloudio/uni-mp-vite'
|
|
9
|
+
|
|
10
|
+
import source from './jsconfig.json'
|
|
11
|
+
import { formatAppJson } from './utils'
|
|
12
|
+
|
|
13
|
+
export const compilerOptions: CompilerOptions = {
|
|
14
|
+
nodeTransforms: [transformRef, transformComponentLink],
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const miniProgram: MiniProgramCompilerOptions = {
|
|
18
|
+
class: {
|
|
19
|
+
array: true,
|
|
20
|
+
},
|
|
21
|
+
slot: {
|
|
22
|
+
fallbackContent: true,
|
|
23
|
+
dynamicSlotNames: true,
|
|
24
|
+
},
|
|
25
|
+
directive: 'qa:',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const projectConfigFilename = 'jsconfig.json'
|
|
29
|
+
|
|
30
|
+
export const options: UniMiniProgramPluginOptions = {
|
|
31
|
+
cdn: process.env.UNI_SUB_PLATFORM === 'quickapp-webview-huawei' ? 200 : 201,
|
|
32
|
+
vite: {
|
|
33
|
+
inject: {
|
|
34
|
+
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
|
|
35
|
+
},
|
|
36
|
+
alias: {
|
|
37
|
+
'uni-mp-runtime': path.resolve(__dirname, 'uni.mp.esm.js'),
|
|
38
|
+
},
|
|
39
|
+
copyOptions: {},
|
|
40
|
+
},
|
|
41
|
+
global: 'qa',
|
|
42
|
+
app: {
|
|
43
|
+
darkmode: false,
|
|
44
|
+
subpackages: true,
|
|
45
|
+
},
|
|
46
|
+
json: {
|
|
47
|
+
formatAppJson,
|
|
48
|
+
},
|
|
49
|
+
template: {
|
|
50
|
+
/* eslint-disable no-restricted-syntax */
|
|
51
|
+
...miniProgram,
|
|
52
|
+
filter: {
|
|
53
|
+
extname: '.qjs',
|
|
54
|
+
lang: 'qjs',
|
|
55
|
+
generate(filter, filename) {
|
|
56
|
+
if (filename) {
|
|
57
|
+
return `<qjs src="${filename}.qjs" module="${filter.name}"/>`
|
|
58
|
+
}
|
|
59
|
+
return `<qjs module="${filter.name}">
|
|
60
|
+
${filter.code}
|
|
61
|
+
</qjs>`
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
extname: '.qxml',
|
|
65
|
+
compilerOptions,
|
|
66
|
+
},
|
|
67
|
+
style: {
|
|
68
|
+
extname: '.css',
|
|
69
|
+
},
|
|
70
|
+
project: {
|
|
71
|
+
filename: projectConfigFilename,
|
|
72
|
+
source,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "项目配置文件。",
|
|
3
|
+
"packOptions": {
|
|
4
|
+
"ignore": []
|
|
5
|
+
},
|
|
6
|
+
"setting": {
|
|
7
|
+
"urlCheck": false,
|
|
8
|
+
"es6": true,
|
|
9
|
+
"postcss": false,
|
|
10
|
+
"minified": false,
|
|
11
|
+
"newFeature": true
|
|
12
|
+
},
|
|
13
|
+
"compileType": "miniprogram",
|
|
14
|
+
"libVersion": "",
|
|
15
|
+
"appid": "touristappid",
|
|
16
|
+
"projectname": "",
|
|
17
|
+
"condition": {
|
|
18
|
+
"search": {
|
|
19
|
+
"current": -1,
|
|
20
|
+
"list": []
|
|
21
|
+
},
|
|
22
|
+
"conversation": {
|
|
23
|
+
"current": -1,
|
|
24
|
+
"list": []
|
|
25
|
+
},
|
|
26
|
+
"game": {
|
|
27
|
+
"current": -1,
|
|
28
|
+
"list": []
|
|
29
|
+
},
|
|
30
|
+
"miniprogram": {
|
|
31
|
+
"current": -1,
|
|
32
|
+
"list": []
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { extend, hasOwn } from '@vue/shared'
|
|
3
|
+
|
|
4
|
+
interface AppJson {
|
|
5
|
+
appType: 'webapp'
|
|
6
|
+
minPlatformVersion: 1070
|
|
7
|
+
name: string
|
|
8
|
+
package: string
|
|
9
|
+
versionName: string
|
|
10
|
+
versionCode: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const properties = ['name', 'versionName', 'versionCode']
|
|
14
|
+
export function formatAppJson(
|
|
15
|
+
_appJson: Record<string, any>,
|
|
16
|
+
manifestJson: Record<string, any>,
|
|
17
|
+
_pagesJson: Record<string, any>
|
|
18
|
+
) {
|
|
19
|
+
const appJson = _appJson as AppJson & Record<string, any>
|
|
20
|
+
// 华为IDE V3.0.2+ 需要此属性,否则无法导入
|
|
21
|
+
appJson.appType = 'webapp'
|
|
22
|
+
appJson.minPlatformVersion = 1070
|
|
23
|
+
|
|
24
|
+
properties.forEach((name) => {
|
|
25
|
+
if (hasOwn(manifestJson, name)) {
|
|
26
|
+
appJson[name] = manifestJson[name]
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (!appJson.name) {
|
|
31
|
+
const inputDir = process.env.UNI_INPUT_DIR
|
|
32
|
+
let projectname = path.basename(inputDir)
|
|
33
|
+
if (projectname === 'src') {
|
|
34
|
+
projectname = path.basename(path.dirname(inputDir))
|
|
35
|
+
}
|
|
36
|
+
appJson.name = projectname
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!appJson.package) {
|
|
40
|
+
appJson.package = appJson.name
|
|
41
|
+
}
|
|
42
|
+
if (manifestJson['quickapp-webview']) {
|
|
43
|
+
extend(appJson, manifestJson['quickapp-webview'])
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
process.env.UNI_SUB_PLATFORM &&
|
|
48
|
+
manifestJson[process.env.UNI_SUB_PLATFORM]
|
|
49
|
+
) {
|
|
50
|
+
extend(appJson, manifestJson[process.env.UNI_SUB_PLATFORM])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!appJson.package) {
|
|
54
|
+
console.warn('manifest.json->quickapp-webview 缺少 package 配置')
|
|
55
|
+
}
|
|
56
|
+
if (!appJson.icon) {
|
|
57
|
+
console.warn('manifest.json->quickapp-webview 缺少 icon 配置')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventChannel } from '@dcloudio/uni-shared'
|
|
2
|
+
import {
|
|
3
|
+
initCreateApp,
|
|
4
|
+
initCreatePage,
|
|
5
|
+
initCreateComponent,
|
|
6
|
+
initCreateSubpackageApp,
|
|
7
|
+
} from '@dcloudio/uni-mp-core'
|
|
8
|
+
|
|
9
|
+
import '@dcloudio/uni-mp-polyfill'
|
|
10
|
+
|
|
11
|
+
import * as parsePageOptions from './parsePageOptions'
|
|
12
|
+
import * as parseComponentOptions from './parseComponentOptions'
|
|
13
|
+
|
|
14
|
+
export const createApp = initCreateApp()
|
|
15
|
+
export const createPage = initCreatePage(parsePageOptions)
|
|
16
|
+
export const createComponent = initCreateComponent(parseComponentOptions)
|
|
17
|
+
export const createSubpackageApp = initCreateSubpackageApp()
|
|
18
|
+
;(qa as any).EventChannel = EventChannel
|
|
19
|
+
;(qa as any).createApp = (global as any).createApp = createApp
|
|
20
|
+
;(qa as any).createPage = createPage
|
|
21
|
+
;(qa as any).createComponent = createComponent
|
|
22
|
+
;(qa as any).createSubpackageApp = createSubpackageApp
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ComponentPublicInstance } from 'vue'
|
|
2
|
+
import { MPComponentInstance } from '@dcloudio/uni-mp-core'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
instances,
|
|
6
|
+
initProvide,
|
|
7
|
+
initInjections,
|
|
8
|
+
} from '@dcloudio/uni-mp-toutiao'
|
|
9
|
+
import { ON_READY } from '@dcloudio/uni-shared'
|
|
10
|
+
|
|
11
|
+
export { mocks, isPage } from '@dcloudio/uni-mp-baidu'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
parseComponent as parse,
|
|
15
|
+
initComponentLifetimes as initLifetimes,
|
|
16
|
+
} from '@dcloudio/uni-mp-toutiao'
|
|
17
|
+
|
|
18
|
+
interface RelationOptions {
|
|
19
|
+
nodeId: string
|
|
20
|
+
webviewId: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function initRelation(mpInstance: MPComponentInstance) {
|
|
24
|
+
// triggerEvent 后,接收事件时机特别晚,已经到了 ready 之后
|
|
25
|
+
const nodeId = mpInstance.nodeId + ''
|
|
26
|
+
const webviewId = (mpInstance as any).pageinstance.__pageId__ + ''
|
|
27
|
+
instances[webviewId + '_' + nodeId] = mpInstance.$vm!
|
|
28
|
+
mpInstance.triggerEvent('__l', {
|
|
29
|
+
nodeId,
|
|
30
|
+
webviewId,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function handleLink(
|
|
35
|
+
this: MPComponentInstance,
|
|
36
|
+
{
|
|
37
|
+
detail: { nodeId, webviewId },
|
|
38
|
+
}: {
|
|
39
|
+
detail: RelationOptions
|
|
40
|
+
}
|
|
41
|
+
) {
|
|
42
|
+
const vm = instances[webviewId + '_' + nodeId] as ComponentPublicInstance & {
|
|
43
|
+
_$childVues?: [Function, Function][]
|
|
44
|
+
}
|
|
45
|
+
if (!vm) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
let parentVm = instances[
|
|
49
|
+
webviewId + '_' + (vm.$scope as any).ownerId
|
|
50
|
+
] as ComponentPublicInstance & {
|
|
51
|
+
_$childVues?: [Function, Function][]
|
|
52
|
+
}
|
|
53
|
+
if (!parentVm) {
|
|
54
|
+
parentVm = this.$vm!
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vm.$.parent = parentVm.$
|
|
58
|
+
|
|
59
|
+
const createdVm = function () {
|
|
60
|
+
if (__VUE_OPTIONS_API__) {
|
|
61
|
+
;(parentVm as any).$children.push(vm)
|
|
62
|
+
const parent = parentVm.$ as any
|
|
63
|
+
;(vm.$ as any).provides = parent
|
|
64
|
+
? parent.provides
|
|
65
|
+
: Object.create(parent.appContext.provides)
|
|
66
|
+
initInjections(vm)
|
|
67
|
+
initProvide(vm)
|
|
68
|
+
}
|
|
69
|
+
vm.$callCreatedHook()
|
|
70
|
+
}
|
|
71
|
+
const mountedVm = function () {
|
|
72
|
+
// 处理当前 vm 子
|
|
73
|
+
if (vm._$childVues) {
|
|
74
|
+
vm._$childVues.forEach(([createdVm]) => createdVm())
|
|
75
|
+
vm._$childVues.forEach(([, mountedVm]) => mountedVm())
|
|
76
|
+
delete vm._$childVues
|
|
77
|
+
}
|
|
78
|
+
vm.$callHook('mounted')
|
|
79
|
+
vm.$callHook(ON_READY)
|
|
80
|
+
}
|
|
81
|
+
// 当 parentVm 已经 mounted 时,直接触发,否则延迟
|
|
82
|
+
if (!parentVm || parentVm.$.isMounted) {
|
|
83
|
+
createdVm()
|
|
84
|
+
mountedVm()
|
|
85
|
+
} else {
|
|
86
|
+
;(parentVm._$childVues || (parentVm._$childVues = [])).push([
|
|
87
|
+
createdVm,
|
|
88
|
+
mountedVm,
|
|
89
|
+
])
|
|
90
|
+
}
|
|
91
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"resolveJsonModule": true,
|
|
5
|
+
"paths": {
|
|
6
|
+
"@dcloudio/*": ["packages/*/src"],
|
|
7
|
+
"@dcloudio/uni-platform": [
|
|
8
|
+
"packages/uni-quickapp-webview/src/platform/index.ts"
|
|
9
|
+
],
|
|
10
|
+
"@dcloudio/uni-mp-polyfill": ["packages/uni-mp-core/src/runtime/polyfill"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|