@vizejs/vite-plugin-musea 0.241.0 → 0.242.0
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.mjs +26 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -3026,12 +3026,26 @@ function emptyTokens() {
|
|
|
3026
3026
|
const MUSEA_STATIC_BUILD_ENV = "VIZE_MUSEA_STATIC_BUILD";
|
|
3027
3027
|
const VIRTUAL_STATIC_RUNTIME = "virtual:musea-static-runtime";
|
|
3028
3028
|
const RESOLVED_STATIC_RUNTIME = "\0musea-static-runtime";
|
|
3029
|
+
const STATIC_RUNTIME_INPUT_NAME = "musea-static-runtime";
|
|
3030
|
+
const STATIC_USER_INPUT_NAME = "musea-static-entry";
|
|
3029
3031
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
3030
3032
|
function isMuseaStaticBuild() {
|
|
3031
3033
|
return process.env[MUSEA_STATIC_BUILD_ENV] === "1";
|
|
3032
3034
|
}
|
|
3033
|
-
function
|
|
3034
|
-
|
|
3035
|
+
function museaStaticBuildInput(input) {
|
|
3036
|
+
const entries = {};
|
|
3037
|
+
if (typeof input === "string") entries[STATIC_USER_INPUT_NAME] = input;
|
|
3038
|
+
else if (Array.isArray(input)) input.forEach((value, index) => {
|
|
3039
|
+
entries[`${STATIC_USER_INPUT_NAME}-${index + 1}`] = value;
|
|
3040
|
+
});
|
|
3041
|
+
else if (input) Object.assign(entries, input);
|
|
3042
|
+
entries[STATIC_RUNTIME_INPUT_NAME] = VIRTUAL_STATIC_RUNTIME;
|
|
3043
|
+
return entries;
|
|
3044
|
+
}
|
|
3045
|
+
function applyMuseaStaticBuildInput(options) {
|
|
3046
|
+
if (!isMuseaStaticBuild()) return null;
|
|
3047
|
+
options.input = museaStaticBuildInput(options.input);
|
|
3048
|
+
return null;
|
|
3035
3049
|
}
|
|
3036
3050
|
function resolveStaticRuntimeId(id) {
|
|
3037
3051
|
return id === "virtual:musea-static-runtime" ? RESOLVED_STATIC_RUNTIME : null;
|
|
@@ -3152,8 +3166,14 @@ function generateStaticPreviewHtml(art, variantName, previewId, basePath, runtim
|
|
|
3152
3166
|
<div class="musea-loading">Loading component...</div>
|
|
3153
3167
|
</div>
|
|
3154
3168
|
<script type="module">
|
|
3155
|
-
import
|
|
3156
|
-
|
|
3169
|
+
import ${JSON.stringify(runtimeUrl)};
|
|
3170
|
+
Promise.resolve().then(() => {
|
|
3171
|
+
const loadMuseaPreview = window.__MUSEA_LOAD_PREVIEW__;
|
|
3172
|
+
if (typeof loadMuseaPreview !== "function") {
|
|
3173
|
+
throw new Error("Musea preview runtime failed to load");
|
|
3174
|
+
}
|
|
3175
|
+
return loadMuseaPreview(${JSON.stringify(previewId)});
|
|
3176
|
+
}).catch((error) => {
|
|
3157
3177
|
const el = document.getElementById("app");
|
|
3158
3178
|
if (el) el.textContent = error instanceof Error ? error.message : String(error);
|
|
3159
3179
|
});
|
|
@@ -3297,11 +3317,9 @@ function musea(options = {}) {
|
|
|
3297
3317
|
return shouldApplyMuseaPlugin(env);
|
|
3298
3318
|
},
|
|
3299
3319
|
config() {
|
|
3300
|
-
return {
|
|
3301
|
-
resolve: { alias: { vue: resolveVueRuntimeCompiler() } },
|
|
3302
|
-
...isMuseaStaticBuild() ? museaStaticBuildConfig() : {}
|
|
3303
|
-
};
|
|
3320
|
+
return { resolve: { alias: { vue: resolveVueRuntimeCompiler() } } };
|
|
3304
3321
|
},
|
|
3322
|
+
options: applyMuseaStaticBuildInput,
|
|
3305
3323
|
configResolved(resolvedConfig) {
|
|
3306
3324
|
config = resolvedConfig;
|
|
3307
3325
|
const vizeConfig = vizeConfigStore.get(resolvedConfig.root);
|