vite-plugin-prism-design 0.1.2 → 0.1.3
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.js +14 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111,8 +111,8 @@ function prismDesign(options = {}) {
|
|
|
111
111
|
agentProcess = null;
|
|
112
112
|
});
|
|
113
113
|
const actualPort = await portPromise;
|
|
114
|
-
agentUrl = `
|
|
115
|
-
config.logger.info(`[PrismDesign] Agent ready
|
|
114
|
+
agentUrl = `__AGENT_PORT__:${actualPort}`;
|
|
115
|
+
config.logger.info(`[PrismDesign] Agent ready on port ${actualPort}`);
|
|
116
116
|
} else {
|
|
117
117
|
config.logger.warn("[PrismDesign] Agent CLI not found. Install prism-design-agent or run agent manually.");
|
|
118
118
|
config.logger.info("[PrismDesign] Widget will show connection form for manual URL input.");
|
|
@@ -130,10 +130,19 @@ function prismDesign(options = {}) {
|
|
|
130
130
|
},
|
|
131
131
|
transformIndexHtml() {
|
|
132
132
|
const initOptions = {};
|
|
133
|
-
if (agentUrl) initOptions.agentUrl = agentUrl;
|
|
134
133
|
if (position !== "bottom-right") initOptions.position = position;
|
|
135
134
|
if (locale) initOptions.locale = locale;
|
|
136
|
-
|
|
135
|
+
let initScript;
|
|
136
|
+
if (agentUrl.startsWith("__AGENT_PORT__:")) {
|
|
137
|
+
const port = agentUrl.split(":")[1];
|
|
138
|
+
const optionsJson = JSON.stringify(initOptions);
|
|
139
|
+
initScript = `(function(){var o=${optionsJson};o.agentUrl="http://"+location.hostname+":${port}";PrismDesignWidget.init(o)})();`;
|
|
140
|
+
} else if (agentUrl) {
|
|
141
|
+
initOptions.agentUrl = agentUrl;
|
|
142
|
+
initScript = `PrismDesignWidget.init(${JSON.stringify(initOptions)});`;
|
|
143
|
+
} else {
|
|
144
|
+
initScript = `PrismDesignWidget.init(${JSON.stringify(initOptions)});`;
|
|
145
|
+
}
|
|
137
146
|
return [
|
|
138
147
|
{
|
|
139
148
|
tag: "script",
|
|
@@ -142,7 +151,7 @@ function prismDesign(options = {}) {
|
|
|
142
151
|
},
|
|
143
152
|
{
|
|
144
153
|
tag: "script",
|
|
145
|
-
children:
|
|
154
|
+
children: initScript,
|
|
146
155
|
injectTo: "body"
|
|
147
156
|
}
|
|
148
157
|
];
|