@proteus-vue/plugin-vite 0.2.0-beta.5 → 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 +1 -1
- package/dist/index.js +48 -7
- package/dist/plugin.d.ts +15 -0
- package/package.json +6 -6
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
|
@@ -118,7 +118,7 @@ function runGenRoutes(options) {
|
|
|
118
118
|
const APP_DIR = path2.resolve(ROOT, path2.dirname(config.pagesDir));
|
|
119
119
|
const OUT_DIR = path2.join(ROOT, "dist", "mp-weixin");
|
|
120
120
|
const FW_COMPONENTS = options.componentsDir ? path2.resolve(ROOT, options.componentsDir) : resolveComponentsRoot(ROOT);
|
|
121
|
-
if (!fs2.existsSync(FW_COMPONENTS)) {
|
|
121
|
+
if (!fs2.existsSync(FW_COMPONENTS) && appUsesFrameworkComponents(APP_DIR)) {
|
|
122
122
|
console.warn(
|
|
123
123
|
`[gen-routes] \u672A\u627E\u5230\u8BED\u4E49\u7EC4\u4EF6\u5E93 @proteus-vue/components\uFF08\u89E3\u6790\u4E3A ${FW_COMPONENTS}\uFF09\u2014\u2014p-* \u7EC4\u4EF6\u5C06\u4E0D\u88AB\u6CE8\u518C\uFF08\u9875\u9762 usingComponents \u7F3A\u5931 \u2192 WXML \u6574\u5757\u4E0D\u6E32\u67D3\uFF09\u3002\u8BF7\u786E\u8BA4\u5DF2\u5B89\u88C5\u4F9D\u8D56\uFF08npm i / pnpm i\uFF09\u3002`
|
|
124
124
|
);
|
|
@@ -148,6 +148,18 @@ function runGenRoutes(options) {
|
|
|
148
148
|
}
|
|
149
149
|
return acc;
|
|
150
150
|
}
|
|
151
|
+
function appUsesFrameworkComponents(appDir) {
|
|
152
|
+
for (const f of walkVueFiles2(appDir)) {
|
|
153
|
+
let src;
|
|
154
|
+
try {
|
|
155
|
+
src = fs2.readFileSync(f, "utf8");
|
|
156
|
+
} catch {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (/<[pP]-[a-z][\w-]*[\s/>]/.test(src) || /<P[A-Z][\w]*[\s/>]/.test(src)) return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
151
163
|
function resolveConfigMeta(configMeta, pageRel) {
|
|
152
164
|
if (!configMeta) return void 0;
|
|
153
165
|
let dirMeta;
|
|
@@ -661,7 +673,14 @@ function runGenRoutes(options) {
|
|
|
661
673
|
out[tag] = `/proteus/${tag}/index`;
|
|
662
674
|
continue;
|
|
663
675
|
}
|
|
664
|
-
console.warn(
|
|
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
|
+
);
|
|
665
684
|
}
|
|
666
685
|
return out;
|
|
667
686
|
}
|
|
@@ -1076,6 +1095,23 @@ var MP_ONLY_TAGS = /* @__PURE__ */ new Set([
|
|
|
1076
1095
|
"ad",
|
|
1077
1096
|
"web-view"
|
|
1078
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
|
+
}
|
|
1079
1115
|
function defaultScopedPlugin() {
|
|
1080
1116
|
return {
|
|
1081
1117
|
name: "proteus-default-scoped",
|
|
@@ -1096,10 +1132,7 @@ function defaultScopedPlugin() {
|
|
|
1096
1132
|
out = out.replace(/<script([^>]*)>/, (m) => `${m}${importLine}`);
|
|
1097
1133
|
out = out.replace("</script>", `${hookCode}</script>`);
|
|
1098
1134
|
}
|
|
1099
|
-
out = out
|
|
1100
|
-
const inner = q.slice(1, -1).replace(/'/g, "\\'");
|
|
1101
|
-
return ` v-p-fluid="'${inner}'"`;
|
|
1102
|
-
});
|
|
1135
|
+
out = rewritePFluidAttribute(out);
|
|
1103
1136
|
return out === code ? null : { code: out, map: null };
|
|
1104
1137
|
}
|
|
1105
1138
|
};
|
|
@@ -2044,7 +2077,14 @@ async function resolveProteusViteConfig(ctx, config) {
|
|
|
2044
2077
|
const vue = vueMod.default({
|
|
2045
2078
|
template: { compilerOptions: { isCustomElement: (tag) => MP_ONLY_TAGS.has(tag) } }
|
|
2046
2079
|
});
|
|
2047
|
-
plugins = [
|
|
2080
|
+
plugins = [
|
|
2081
|
+
platformVariantPlugin(root, "web"),
|
|
2082
|
+
vue,
|
|
2083
|
+
platformMacroPlugin("web"),
|
|
2084
|
+
platformPublicAssetsPlugin(root, "web"),
|
|
2085
|
+
routeBlocksPlugin(),
|
|
2086
|
+
pFluidLayoutPlugin()
|
|
2087
|
+
];
|
|
2048
2088
|
}
|
|
2049
2089
|
const frameworkConfig = {
|
|
2050
2090
|
configFile: false,
|
|
@@ -2135,6 +2175,7 @@ export {
|
|
|
2135
2175
|
devtoolsRelayPlugin,
|
|
2136
2176
|
isOriginAllowed,
|
|
2137
2177
|
mpTransform,
|
|
2178
|
+
pFluidLayoutPlugin,
|
|
2138
2179
|
printPanelUrl,
|
|
2139
2180
|
resolveComponentsRoot,
|
|
2140
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
|
+
"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.
|
|
23
|
-
"@proteus-vue/module": "0.
|
|
24
|
-
"@proteus-vue/router": "0.
|
|
25
|
-
"@proteus-vue/types": "0.
|
|
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.
|
|
29
|
+
"@proteus-vue/compiler-backend": "0.3.0-beta.10"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"vite": "^5.0.0"
|