@dcloudio/uni-cli-shared 3.0.0-4000820240401001 → 3.0.0-4010420240430002

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.
Files changed (98) hide show
  1. package/dist/deps.d.ts +2 -0
  2. package/dist/deps.js +3 -0
  3. package/dist/easycom.js +4 -3
  4. package/dist/hbx/alias.js +26 -5
  5. package/dist/hbx/index.d.ts +1 -1
  6. package/dist/hbx/log.d.ts +1 -1
  7. package/dist/hbx/log.js +2 -1
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +3 -2
  10. package/dist/json/app/pages/code.d.ts +1 -1
  11. package/dist/json/mp/index.d.ts +1 -1
  12. package/dist/json/mp/jsonFile.d.ts +1 -1
  13. package/dist/json/mp/pages.d.ts +1 -1
  14. package/dist/json/mp/project.js +2 -2
  15. package/dist/json/mp/types.d.ts +1 -1
  16. package/dist/json/mp/utils.d.ts +1 -1
  17. package/dist/json/uni-x/uniConfig.js +4 -0
  18. package/dist/logs/console.d.ts +2 -4
  19. package/dist/logs/console.js +7 -4
  20. package/dist/logs/format.d.ts +1 -1
  21. package/dist/mp/ast.d.ts +1 -1
  22. package/dist/mp/externalClasses.d.ts +1 -1
  23. package/dist/mp/imports.d.ts +2 -2
  24. package/dist/mp/plugin.d.ts +1 -1
  25. package/dist/mp/tags.js +5 -6
  26. package/dist/mp/usingComponents.d.ts +1 -1
  27. package/dist/postcss/index.d.ts +1 -1
  28. package/dist/uni_modules.d.ts +23 -0
  29. package/dist/uni_modules.js +80 -12
  30. package/dist/utils.d.ts +3 -5
  31. package/dist/utils.js +7 -7
  32. package/dist/uts.d.ts +3 -4
  33. package/dist/uts.js +28 -42
  34. package/dist/utsUtils.d.ts +2 -0
  35. package/dist/utsUtils.js +44 -0
  36. package/dist/vite/autoImport.d.ts +1 -1
  37. package/dist/vite/autoImport.js +1 -0
  38. package/dist/vite/features.d.ts +1 -0
  39. package/dist/vite/features.js +31 -28
  40. package/dist/vite/index.d.ts +2 -1
  41. package/dist/vite/plugins/console.d.ts +2 -2
  42. package/dist/vite/plugins/copy.d.ts +1 -1
  43. package/dist/vite/plugins/easycom.d.ts +2 -2
  44. package/dist/vite/plugins/index.d.ts +1 -0
  45. package/dist/vite/plugins/index.js +3 -1
  46. package/dist/vite/plugins/inject.d.ts +1 -1
  47. package/dist/vite/plugins/inject.js +2 -2
  48. package/dist/vite/plugins/jsonJs.d.ts +3 -3
  49. package/dist/vite/plugins/mainJs.d.ts +2 -2
  50. package/dist/vite/plugins/sfc.d.ts +6 -0
  51. package/dist/vite/plugins/sfc.js +136 -0
  52. package/dist/vite/plugins/uts/ext-api.d.ts +2 -1
  53. package/dist/vite/plugins/uts/ext-api.js +4 -5
  54. package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
  55. package/dist/vite/plugins/uts/uni_modules.js +20 -7
  56. package/dist/vite/plugins/uts/uvue.js +1 -1
  57. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +2 -2
  58. package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
  59. package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
  60. package/dist/vite/plugins/vitejs/plugins/css.js +10 -2
  61. package/dist/vite/plugins/vitejs/utils.d.ts +1 -1
  62. package/dist/vite/utils/ast.d.ts +2 -2
  63. package/dist/vite/utils/ast.js +7 -6
  64. package/dist/vite/utils/utils.d.ts +2 -2
  65. package/dist/vue/babel.d.ts +1 -1
  66. package/dist/vue/parse.d.ts +1 -1
  67. package/dist/vue/parse.js +8 -7
  68. package/dist/vue/transforms/index.d.ts +1 -0
  69. package/dist/vue/transforms/index.js +1 -0
  70. package/dist/vue/transforms/templateTransformAssetUrl.d.ts +1 -1
  71. package/dist/vue/transforms/templateTransformAssetUrl.js +8 -8
  72. package/dist/vue/transforms/templateTransformSrcset.d.ts +2 -2
  73. package/dist/vue/transforms/templateTransformSrcset.js +7 -7
  74. package/dist/vue/transforms/templateUtils.d.ts +1 -1
  75. package/dist/vue/transforms/transformComponent.d.ts +2 -2
  76. package/dist/vue/transforms/transformComponent.js +7 -3
  77. package/dist/vue/transforms/transformEvent.d.ts +1 -1
  78. package/dist/vue/transforms/transformPageHead.d.ts +1 -1
  79. package/dist/vue/transforms/transformRef.d.ts +1 -1
  80. package/dist/vue/transforms/transformRef.js +1 -1
  81. package/dist/vue/transforms/transformRefresherSlot.d.ts +8 -0
  82. package/dist/vue/transforms/transformRefresherSlot.js +58 -0
  83. package/dist/vue/transforms/transformTag.d.ts +1 -1
  84. package/dist/vue/transforms/transformUTSComponent.d.ts +1 -1
  85. package/dist/vue/transforms/transformUTSComponent.js +2 -2
  86. package/dist/vue/transforms/vModel.d.ts +1 -1
  87. package/dist/vue/transforms/vOn.d.ts +1 -1
  88. package/dist/vue/transforms/vOn.js +4 -4
  89. package/dist/vue/utils.d.ts +4 -1
  90. package/dist/vue/utils.js +47 -8
  91. package/dist/watcher.d.ts +1 -1
  92. package/lib/@vue/compiler-sfc/LICENSE +21 -0
  93. package/lib/@vue/compiler-sfc/README.md +80 -0
  94. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +20665 -0
  95. package/lib/@vue/compiler-sfc/dist/compiler-sfc.d.ts +543 -0
  96. package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +48237 -0
  97. package/lib/@vue/compiler-sfc/package.json +67 -0
  98. package/package.json +20 -18
package/dist/vue/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
3
+ exports.advancePositionWithMutation = exports.advancePositionWithClone = exports.getInnerRange = exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
5
  const uni_shared_1 = require("@dcloudio/uni-shared");
6
6
  const compiler_core_1 = require("@vue/compiler-core");
@@ -17,8 +17,8 @@ function isVueSfcFile(id) {
17
17
  }
18
18
  exports.isVueSfcFile = isVueSfcFile;
19
19
  function isUserComponent(node, context) {
20
- return (node.type === 1 /* NodeTypes.ELEMENT */ &&
21
- node.tagType === 1 /* ElementTypes.COMPONENT */ &&
20
+ return (node.type === compiler_core_1.NodeTypes.ELEMENT &&
21
+ node.tagType === compiler_core_1.ElementTypes.COMPONENT &&
22
22
  !(0, uni_shared_1.isComponentTag)(node.tag) &&
23
23
  !(0, compiler_core_1.isCoreComponent)(node.tag) &&
24
24
  !context.isBuiltInComponent(node.tag));
@@ -26,11 +26,12 @@ function isUserComponent(node, context) {
26
26
  exports.isUserComponent = isUserComponent;
27
27
  function createAttributeNode(name, content) {
28
28
  return {
29
- type: 6 /* NodeTypes.ATTRIBUTE */,
29
+ type: compiler_core_1.NodeTypes.ATTRIBUTE,
30
30
  loc: compiler_core_1.locStub,
31
+ nameLoc: compiler_core_1.locStub,
31
32
  name,
32
33
  value: {
33
- type: 2 /* NodeTypes.TEXT */,
34
+ type: compiler_core_1.NodeTypes.TEXT,
34
35
  loc: compiler_core_1.locStub,
35
36
  content,
36
37
  },
@@ -41,7 +42,7 @@ function createClassAttribute(clazz) {
41
42
  return createAttributeNode('class', clazz);
42
43
  }
43
44
  function addStaticClass(node, clazz) {
44
- const classProp = node.props.find((prop) => prop.type === 6 /* NodeTypes.ATTRIBUTE */ && prop.name === 'class');
45
+ const classProp = node.props.find((prop) => prop.type === compiler_core_1.NodeTypes.ATTRIBUTE && prop.name === 'class');
45
46
  if (!classProp) {
46
47
  return node.props.unshift(createClassAttribute(clazz));
47
48
  }
@@ -49,7 +50,7 @@ function addStaticClass(node, clazz) {
49
50
  return (classProp.value.content = classProp.value.content + ' ' + clazz);
50
51
  }
51
52
  classProp.value = {
52
- type: 2 /* NodeTypes.TEXT */,
53
+ type: compiler_core_1.NodeTypes.TEXT,
53
54
  loc: compiler_core_1.locStub,
54
55
  content: clazz,
55
56
  };
@@ -57,7 +58,7 @@ function addStaticClass(node, clazz) {
57
58
  exports.addStaticClass = addStaticClass;
58
59
  function createDirectiveNode(name, arg, exp) {
59
60
  return {
60
- type: 7 /* NodeTypes.DIRECTIVE */,
61
+ type: compiler_core_1.NodeTypes.DIRECTIVE,
61
62
  name,
62
63
  modifiers: [],
63
64
  loc: compiler_core_1.locStub,
@@ -118,3 +119,41 @@ function renameProp(name, prop) {
118
119
  }
119
120
  }
120
121
  exports.renameProp = renameProp;
122
+ // @vue/compiler-core 没有导出 getLoc,先使用旧版本的 getInnerRange
123
+ function getInnerRange(loc, offset, length) {
124
+ const source = loc.source.slice(offset, offset + length);
125
+ const newLoc = {
126
+ source,
127
+ start: advancePositionWithClone(loc.start, loc.source, offset),
128
+ end: loc.end,
129
+ };
130
+ if (length != null) {
131
+ newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
132
+ }
133
+ return newLoc;
134
+ }
135
+ exports.getInnerRange = getInnerRange;
136
+ function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
137
+ return advancePositionWithMutation((0, shared_1.extend)({}, pos), source, numberOfCharacters);
138
+ }
139
+ exports.advancePositionWithClone = advancePositionWithClone;
140
+ // advance by mutation without cloning (for performance reasons), since this
141
+ // gets called a lot in the parser
142
+ function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
143
+ let linesCount = 0;
144
+ let lastNewLinePos = -1;
145
+ for (let i = 0; i < numberOfCharacters; i++) {
146
+ if (source.charCodeAt(i) === 10 /* newline char code */) {
147
+ linesCount++;
148
+ lastNewLinePos = i;
149
+ }
150
+ }
151
+ pos.offset += numberOfCharacters;
152
+ pos.line += linesCount;
153
+ pos.column =
154
+ lastNewLinePos === -1
155
+ ? pos.column + numberOfCharacters
156
+ : numberOfCharacters - lastNewLinePos;
157
+ return pos;
158
+ }
159
+ exports.advancePositionWithMutation = advancePositionWithMutation;
package/dist/watcher.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { FSWatcher, WatchOptions } from 'chokidar';
2
+ import { type FSWatcher, type WatchOptions } from 'chokidar';
3
3
  type FileTransform = (source: Buffer, filename: string) => void | string;
4
4
  export interface FileWatcherOptions {
5
5
  src: string | string[];
@@ -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).