@proteus-vue/plugin-vite 0.3.0-beta.7 → 0.3.0-beta.8

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 ADDED
@@ -0,0 +1,218 @@
1
+ Proteus(普罗透斯)Vue 跨端编译框架
2
+ Copyright (c) 2026 Proteus Contributors
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ ═══════════════════════════════════════════════════════════════════════════════
17
+
18
+ Apache License
19
+ Version 2.0, January 2004
20
+ http://www.apache.org/licenses/
21
+
22
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
23
+
24
+ 1. Definitions.
25
+
26
+ "License" shall mean the terms and conditions for use, reproduction,
27
+ and distribution as defined by Sections 1 through 9 of this document.
28
+
29
+ "Licensor" shall mean the copyright owner or entity authorized by
30
+ the copyright owner that is granting the License.
31
+
32
+ "Legal Entity" shall mean the union of the acting entity and all
33
+ other entities that control, are controlled by, or are under common
34
+ control with that entity. For the purposes of this definition,
35
+ "control" means (i) the power, direct or indirect, to cause the
36
+ direction or management of such entity, whether by contract or
37
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
38
+ outstanding shares, or (iii) beneficial ownership of such entity.
39
+
40
+ "You" (or "Your") shall mean an individual or Legal Entity
41
+ exercising permissions granted by this License.
42
+
43
+ "Source" form shall mean the preferred form for making modifications,
44
+ including but not limited to software source code, documentation
45
+ source, and configuration files.
46
+
47
+ "Object" form shall mean any form resulting from mechanical
48
+ transformation or translation of a Source form, including but
49
+ not limited to compiled object code, generated documentation,
50
+ and conversions to other media types.
51
+
52
+ "Work" shall mean the work of authorship, whether in Source or
53
+ Object form, made available under the License, as indicated by a
54
+ copyright notice that is included in or attached to the work
55
+ (an example is provided in the Appendix below).
56
+
57
+ "Derivative Works" shall mean any work, whether in Source or Object
58
+ form, that is based on (or derived from) the Work and for which the
59
+ editorial revisions, annotations, elaborations, or other modifications
60
+ represent, as a whole, an original work of authorship. For the purposes
61
+ of this License, Derivative Works shall not include works that remain
62
+ separable from, or merely link (or bind by name) to the interfaces of,
63
+ the Work and Derivative Works thereof.
64
+
65
+ "Contribution" shall mean any work of authorship, including
66
+ the original version of the Work and any modifications or additions
67
+ to that Work or Derivative Works thereof, that is intentionally
68
+ submitted to Licensor for inclusion in the Work by the copyright owner
69
+ or by an individual or Legal Entity authorized to submit on behalf of
70
+ the copyright owner. For the purposes of this definition, "submitted"
71
+ means any form of electronic, verbal, or written communication sent
72
+ to the Licensor or its representatives, including but not limited to
73
+ communication on electronic mailing lists, source code control systems,
74
+ and issue tracking systems that are managed by, or on behalf of, the
75
+ Licensor for the purpose of discussing and improving the Work, but
76
+ excluding communication that is conspicuously marked or otherwise
77
+ designated in writing by the copyright owner as "Not a Contribution."
78
+
79
+ "Contributor" shall mean Licensor and any individual or Legal Entity
80
+ on behalf of whom a Contribution has been received by Licensor and
81
+ subsequently incorporated within the Work.
82
+
83
+ 2. Grant of Copyright License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ copyright license to reproduce, prepare Derivative Works of,
87
+ publicly display, publicly perform, sublicense, and distribute the
88
+ Work and such Derivative Works in Source or Object form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in Source or Object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, patent, trademark, and
119
+ attribution notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright statement to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Additional Liability. While redistributing
183
+ the Work or Derivative Works thereof, You may choose to offer,
184
+ and charge a fee for, acceptance of support, warranty, indemnity,
185
+ or other liability obligations and/or rights consistent with this
186
+ License. However, in accepting such obligations, You may act only
187
+ on Your own behalf and on Your sole responsibility, not on behalf
188
+ of any other Contributor, and only if You agree to indemnify,
189
+ defend, and hold each Contributor harmless for any liability
190
+ incurred by, or claims asserted against, such Contributor by reason
191
+ of your accepting any such warranty or additional liability.
192
+
193
+ END OF TERMS AND CONDITIONS
194
+
195
+ APPENDIX: How to apply the Apache License to your work.
196
+
197
+ To apply the Apache License to your work, attach the following
198
+ boilerplate notice, with the fields enclosed by brackets "[]"
199
+ replaced with your own identifying information. (Don't include
200
+ the brackets!) The text should be enclosed in the appropriate
201
+ comment syntax for the file format. We also recommend that a
202
+ file or class name and description of purpose be included on the
203
+ same "printed page" as the copyright notice for easier
204
+ identification within third-party archives.
205
+
206
+ Copyright [yyyy] [name of copyright owner]
207
+
208
+ Licensed under the Apache License, Version 2.0 (the "License");
209
+ you may not use this file except in compliance with the License.
210
+ You may obtain a copy of the License at
211
+
212
+ http://www.apache.org/licenses/LICENSE-2.0
213
+
214
+ Unless required by applicable law or agreed to in writing, software
215
+ distributed under the License is distributed on an "AS IS" BASIS,
216
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217
+ See the License for the specific language governing permissions and
218
+ limitations under the License.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default as mpTransform, defaultScopedPlugin, resolveSharedModule, rewriteRootToPage } from './plugin';
1
+ export { default as mpTransform, defaultScopedPlugin, pFluidLayoutPlugin, resolveSharedModule, rewriteRootToPage } from './plugin';
2
2
  export { devtoolsRelayPlugin } from './devtools-plugin';
3
3
  export { createPanelPageHandler, resolveDevtoolsDir, printPanelUrl, isOriginAllowed } from './devtools-plugin';
4
4
  export type { DevtoolsRelayOptions } from './devtools-plugin';
package/dist/index.js CHANGED
@@ -673,7 +673,14 @@ function runGenRoutes(options) {
673
673
  out[tag] = `/proteus/${tag}/index`;
674
674
  continue;
675
675
  }
676
- console.warn(`[gen-routes] ${file} \u4F7F\u7528\u4E86\u7EC4\u4EF6 <${tag}>\uFF0C\u4F46\u672A\u627E\u5230 ${appCandidates.join(" \u6216 ")} \u6216\u6846\u67B6\u7EC4\u4EF6 ${fwCandidates.join(" \u6216 ")}`);
676
+ console.warn(
677
+ `[gen-routes] ${file} \u4F7F\u7528\u4E86\u7EC4\u4EF6 <${tag}>\uFF0C\u4F46\u672A\u627E\u5230\u5176\u6E90\u7801\uFF1A
678
+ \u5E94\u7528\u7EC4\u4EF6\u653E\u8FD9\u91CC \u2192 ${appCandidates.join("\n \u6216 ")}
679
+ \u6846\u67B6\u7EC4\u4EF6\u653E\u8FD9\u91CC \u2192 ${fwCandidates.join("\n \u6216 ")}
680
+ \uFF08\u5E94\u7528\u7EC4\u4EF6\u76EE\u5F55\u76F8\u5BF9 pagesDir \u7684\u4E0A\u7EA7\uFF0C\u5373 <pagesDir>/../components/<tag>/index.vue\uFF09
681
+ \u82E5\u8FD9\u662F\u5C0F\u7A0B\u5E8F\u5185\u7F6E/\u5BBF\u4E3B\u6807\u7B7E\uFF0C\u8BF7\u786E\u8BA4\u62FC\u5199\uFF0C\u6216\u5728 proteus.config.ts \u7684 page \u914D\u7F6E\u4E2D\u58F0\u660E\uFF1B
682
+ \u8BE5\u6807\u7B7E\u672C\u6B21**\u672A\u5199\u5165 usingComponents**\uFF0C\u771F\u673A\u4F1A\u62A5 usingComponents \u672A\u627E\u5230\u7EC4\u4EF6\u3002`
683
+ );
677
684
  }
678
685
  return out;
679
686
  }
@@ -1088,6 +1095,23 @@ var MP_ONLY_TAGS = /* @__PURE__ */ new Set([
1088
1095
  "ad",
1089
1096
  "web-view"
1090
1097
  ]);
1098
+ function pFluidLayoutPlugin() {
1099
+ return {
1100
+ name: "proteus-p-fluid-layout",
1101
+ enforce: "pre",
1102
+ transform(code, id) {
1103
+ if (!id.endsWith(".vue")) return null;
1104
+ const out = rewritePFluidAttribute(code);
1105
+ return out === code ? null : { code: out, map: null };
1106
+ }
1107
+ };
1108
+ }
1109
+ function rewritePFluidAttribute(code) {
1110
+ return code.replace(/\sp-fluid=("[^"]*"|'[^']*')/g, (_m, q) => {
1111
+ const inner = q.slice(1, -1).replace(/'/g, "\\'");
1112
+ return ` v-p-fluid="'${inner}'"`;
1113
+ });
1114
+ }
1091
1115
  function defaultScopedPlugin() {
1092
1116
  return {
1093
1117
  name: "proteus-default-scoped",
@@ -1108,10 +1132,7 @@ function defaultScopedPlugin() {
1108
1132
  out = out.replace(/<script([^>]*)>/, (m) => `${m}${importLine}`);
1109
1133
  out = out.replace("</script>", `${hookCode}</script>`);
1110
1134
  }
1111
- out = out.replace(/\sp-fluid=("[^"]*"|'[^']*')/g, (_m, q) => {
1112
- const inner = q.slice(1, -1).replace(/'/g, "\\'");
1113
- return ` v-p-fluid="'${inner}'"`;
1114
- });
1135
+ out = rewritePFluidAttribute(out);
1115
1136
  return out === code ? null : { code: out, map: null };
1116
1137
  }
1117
1138
  };
@@ -2056,7 +2077,14 @@ async function resolveProteusViteConfig(ctx, config) {
2056
2077
  const vue = vueMod.default({
2057
2078
  template: { compilerOptions: { isCustomElement: (tag) => MP_ONLY_TAGS.has(tag) } }
2058
2079
  });
2059
- plugins = [platformVariantPlugin(root, "web"), vue, platformMacroPlugin("web"), platformPublicAssetsPlugin(root, "web"), routeBlocksPlugin()];
2080
+ plugins = [
2081
+ platformVariantPlugin(root, "web"),
2082
+ vue,
2083
+ platformMacroPlugin("web"),
2084
+ platformPublicAssetsPlugin(root, "web"),
2085
+ routeBlocksPlugin(),
2086
+ pFluidLayoutPlugin()
2087
+ ];
2060
2088
  }
2061
2089
  const frameworkConfig = {
2062
2090
  configFile: false,
@@ -2147,6 +2175,7 @@ export {
2147
2175
  devtoolsRelayPlugin,
2148
2176
  isOriginAllowed,
2149
2177
  mpTransform,
2178
+ pFluidLayoutPlugin,
2150
2179
  printPanelUrl,
2151
2180
  resolveComponentsRoot,
2152
2181
  resolveDevtoolsDir,
package/dist/plugin.d.ts CHANGED
@@ -6,6 +6,21 @@ import type { ProteusConfig } from './config';
6
6
  * 但 Vue 会把 `resolveComponent` 提升到 render 顶部 → Web 端仍会解析失败告警。
7
7
  * 在 @vitejs/plugin-vue 的 `isCustomElement` 里声明为自定义元素即消除(见 vite-config.ts)。 */
8
8
  export declare const MP_ONLY_TAGS: Set<string>;
9
+ /**
10
+ * ★G-22 柔性布局(Web 端):`p-fluid="font-size(20, 32)"` 属性 → `v-p-fluid="'font-size(20, 32)'"` 指令。
11
+ *
12
+ * ★为什么单独成插件(2026-09-20 修外部实战报告第十一节第二条):此前这一改写**捆在**
13
+ * `defaultScopedPlugin` 里,而框架的 Web 分支(`resolveProteusViteConfig`)只注册了 5 个插件、
14
+ * **从未注册它** → Web 端 `p-fluid` 原样留在 DOM、不生成任何样式、也不报错(静默失效)。
15
+ * 而用户**不能**直接把 `defaultScopedPlugin` 加进去——它顺带把原生标签改写成 MP 标签
16
+ * (`<button>`→`<proteus-button>`、`<textarea>`→`<proteus-textarea>`…),没有 `installWebPlatform`
17
+ * 注册这些全局组件的工程会**整页渲染不出来**(实测报 Failed to resolve component: proteus-*)。
18
+ * → 拆开:本插件只做 p-fluid 改写(可被框架默认注册,零副作用),MP 标签改写仍留在
19
+ * `defaultScopedPlugin`(需要 Web 模拟层的工程显式启用)。
20
+ * 配套运行时:`installFluidLayout(app)` 注册 `v-p-fluid` 指令(@proteus-vue/components)。
21
+ * 幂等:` v-p-fluid=` 的 `-` 前不是空白,故 `\sp-fluid=` 不会二次匹配。
22
+ */
23
+ export declare function pFluidLayoutPlugin(): Plugin;
9
24
  export declare function defaultScopedPlugin(): Plugin;
10
25
  export declare function resolvePkgPath(projectRoot: string, modPath: string): string;
11
26
  /** ★平台变体·CSS(2026-09-13,第 5 层):`<style src="./theme.css">` 加载并按目标平台解析变体。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteus-vue/plugin-vite",
3
- "version": "0.3.0-beta.7",
3
+ "version": "0.3.0-beta.8",
4
4
  "description": "Proteus Vite 插件(mp-weixin 编译管线适配层)+ gen-routes 路由表生成器",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -18,18 +18,15 @@
18
18
  "dist",
19
19
  "README.md"
20
20
  ],
21
- "scripts": {
22
- "build": "tsc -p tsconfig.build.json --emitDeclarationOnly && esbuild src/index.ts --bundle --format=esm --platform=node --outfile=dist/index.js --external:@proteus-vue/compiler-backend --external:@proteus-vue/compiler --external:@proteus-vue/router --external:esbuild --external:sass --external:vite --external:ws"
23
- },
24
21
  "dependencies": {
25
- "@proteus-vue/compiler": "0.3.0-beta.7",
26
- "@proteus-vue/module": "0.3.0-beta.7",
27
- "@proteus-vue/router": "0.3.0-beta.7",
28
- "@proteus-vue/types": "0.3.0-beta.7",
22
+ "@proteus-vue/compiler": "0.3.0-beta.8",
23
+ "@proteus-vue/module": "0.3.0-beta.8",
24
+ "@proteus-vue/router": "0.3.0-beta.8",
25
+ "@proteus-vue/types": "0.3.0-beta.8",
29
26
  "esbuild": "^0.28.2",
30
27
  "sass": "^1.103.1",
31
28
  "ws": "^8.0.0",
32
- "@proteus-vue/compiler-backend": "0.3.0-beta.7"
29
+ "@proteus-vue/compiler-backend": "0.3.0-beta.8"
33
30
  },
34
31
  "peerDependencies": {
35
32
  "vite": "^5.0.0"
@@ -38,5 +35,8 @@
38
35
  "@types/node": "^20.0.0",
39
36
  "vite": "^5.0.0",
40
37
  "@types/ws": "^8.18.0"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.build.json --emitDeclarationOnly && esbuild src/index.ts --bundle --format=esm --platform=node --outfile=dist/index.js --external:@proteus-vue/compiler-backend --external:@proteus-vue/compiler --external:@proteus-vue/router --external:esbuild --external:sass --external:vite --external:ws"
41
41
  }
42
- }
42
+ }