@dcloudio/uni-quickapp-webview 3.0.0-alpha-3021320211109003 → 3.0.0-alpha-3021320211117002

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.
@@ -3,7 +3,6 @@
3
3
  var uniCliShared = require('@dcloudio/uni-cli-shared');
4
4
  var initMiniProgramPlugin = require('@dcloudio/uni-mp-vite');
5
5
  var path = require('path');
6
- var uniShared = require('@dcloudio/uni-shared');
7
6
  var shared = require('@vue/shared');
8
7
 
9
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -57,8 +56,6 @@ function formatAppJson(_appJson, manifestJson, _pagesJson) {
57
56
  }
58
57
 
59
58
  const compilerOptions = {
60
- isNativeTag: uniShared.isNativeTag,
61
- isCustomElement: uniShared.isCustomElement,
62
59
  nodeTransforms: [uniCliShared.transformRef, uniCliShared.transformComponentLink],
63
60
  };
64
61
  const miniProgram = {
@@ -1,6 +1,71 @@
1
1
  import { isPlainObject, isArray, hasOwn, isFunction, extend, camelize, isObject } from '@vue/shared';
2
2
  import { injectHook, ref } from 'vue';
3
3
 
4
+ const ON_READY$1 = 'onReady';
5
+
6
+ class EventChannel$1 {
7
+ constructor(id, events) {
8
+ this.id = id;
9
+ this.listener = {};
10
+ this.emitCache = {};
11
+ if (events) {
12
+ Object.keys(events).forEach((name) => {
13
+ this.on(name, events[name]);
14
+ });
15
+ }
16
+ }
17
+ emit(eventName, ...args) {
18
+ const fns = this.listener[eventName];
19
+ if (!fns) {
20
+ return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args);
21
+ }
22
+ fns.forEach((opt) => {
23
+ opt.fn.apply(opt.fn, args);
24
+ });
25
+ this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
26
+ }
27
+ on(eventName, fn) {
28
+ this._addListener(eventName, 'on', fn);
29
+ this._clearCache(eventName);
30
+ }
31
+ once(eventName, fn) {
32
+ this._addListener(eventName, 'once', fn);
33
+ this._clearCache(eventName);
34
+ }
35
+ off(eventName, fn) {
36
+ const fns = this.listener[eventName];
37
+ if (!fns) {
38
+ return;
39
+ }
40
+ if (fn) {
41
+ for (let i = 0; i < fns.length;) {
42
+ if (fns[i].fn === fn) {
43
+ fns.splice(i, 1);
44
+ i--;
45
+ }
46
+ i++;
47
+ }
48
+ }
49
+ else {
50
+ delete this.listener[eventName];
51
+ }
52
+ }
53
+ _clearCache(eventName) {
54
+ const cacheArgs = this.emitCache[eventName];
55
+ if (cacheArgs) {
56
+ for (; cacheArgs.length > 0;) {
57
+ this.emit.apply(this, [eventName, ...cacheArgs.shift()]);
58
+ }
59
+ }
60
+ }
61
+ _addListener(eventName, type, fn) {
62
+ (this.listener[eventName] || (this.listener[eventName] = [])).push({
63
+ fn,
64
+ type,
65
+ });
66
+ }
67
+ }
68
+
4
69
  // quickapp-webview 不能使用 default 作为插槽名称
5
70
  const SLOT_DEFAULT_NAME = 'd';
6
71
  // lifecycle
@@ -298,7 +363,7 @@ function parseApp(instance, parseAppOptions) {
298
363
  });
299
364
  injectAppLaunchHooks(internalInstance);
300
365
  ctx.globalData = this.globalData;
301
- instance.$callHook(ON_LAUNCH, extend({ app: this }, options));
366
+ instance.$callHook(ON_LAUNCH, extend({ app: { mixin: internalInstance.appContext.app.mixin } }, options));
302
367
  },
303
368
  };
304
369
  initLocale(instance);
@@ -319,6 +384,43 @@ function initCreateApp(parseAppOptions) {
319
384
  return App(parseApp(vm, parseAppOptions));
320
385
  };
321
386
  }
387
+ function initCreateSubpackageApp(parseAppOptions) {
388
+ return function createApp(vm) {
389
+ const appOptions = parseApp(vm, parseAppOptions);
390
+ const app = getApp({
391
+ allowDefault: true,
392
+ });
393
+ vm.$.ctx.$scope = app;
394
+ const globalData = app.globalData;
395
+ if (globalData) {
396
+ Object.keys(appOptions.globalData).forEach((name) => {
397
+ if (!hasOwn(globalData, name)) {
398
+ globalData[name] = appOptions.globalData[name];
399
+ }
400
+ });
401
+ }
402
+ Object.keys(appOptions).forEach((name) => {
403
+ if (!hasOwn(app, name)) {
404
+ app[name] = appOptions[name];
405
+ }
406
+ });
407
+ if (isFunction(appOptions.onShow) && qa.onAppShow) {
408
+ qa.onAppShow((args) => {
409
+ vm.$callHook('onShow', args);
410
+ });
411
+ }
412
+ if (isFunction(appOptions.onHide) && qa.onAppHide) {
413
+ qa.onAppHide((args) => {
414
+ vm.$callHook('onHide', args);
415
+ });
416
+ }
417
+ if (isFunction(appOptions.onLaunch)) {
418
+ const args = qa.getLaunchOptionsSync && qa.getLaunchOptionsSync();
419
+ vm.$callHook('onLaunch', args);
420
+ }
421
+ return App(appOptions);
422
+ };
423
+ }
322
424
  function initLocale(appVm) {
323
425
  const locale = ref(qa.getSystemInfoSync().language || 'zh-Hans');
324
426
  Object.defineProperty(appVm, '$locale', {
@@ -838,7 +940,7 @@ function initLifetimes(lifetimesOptions) {
838
940
  }
839
941
  this.$vm.$callCreatedHook();
840
942
  this.$vm.$callHook('mounted');
841
- this.$vm.$callHook(ON_READY);
943
+ this.$vm.$callHook(ON_READY$1);
842
944
  }
843
945
  else {
844
946
  this.is && console.warn(this.is + ' is not ready');
@@ -903,7 +1005,7 @@ function handleLink({ detail: { nodeId, webviewId }, }) {
903
1005
  delete vm._$childVues;
904
1006
  }
905
1007
  vm.$callHook('mounted');
906
- vm.$callHook(ON_READY);
1008
+ vm.$callHook(ON_READY$1);
907
1009
  };
908
1010
  // 当 parentVm 已经 mounted 时,直接触发,否则延迟
909
1011
  if (!parentVm || parentVm.$.isMounted) {
@@ -919,31 +1021,33 @@ function handleLink({ detail: { nodeId, webviewId }, }) {
919
1021
  }
920
1022
 
921
1023
  var parseComponentOptions = /*#__PURE__*/Object.freeze({
922
- __proto__: null,
923
- initRelation: initRelation,
924
- handleLink: handleLink,
925
- mocks: mocks,
926
- isPage: isPage,
927
- parse: parse,
928
- initLifetimes: initLifetimes$1
1024
+ __proto__: null,
1025
+ initRelation: initRelation,
1026
+ handleLink: handleLink,
1027
+ mocks: mocks,
1028
+ isPage: isPage,
1029
+ parse: parse,
1030
+ initLifetimes: initLifetimes$1
929
1031
  });
930
1032
 
931
1033
  var parsePageOptions = /*#__PURE__*/Object.freeze({
932
- __proto__: null,
933
- mocks: mocks,
934
- isPage: isPage,
935
- initRelation: initRelation,
936
- handleLink: handleLink,
937
- parse: parse,
938
- initLifetimes: initLifetimes
1034
+ __proto__: null,
1035
+ mocks: mocks,
1036
+ isPage: isPage,
1037
+ initRelation: initRelation,
1038
+ handleLink: handleLink,
1039
+ parse: parse,
1040
+ initLifetimes: initLifetimes
939
1041
  });
940
1042
 
941
1043
  const createApp = initCreateApp();
942
1044
  const createPage = initCreatePage(parsePageOptions);
943
1045
  const createComponent = initCreateComponent(parseComponentOptions);
944
- qa.EventChannel = EventChannel;
1046
+ const createSubpackageApp = initCreateSubpackageApp();
1047
+ qa.EventChannel = EventChannel$1;
945
1048
  qa.createApp = global.createApp = createApp;
946
1049
  qa.createPage = createPage;
947
- qa.createComponent = createComponent;
1050
+ qa.createComponent = createComponent;
1051
+ qa.createSubpackageApp = createSubpackageApp;
948
1052
 
949
- export { createApp, createComponent, createPage };
1053
+ export { createApp, createComponent, createPage, createSubpackageApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-quickapp-webview",
3
- "version": "3.0.0-alpha-3021320211109003",
3
+ "version": "3.0.0-alpha-3021320211117002",
4
4
  "description": "uni-app quickapp-webview",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -22,11 +22,13 @@
22
22
  },
23
23
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
24
24
  "devDependencies": {
25
- "@vue/compiler-core": "^3.2.21"
25
+ "@vue/compiler-core": "3.2.22"
26
26
  },
27
27
  "dependencies": {
28
- "@dcloudio/uni-cli-shared": "3.0.0-alpha-3021320211109003",
29
- "@dcloudio/uni-mp-vite": "3.0.0-alpha-3021320211109003",
30
- "@dcloudio/uni-mp-vue": "3.0.0-alpha-3021320211109003"
28
+ "@dcloudio/uni-cli-shared": "3.0.0-alpha-3021320211117002",
29
+ "@dcloudio/uni-mp-vite": "3.0.0-alpha-3021320211117002",
30
+ "@dcloudio/uni-mp-vue": "3.0.0-alpha-3021320211117002",
31
+ "@dcloudio/uni-shared": "3.0.0-alpha-3021320211117002",
32
+ "@vue/shared": "3.2.22"
31
33
  }
32
34
  }
@@ -1,6 +1,5 @@
1
1
  import path from 'path'
2
2
  import type { CompilerOptions } from '@vue/compiler-core'
3
- import { isNativeTag, isCustomElement } from '@dcloudio/uni-shared'
4
3
  import {
5
4
  MiniProgramCompilerOptions,
6
5
  transformComponentLink,
@@ -12,8 +11,6 @@ import source from './jsconfig.json'
12
11
  import { formatAppJson } from './utils'
13
12
 
14
13
  export const compilerOptions: CompilerOptions = {
15
- isNativeTag,
16
- isCustomElement,
17
14
  nodeTransforms: [transformRef, transformComponentLink],
18
15
  }
19
16
 
@@ -3,6 +3,7 @@ import {
3
3
  initCreateApp,
4
4
  initCreatePage,
5
5
  initCreateComponent,
6
+ initCreateSubpackageApp,
6
7
  } from '@dcloudio/uni-mp-core'
7
8
 
8
9
  import '@dcloudio/uni-mp-polyfill'
@@ -13,7 +14,9 @@ import * as parseComponentOptions from './parseComponentOptions'
13
14
  export const createApp = initCreateApp()
14
15
  export const createPage = initCreatePage(parsePageOptions)
15
16
  export const createComponent = initCreateComponent(parseComponentOptions)
17
+ export const createSubpackageApp = initCreateSubpackageApp()
16
18
  ;(qa as any).EventChannel = EventChannel
17
19
  ;(qa as any).createApp = (global as any).createApp = createApp
18
20
  ;(qa as any).createPage = createPage
19
21
  ;(qa as any).createComponent = createComponent
22
+ ;(qa as any).createSubpackageApp = createSubpackageApp
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
+ "resolveJsonModule": true,
4
5
  "paths": {
5
6
  "@dcloudio/*": ["packages/*/src"],
6
7
  "@dcloudio/uni-platform": [