mechanica 2.0.0 → 2.0.1

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/README.md CHANGED
@@ -45,7 +45,7 @@ src/composer.ts optional: your design system for the Block Composer
45
45
  .mech/data.json site-wide data values
46
46
  ```
47
47
 
48
- `.mech/` is content — commit it. Scaffolded projects also include a `CLAUDE.md` that teaches AI coding assistants to author blocks and pages in this format.
48
+ `.mech/` is content — commit it. Scaffolded projects also include an `AGENTS.md` that teaches AI coding assistants (Claude Code, Codex and others) to author blocks and pages in this format.
49
49
 
50
50
  ### Adding Mechanica to an existing Vite + Vue project
51
51
 
@@ -139,14 +139,29 @@ data:
139
139
 
140
140
  ::: hero
141
141
  title: About us
142
+ cta: { url: /contacts, title: Write to us }
142
143
  @subtitle
143
144
  We build fast websites
144
145
  for people who care about the details.
145
146
  :::
147
+
148
+ ::: columns
149
+ gap: lg
150
+ ::: card slot=left
151
+ title: Fast
152
+ :::
153
+ ::: card slot=right
154
+ title: Readable
155
+ :::
156
+ ::: /columns
146
157
  ```
147
158
 
148
159
  - The YAML frontmatter holds the editor label (`name`), page-scoped data (`data`) and optional `layout`, `draft: true` (hidden from listings and the export) and `meta` (`noindex: true`, `lastmod`).
149
- - Each block is a fence: `::: <blockId>`, then its props as YAML, then `@field` regions for long text, closed by `:::`. A region fills a `text` prop with its text as written, and a `richText` prop with its Markdown turned into rich text. Blocks nest by placing fences inside a container's fence.
160
+ - Each block is a fence: `::: <blockId>`, then its props as YAML, then `@field` regions for long text, then any child blocks, closed by `:::`. Keep that order: once a region has started, a `key: value` line is part of its text.
161
+ - A region runs until the next `@field`, child block or `:::`, and is taken as written, blank lines and Markdown included. It fills a `text` prop with that text, and a `richText` prop with its Markdown turned into rich text.
162
+ - Blocks nest by placing fences inside a container's fence, and `slot=<name>` puts a child into a named slot (a container's children go either all to the default slot or all to named ones). Nothing is indented: every `:::` and `@field` starts at the beginning of its line, and a block is a child of whichever fence is still open. A container may close with `::: /<blockId>`, which reports a missing `:::` at the line where the fences stop pairing up.
163
+ - Props are YAML, so quote a value that starts with `#` or contains `: `, as in `href: "#pricing"`. Inside a region nothing needs quoting; only a line that starts with `:::`, or consists of just `@name`, takes a leading backslash (`\:::`), and not even that inside a code fence.
164
+ - An `image` prop points at an uploaded file: `photo: { src: /@mechanica/assets/team.jpg, alt: "Our team" }`.
150
165
  - Props left out take their schema defaults, so a hand-written page renders exactly like one made in the editor.
151
166
 
152
167
  With `npm run dev` running, edits you make to these files show up in the editor live, and the editor won't overwrite a file that changed on disk underneath it.
package/bin/mechanica.js CHANGED
File without changes
@@ -975,6 +975,12 @@ function resolveChunkAssets(manifest, key, into = {
975
975
  * Build the `<link>` tags for one page: stylesheets first (they must apply
976
976
  * before first paint — the server-rendered blocks are already in the HTML),
977
977
  * then `modulepreload` for the block chunks and their shared imports.
978
+ *
979
+ * Every tag carries `crossorigin`, like the ones Vite writes into the built
980
+ * index: a later `import()` of the same chunk always fetches in CORS mode, and
981
+ * on a cross-origin CDN a copy cached by a no-CORS hint has no
982
+ * `Access-Control-Allow-Origin`, so the browser would block the import. The
983
+ * attribute is a no-op for same-origin builds.
978
984
  */
979
985
  function blockAssetLinks(options) {
980
986
  const keyByFile = /* @__PURE__ */ new Map();
@@ -991,7 +997,7 @@ function blockAssetLinks(options) {
991
997
  }
992
998
  const wanted = (file) => !options.alreadyLinked?.(file);
993
999
  const href = (file) => `${options.base ?? ""}/${file}`;
994
- return [...assets.css.filter(wanted).map((file) => `<link rel="stylesheet" href="${href(file)}">`), ...assets.js.filter(wanted).map((file) => `<link rel="modulepreload" href="${href(file)}">`)];
1000
+ return [...assets.css.filter(wanted).map((file) => `<link rel="stylesheet" crossorigin href="${href(file)}">`), ...assets.js.filter(wanted).map((file) => `<link rel="modulepreload" crossorigin href="${href(file)}">`)];
995
1001
  }
996
1002
  //#endregion
997
1003
  export { renamePage as A, readImageManifest as B, getPagePath as C, pageUrlOf as D, movePage as E, translationsOf as F, wasRecentlyMutated as G, saveUpload as H, UPLOADS_PREFIX as I, hasSharp as J, writeFileAtomic as K, assetFileOf as L, setPageBlocks as M, setPageCodec as N, pageVersion as O, setPageDraft as P, isDerivedAsset as R, fillImageMeta as S, listPages as T, updateImageManifest as U, saveDerivedAsset as V, markMutated as W, isRasterImage as Y, createTranslation as _, toBlockMeta as a, duplicatePage as b, mergeLocaleFolderData as c, readFolderData as d, readFoldersData as f, createPage as g, PageExistsError as h, composedBlockMeta as i, savePage as j, readPage as k, mergeLocaleSiteData as l, readSiteLocaleOverride as m, blockAssetLinks as n, folderOf as o, readSiteData as p, analyzeImageBuffer as q, buildRichTextCodec as r, mergeFolderData as s, BLOCKS_MANIFEST_FILE as t, mergeSiteData as u, deletePage as v, listFolders as w, fillContentDefaults as x, deleteTranslation as y, listImages as z };
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as readImageManifest, C as getPagePath, I as UPLOADS_PREFIX, J as hasSharp, L as assetFileOf, N as setPageCodec, R as isDerivedAsset, T as listPages, U as updateImageManifest, Y as isRasterImage, a as toBlockMeta, d as readFolderData, f as readFoldersData, i as composedBlockMeta, m as readSiteLocaleOverride, n as blockAssetLinks, p as readSiteData, q as analyzeImageBuffer, r as buildRichTextCodec, t as BLOCKS_MANIFEST_FILE } from "./chunks/page-assets-Bp6mxPSy.js";
1
+ import { B as readImageManifest, C as getPagePath, I as UPLOADS_PREFIX, J as hasSharp, L as assetFileOf, N as setPageCodec, R as isDerivedAsset, T as listPages, U as updateImageManifest, Y as isRasterImage, a as toBlockMeta, d as readFolderData, f as readFoldersData, i as composedBlockMeta, m as readSiteLocaleOverride, n as blockAssetLinks, p as readSiteData, q as analyzeImageBuffer, r as buildRichTextCodec, t as BLOCKS_MANIFEST_FILE } from "./chunks/page-assets-CM_MCuoa.js";
2
2
  import fs from "node:fs";
3
3
  import { dirname, join, parse, relative } from "node:path";
4
4
  import { applySeoTags, auditPageHtml, buildRobotsTxt, buildSitemap, findUnknownBlocks, generateProject, isPaginatedQuery, localePath, mergeTranslation, migrateContent, paginationVariantPath, registerFieldSchemas, resolveQueryKey, templateBlockIds, validateLinks, walkSchema, walkTree } from "mechanica-shared";
package/dist/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as renamePage, D as pageUrlOf, E as movePage, F as translationsOf, G as wasRecentlyMutated, H as saveUpload, K as writeFileAtomic, M as setPageBlocks, N as setPageCodec, O as pageVersion, P as setPageDraft, S as fillImageMeta, T as listPages, V as saveDerivedAsset, W as markMutated, _ as createTranslation, a as toBlockMeta, b as duplicatePage, c as mergeLocaleFolderData, d as readFolderData, g as createPage, h as PageExistsError, i as composedBlockMeta, j as savePage, k as readPage, l as mergeLocaleSiteData, o as folderOf, p as readSiteData, r as buildRichTextCodec, s as mergeFolderData, t as BLOCKS_MANIFEST_FILE, u as mergeSiteData, v as deletePage, w as listFolders, x as fillContentDefaults, y as deleteTranslation, z as listImages } from "./chunks/page-assets-Bp6mxPSy.js";
1
+ import { A as renamePage, D as pageUrlOf, E as movePage, F as translationsOf, G as wasRecentlyMutated, H as saveUpload, K as writeFileAtomic, M as setPageBlocks, N as setPageCodec, O as pageVersion, P as setPageDraft, S as fillImageMeta, T as listPages, V as saveDerivedAsset, W as markMutated, _ as createTranslation, a as toBlockMeta, b as duplicatePage, c as mergeLocaleFolderData, d as readFolderData, g as createPage, h as PageExistsError, i as composedBlockMeta, j as savePage, k as readPage, l as mergeLocaleSiteData, o as folderOf, p as readSiteData, r as buildRichTextCodec, s as mergeFolderData, t as BLOCKS_MANIFEST_FILE, u as mergeSiteData, v as deletePage, w as listFolders, x as fillContentDefaults, y as deleteTranslation, z as listImages } from "./chunks/page-assets-CM_MCuoa.js";
2
2
  import fs, { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { basename, join, relative, resolve, sep } from "node:path";
4
4
  import { parseVueRequest } from "@vitejs/plugin-vue";
@@ -68,5 +68,11 @@ export interface BlockAssetLinkOptions {
68
68
  * Build the `<link>` tags for one page: stylesheets first (they must apply
69
69
  * before first paint — the server-rendered blocks are already in the HTML),
70
70
  * then `modulepreload` for the block chunks and their shared imports.
71
+ *
72
+ * Every tag carries `crossorigin`, like the ones Vite writes into the built
73
+ * index: a later `import()` of the same chunk always fetches in CORS mode, and
74
+ * on a cross-origin CDN a copy cached by a no-CORS hint has no
75
+ * `Access-Control-Allow-Origin`, so the browser would block the import. The
76
+ * attribute is a no-op for same-origin builds.
71
77
  */
72
78
  export declare function blockAssetLinks(options: BlockAssetLinkOptions): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mechanica",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Build Vue 3 websites with a visual block editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,10 +54,10 @@
54
54
  "test": "vitest run",
55
55
  "test:watch": "vitest",
56
56
  "typecheck": "tsc --noEmit",
57
- "prepublishOnly": "bun run build"
57
+ "prepublishOnly": "bun ../../scripts/ensure-bun-publish.js && bun run build"
58
58
  },
59
59
  "dependencies": {
60
- "mechanica-shared": "workspace:*",
60
+ "mechanica-shared": "2.0.1",
61
61
  "@vue/compiler-sfc": "^3.5.38",
62
62
  "compact-json-schema": "^0.1.5",
63
63
  "estree-walker": "^3.0.3",