mechanica 1.0.12 → 1.0.14
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/bin/compile.js +45 -11
- package/dist/editor.js +2 -3
- package/dist/editor.js.map +1 -1
- package/dist/main.js +2 -3
- package/dist/main.js.map +1 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.js.map +1 -1
- package/dist/schemaAliases-3G_-tJU0.js +160 -0
- package/dist/schemaAliases-3G_-tJU0.js.map +1 -0
- package/package.json +1 -2
- package/dist/schemaAliases-CX3SQvLF.js +0 -54
- package/dist/schemaAliases-CX3SQvLF.js.map +0 -1
package/bin/compile.js
CHANGED
|
@@ -169,7 +169,8 @@ async function* generateProject(options) {
|
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
|
-
const
|
|
172
|
+
const assetsUrl = options.assetsUrl ?? (options.baseUrl && options.baseUrl !== "/" ? options.baseUrl + "/assets/" : void 0);
|
|
173
|
+
const html = await generatePage({ ...options, assetsUrl, state: page, path: page.path });
|
|
173
174
|
yield [html, page.path];
|
|
174
175
|
}
|
|
175
176
|
}
|
|
@@ -179,6 +180,9 @@ const getBlockName = (path) => {
|
|
|
179
180
|
return (str == null ? void 0 : str.split(".", 1)[0].replace(/([A-Z])/g, " $1").trimStart()) ?? "Unnamed block";
|
|
180
181
|
};
|
|
181
182
|
const aliases$1 = {};
|
|
183
|
+
const registerAlias$1 = (key, item) => {
|
|
184
|
+
aliases$1[key] = item;
|
|
185
|
+
};
|
|
182
186
|
const baseTypes = ["string", "boolean", "number", "integer", "bigint", "object", "array"];
|
|
183
187
|
const isBaseType = (key) => {
|
|
184
188
|
return baseTypes.some((item) => item === key || item + "?" === key || item + "??" === key);
|
|
@@ -279,12 +283,13 @@ const aliases = {};
|
|
|
279
283
|
const registerAlias = (key, item) => {
|
|
280
284
|
aliases[key] = item;
|
|
281
285
|
};
|
|
282
|
-
const registerAliases = () => {
|
|
283
|
-
registerAlias
|
|
284
|
-
registerAlias("
|
|
285
|
-
registerAlias("
|
|
286
|
-
registerAlias("
|
|
287
|
-
registerAlias("
|
|
286
|
+
const registerAliases = (registerCallback) => {
|
|
287
|
+
const registerAlias$12 = registerCallback ?? registerAlias;
|
|
288
|
+
registerAlias$12("image", { type: "object", format: "image", properties: { src: "string", previewSrc: "string?" } });
|
|
289
|
+
registerAlias$12("file", { type: "object", format: "file", properties: { src: "string" } });
|
|
290
|
+
registerAlias$12("color", { type: "string", format: "color" });
|
|
291
|
+
registerAlias$12("smartLink", { type: "object", format: "smartLink", properties: { url: "string", title: "string", external: "boolean" } });
|
|
292
|
+
registerAlias$12("richText", {
|
|
288
293
|
type: "array",
|
|
289
294
|
format: "richText",
|
|
290
295
|
items: { type: "object", properties: { text: "string", type: "string?", styles: "object?" } }
|
|
@@ -356,11 +361,38 @@ const getAvailablePages = async (options) => {
|
|
|
356
361
|
};
|
|
357
362
|
const compile = async () => {
|
|
358
363
|
console.info("Build client files...");
|
|
359
|
-
registerAliases();
|
|
364
|
+
registerAliases(registerAlias$1);
|
|
360
365
|
process.env.DISABLE_HTML_GENERATE = "true";
|
|
366
|
+
let baseUrl = "/";
|
|
367
|
+
let assetsUrl = void 0;
|
|
368
|
+
let uploadsUrl = "/mech-assets";
|
|
369
|
+
for (let argv of process.argv) {
|
|
370
|
+
if (argv.startsWith("--base")) {
|
|
371
|
+
baseUrl = argv.split("=")[1];
|
|
372
|
+
if (!baseUrl) {
|
|
373
|
+
return console.error(`Use --base=/path`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (argv.startsWith("--assets-dir")) {
|
|
377
|
+
assetsUrl = argv.split("=")[1];
|
|
378
|
+
if (!assetsUrl) {
|
|
379
|
+
return console.error(`Use --assets-dir=/path`);
|
|
380
|
+
}
|
|
381
|
+
if (!assetsUrl.endsWith("/")) {
|
|
382
|
+
assetsUrl = assetsUrl + "/";
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (argv.startsWith("--uploads-dir")) {
|
|
386
|
+
uploadsUrl = argv.split("=")[1].replace(/\/+$/, "");
|
|
387
|
+
if (!uploadsUrl) {
|
|
388
|
+
return console.error(`Use --uploads-dir=/path`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
let assetsPath = (assetsUrl == null ? void 0 : assetsUrl.replace(/^\.?\/+/, "").replace(/\/+$/, "")) ?? "assets";
|
|
361
393
|
fs.rmSync(`${process.cwd()}/export`, { recursive: true, force: true });
|
|
362
394
|
fs.mkdirSync(`${process.cwd()}/export`, { recursive: true });
|
|
363
|
-
fs.cpSync(`${process.cwd()}/dist/assets`, `${process.cwd()}/export
|
|
395
|
+
fs.cpSync(`${process.cwd()}/dist/assets`, `${process.cwd()}/export/${assetsPath}`, { recursive: true });
|
|
364
396
|
const index = fs.readFileSync(`${process.cwd()}/dist/index.html`, "utf-8");
|
|
365
397
|
const pagesPath = "/.mech/pages";
|
|
366
398
|
const window = { addEventListener() {
|
|
@@ -392,11 +424,11 @@ const compile = async () => {
|
|
|
392
424
|
const copiedFiles = /* @__PURE__ */ new Set();
|
|
393
425
|
const onFile = (imagePath) => {
|
|
394
426
|
if (!hasUploadFolder) {
|
|
395
|
-
fs.mkdirSync(`${process.cwd()}/export
|
|
427
|
+
fs.mkdirSync(`${process.cwd()}/export${uploadsUrl}`, { recursive: true });
|
|
396
428
|
hasUploadFolder = true;
|
|
397
429
|
}
|
|
398
430
|
const path = imagePath.replace("@mechanica", ".mech");
|
|
399
|
-
const newPath =
|
|
431
|
+
const newPath = uploadsUrl + imagePath.replace("/@mechanica", "").replace("/assets", "");
|
|
400
432
|
if (!copiedFiles.has(newPath)) {
|
|
401
433
|
copiedFiles.add(newPath);
|
|
402
434
|
fs.copyFileSync(`${process.cwd()}${path}`, `${process.cwd()}/export/${newPath}`);
|
|
@@ -425,6 +457,8 @@ const compile = async () => {
|
|
|
425
457
|
dataEntries: module.dataEntries,
|
|
426
458
|
projectData: {},
|
|
427
459
|
blocksMap,
|
|
460
|
+
baseUrl,
|
|
461
|
+
assetsUrl,
|
|
428
462
|
queryResolver: getQuery,
|
|
429
463
|
render,
|
|
430
464
|
onFile
|
package/dist/editor.js
CHANGED
|
@@ -2,9 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { defineComponent, ref, watch, createElementBlock, openBlock, normalizeStyle, createElementVNode, reactive, computed, shallowRef, onMounted, onBeforeUnmount, triggerRef, inject, normalizeClass, createCommentVNode, renderSlot, createVNode, createTextVNode, toDisplayString, Transition, withCtx, getCurrentScope, onScopeDispose, toRef as toRef$1, readonly, customRef, toValue as toValue$1, getCurrentInstance, nextTick, unref, createBlock, createSlots, withDirectives, vModelText, vModelDynamic, Fragment, renderList, h, TransitionGroup, useSlots, Teleport, mergeProps, withModifiers, mergeModels, useModel, createStaticVNode, resolveDynamicComponent, isRef, vShow, shallowReactive, vModelCheckbox, isProxy, toRaw, resolveComponent, normalizeProps, guardReactiveProps, provide, createApp } from "vue";
|
|
5
|
-
import { p as passDefaultValue, d as defaultImageSrc, g as getDefaultValue, r as registerAliases } from "./schemaAliases-
|
|
5
|
+
import { p as passDefaultValue, d as defaultImageSrc, g as getDefaultValue, r as registerAliases, a as registerAlias, u as unfoldSchema } from "./schemaAliases-3G_-tJU0.js";
|
|
6
6
|
import { blocksList as blocksList$1, addUpdateListener } from "virtual:builder-blocks";
|
|
7
|
-
import { unfoldSchema } from "compact-json-schema";
|
|
8
7
|
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
9
8
|
__name: "HoverFrame",
|
|
10
9
|
props: {
|
|
@@ -5716,7 +5715,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
5716
5715
|
};
|
|
5717
5716
|
}
|
|
5718
5717
|
});
|
|
5719
|
-
registerAliases();
|
|
5718
|
+
registerAliases(registerAlias);
|
|
5720
5719
|
const blocksList = shallowRef(blocksList$1.map((file) => ({
|
|
5721
5720
|
...file.blockSchema,
|
|
5722
5721
|
id: file.blockSchema.id ?? file.__name,
|