@proteus-vue/plugin-vite 0.2.0-beta.6 → 0.3.0-beta.10

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/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.2.0-beta.6",
3
+ "version": "0.3.0-beta.10",
4
4
  "description": "Proteus Vite 插件(mp-weixin 编译管线适配层)+ gen-routes 路由表生成器",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -19,14 +19,14 @@
19
19
  "README.md"
20
20
  ],
21
21
  "dependencies": {
22
- "@proteus-vue/compiler": "0.3.0-beta.3",
23
- "@proteus-vue/module": "0.1.1-beta.0",
24
- "@proteus-vue/router": "0.2.0-beta.5",
25
- "@proteus-vue/types": "0.2.0-beta.2",
22
+ "@proteus-vue/compiler": "0.3.0-beta.10",
23
+ "@proteus-vue/module": "0.3.0-beta.10",
24
+ "@proteus-vue/router": "0.3.0-beta.10",
25
+ "@proteus-vue/types": "0.3.0-beta.10",
26
26
  "esbuild": "^0.28.2",
27
27
  "sass": "^1.103.1",
28
28
  "ws": "^8.0.0",
29
- "@proteus-vue/compiler-backend": "0.1.1-beta.1"
29
+ "@proteus-vue/compiler-backend": "0.3.0-beta.10"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "vite": "^5.0.0"