@caretcms/core 0.1.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/LICENSE +21 -0
- package/README.md +191 -0
- package/dist/browser-runtime.d.ts +12 -0
- package/dist/browser-runtime.d.ts.map +1 -0
- package/dist/browser-runtime.js +298 -0
- package/dist/browser-runtime.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +343 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +61 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +80 -0
- package/dist/loader.js.map +1 -0
- package/dist/providers/storage/filesystem.d.ts +7 -0
- package/dist/providers/storage/filesystem.d.ts.map +1 -0
- package/dist/providers/storage/filesystem.js +6 -0
- package/dist/providers/storage/filesystem.js.map +1 -0
- package/dist/providers/uploads/local.d.ts +6 -0
- package/dist/providers/uploads/local.d.ts.map +1 -0
- package/dist/providers/uploads/local.js +6 -0
- package/dist/providers/uploads/local.js.map +1 -0
- package/dist/runtime/auth/cookie-utils.d.ts +3 -0
- package/dist/runtime/auth/cookie-utils.d.ts.map +1 -0
- package/dist/runtime/auth/cookie-utils.js +33 -0
- package/dist/runtime/auth/cookie-utils.js.map +1 -0
- package/dist/runtime/auth/demo-session.d.ts +24 -0
- package/dist/runtime/auth/demo-session.d.ts.map +1 -0
- package/dist/runtime/auth/demo-session.js +42 -0
- package/dist/runtime/auth/demo-session.js.map +1 -0
- package/dist/runtime/auth/rate-limiter.d.ts +26 -0
- package/dist/runtime/auth/rate-limiter.d.ts.map +1 -0
- package/dist/runtime/auth/rate-limiter.js +65 -0
- package/dist/runtime/auth/rate-limiter.js.map +1 -0
- package/dist/runtime/auth/session.d.ts +14 -0
- package/dist/runtime/auth/session.d.ts.map +1 -0
- package/dist/runtime/auth/session.js +128 -0
- package/dist/runtime/auth/session.js.map +1 -0
- package/dist/runtime/bind.d.ts +14 -0
- package/dist/runtime/bind.d.ts.map +1 -0
- package/dist/runtime/bind.js +19 -0
- package/dist/runtime/bind.js.map +1 -0
- package/dist/runtime/config.d.ts +20 -0
- package/dist/runtime/config.d.ts.map +1 -0
- package/dist/runtime/config.js +40 -0
- package/dist/runtime/config.js.map +1 -0
- package/dist/runtime/content.d.ts +28 -0
- package/dist/runtime/content.d.ts.map +1 -0
- package/dist/runtime/content.js +37 -0
- package/dist/runtime/content.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +16 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/middleware.d.ts +14 -0
- package/dist/runtime/middleware.d.ts.map +1 -0
- package/dist/runtime/middleware.js +80 -0
- package/dist/runtime/middleware.js.map +1 -0
- package/dist/runtime/mutations/contracts.d.ts +91 -0
- package/dist/runtime/mutations/contracts.d.ts.map +1 -0
- package/dist/runtime/mutations/contracts.js +320 -0
- package/dist/runtime/mutations/contracts.js.map +1 -0
- package/dist/runtime/mutations/engine.d.ts +23 -0
- package/dist/runtime/mutations/engine.d.ts.map +1 -0
- package/dist/runtime/mutations/engine.js +255 -0
- package/dist/runtime/mutations/engine.js.map +1 -0
- package/dist/runtime/providers.d.ts +9 -0
- package/dist/runtime/providers.d.ts.map +1 -0
- package/dist/runtime/providers.js +44 -0
- package/dist/runtime/providers.js.map +1 -0
- package/dist/runtime/request-context.d.ts +11 -0
- package/dist/runtime/request-context.d.ts.map +1 -0
- package/dist/runtime/request-context.js +16 -0
- package/dist/runtime/request-context.js.map +1 -0
- package/dist/runtime/rewrite.d.ts +13 -0
- package/dist/runtime/rewrite.d.ts.map +1 -0
- package/dist/runtime/rewrite.js +253 -0
- package/dist/runtime/rewrite.js.map +1 -0
- package/dist/runtime/routes/_helpers.d.ts +17 -0
- package/dist/runtime/routes/_helpers.d.ts.map +1 -0
- package/dist/runtime/routes/_helpers.js +38 -0
- package/dist/runtime/routes/_helpers.js.map +1 -0
- package/dist/runtime/routes/admin-entry.d.ts +3 -0
- package/dist/runtime/routes/admin-entry.d.ts.map +1 -0
- package/dist/runtime/routes/admin-entry.js +170 -0
- package/dist/runtime/routes/admin-entry.js.map +1 -0
- package/dist/runtime/routes/admin.d.ts +3 -0
- package/dist/runtime/routes/admin.d.ts.map +1 -0
- package/dist/runtime/routes/admin.js +189 -0
- package/dist/runtime/routes/admin.js.map +1 -0
- package/dist/runtime/routes/auth-login.d.ts +4 -0
- package/dist/runtime/routes/auth-login.d.ts.map +1 -0
- package/dist/runtime/routes/auth-login.js +71 -0
- package/dist/runtime/routes/auth-login.js.map +1 -0
- package/dist/runtime/routes/auth-logout.d.ts +4 -0
- package/dist/runtime/routes/auth-logout.d.ts.map +1 -0
- package/dist/runtime/routes/auth-logout.js +47 -0
- package/dist/runtime/routes/auth-logout.js.map +1 -0
- package/dist/runtime/routes/auth-session.d.ts +3 -0
- package/dist/runtime/routes/auth-session.d.ts.map +1 -0
- package/dist/runtime/routes/auth-session.js +8 -0
- package/dist/runtime/routes/auth-session.js.map +1 -0
- package/dist/runtime/routes/collection-list.d.ts +3 -0
- package/dist/runtime/routes/collection-list.d.ts.map +1 -0
- package/dist/runtime/routes/collection-list.js +420 -0
- package/dist/runtime/routes/collection-list.js.map +1 -0
- package/dist/runtime/routes/collections-metadata.d.ts +3 -0
- package/dist/runtime/routes/collections-metadata.d.ts.map +1 -0
- package/dist/runtime/routes/collections-metadata.js +17 -0
- package/dist/runtime/routes/collections-metadata.js.map +1 -0
- package/dist/runtime/routes/editor-assets.d.ts +3 -0
- package/dist/runtime/routes/editor-assets.d.ts.map +1 -0
- package/dist/runtime/routes/editor-assets.js +73 -0
- package/dist/runtime/routes/editor-assets.js.map +1 -0
- package/dist/runtime/routes/entries.d.ts +3 -0
- package/dist/runtime/routes/entries.d.ts.map +1 -0
- package/dist/runtime/routes/entries.js +96 -0
- package/dist/runtime/routes/entries.js.map +1 -0
- package/dist/runtime/routes/history.d.ts +4 -0
- package/dist/runtime/routes/history.d.ts.map +1 -0
- package/dist/runtime/routes/history.js +54 -0
- package/dist/runtime/routes/history.js.map +1 -0
- package/dist/runtime/routes/mutate.d.ts +4 -0
- package/dist/runtime/routes/mutate.d.ts.map +1 -0
- package/dist/runtime/routes/mutate.js +38 -0
- package/dist/runtime/routes/mutate.js.map +1 -0
- package/dist/runtime/routes/schema.d.ts +3 -0
- package/dist/runtime/routes/schema.d.ts.map +1 -0
- package/dist/runtime/routes/schema.js +58 -0
- package/dist/runtime/routes/schema.js.map +1 -0
- package/dist/runtime/routes/studio-home.d.ts +3 -0
- package/dist/runtime/routes/studio-home.d.ts.map +1 -0
- package/dist/runtime/routes/studio-home.js +99 -0
- package/dist/runtime/routes/studio-home.js.map +1 -0
- package/dist/runtime/routes/theme-stylesheet.d.ts +3 -0
- package/dist/runtime/routes/theme-stylesheet.d.ts.map +1 -0
- package/dist/runtime/routes/theme-stylesheet.js +32 -0
- package/dist/runtime/routes/theme-stylesheet.js.map +1 -0
- package/dist/runtime/routes/upload.d.ts +3 -0
- package/dist/runtime/routes/upload.d.ts.map +1 -0
- package/dist/runtime/routes/upload.js +33 -0
- package/dist/runtime/routes/upload.js.map +1 -0
- package/dist/runtime/sanitize-html.d.ts +8 -0
- package/dist/runtime/sanitize-html.d.ts.map +1 -0
- package/dist/runtime/sanitize-html.js +86 -0
- package/dist/runtime/sanitize-html.js.map +1 -0
- package/dist/runtime/schema/template.d.ts +15 -0
- package/dist/runtime/schema/template.d.ts.map +1 -0
- package/dist/runtime/schema/template.js +38 -0
- package/dist/runtime/schema/template.js.map +1 -0
- package/dist/runtime/schema-registry.d.ts +17 -0
- package/dist/runtime/schema-registry.d.ts.map +1 -0
- package/dist/runtime/schema-registry.js +16 -0
- package/dist/runtime/schema-registry.js.map +1 -0
- package/dist/runtime/storage/filesystem-adapter.d.ts +36 -0
- package/dist/runtime/storage/filesystem-adapter.d.ts.map +1 -0
- package/dist/runtime/storage/filesystem-adapter.js +291 -0
- package/dist/runtime/storage/filesystem-adapter.js.map +1 -0
- package/dist/runtime/storage/filesystem-upload-handler.d.ts +11 -0
- package/dist/runtime/storage/filesystem-upload-handler.d.ts.map +1 -0
- package/dist/runtime/storage/filesystem-upload-handler.js +20 -0
- package/dist/runtime/storage/filesystem-upload-handler.js.map +1 -0
- package/dist/runtime/storage/image-validation.d.ts +28 -0
- package/dist/runtime/storage/image-validation.d.ts.map +1 -0
- package/dist/runtime/storage/image-validation.js +94 -0
- package/dist/runtime/storage/image-validation.js.map +1 -0
- package/dist/runtime/storage/in-memory-adapter.d.ts +29 -0
- package/dist/runtime/storage/in-memory-adapter.d.ts.map +1 -0
- package/dist/runtime/storage/in-memory-adapter.js +110 -0
- package/dist/runtime/storage/in-memory-adapter.js.map +1 -0
- package/dist/runtime/storage/quota-upload-handler.d.ts +27 -0
- package/dist/runtime/storage/quota-upload-handler.d.ts.map +1 -0
- package/dist/runtime/storage/quota-upload-handler.js +34 -0
- package/dist/runtime/storage/quota-upload-handler.js.map +1 -0
- package/dist/runtime/storage/session-overlay-adapter.d.ts +33 -0
- package/dist/runtime/storage/session-overlay-adapter.d.ts.map +1 -0
- package/dist/runtime/storage/session-overlay-adapter.js +121 -0
- package/dist/runtime/storage/session-overlay-adapter.js.map +1 -0
- package/dist/runtime/themes/preset-tokens.d.ts +17 -0
- package/dist/runtime/themes/preset-tokens.d.ts.map +1 -0
- package/dist/runtime/themes/preset-tokens.js +47 -0
- package/dist/runtime/themes/preset-tokens.js.map +1 -0
- package/dist/runtime/utils.d.ts +6 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/utils.js +29 -0
- package/dist/runtime/utils.js.map +1 -0
- package/dist/runtime/views/studio-layout.d.ts +25 -0
- package/dist/runtime/views/studio-layout.d.ts.map +1 -0
- package/dist/runtime/views/studio-layout.js +108 -0
- package/dist/runtime/views/studio-layout.js.map +1 -0
- package/dist/schema-utils.d.ts +16 -0
- package/dist/schema-utils.d.ts.map +1 -0
- package/dist/schema-utils.js +62 -0
- package/dist/schema-utils.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/editor-runtime.d.ts +6 -0
- package/editor-runtime.js +2 -0
- package/package.json +88 -0
- package/static/cms/admin-entry.css +207 -0
- package/static/cms/admin-entry.js +1083 -0
- package/static/cms/editor/config.js +118 -0
- package/static/cms/editor/content-map.css +141 -0
- package/static/cms/editor/content-map.js +172 -0
- package/static/cms/editor/guards.js +72 -0
- package/static/cms/editor/helpers.js +51 -0
- package/static/cms/editor/image-edit.js +151 -0
- package/static/cms/editor/image-utils.js +84 -0
- package/static/cms/editor/image.css +133 -0
- package/static/cms/editor/link-follow.js +144 -0
- package/static/cms/editor/link-ui.css +199 -0
- package/static/cms/editor/linkify.js +55 -0
- package/static/cms/editor/panel.css +91 -0
- package/static/cms/editor/panel.js +70 -0
- package/static/cms/editor/rich-toolbar.css +67 -0
- package/static/cms/editor/rich-toolbar.js +200 -0
- package/static/cms/editor/sanitize.js +89 -0
- package/static/cms/editor/save-queue.js +166 -0
- package/static/cms/editor/section-controls/activation.js +10 -0
- package/static/cms/editor/section-controls/api.js +87 -0
- package/static/cms/editor/section-controls/constants.js +24 -0
- package/static/cms/editor/section-controls/index.js +622 -0
- package/static/cms/editor/section-controls/model.js +76 -0
- package/static/cms/editor/section-controls/mutations.js +112 -0
- package/static/cms/editor/section-controls/page-context.js +34 -0
- package/static/cms/editor/section-controls/pickers.js +196 -0
- package/static/cms/editor/section-controls/reorder.js +92 -0
- package/static/cms/editor/section-controls/selection.js +54 -0
- package/static/cms/editor/section-controls/spacing-drag.js +83 -0
- package/static/cms/editor/section-controls/ui-elements.js +54 -0
- package/static/cms/editor/section-controls/utils.js +35 -0
- package/static/cms/editor/section-controls.css +349 -0
- package/static/cms/editor/section-controls.js +1 -0
- package/static/cms/editor/security.js +48 -0
- package/static/cms/editor/sync.js +72 -0
- package/static/cms/editor/text-edit.js +151 -0
- package/static/cms/editor/text-link-interactions.js +254 -0
- package/static/cms/editor/toast.css +50 -0
- package/static/cms/editor/toast.js +29 -0
- package/static/cms/editor/tokens-and-text.css +93 -0
- package/static/cms/editor/toolbar.css +249 -0
- package/static/cms/editor/toolbar.js +117 -0
- package/static/cms/editor.css +12 -0
- package/static/cms/editor.js +116 -0
- package/static/cms/studio-login.css +300 -0
- package/static/cms/studio-tokens.css +85 -0
- package/static/cms/studio.css +437 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTML chrome for studio pages (dashboard, collection list, entry editor).
|
|
3
|
+
* Renders the document, theme stylesheet links, sticky header with brand mark,
|
|
4
|
+
* breadcrumb trail, and slots in the page-specific body content.
|
|
5
|
+
*/
|
|
6
|
+
export function escapeHtml(value) {
|
|
7
|
+
return value
|
|
8
|
+
.replace(/&/g, "&")
|
|
9
|
+
.replace(/</g, "<")
|
|
10
|
+
.replace(/>/g, ">")
|
|
11
|
+
.replace(/"/g, """)
|
|
12
|
+
.replace(/'/g, "'");
|
|
13
|
+
}
|
|
14
|
+
function renderBrandMark(logo) {
|
|
15
|
+
if (logo) {
|
|
16
|
+
return `<img src="${escapeHtml(logo)}" alt="" class="studio-brand-mark" style="object-fit: contain;" />`;
|
|
17
|
+
}
|
|
18
|
+
return `<svg class="studio-brand-mark" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
19
|
+
<path d="M12 2L2 9l10 13 10-13L12 2zm0 3.84L18.26 9 12 17.65 5.74 9 12 5.84z"/>
|
|
20
|
+
</svg>`;
|
|
21
|
+
}
|
|
22
|
+
function renderBreadcrumb(mountPath, crumbs) {
|
|
23
|
+
if (crumbs.length === 0)
|
|
24
|
+
return "";
|
|
25
|
+
const items = crumbs
|
|
26
|
+
.map((crumb, idx) => {
|
|
27
|
+
const isLast = idx === crumbs.length - 1;
|
|
28
|
+
const sep = idx === 0 ? "" : `<span class="studio-breadcrumb-sep">/</span>`;
|
|
29
|
+
if (isLast || !crumb.href) {
|
|
30
|
+
return `${sep}<span class="studio-breadcrumb-current">${escapeHtml(crumb.label)}</span>`;
|
|
31
|
+
}
|
|
32
|
+
return `${sep}<a href="${escapeHtml(crumb.href)}">${escapeHtml(crumb.label)}</a>`;
|
|
33
|
+
})
|
|
34
|
+
.join("");
|
|
35
|
+
return `<nav class="studio-breadcrumb" aria-label="Breadcrumb">
|
|
36
|
+
<a href="${escapeHtml(`${mountPath}/cms`)}">Studio</a>
|
|
37
|
+
${items ? `<span class="studio-breadcrumb-sep">/</span>${items}` : ""}
|
|
38
|
+
</nav>`;
|
|
39
|
+
}
|
|
40
|
+
export function renderStudioPage(opts) {
|
|
41
|
+
const { runtime, title, breadcrumb = [], body, extraStyles = "", inlineScript = "" } = opts;
|
|
42
|
+
const brand = runtime.brand;
|
|
43
|
+
const themeCss = `${runtime.apiBasePath}/theme.css`;
|
|
44
|
+
const studioCss = "/__caret/studio.css";
|
|
45
|
+
const favicon = brand.faviconUrl
|
|
46
|
+
? `<link rel="icon" href="${escapeHtml(brand.faviconUrl)}" />`
|
|
47
|
+
: "";
|
|
48
|
+
return `<!doctype html>
|
|
49
|
+
<html lang="en">
|
|
50
|
+
<head>
|
|
51
|
+
<meta charset="utf-8" />
|
|
52
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
53
|
+
<title>${escapeHtml(title)} — ${escapeHtml(brand.name)}</title>
|
|
54
|
+
${favicon}
|
|
55
|
+
<link rel="stylesheet" href="${themeCss}" />
|
|
56
|
+
<link rel="stylesheet" href="${studioCss}" />
|
|
57
|
+
${extraStyles ? `<style>${extraStyles}</style>` : ""}
|
|
58
|
+
</head>
|
|
59
|
+
<body>
|
|
60
|
+
<div class="studio-shell">
|
|
61
|
+
<header class="studio-header">
|
|
62
|
+
<a href="${escapeHtml(`${runtime.mountPath}/cms`)}" class="studio-brand">
|
|
63
|
+
${renderBrandMark(brand.logo)}
|
|
64
|
+
<span>${escapeHtml(brand.name)}</span>
|
|
65
|
+
</a>
|
|
66
|
+
${renderBreadcrumb(runtime.mountPath, breadcrumb)}
|
|
67
|
+
<nav style="display:flex;gap:0.25rem;">
|
|
68
|
+
<a href="${escapeHtml(`${runtime.mountPath}/cms`)}" class="studio-nav-link">Studio</a>
|
|
69
|
+
<button id="studio-logout-btn" class="studio-nav-link" type="button" style="border:none;cursor:pointer;background:transparent;font:inherit;">Sign Out</button>
|
|
70
|
+
</nav>
|
|
71
|
+
</header>
|
|
72
|
+
<main class="studio-main studio-scroll">
|
|
73
|
+
${body}
|
|
74
|
+
</main>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<script>
|
|
78
|
+
(function () {
|
|
79
|
+
var btn = document.getElementById('studio-logout-btn');
|
|
80
|
+
if (!btn) return;
|
|
81
|
+
btn.addEventListener('click', function () {
|
|
82
|
+
fetch(${JSON.stringify(`${runtime.apiBasePath}/auth/logout`)}, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
headers: { 'x-caret-request': '1' },
|
|
85
|
+
credentials: 'same-origin'
|
|
86
|
+
}).finally(function () {
|
|
87
|
+
window.location.href = ${JSON.stringify(runtime.mountPath)};
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
})();
|
|
91
|
+
</script>
|
|
92
|
+
${inlineScript ? `<script>${inlineScript}</script>` : ""}
|
|
93
|
+
</body>
|
|
94
|
+
</html>`;
|
|
95
|
+
}
|
|
96
|
+
export function htmlResponse(content, status = 200) {
|
|
97
|
+
return new Response(content, {
|
|
98
|
+
status,
|
|
99
|
+
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export function redirectResponse(location) {
|
|
103
|
+
return new Response(null, {
|
|
104
|
+
status: 302,
|
|
105
|
+
headers: { Location: location },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=studio-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio-layout.js","sourceRoot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hE,YAAY,CAAC,CAAC,CAAC,WAAW,YAAY,WAAW,CAAC,CAAC,CAAC,EAAE;;QAEpD,CAAC;AACT,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,MAAM,GAAG,GAAG;IACxD,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE;QAC3B,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE;KACxD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,GAAG;QACX,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared schema utility functions used by both the schema route and the
|
|
3
|
+
* virtual schemas module to build default templates from JSON Schema.
|
|
4
|
+
*/
|
|
5
|
+
export type JsonSchemaNode = {
|
|
6
|
+
type?: string;
|
|
7
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
8
|
+
items?: JsonSchemaNode;
|
|
9
|
+
enum?: unknown[];
|
|
10
|
+
required?: string[];
|
|
11
|
+
default?: unknown;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export declare function inferJsonSchema(value: unknown): JsonSchemaNode;
|
|
15
|
+
export declare function buildTemplate(schema: unknown): Record<string, unknown> | null;
|
|
16
|
+
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../src/schema-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CA0B9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2B7E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared schema utility functions used by both the schema route and the
|
|
3
|
+
* virtual schemas module to build default templates from JSON Schema.
|
|
4
|
+
*/
|
|
5
|
+
export function inferJsonSchema(value) {
|
|
6
|
+
if (value === null || value === undefined) {
|
|
7
|
+
return { type: "string", default: "" };
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
if (value.length === 0) {
|
|
11
|
+
return { type: "array", items: { type: "string" }, default: [] };
|
|
12
|
+
}
|
|
13
|
+
return { type: "array", items: inferJsonSchema(value[0]), default: [] };
|
|
14
|
+
}
|
|
15
|
+
if (typeof value === "object") {
|
|
16
|
+
const properties = {};
|
|
17
|
+
const required = [];
|
|
18
|
+
Object.entries(value).forEach(([key, nested]) => {
|
|
19
|
+
properties[key] = inferJsonSchema(nested);
|
|
20
|
+
required.push(key);
|
|
21
|
+
});
|
|
22
|
+
return { type: "object", properties, required };
|
|
23
|
+
}
|
|
24
|
+
if (typeof value === "string")
|
|
25
|
+
return { type: "string", default: "" };
|
|
26
|
+
if (typeof value === "number")
|
|
27
|
+
return { type: "number", default: 0 };
|
|
28
|
+
if (typeof value === "boolean")
|
|
29
|
+
return { type: "boolean", default: false };
|
|
30
|
+
return { type: "string", default: "" };
|
|
31
|
+
}
|
|
32
|
+
export function buildTemplate(schema) {
|
|
33
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
34
|
+
return null;
|
|
35
|
+
const normalized = schema;
|
|
36
|
+
if (normalized.default !== undefined)
|
|
37
|
+
return normalized.default;
|
|
38
|
+
switch (normalized.type) {
|
|
39
|
+
case "object": {
|
|
40
|
+
const obj = {};
|
|
41
|
+
if (normalized.properties) {
|
|
42
|
+
Object.entries(normalized.properties).forEach(([key, prop]) => {
|
|
43
|
+
obj[key] = buildTemplate(prop);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
case "array":
|
|
49
|
+
return [];
|
|
50
|
+
case "string":
|
|
51
|
+
if (normalized.enum && normalized.enum.length > 0)
|
|
52
|
+
return normalized.enum[0];
|
|
53
|
+
return "";
|
|
54
|
+
case "number":
|
|
55
|
+
return 0;
|
|
56
|
+
case "boolean":
|
|
57
|
+
return false;
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=schema-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-utils.js","sourceRoot":"","sources":["../src/schema-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACnE,CAAC;QACD,O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C,OAAO,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,OAAyC,CAAC;IAElG,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GAA4B,EAAE,CAAC;YACxC,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;gBAC1B,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;oBAC5D,GAAG,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;gBACjC,CAAC,CAAC,CAAC;YACL,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,KAAK,OAAO;YACV,OAAO,EAAwC,CAAC;QAClD,KAAK,QAAQ;YACX,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAmC,CAAC;YAC/G,OAAO,EAAwC,CAAC;QAClD,KAAK,QAAQ;YACX,OAAO,CAAuC,CAAC;QACjD,KAAK,SAAS;YACZ,OAAO,KAA2C,CAAC;QACrD;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type EntryData = {
|
|
2
|
+
id: string;
|
|
3
|
+
data: Record<string, unknown>;
|
|
4
|
+
};
|
|
5
|
+
export type HistoryEntry = {
|
|
6
|
+
ts: number;
|
|
7
|
+
data: unknown;
|
|
8
|
+
action: string;
|
|
9
|
+
};
|
|
10
|
+
export type CaretMode = "embedded" | "cloud";
|
|
11
|
+
export type CaretProviderKind = "storage" | "uploads";
|
|
12
|
+
export type RuntimeProviderReference<TKind extends CaretProviderKind = CaretProviderKind> = {
|
|
13
|
+
kind: TKind;
|
|
14
|
+
entrypoint: string;
|
|
15
|
+
exportName?: string;
|
|
16
|
+
options?: Record<string, unknown> | null;
|
|
17
|
+
};
|
|
18
|
+
export type CaretStorageProvider = RuntimeProviderReference<"storage">;
|
|
19
|
+
export type CaretUploadProvider = RuntimeProviderReference<"uploads">;
|
|
20
|
+
export type CollectionSchema = {
|
|
21
|
+
type: "object";
|
|
22
|
+
properties: Record<string, unknown>;
|
|
23
|
+
required?: string[];
|
|
24
|
+
title?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
};
|
|
27
|
+
export type CollectionMetadata = {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
icon?: string;
|
|
32
|
+
creatable?: boolean;
|
|
33
|
+
orderable?: boolean;
|
|
34
|
+
schema: CollectionSchema;
|
|
35
|
+
created_at: number;
|
|
36
|
+
updated_at: number;
|
|
37
|
+
};
|
|
38
|
+
export interface StorageAdapter {
|
|
39
|
+
discoverCollections(): Promise<string[]>;
|
|
40
|
+
isKnownCollection(collection: string): Promise<boolean>;
|
|
41
|
+
getEntry(collection: string, id: string): Promise<EntryData | null>;
|
|
42
|
+
listEntryIds(collection: string): Promise<string[]>;
|
|
43
|
+
listEntries(collection: string): Promise<EntryData[]>;
|
|
44
|
+
writeEntry(collection: string, id: string, data: Record<string, unknown>): Promise<void>;
|
|
45
|
+
deleteEntry(collection: string, id: string): Promise<void>;
|
|
46
|
+
getRevision(collection: string, id: string): Promise<number>;
|
|
47
|
+
bumpRevision(collection: string, id: string): Promise<number>;
|
|
48
|
+
getHistory(collection: string, id: string): Promise<HistoryEntry[]>;
|
|
49
|
+
appendHistory(collection: string, id: string, entry: HistoryEntry): Promise<void>;
|
|
50
|
+
createCollection(metadata: CollectionMetadata): Promise<void>;
|
|
51
|
+
deleteCollection(collection: string): Promise<void>;
|
|
52
|
+
getCollectionMetadata(collection: string): Promise<CollectionMetadata | null>;
|
|
53
|
+
listCollectionMetadata(): Promise<CollectionMetadata[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Optional: build a write-isolated overlay adapter scoped to a session id.
|
|
56
|
+
* Used by demo / sandbox mode together with `SessionOverlayAdapter`. Adapters
|
|
57
|
+
* that don't support multi-tenant scoping can omit this.
|
|
58
|
+
*/
|
|
59
|
+
makeSessionOverlay?(sessionId: string): Promise<StorageAdapter>;
|
|
60
|
+
}
|
|
61
|
+
export interface UploadContext {
|
|
62
|
+
sessionId?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface UploadHandler {
|
|
65
|
+
upload(file: File, ctx?: UploadContext): Promise<{
|
|
66
|
+
url: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Optional: build a per-session wrapper that enforces sandbox quotas
|
|
70
|
+
* (per-file size, total session bytes). Used by demo mode together with
|
|
71
|
+
* `QuotaUploadHandler`. Adapters that don't support quota tracking can
|
|
72
|
+
* omit this.
|
|
73
|
+
*/
|
|
74
|
+
makeSessionWrapper?(sessionId: string): Promise<UploadHandler>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AACtE,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAC7C,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD,MAAM,MAAM,wBAAwB,CAAC,KAAK,SAAS,iBAAiB,GAAG,iBAAiB,IAAI;IAC1F,IAAI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AM,WAAW,aAAa;IAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAElE;;;;;OAKG;IACH,kBAAkB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAChE"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Side-effect module — loaded by the cloud bootstrap script under
|
|
2
|
+
// Vite/Astro bundling. Imports the editor CSS + JS bundled assets.
|
|
3
|
+
// No runtime exports. Cloud mode is currently alpha; the self-hosted
|
|
4
|
+
// path serves the editor via the `/__caret/editor.{js,css}` route
|
|
5
|
+
// instead of importing this module.
|
|
6
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@caretcms/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Platform-neutral core for CaretCMS: attribute-first inline editing, mutation engine, studio admin, StorageAdapter interface.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"astro",
|
|
9
|
+
"astro-integration",
|
|
10
|
+
"cms",
|
|
11
|
+
"inline-editing",
|
|
12
|
+
"caret",
|
|
13
|
+
"content-management",
|
|
14
|
+
"headless-cms"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/web-stacked/caretcms/tree/main/packages/core#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/web-stacked/caretcms.git",
|
|
20
|
+
"directory": "packages/core"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/web-stacked/caretcms/issues"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./loader": {
|
|
33
|
+
"types": "./dist/loader.d.ts",
|
|
34
|
+
"import": "./dist/loader.js"
|
|
35
|
+
},
|
|
36
|
+
"./runtime": {
|
|
37
|
+
"types": "./dist/runtime/index.d.ts",
|
|
38
|
+
"import": "./dist/runtime/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./providers/storage/filesystem": {
|
|
41
|
+
"types": "./dist/providers/storage/filesystem.d.ts",
|
|
42
|
+
"import": "./dist/providers/storage/filesystem.js"
|
|
43
|
+
},
|
|
44
|
+
"./providers/uploads/local": {
|
|
45
|
+
"types": "./dist/providers/uploads/local.d.ts",
|
|
46
|
+
"import": "./dist/providers/uploads/local.js"
|
|
47
|
+
},
|
|
48
|
+
"./schema-registry": {
|
|
49
|
+
"types": "./dist/runtime/schema-registry.d.ts",
|
|
50
|
+
"import": "./dist/runtime/schema-registry.js"
|
|
51
|
+
},
|
|
52
|
+
"./schema-utils": {
|
|
53
|
+
"types": "./dist/schema-utils.d.ts",
|
|
54
|
+
"import": "./dist/schema-utils.js"
|
|
55
|
+
},
|
|
56
|
+
"./browser-runtime": {
|
|
57
|
+
"types": "./dist/browser-runtime.d.ts",
|
|
58
|
+
"import": "./dist/browser-runtime.js"
|
|
59
|
+
},
|
|
60
|
+
"./editor-runtime": {
|
|
61
|
+
"types": "./editor-runtime.d.ts",
|
|
62
|
+
"import": "./editor-runtime.js"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"dist",
|
|
67
|
+
"static",
|
|
68
|
+
"editor-runtime.js",
|
|
69
|
+
"editor-runtime.d.ts"
|
|
70
|
+
],
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsc -p tsconfig.build.json",
|
|
73
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
74
|
+
"clean": "rm -rf dist",
|
|
75
|
+
"prepublishOnly": "node scripts/check-version.mjs && npm run clean && npm run build"
|
|
76
|
+
},
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"access": "public"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"astro": "^5.0.0 || ^6.0.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@types/node": "25.6.0",
|
|
85
|
+
"typescript": "6.0.3",
|
|
86
|
+
"vitest": "4.1.7"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* Studio entry editor — page-specific styles. Tokens derive from studio.css. */
|
|
2
|
+
|
|
3
|
+
.caret-field-group {
|
|
4
|
+
padding: 1rem 0;
|
|
5
|
+
border-bottom: 1px solid var(--studio-border);
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.caret-field-inline {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.caret-field-group .studio-label { margin-bottom: 0.5rem; }
|
|
16
|
+
.caret-field-inline .studio-label { margin-bottom: 0; }
|
|
17
|
+
|
|
18
|
+
.caret-nested {
|
|
19
|
+
padding-left: 1rem;
|
|
20
|
+
border-left: 1px solid var(--studio-border);
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Image gallery */
|
|
26
|
+
.caret-gallery-grid {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
29
|
+
gap: 0.75rem;
|
|
30
|
+
margin-bottom: 1rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.caret-gallery-cell {
|
|
34
|
+
position: relative;
|
|
35
|
+
aspect-ratio: 1;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
cursor: grab;
|
|
38
|
+
border: 1px solid var(--studio-border);
|
|
39
|
+
background: var(--studio-surface);
|
|
40
|
+
}
|
|
41
|
+
.caret-gallery-cell img {
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
object-fit: cover;
|
|
45
|
+
display: block;
|
|
46
|
+
}
|
|
47
|
+
.caret-gallery-cell.dragging { opacity: 0.5; transform: scale(0.95); }
|
|
48
|
+
.caret-gallery-cell.drag-over-item {
|
|
49
|
+
outline: 2px solid var(--studio-accent);
|
|
50
|
+
outline-offset: 2px;
|
|
51
|
+
}
|
|
52
|
+
.caret-gallery-remove {
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: 4px;
|
|
55
|
+
right: 4px;
|
|
56
|
+
width: 22px;
|
|
57
|
+
height: 22px;
|
|
58
|
+
border: none;
|
|
59
|
+
background: rgba(239, 68, 68, 0.9);
|
|
60
|
+
color: white;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
line-height: 1;
|
|
64
|
+
opacity: 0;
|
|
65
|
+
transition: opacity 0.15s;
|
|
66
|
+
}
|
|
67
|
+
.caret-gallery-cell:hover .caret-gallery-remove { opacity: 1; }
|
|
68
|
+
.caret-gallery-index {
|
|
69
|
+
position: absolute;
|
|
70
|
+
bottom: 4px;
|
|
71
|
+
left: 4px;
|
|
72
|
+
padding: 1px 6px;
|
|
73
|
+
font-size: 9px;
|
|
74
|
+
background: rgba(0, 0, 0, 0.6);
|
|
75
|
+
color: rgba(255, 255, 255, 0.85);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.caret-dropzone {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
padding: 2rem 1rem;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
text-align: center;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Single image */
|
|
89
|
+
.caret-single-image-preview {
|
|
90
|
+
position: relative;
|
|
91
|
+
width: 128px;
|
|
92
|
+
height: 128px;
|
|
93
|
+
margin-bottom: 0.75rem;
|
|
94
|
+
border: 1px solid var(--studio-border);
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
}
|
|
97
|
+
.caret-single-image-preview img {
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
object-fit: cover;
|
|
101
|
+
display: block;
|
|
102
|
+
}
|
|
103
|
+
.caret-single-image-row {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 0.75rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Tags */
|
|
110
|
+
.caret-tags {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-wrap: wrap;
|
|
113
|
+
gap: 0.5rem;
|
|
114
|
+
margin-bottom: 0.75rem;
|
|
115
|
+
}
|
|
116
|
+
.caret-add-row {
|
|
117
|
+
display: flex;
|
|
118
|
+
gap: 0.5rem;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Object array */
|
|
122
|
+
.caret-object-array {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: 0.75rem;
|
|
126
|
+
}
|
|
127
|
+
.caret-object-array-item {
|
|
128
|
+
position: relative;
|
|
129
|
+
padding: 0.75rem;
|
|
130
|
+
border: 1px solid var(--studio-border);
|
|
131
|
+
background: rgba(255, 255, 255, 0.02);
|
|
132
|
+
}
|
|
133
|
+
.caret-object-array-remove {
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 6px;
|
|
136
|
+
right: 6px;
|
|
137
|
+
width: 22px;
|
|
138
|
+
height: 22px;
|
|
139
|
+
border: none;
|
|
140
|
+
background: transparent;
|
|
141
|
+
color: var(--studio-red);
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
font-size: 16px;
|
|
144
|
+
line-height: 1;
|
|
145
|
+
opacity: 0;
|
|
146
|
+
transition: opacity 0.15s;
|
|
147
|
+
}
|
|
148
|
+
.caret-object-array-item:hover .caret-object-array-remove { opacity: 1; }
|
|
149
|
+
.caret-object-array-index {
|
|
150
|
+
display: block;
|
|
151
|
+
font-size: 9px;
|
|
152
|
+
color: var(--studio-text-dim);
|
|
153
|
+
margin-bottom: 0.5rem;
|
|
154
|
+
}
|
|
155
|
+
.caret-object-array-fields {
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
gap: 0.5rem;
|
|
159
|
+
}
|
|
160
|
+
.caret-object-array-row {
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
gap: 0.75rem;
|
|
164
|
+
}
|
|
165
|
+
.caret-object-array-key {
|
|
166
|
+
font-size: 10px;
|
|
167
|
+
width: 80px;
|
|
168
|
+
text-align: right;
|
|
169
|
+
flex-shrink: 0;
|
|
170
|
+
color: var(--studio-text-dim);
|
|
171
|
+
}
|
|
172
|
+
.caret-object-array-add {
|
|
173
|
+
width: 100%;
|
|
174
|
+
padding: 0.5rem;
|
|
175
|
+
font-size: 12px;
|
|
176
|
+
border: 1px dashed var(--studio-border);
|
|
177
|
+
background: transparent;
|
|
178
|
+
color: var(--studio-text-dim);
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
transition: border-color 0.15s, color 0.15s;
|
|
181
|
+
}
|
|
182
|
+
.caret-object-array-add:hover {
|
|
183
|
+
border-color: var(--studio-accent);
|
|
184
|
+
color: var(--studio-accent);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* History panel */
|
|
188
|
+
.caret-history-row {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: space-between;
|
|
192
|
+
padding: 8px 0;
|
|
193
|
+
border-bottom: 1px solid var(--studio-border);
|
|
194
|
+
}
|
|
195
|
+
.caret-history-row:last-child { border-bottom: none; }
|
|
196
|
+
.caret-history-action {
|
|
197
|
+
display: inline-block;
|
|
198
|
+
padding: 2px 8px;
|
|
199
|
+
font-size: 9px;
|
|
200
|
+
text-transform: uppercase;
|
|
201
|
+
letter-spacing: 0.08em;
|
|
202
|
+
border-radius: 2px;
|
|
203
|
+
}
|
|
204
|
+
.caret-history-action[data-action="save"] { background: rgba(34,197,94,0.15); color: var(--studio-green); }
|
|
205
|
+
.caret-history-action[data-action="put"] { background: rgba(59,130,246,0.15); color: var(--studio-blue); }
|
|
206
|
+
.caret-history-action[data-action="delete"] { background: rgba(239,68,68,0.15); color: var(--studio-red); }
|
|
207
|
+
.caret-history-action[data-action="restore"] { background: rgba(59,130,246,0.15); color: var(--studio-accent); }
|