mockpit 1.2.0 → 2.0.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/README.md +69 -48
- package/bin/demoData.js +3 -3
- package/bin/mockpit.js +426 -51
- package/dist/mcp/server.js +45 -7
- package/dist/server/apiViews.d.ts +407 -21
- package/dist/server/apiViews.js +110 -11
- package/dist/server/app.d.ts +5 -1
- package/dist/server/app.js +1454 -192
- package/dist/server/codeWorker.js +2 -1
- package/dist/server/decisions.d.ts +23 -0
- package/dist/server/decisions.js +100 -0
- package/dist/server/designGuide.d.ts +6 -2
- package/dist/server/designGuide.js +96 -27
- package/dist/server/embeds.d.ts +26 -0
- package/dist/server/embeds.js +144 -0
- package/dist/server/eventLog.js +2 -1
- package/dist/server/feedbackBatch.d.ts +15 -4
- package/dist/server/feedbackBatch.js +31 -7
- package/dist/server/fills.d.ts +41 -0
- package/dist/server/fills.js +328 -0
- package/dist/server/guidance.d.ts +23 -0
- package/dist/server/guidance.js +71 -0
- package/dist/server/index.js +25 -2
- package/dist/server/knobs.d.ts +6 -2
- package/dist/server/knobs.js +11 -1
- package/dist/server/mcpHttp.d.ts +6 -0
- package/dist/server/mcpHttp.js +35 -0
- package/dist/server/mcpSpec.d.ts +14 -13
- package/dist/server/mcpSpec.js +133 -18
- package/dist/server/postSurfaces.js +6 -12
- package/dist/server/richRender.js +3 -1
- package/dist/server/run.js +10 -1
- package/dist/server/runApi.d.ts +3 -3
- package/dist/server/runApi.js +18 -13
- package/dist/server/sqlStore.d.ts +97 -5
- package/dist/server/sqlStore.js +367 -27
- package/dist/server/surfacePage.d.ts +6 -2
- package/dist/server/surfacePage.js +142 -10
- package/dist/server/themes.d.ts +2 -0
- package/dist/server/themes.js +23 -3
- package/dist/server/types.d.ts +107 -16
- package/dist/server/types.js +73 -10
- package/dist/server/viewerRequest.d.ts +2 -0
- package/dist/server/viewerRequest.js +14 -0
- package/extensions/mockpit.js +179 -16
- package/guide/packs/design-craft.md +35 -0
- package/guide/topics/asks.md +82 -31
- package/guide/topics/feedback.md +151 -43
- package/guide/topics/html.md +8 -10
- package/guide/topics/http.md +8 -4
- package/guide/topics/knobs.md +4 -3
- package/guide/topics/scripts.md +2 -2
- package/guide/topics/surfaces.md +45 -11
- package/package.json +3 -15
- package/skills/launch-video/SKILL.md +2 -2
- package/skills/mockpit/SKILL.md +23 -7
- package/viewer/dist/index.html +9 -8
- package/dist/server/slots.d.ts +0 -14
- package/dist/server/slots.js +0 -71
package/dist/server/slots.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Slot } from "./types.ts";
|
|
2
|
-
export interface SlotTag {
|
|
3
|
-
raw: string;
|
|
4
|
-
slug: string;
|
|
5
|
-
variant: string;
|
|
6
|
-
version: number | null;
|
|
7
|
-
}
|
|
8
|
-
export declare function parseSlotTags(html: string): SlotTag[];
|
|
9
|
-
export declare function resolveSlots(html: string, currentVersion: (slug: string, variant: string) => number | null): Slot[];
|
|
10
|
-
export declare function expandSlots(html: string, body: (slot: {
|
|
11
|
-
slug: string;
|
|
12
|
-
variant: string;
|
|
13
|
-
version: number | null;
|
|
14
|
-
}) => string | null): string;
|
package/dist/server/slots.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Page composition: `<mockpit-slot slug="…" variant="…" version="…">` tags in a
|
|
2
|
-
// page item's html are expanded server-side by inlining the referenced variant
|
|
3
|
-
// version's first html surface body. Snapshot semantics — publish resolves a
|
|
4
|
-
// missing `version` to the component's current one and stores the resolved list
|
|
5
|
-
// on the post, so a page keeps rendering what it was composed from.
|
|
6
|
-
//
|
|
7
|
-
// Runtime-agnostic (no node imports) and string-only: the result is handed to
|
|
8
|
-
// renderHtmlPage, which serves it from /s/:id under the sandbox CSP header, so
|
|
9
|
-
// an inlined component body is exactly as contained as the page's own markup.
|
|
10
|
-
const SLOT_TAG = /<mockpit-slot\b([^>]*?)(?:\/>|>\s*<\/mockpit-slot\s*>|>)/gi;
|
|
11
|
-
const ATTR = /([a-z-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi;
|
|
12
|
-
function attributes(raw) {
|
|
13
|
-
const out = {};
|
|
14
|
-
ATTR.lastIndex = 0;
|
|
15
|
-
let m;
|
|
16
|
-
while ((m = ATTR.exec(raw)))
|
|
17
|
-
out[m[1].toLowerCase()] = m[2] ?? m[3] ?? m[4] ?? "";
|
|
18
|
-
return out;
|
|
19
|
-
}
|
|
20
|
-
export function parseSlotTags(html) {
|
|
21
|
-
const tags = [];
|
|
22
|
-
SLOT_TAG.lastIndex = 0;
|
|
23
|
-
let m;
|
|
24
|
-
while ((m = SLOT_TAG.exec(html))) {
|
|
25
|
-
const attrs = attributes(m[1] ?? "");
|
|
26
|
-
const slug = attrs.slug ?? "";
|
|
27
|
-
if (!slug)
|
|
28
|
-
continue;
|
|
29
|
-
const version = Number(attrs.version);
|
|
30
|
-
tags.push({
|
|
31
|
-
raw: m[0],
|
|
32
|
-
slug,
|
|
33
|
-
variant: attrs.variant || "default",
|
|
34
|
-
version: Number.isInteger(version) && version > 0 ? version : null,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return tags;
|
|
38
|
-
}
|
|
39
|
-
// The slot list to store on a page post: every tag with its version resolved
|
|
40
|
-
// (a missing one pins to the component's current version at publish time).
|
|
41
|
-
export function resolveSlots(html, currentVersion) {
|
|
42
|
-
const slots = [];
|
|
43
|
-
for (const tag of parseSlotTags(html)) {
|
|
44
|
-
const version = tag.version ?? currentVersion(tag.slug, tag.variant);
|
|
45
|
-
if (version == null)
|
|
46
|
-
continue;
|
|
47
|
-
slots.push({ slug: tag.slug, variant: tag.variant, version });
|
|
48
|
-
}
|
|
49
|
-
return slots;
|
|
50
|
-
}
|
|
51
|
-
const escapeAttr = (s) => s.replace(/&/g, "&").replace(/"/g, """);
|
|
52
|
-
// Replace each tag with the resolved body. An unresolvable slot renders as an
|
|
53
|
-
// empty marked-up placeholder rather than vanishing, so a broken reference is
|
|
54
|
-
// visible in review instead of silently changing the layout.
|
|
55
|
-
export function expandSlots(html, body) {
|
|
56
|
-
SLOT_TAG.lastIndex = 0;
|
|
57
|
-
return html.replace(SLOT_TAG, (raw, attrRaw) => {
|
|
58
|
-
const attrs = attributes(attrRaw ?? "");
|
|
59
|
-
const slug = attrs.slug ?? "";
|
|
60
|
-
if (!slug)
|
|
61
|
-
return raw;
|
|
62
|
-
const variant = attrs.variant || "default";
|
|
63
|
-
const parsed = Number(attrs.version);
|
|
64
|
-
const version = Number.isInteger(parsed) && parsed > 0 ? parsed : null;
|
|
65
|
-
const resolved = body({ slug, variant, version });
|
|
66
|
-
const label = `data-mockpit-slot="${escapeAttr(slug)}" data-mockpit-variant="${escapeAttr(variant)}"${version == null ? "" : ` data-mockpit-version="${version}"`}`;
|
|
67
|
-
return resolved == null
|
|
68
|
-
? `<div ${label} data-mockpit-missing="1"></div>`
|
|
69
|
-
: `<div ${label}>${resolved}</div>`;
|
|
70
|
-
});
|
|
71
|
-
}
|