@dcloudio/uni-cli-shared 3.0.0-alpha-4010120240403001 → 3.0.0-alpha-4010120240403003

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/dist/hbx/alias.js CHANGED
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
8
8
  const module_alias_1 = __importDefault(require("module-alias"));
9
9
  const env_1 = require("./env");
10
10
  const hbxPlugins = {
11
- // typescript: 'compile-typescript/node_modules/typescript',
11
+ typescript: 'compile-typescript/node_modules/typescript',
12
12
  less: 'compile-less/node_modules/less',
13
13
  sass: 'compile-dart-sass/node_modules/sass',
14
14
  stylus: 'compile-stylus/node_modules/stylus',
@@ -120,6 +120,10 @@ exports.moduleAliasFormatter = {
120
120
  lang = 'stylus';
121
121
  preprocessor = 'compile-stylus';
122
122
  }
123
+ else if (msg.includes('"typescript"')) {
124
+ lang = 'typescript';
125
+ preprocessor = 'compile-typescript';
126
+ }
123
127
  if (lang) {
124
128
  // 仅提醒一次
125
129
  if (installPreprocessorTips[lang]) {
package/dist/utils.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
10
10
  export declare function removeExt(str: string): string;
11
11
  export declare function normalizeNodeModules(str: string): string;
12
12
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
13
- export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("jsx" | "asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple" | "typescript"))[];
13
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("jsx" | "typescript" | "asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple"))[];
14
14
  export declare function pathToGlob(pathString: string, glob: string, options?: {
15
15
  windows?: boolean;
16
16
  escape?: boolean;
package/dist/uts.d.ts CHANGED
@@ -23,3 +23,4 @@ export declare function parseSwiftPackageWithPluginId(id: string, is_uni_modules
23
23
  export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
24
24
  export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
25
25
  export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
26
+ export declare function resolveUniTypeScript(): any;
package/dist/uts.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
6
+ exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
7
7
  // 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -272,3 +272,10 @@ exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
272
272
  });
273
273
  return namespaces;
274
274
  });
275
+ function resolveUniTypeScript() {
276
+ if ((0, hbx_1.isInHBuilderX)()) {
277
+ return require(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1', 'node_modules', '@dcloudio', 'uni-uts-v1', 'lib', 'typescript'));
278
+ }
279
+ return require('@dcloudio/uni-uts-v1/lib/typescript');
280
+ }
281
+ exports.resolveUniTypeScript = resolveUniTypeScript;
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018-present, Yuxi (Evan) You
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ # @vue/compiler-sfc
2
+
3
+ > Lower level utilities for compiling Vue Single File Components
4
+
5
+ **Note: as of 3.2.13+, this package is included as a dependency of the main `vue` package and can be accessed as `vue/compiler-sfc`. This means you no longer need to explicitly install this package and ensure its version match that of `vue`'s. Just use the main `vue/compiler-sfc` deep import instead.**
6
+
7
+ This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader) and [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
8
+
9
+ ## API
10
+
11
+ The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
12
+
13
+ - Separate hot-module replacement (HMR) for script, template and styles
14
+
15
+ - template updates should not reset component state
16
+ - style updates should be performed without component re-render
17
+
18
+ - Leveraging the tool's plugin system for pre-processor handling. e.g. `<style lang="scss">` should be processed by the corresponding webpack loader.
19
+
20
+ - In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with `thread-loader` or other parallelized configurations, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor.
21
+
22
+ The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
23
+
24
+ ```
25
+ +--------------------+
26
+ | |
27
+ | script transform |
28
+ +----->+ |
29
+ | +--------------------+
30
+ |
31
+ +--------------------+ | +--------------------+
32
+ | | | | |
33
+ | facade transform +----------->+ template transform |
34
+ | | | | |
35
+ +--------------------+ | +--------------------+
36
+ |
37
+ | +--------------------+
38
+ +----->+ |
39
+ | style transform |
40
+ | |
41
+ +--------------------+
42
+ ```
43
+
44
+ Where the facade module looks like this:
45
+
46
+ ```js
47
+ // main script
48
+ import script from '/project/foo.vue?vue&type=script'
49
+ // template compiled to render function
50
+ import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx'
51
+ // css
52
+ import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx'
53
+
54
+ // attach render function to script
55
+ script.render = render
56
+
57
+ // attach additional metadata
58
+ // some of these should be dev only
59
+ script.__file = 'example.vue'
60
+ script.__scopeId = 'xxxxxx'
61
+
62
+ // additional tooling-specific HMR handling code
63
+ // using __VUE_HMR_API__ global
64
+
65
+ export default script
66
+ ```
67
+
68
+ ### High Level Workflow
69
+
70
+ 1. In facade transform, parse the source into descriptor with the `parse` API and generate the above facade module code based on the descriptor;
71
+
72
+ 2. In script transform, use `compileScript` to process the script. This handles features like `<script setup>` and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting `export default` to a temp variable (a `rewriteDefault` convenience API is provided for this purpose) so additional options can be attached to the exported object.
73
+
74
+ 3. In template transform, use `compileTemplate` to compile the raw template into render function code.
75
+
76
+ 4. In style transform, use `compileStyle` to compile raw CSS to handle `<style scoped>`, `<style module>` and CSS variable injection.
77
+
78
+ Options needed for these APIs can be passed via the query string.
79
+
80
+ For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).