mechanica 2.0.1 → 2.0.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/README.md +35 -2
- package/bin/mechanica.js +3 -1
- package/dist/chunks/{ImagePickerDialog-6skSAzJh.js → ImagePickerDialog-DJGhtW3r.js} +1 -1
- package/dist/chunks/{editor-B0r4EOIM.js → editor-JV0Nhfw4.js} +1 -1
- package/dist/cli.js +448 -620
- package/dist/composer.js +2 -2
- package/dist/editor.js +2 -2
- package/dist/export.js +580 -0
- package/dist/types/cli/export.d.ts +31 -2
- package/dist/types/cli/platform/api.d.ts +33 -0
- package/dist/types/cli/platform/bundle-format.d.ts +40 -0
- package/dist/types/cli/platform/credentials.d.ts +11 -0
- package/dist/types/cli/platform/engine-version.d.ts +6 -0
- package/dist/types/cli/platform/git.d.ts +15 -0
- package/dist/types/cli/platform/link.d.ts +11 -0
- package/dist/types/cli/platform/login.d.ts +9 -0
- package/dist/types/cli/platform/push.d.ts +12 -0
- package/dist/types/cli/run-export.d.ts +7 -0
- package/dist/widgets.js +1 -1
- package/package.json +8 -3
- package/dist/types/cli/push.d.ts +0 -10
package/README.md
CHANGED
|
@@ -30,6 +30,37 @@ npm run export
|
|
|
30
30
|
|
|
31
31
|
Prefer Bun? `bun create mechanica my-site`, then `bun install` and `bun run dev`.
|
|
32
32
|
|
|
33
|
+
### With an AI coding agent
|
|
34
|
+
|
|
35
|
+
Claude Code, Codex and similar agents can set the site up and build it for you. Open an empty folder in the agent and paste:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Create a Mechanica site in this folder.
|
|
39
|
+
|
|
40
|
+
1. Check for Node.js 20.19+ (`node -v`) or Bun (`bun -v`). If neither is
|
|
41
|
+
installed, ask me before installing Bun from https://bun.sh.
|
|
42
|
+
2. Run `npm create mechanica@latest .` (or `bun create mechanica .`), install
|
|
43
|
+
the dependencies, and start the dev server in the background.
|
|
44
|
+
3. Read AGENTS.md in the project and follow it for everything else.
|
|
45
|
+
|
|
46
|
+
Then build: <describe your site>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To skip the pasting, install the skill once. It does the same setup and also handles a machine with no Node.js.
|
|
50
|
+
|
|
51
|
+
Claude Code:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
claude plugin marketplace add den59k/mechanica
|
|
55
|
+
claude plugin install mechanica@mechanica
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Codex: save [SKILL.md](https://github.com/den59k/mechanica/blob/main/plugins/mechanica/skills/create-mechanica-site/SKILL.md) as `~/.agents/skills/create-mechanica-site/SKILL.md`.
|
|
59
|
+
|
|
60
|
+
Then ask the agent to create a Mechanica site.
|
|
61
|
+
|
|
62
|
+
The starter's `AGENTS.md` teaches the agent how to write blocks and pages and how to check its work with screenshots, and points it at the documentation of the installed version. Run the agent on your own machine: the editor opens in your browser from the local dev server.
|
|
63
|
+
|
|
33
64
|
## A Mechanica project
|
|
34
65
|
|
|
35
66
|
```text
|
|
@@ -328,7 +359,9 @@ These drive a locally installed Chrome or Edge (or `--browser <path>`) and need
|
|
|
328
359
|
| `mechanica shot <blockId \| /path>` | Screenshot a block or a page. Flags: `--width`, `--data`, `--out`, `--full`, `--server`, `--browser` |
|
|
329
360
|
| `mechanica thumbs [--blocks]` | Regenerate page or block thumbnails for the editor |
|
|
330
361
|
| `mechanica images` | Generate image dimensions and blur-up previews for `.mech/assets` (needs `sharp`; `--force` redoes all) |
|
|
331
|
-
| `mechanica
|
|
362
|
+
| `mechanica login` | Sign in to the Mechanica platform and save an access token for this machine (`--host`, `--token`) |
|
|
363
|
+
| `mechanica link <slug>` | Point this repository at a site on the platform (`--create` makes the site) |
|
|
364
|
+
| `mechanica push` | Publish the committed project to the platform: pull what was edited online, `git push`, build and upload the bundle when the code changed, wait for the deploy |
|
|
332
365
|
|
|
333
366
|
## Plugin options
|
|
334
367
|
|
|
@@ -357,7 +390,7 @@ From `mechanica`:
|
|
|
357
390
|
- **Composables:** `usePages`, `usePagination`, `useFetch`, `useLocale`, `useLayout`, `usePageData` (the current page's path, `meta`, layout and locale), `useRouter`, `useRoute`
|
|
358
391
|
- **Helpers:** `imagePosition`
|
|
359
392
|
|
|
360
|
-
From `mechanica/plugin`: `mechanica` and the `PageProvider` type. From `mechanica/widgets`: `defineWidget` and `useWidgetServices` (uploads and the image picker inside widget editors). `mechanica/editor` and `mechanica/composer` are loaded by the plugin in development; you don't import them.
|
|
393
|
+
From `mechanica/plugin`: `mechanica` and the `PageProvider` type. From `mechanica/widgets`: `defineWidget` and `useWidgetServices` (uploads and the image picker inside widget editors). `mechanica/editor` and `mechanica/composer` are loaded by the plugin in development; you don't import them. From `mechanica/export`: `exportBuilt(projectDir, options)`, which statically renders an already built project (`dist/` + `.mech/`) without running a build and resolves to `{ pages, warnings }` — for render services that receive a prebuilt bundle; `options.outDir` sets where the site is written, and `options.fetchJson` replaces how `useFetch` requests are made.
|
|
361
394
|
|
|
362
395
|
## Upgrading from 1.x
|
|
363
396
|
|
package/bin/mechanica.js
CHANGED
|
@@ -10,6 +10,8 @@ const entry = process.versions.bun && existsSync(srcEntry) ? '../src/cli/cli.ts'
|
|
|
10
10
|
const { run } = await import(entry)
|
|
11
11
|
|
|
12
12
|
run(process.argv.slice(2)).catch((error) => {
|
|
13
|
-
|
|
13
|
+
// A plain Error is a message for the user (bad usage, a refused push);
|
|
14
|
+
// anything else is a bug worth its stack trace.
|
|
15
|
+
console.error(error?.constructor === Error ? `mechanica: ${error.message}` : error)
|
|
14
16
|
process.exit(1)
|
|
15
17
|
})
|
|
@@ -6,7 +6,7 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
|
6
6
|
return target;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region \0svg-glob
|
|
9
|
+
//#region \0svg-glob:/home/runner/work/mechanica/mechanica/packages/mechanica/src/editor/icons
|
|
10
10
|
var contents = {
|
|
11
11
|
"align-center": `<path d="M4 6h16M7 12h10M6 18h12"/>`,
|
|
12
12
|
"align-left": `<path d="M4 6h16M4 12h10M4 18h13"/>`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as renderCrop, c as useDialog, d as _plugin_vue_export_helper_default, i as readImageSize, l as VIcon_default, n as VDialog_default, r as analyzeImageFile, s as dialogKey, t as ImagePickerDialog_default } from "./ImagePickerDialog-
|
|
1
|
+
import { a as renderCrop, c as useDialog, d as _plugin_vue_export_helper_default, i as readImageSize, l as VIcon_default, n as VDialog_default, r as analyzeImageFile, s as dialogKey, t as ImagePickerDialog_default } from "./ImagePickerDialog-DJGhtW3r.js";
|
|
2
2
|
import { Fragment, Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onErrorCaptured, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, unref, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
3
3
|
import { deepEqual, getDefaultValue } from "mechanica-shared";
|
|
4
4
|
import { unfoldSchema } from "compact-json-schema";
|