@dcloudio/uni-cli-shared 3.0.0-alpha-3090720231103001 → 3.0.0-alpha-3090820231110001

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.
@@ -1,5 +1,6 @@
1
1
  export declare const PUBLIC_DIR = "static";
2
2
  export declare const EXTNAME_JS: string[];
3
+ export declare const X_EXTNAME_JS: string[];
3
4
  export declare const EXTNAME_TS: string[];
4
5
  export declare const EXTNAME_VUE: string[];
5
6
  export declare const X_EXTNAME_VUE: string[];
package/dist/constants.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.X_EXTNAME_JS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
4
4
  exports.PUBLIC_DIR = 'static';
5
5
  exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
6
+ exports.X_EXTNAME_JS = ['.uts', ...exports.EXTNAME_JS];
6
7
  exports.EXTNAME_TS = ['.ts', '.tsx'];
7
8
  exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
8
9
  exports.X_EXTNAME_VUE = ['.uvue', '.vue'];
@@ -38,7 +39,7 @@ exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
38
39
  exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
39
40
  // 其他平台解析页面后缀的优先级
40
41
  exports.PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js'];
41
- exports.X_PAGE_EXTNAME = ['.vue', '.uvue', '.tsx', '.jsx', '.js'];
42
+ exports.X_PAGE_EXTNAME = ['.uvue', '.vue', '.tsx', '.jsx', '.js'];
42
43
  exports.X_PAGE_EXTNAME_APP = ['.uvue', '.tsx', '.jsx', '.js'];
43
44
  exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
44
45
  exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
@@ -1,4 +1,4 @@
1
1
  export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
2
- export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "weex" | "vue" | "vite";
2
+ export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "vue" | "weex" | "vite";
3
3
  export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
4
4
  export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
@@ -194,23 +194,28 @@ function normalizeSubpackageSubNVues(root, style = { navigationBar: {} }) {
194
194
  return style;
195
195
  }
196
196
  function normalizePageStyle(pagePath, pageStyle, platform) {
197
- const hasNVue = pagePath &&
198
- process.env.UNI_INPUT_DIR &&
199
- fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))
200
- ? true
201
- : undefined;
202
197
  let isNVue = false;
203
- if (hasNVue) {
204
- const hasVue = fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.vue'));
205
- if (hasVue) {
206
- if (platform === 'app') {
207
- if (process.env.UNI_NVUE_COMPILER !== 'vue') {
208
- isNVue = true;
198
+ if (process.env.UNI_APP_X === 'true') {
199
+ isNVue = undefined;
200
+ }
201
+ else {
202
+ const hasNVue = pagePath &&
203
+ process.env.UNI_INPUT_DIR &&
204
+ fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))
205
+ ? true
206
+ : undefined;
207
+ if (hasNVue) {
208
+ const hasVue = fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.vue'));
209
+ if (hasVue) {
210
+ if (platform === 'app') {
211
+ if (process.env.UNI_NVUE_COMPILER !== 'vue') {
212
+ isNVue = true;
213
+ }
209
214
  }
210
215
  }
211
- }
212
- else {
213
- isNVue = true;
216
+ else {
217
+ isNVue = true;
218
+ }
214
219
  }
215
220
  }
216
221
  if (pageStyle) {
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initPreContext = exports.getPreUVueContext = exports.getPreNVueContext = exports.getPreVueContext = void 0;
4
- const shared_1 = require("@vue/shared");
4
+ const extend = Object.assign;
5
+ const isString = (val) => typeof val === 'string';
6
+ const objectToString = Object.prototype.toString;
7
+ const toTypeString = (value) => objectToString.call(value);
8
+ const isPlainObject = (val) => toTypeString(val) === '[object Object]';
5
9
  const DEFAULT_KEYS = [
6
10
  'UNI_APP_X',
7
11
  'APP',
@@ -88,21 +92,21 @@ function initPreContext(platform, userPreContext, utsPlatform, isX) {
88
92
  defaultContext.WEB = true;
89
93
  }
90
94
  if (userPreContext) {
91
- if ((0, shared_1.isString)(userPreContext)) {
95
+ if (isString(userPreContext)) {
92
96
  try {
93
97
  userPreContext = JSON.parse(userPreContext);
94
98
  }
95
99
  catch (e) { }
96
100
  }
97
- if ((0, shared_1.isPlainObject)(userPreContext)) {
101
+ if (isPlainObject(userPreContext)) {
98
102
  Object.keys(userPreContext).forEach((key) => {
99
103
  defaultContext[normalizeKey(key)] = !!userPreContext[key];
100
104
  });
101
105
  }
102
106
  }
103
- (0, shared_1.extend)(preVueContext, defaultContext, vueContext);
104
- (0, shared_1.extend)(preNVueContext, defaultContext, nvueContext);
105
- (0, shared_1.extend)(preUVueContext, defaultContext, uvueContext);
107
+ extend(preVueContext, defaultContext, vueContext);
108
+ extend(preNVueContext, defaultContext, nvueContext);
109
+ extend(preUVueContext, defaultContext, uvueContext);
106
110
  }
107
111
  exports.initPreContext = initPreContext;
108
112
  function normalizeKey(name) {
@@ -0,0 +1,3 @@
1
+ import { Options } from 'unplugin-auto-import/types';
2
+ export type AutoImportOptions = Options;
3
+ export declare function initAutoImportOptions(platform: typeof process.env.UNI_UTS_PLATFORM, { imports, ...userOptions }: AutoImportOptions): AutoImportOptions;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initAutoImportOptions = void 0;
4
+ const uniPreset = {
5
+ from: '@dcloudio/uni-app',
6
+ imports: [
7
+ // uni-app lifecycle
8
+ // App and Page
9
+ 'onShow',
10
+ 'onHide',
11
+ // App
12
+ 'onAppShow',
13
+ 'onLaunch',
14
+ 'onError',
15
+ 'onThemeChange',
16
+ 'onKeyboardHeightChange',
17
+ 'onPageNotFound',
18
+ 'onUnhandledRejection',
19
+ 'onLastPageBackPress',
20
+ 'onExit',
21
+ // Page
22
+ 'onLoad',
23
+ 'onReady',
24
+ 'onUnload',
25
+ 'onResize',
26
+ 'onBackPress',
27
+ 'onPageScroll',
28
+ 'onTabItemTap',
29
+ 'onReachBottom',
30
+ 'onPullDownRefresh',
31
+ ],
32
+ };
33
+ const cloudPreset = {
34
+ '@dcloudio/uni-cloud': [['default', 'uniCloud']],
35
+ };
36
+ const vuePreset = {
37
+ from: 'vue',
38
+ imports: [
39
+ // vue lifecycle
40
+ 'onActivated',
41
+ 'onBeforeMount',
42
+ 'onBeforeUnmount',
43
+ 'onBeforeUpdate',
44
+ 'onErrorCaptured',
45
+ 'onDeactivated',
46
+ 'onMounted',
47
+ 'onServerPrefetch',
48
+ 'onUnmounted',
49
+ 'onUpdated',
50
+ // setup helpers
51
+ 'useAttrs',
52
+ 'useSlots',
53
+ // reactivity,
54
+ 'computed',
55
+ 'customRef',
56
+ 'isReadonly',
57
+ 'isRef',
58
+ 'isProxy',
59
+ 'isReactive',
60
+ 'markRaw',
61
+ 'reactive',
62
+ 'readonly',
63
+ 'ref',
64
+ 'shallowReactive',
65
+ 'shallowReadonly',
66
+ 'shallowRef',
67
+ 'triggerRef',
68
+ 'toRaw',
69
+ 'toRef',
70
+ 'toRefs',
71
+ 'toValue',
72
+ 'unref',
73
+ 'watch',
74
+ 'watchEffect',
75
+ 'watchPostEffect',
76
+ 'watchSyncEffect',
77
+ // component
78
+ 'defineComponent',
79
+ 'defineAsyncComponent',
80
+ 'getCurrentInstance',
81
+ 'h',
82
+ 'inject',
83
+ 'nextTick',
84
+ 'provide',
85
+ 'useCssModule',
86
+ 'createApp',
87
+ // effect scope
88
+ 'effectScope',
89
+ 'EffectScope',
90
+ 'getCurrentScope',
91
+ 'onScopeDispose',
92
+ // types 全部全局导入
93
+ ],
94
+ };
95
+ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
96
+ return {
97
+ ...userOptions,
98
+ include: [/\.[u]?ts$/, /\.[u]?vue$/, /\.[u]?vue\?vue/],
99
+ imports: imports.concat(
100
+ // app-android 平台暂不注入其他
101
+ platform === 'app-android' ? [] : [uniPreset, cloudPreset, vuePreset]),
102
+ dts: false,
103
+ };
104
+ }
105
+ exports.initAutoImportOptions = initAutoImportOptions;
@@ -34,3 +34,4 @@ export interface UniVitePlugin extends Plugin {
34
34
  export * from './utils';
35
35
  export * from './plugins';
36
36
  export * from './features';
37
+ export * from './autoImport';
@@ -19,3 +19,4 @@ exports.cssTarget = 'chrome53';
19
19
  __exportStar(require("./utils"), exports);
20
20
  __exportStar(require("./plugins"), exports);
21
21
  __exportStar(require("./features"), exports);
22
+ __exportStar(require("./autoImport"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3090720231103001",
3
+ "version": "3.0.0-alpha-3090820231110001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "@babel/core": "^7.21.3",
26
26
  "@babel/parser": "^7.16.4",
27
27
  "@babel/types": "^7.20.7",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3090720231103001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3090720231103001",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3090820231110001",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3090820231110001",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090720231103001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090820231110001",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",
@@ -77,6 +77,7 @@
77
77
  "@types/sass": "^1.43.1",
78
78
  "@types/stylus": "^0.48.36",
79
79
  "postcss": "^8.4.21",
80
+ "unplugin-auto-import": "^0.16.7",
80
81
  "vue": "3.2.47"
81
82
  }
82
83
  }