@pixerate/editor-react 0.15.0 → 0.16.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.
Files changed (46) hide show
  1. package/README.md +4 -0
  2. package/dist/canvas/index.cjs +219 -118
  3. package/dist/canvas/index.cjs.map +1 -1
  4. package/dist/canvas/index.d.cts +59 -3
  5. package/dist/canvas/index.d.ts +59 -3
  6. package/dist/canvas/index.js +103 -0
  7. package/dist/canvas/index.js.map +1 -1
  8. package/dist/chunk-7SPRQZ6H.js +216 -0
  9. package/dist/chunk-7SPRQZ6H.js.map +1 -0
  10. package/dist/{chunk-QVQYYHJ5.js → chunk-FYIPXHAE.js} +21 -13
  11. package/dist/chunk-FYIPXHAE.js.map +1 -0
  12. package/dist/{chunk-LPFZMZ3L.js → chunk-XTFR3IMK.js} +676 -322
  13. package/dist/chunk-XTFR3IMK.js.map +1 -0
  14. package/dist/chunk-XWFU2CSG.js +167 -0
  15. package/dist/chunk-XWFU2CSG.js.map +1 -0
  16. package/dist/generation/index.cjs +235 -0
  17. package/dist/generation/index.cjs.map +1 -0
  18. package/dist/generation/index.d.cts +60 -0
  19. package/dist/generation/index.d.ts +60 -0
  20. package/dist/generation/index.js +13 -0
  21. package/dist/generation/index.js.map +1 -0
  22. package/dist/image-editor/index.cjs +684 -336
  23. package/dist/image-editor/index.cjs.map +1 -1
  24. package/dist/image-editor/index.d.cts +60 -2
  25. package/dist/image-editor/index.d.ts +60 -2
  26. package/dist/image-editor/index.js +13 -3
  27. package/dist/index.cjs +1881 -648
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +143 -4
  30. package/dist/index.d.ts +143 -4
  31. package/dist/index.js +626 -73
  32. package/dist/index.js.map +1 -1
  33. package/dist/persistence/index.cjs +191 -0
  34. package/dist/persistence/index.cjs.map +1 -0
  35. package/dist/persistence/index.d.cts +77 -0
  36. package/dist/persistence/index.d.ts +77 -0
  37. package/dist/persistence/index.js +9 -0
  38. package/dist/persistence/index.js.map +1 -0
  39. package/dist/spreadsheet/index.cjs +17 -10
  40. package/dist/spreadsheet/index.cjs.map +1 -1
  41. package/dist/spreadsheet/index.d.cts +2 -0
  42. package/dist/spreadsheet/index.d.ts +2 -0
  43. package/dist/spreadsheet/index.js +1 -1
  44. package/package.json +18 -2
  45. package/dist/chunk-LPFZMZ3L.js.map +0 -1
  46. package/dist/chunk-QVQYYHJ5.js.map +0 -1
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/generation/index.ts
21
+ var generation_exports = {};
22
+ __export(generation_exports, {
23
+ GenerationSettings: () => GenerationSettings,
24
+ JobProgress: () => JobProgress,
25
+ useGenerationPlan: () => useGenerationPlan,
26
+ useJobProgress: () => useJobProgress
27
+ });
28
+ module.exports = __toCommonJS(generation_exports);
29
+
30
+ // src/generation/useGenerationPlan.ts
31
+ var import_react = require("react");
32
+ var import_generation = require("@pixerate/editor/generation");
33
+ function useGenerationPlan(request, capabilities, options = {}) {
34
+ const key = JSON.stringify([request, capabilities, options]);
35
+ return (0, import_react.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
36
+ }
37
+ function useJobProgress(options) {
38
+ const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
39
+ const [tick, setTick] = (0, import_react.useState)(() => Date.now());
40
+ const ticking = !done && now === void 0;
41
+ (0, import_react.useEffect)(() => {
42
+ if (!ticking) return;
43
+ setTick(Date.now());
44
+ const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
45
+ return () => clearInterval(id);
46
+ }, [ticking, intervalMs]);
47
+ return (0, import_generation.estimateJobProgress)({ startedAt, expectedMs, done, now: now ?? tick });
48
+ }
49
+
50
+ // src/generation/GenerationSettings.tsx
51
+ var import_react2 = require("react");
52
+ var import_generation2 = require("@pixerate/editor/generation");
53
+ var import_jsx_runtime = require("react/jsx-runtime");
54
+ var inputClass = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
55
+ function Control({
56
+ control,
57
+ value,
58
+ id,
59
+ onValue
60
+ }) {
61
+ const shown = value ?? control.defaultValue;
62
+ if (control.kind === "checkbox") {
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ "input",
65
+ {
66
+ id,
67
+ type: "checkbox",
68
+ "data-field": control.key,
69
+ checked: Boolean(shown),
70
+ onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.checked))
71
+ }
72
+ );
73
+ }
74
+ if (control.kind === "select") {
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
76
+ "select",
77
+ {
78
+ id,
79
+ "data-field": control.key,
80
+ className: inputClass,
81
+ value: shown === void 0 ? "" : String(shown),
82
+ onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value)),
83
+ children: [
84
+ shown === void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "Default" }),
85
+ control.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: String(option.value), children: option.label }, String(option.value)))
86
+ ]
87
+ }
88
+ );
89
+ }
90
+ if (control.kind === "textarea") {
91
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ "textarea",
93
+ {
94
+ id,
95
+ "data-field": control.key,
96
+ className: inputClass,
97
+ rows: 2,
98
+ maxLength: control.maxLength,
99
+ value: typeof value === "string" ? value : "",
100
+ onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
101
+ }
102
+ );
103
+ }
104
+ const numeric = typeof shown === "number" ? shown : void 0;
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
107
+ "input",
108
+ {
109
+ id,
110
+ type: control.kind === "range" ? "range" : "number",
111
+ "data-field": control.key,
112
+ className: control.kind === "range" ? "flex-1" : inputClass,
113
+ min: control.min,
114
+ max: control.max,
115
+ step: control.step ?? "any",
116
+ value: numeric ?? (control.kind === "range" ? control.min ?? 0 : ""),
117
+ onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
118
+ }
119
+ ),
120
+ control.kind === "range" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "w-10 text-right tabular-nums text-muted-foreground", "data-field-value": "", children: numeric ?? "\u2013" })
121
+ ] });
122
+ }
123
+ var GenerationSettings = ({
124
+ capabilities,
125
+ value,
126
+ onChange,
127
+ plan: planProp,
128
+ strategy,
129
+ showAdjustments = true,
130
+ onAddReference,
131
+ renderReference,
132
+ className = ""
133
+ }) => {
134
+ const baseId = (0, import_react2.useId)();
135
+ const controls = (0, import_react2.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
136
+ const computed = useGenerationPlan(value, capabilities, { strategy });
137
+ const plan = planProp ?? computed;
138
+ const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
139
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `flex flex-col gap-3 text-sm ${className}`, "data-generation-settings": "", "data-model": capabilities.id, children: [
140
+ controls.map((control) => {
141
+ const id = `${baseId}-${control.key}`;
142
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-1", "data-control": control.key, children: [
143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: id, className: "text-xs font-medium text-muted-foreground", title: control.description, children: control.label }),
144
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
145
+ Control,
146
+ {
147
+ control,
148
+ id,
149
+ value: (0, import_generation2.getRequestValue)(value, control.key),
150
+ onValue: (next) => onChange((0, import_generation2.setRequestValue)(value, control.key, next))
151
+ }
152
+ )
153
+ ] }, control.key);
154
+ }),
155
+ slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { className: "flex flex-col gap-1", "data-reference-role": slot.role, children: [
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("legend", { className: "text-xs font-medium text-muted-foreground", title: slot.description, children: [
157
+ slot.label,
158
+ " ",
159
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "tabular-nums", "data-reference-count": "", children: [
160
+ "(",
161
+ slot.references.length,
162
+ "/",
163
+ slot.max,
164
+ ")"
165
+ ] }),
166
+ slot.min > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-destructive", children: " *" })
167
+ ] }),
168
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", { className: "flex flex-wrap gap-1", children: [
169
+ slot.references.map((ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex items-center gap-1 rounded border border-border px-1.5 py-0.5", "data-reference-id": ref.id, children: [
170
+ renderReference ? renderReference(ref) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "max-w-[10rem] truncate", children: ref.id }),
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
+ "button",
173
+ {
174
+ type: "button",
175
+ "aria-label": `Remove ${slot.label} ${ref.id}`,
176
+ className: "text-muted-foreground hover:text-foreground",
177
+ onClick: () => onChange((0, import_generation2.removeReference)(value, slot.role, ref.id)),
178
+ children: "\xD7"
179
+ }
180
+ )
181
+ ] }, ref.id)),
182
+ onAddReference && slot.canAdd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ "button",
184
+ {
185
+ type: "button",
186
+ className: "rounded border border-dashed border-border px-1.5 py-0.5 text-muted-foreground hover:text-foreground",
187
+ onClick: () => onAddReference(slot.role),
188
+ children: "Add"
189
+ }
190
+ ) })
191
+ ] })
192
+ ] }, slot.role)),
193
+ showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { role: "status", className: "flex flex-col gap-0.5 text-xs text-muted-foreground", "data-generation-adjustments": "", children: plan.adjustments.map((adjustment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { "data-adjustment-field": adjustment.field, "data-adjustment-kind": adjustment.kind, children: adjustment.reason }, index)) }),
194
+ showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { role: "alert", className: "flex flex-col gap-0.5 text-xs text-destructive", "data-generation-errors": "", children: plan.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { "data-error-field": error.field, children: error.message }, index)) })
195
+ ] });
196
+ };
197
+
198
+ // src/generation/JobProgress.tsx
199
+ var import_jsx_runtime2 = require("react/jsx-runtime");
200
+ var JobProgress = ({ title, className = "", ...options }) => {
201
+ const progress = useJobProgress(options);
202
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `flex flex-col gap-1 text-sm ${className}`, "data-job-progress": "", "data-done": options.done ? "" : void 0, children: [
203
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between gap-2 text-muted-foreground", children: [
204
+ title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "truncate text-foreground", children: title }),
205
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-job-progress-label": "", "aria-live": "polite", children: progress.label })
206
+ ] }),
207
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
208
+ "div",
209
+ {
210
+ role: "progressbar",
211
+ "aria-label": title ?? "Generation progress",
212
+ "aria-valuemin": 0,
213
+ "aria-valuemax": 100,
214
+ "aria-valuenow": progress.percent,
215
+ "aria-valuetext": `${progress.percent}%, ${progress.label}`,
216
+ className: "h-1.5 w-full overflow-hidden rounded-full bg-muted",
217
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
218
+ "div",
219
+ {
220
+ className: "h-full rounded-full bg-primary transition-[width] duration-500",
221
+ style: { width: `${progress.percent}%`, background: "var(--primary, currentColor)" }
222
+ }
223
+ )
224
+ }
225
+ )
226
+ ] });
227
+ };
228
+ // Annotate the CommonJS export names for ESM import in node:
229
+ 0 && (module.exports = {
230
+ GenerationSettings,
231
+ JobProgress,
232
+ useGenerationPlan,
233
+ useJobProgress
234
+ });
235
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/generation/index.ts","../../src/generation/useGenerationPlan.ts","../../src/generation/GenerationSettings.tsx","../../src/generation/JobProgress.tsx"],"sourcesContent":["export * from './useGenerationPlan';\nexport * from './GenerationSettings';\nexport * from './JobProgress';\n","import { useEffect, useMemo, useState } from 'react';\nimport {\n estimateJobProgress,\n planGenerationRequest,\n type GenerationPlan,\n type GenerationRequest,\n type JobProgressEstimate,\n type ModelCapabilities,\n type PlanOptions,\n} from '@pixerate/editor/generation';\n\n/**\n * Plans `request` against `capabilities` (see `planGenerationRequest`) and\n * returns the adjusted request, adjustments and errors. Recomputed only when\n * the request, capabilities or options change by value, so inline objects are fine.\n */\nexport function useGenerationPlan(\n request: GenerationRequest,\n capabilities: ModelCapabilities,\n options: PlanOptions = {},\n): GenerationPlan {\n const key = JSON.stringify([request, capabilities, options]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => planGenerationRequest(request, capabilities, options), [key]);\n}\n\nexport interface UseJobProgressOptions {\n startedAt: number | Date | string;\n expectedMs?: number;\n done?: boolean;\n /** Fixed current time (disables ticking; useful for SSR and tests). */\n now?: number | Date | string;\n /** Re-render interval while running in ms (default 1000). */\n intervalMs?: number;\n}\n\n/** Ticking `estimateJobProgress` for a running job; stops ticking when `done`. */\nexport function useJobProgress(options: UseJobProgressOptions): JobProgressEstimate {\n const { startedAt, expectedMs, done, now, intervalMs = 1000 } = options;\n const [tick, setTick] = useState(() => Date.now());\n const ticking = !done && now === undefined;\n useEffect(() => {\n if (!ticking) return;\n setTick(Date.now());\n const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));\n return () => clearInterval(id);\n }, [ticking, intervalMs]);\n return estimateJobProgress({ startedAt, expectedMs, done, now: now ?? tick });\n}\n","import React, { useId, useMemo } from 'react';\nimport {\n getGenerationControls,\n getReferenceSlots,\n getRequestValue,\n parseControlValue,\n removeReference,\n setRequestValue,\n type GenerationControl,\n type GenerationPlan,\n type GenerationReference,\n type GenerationRequest,\n type ModelCapabilities,\n type PlanStrategy,\n type ReferenceRole,\n} from '@pixerate/editor/generation';\nimport { useGenerationPlan } from './useGenerationPlan';\n\nexport interface GenerationSettingsProps {\n capabilities: ModelCapabilities;\n /** The request being edited (controlled). */\n value: GenerationRequest;\n onChange: (next: GenerationRequest) => void;\n /** A plan computed elsewhere; otherwise one is computed with `strategy`. */\n plan?: GenerationPlan;\n /** Strategy for the built-in plan (default `nearest`). */\n strategy?: PlanStrategy;\n /** List plan adjustments and errors under the controls (default `true`). */\n showAdjustments?: boolean;\n /** Shows an \"Add\" button per reference role; you pick the asset and call `onChange`. */\n onAddReference?: (role: ReferenceRole) => void;\n /** Custom rendering of a reference chip (default: its id). */\n renderReference?: (reference: GenerationReference) => React.ReactNode;\n className?: string;\n}\n\nconst inputClass =\n 'w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring';\n\nfunction Control({\n control,\n value,\n id,\n onValue,\n}: {\n control: GenerationControl;\n value: unknown;\n id: string;\n onValue: (value: unknown) => void;\n}) {\n const shown = value ?? control.defaultValue;\n if (control.kind === 'checkbox') {\n return (\n <input\n id={id}\n type=\"checkbox\"\n data-field={control.key}\n checked={Boolean(shown)}\n onChange={(e) => onValue(parseControlValue(control, e.target.checked))}\n />\n );\n }\n if (control.kind === 'select') {\n return (\n <select\n id={id}\n data-field={control.key}\n className={inputClass}\n value={shown === undefined ? '' : String(shown)}\n onChange={(e) => onValue(parseControlValue(control, e.target.value))}\n >\n {shown === undefined && <option value=\"\">Default</option>}\n {control.options!.map((option) => (\n <option key={String(option.value)} value={String(option.value)}>\n {option.label}\n </option>\n ))}\n </select>\n );\n }\n if (control.kind === 'textarea') {\n return (\n <textarea\n id={id}\n data-field={control.key}\n className={inputClass}\n rows={2}\n maxLength={control.maxLength}\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => onValue(parseControlValue(control, e.target.value))}\n />\n );\n }\n const numeric = typeof shown === 'number' ? shown : undefined;\n return (\n <div className=\"flex items-center gap-2\">\n <input\n id={id}\n type={control.kind === 'range' ? 'range' : 'number'}\n data-field={control.key}\n className={control.kind === 'range' ? 'flex-1' : inputClass}\n min={control.min}\n max={control.max}\n step={control.step ?? 'any'}\n value={numeric ?? (control.kind === 'range' ? (control.min ?? 0) : '')}\n onChange={(e) => onValue(parseControlValue(control, e.target.value))}\n />\n {control.kind === 'range' && (\n <span className=\"w-10 text-right tabular-nums text-muted-foreground\" data-field-value=\"\">\n {numeric ?? '–'}\n </span>\n )}\n </div>\n );\n}\n\n/**\n * Headless-styled settings form generated from a model's capabilities:\n * selects for choices, sliders/number inputs for ranges, text areas for\n * negative/system prompts, checkboxes for boolean params, reference slots by\n * role, and the plan's adjustments and errors. Controlled via `value` / `onChange`.\n */\nexport const GenerationSettings: React.FC<GenerationSettingsProps> = ({\n capabilities,\n value,\n onChange,\n plan: planProp,\n strategy,\n showAdjustments = true,\n onAddReference,\n renderReference,\n className = '',\n}) => {\n const baseId = useId();\n const controls = useMemo(() => getGenerationControls(capabilities), [capabilities]);\n const computed = useGenerationPlan(value, capabilities, { strategy });\n const plan = planProp ?? computed;\n const slots = getReferenceSlots(capabilities, value);\n\n return (\n <div className={`flex flex-col gap-3 text-sm ${className}`} data-generation-settings=\"\" data-model={capabilities.id}>\n {controls.map((control) => {\n const id = `${baseId}-${control.key}`;\n return (\n <div key={control.key} className=\"flex flex-col gap-1\" data-control={control.key}>\n <label htmlFor={id} className=\"text-xs font-medium text-muted-foreground\" title={control.description}>\n {control.label}\n </label>\n <Control\n control={control}\n id={id}\n value={getRequestValue(value, control.key)}\n onValue={(next) => onChange(setRequestValue(value, control.key, next))}\n />\n </div>\n );\n })}\n\n {slots.map((slot) => (\n <fieldset key={slot.role} className=\"flex flex-col gap-1\" data-reference-role={slot.role}>\n <legend className=\"text-xs font-medium text-muted-foreground\" title={slot.description}>\n {slot.label}{' '}\n <span className=\"tabular-nums\" data-reference-count=\"\">\n ({slot.references.length}/{slot.max})\n </span>\n {slot.min > 0 && <span className=\"text-destructive\"> *</span>}\n </legend>\n <ul className=\"flex flex-wrap gap-1\">\n {slot.references.map((ref) => (\n <li key={ref.id} className=\"flex items-center gap-1 rounded border border-border px-1.5 py-0.5\" data-reference-id={ref.id}>\n {renderReference ? renderReference(ref) : <span className=\"max-w-[10rem] truncate\">{ref.id}</span>}\n <button\n type=\"button\"\n aria-label={`Remove ${slot.label} ${ref.id}`}\n className=\"text-muted-foreground hover:text-foreground\"\n onClick={() => onChange(removeReference(value, slot.role, ref.id))}\n >\n ×\n </button>\n </li>\n ))}\n {onAddReference && slot.canAdd && (\n <li>\n <button\n type=\"button\"\n className=\"rounded border border-dashed border-border px-1.5 py-0.5 text-muted-foreground hover:text-foreground\"\n onClick={() => onAddReference(slot.role)}\n >\n Add\n </button>\n </li>\n )}\n </ul>\n </fieldset>\n ))}\n\n {showAdjustments && plan.adjustments.length > 0 && (\n <ul role=\"status\" className=\"flex flex-col gap-0.5 text-xs text-muted-foreground\" data-generation-adjustments=\"\">\n {plan.adjustments.map((adjustment, index) => (\n <li key={index} data-adjustment-field={adjustment.field} data-adjustment-kind={adjustment.kind}>\n {adjustment.reason}\n </li>\n ))}\n </ul>\n )}\n {showAdjustments && plan.errors.length > 0 && (\n <ul role=\"alert\" className=\"flex flex-col gap-0.5 text-xs text-destructive\" data-generation-errors=\"\">\n {plan.errors.map((error, index) => (\n <li key={index} data-error-field={error.field}>\n {error.message}\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n};\n","import React from 'react';\nimport { useJobProgress, type UseJobProgressOptions } from './useGenerationPlan';\n\nexport interface JobProgressProps extends UseJobProgressOptions {\n /** Text shown before the time label, e.g. the model name. */\n title?: string;\n /** Extra classes for the root. */\n className?: string;\n}\n\n/**\n * Headless-styled progress bar for a generation job that reports no progress\n * of its own: time-based percent (held at 95% until `done`) with a\n * \"~2m left\" / \"Almost done…\" label. Exposes `role=\"progressbar\"`.\n */\nexport const JobProgress: React.FC<JobProgressProps> = ({ title, className = '', ...options }) => {\n const progress = useJobProgress(options);\n return (\n <div className={`flex flex-col gap-1 text-sm ${className}`} data-job-progress=\"\" data-done={options.done ? '' : undefined}>\n <div className=\"flex items-center justify-between gap-2 text-muted-foreground\">\n {title && <span className=\"truncate text-foreground\">{title}</span>}\n <span data-job-progress-label=\"\" aria-live=\"polite\">\n {progress.label}\n </span>\n </div>\n <div\n role=\"progressbar\"\n aria-label={title ?? 'Generation progress'}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={progress.percent}\n aria-valuetext={`${progress.percent}%, ${progress.label}`}\n className=\"h-1.5 w-full overflow-hidden rounded-full bg-muted\"\n >\n <div\n className=\"h-full rounded-full bg-primary transition-[width] duration-500\"\n style={{ width: `${progress.percent}%`, background: 'var(--primary, currentColor)' }}\n />\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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C,EAAE,OAAO,YAAY,IAAI,GAAG,QAAQ,MAAM;AAChG,QAAM,WAAW,eAAe,OAAO;AACvC,SACE,8CAAC,SAAI,WAAW,+BAA+B,SAAS,IAAI,qBAAkB,IAAG,aAAW,QAAQ,OAAO,KAAK,QAC9G;AAAA,kDAAC,SAAI,WAAU,iEACZ;AAAA,eAAS,6CAAC,UAAK,WAAU,4BAA4B,iBAAM;AAAA,MAC5D,6CAAC,UAAK,2BAAwB,IAAG,aAAU,UACxC,mBAAS,OACZ;AAAA,OACF;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,cAAY,SAAS;AAAA,QACrB,iBAAe;AAAA,QACf,iBAAe;AAAA,QACf,iBAAe,SAAS;AAAA,QACxB,kBAAgB,GAAG,SAAS,OAAO,MAAM,SAAS,KAAK;AAAA,QACvD,WAAU;AAAA,QAEV;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO,EAAE,OAAO,GAAG,SAAS,OAAO,KAAK,YAAY,+BAA+B;AAAA;AAAA,QACrF;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["import_react","import_generation","import_jsx_runtime"]}
@@ -0,0 +1,60 @@
1
+ import { GenerationRequest, ModelCapabilities, PlanOptions, GenerationPlan, JobProgressEstimate, PlanStrategy, ReferenceRole, GenerationReference } from '@pixerate/editor/generation';
2
+ import React__default from 'react';
3
+
4
+ /**
5
+ * Plans `request` against `capabilities` (see `planGenerationRequest`) and
6
+ * returns the adjusted request, adjustments and errors. Recomputed only when
7
+ * the request, capabilities or options change by value, so inline objects are fine.
8
+ */
9
+ declare function useGenerationPlan(request: GenerationRequest, capabilities: ModelCapabilities, options?: PlanOptions): GenerationPlan;
10
+ interface UseJobProgressOptions {
11
+ startedAt: number | Date | string;
12
+ expectedMs?: number;
13
+ done?: boolean;
14
+ /** Fixed current time (disables ticking; useful for SSR and tests). */
15
+ now?: number | Date | string;
16
+ /** Re-render interval while running in ms (default 1000). */
17
+ intervalMs?: number;
18
+ }
19
+ /** Ticking `estimateJobProgress` for a running job; stops ticking when `done`. */
20
+ declare function useJobProgress(options: UseJobProgressOptions): JobProgressEstimate;
21
+
22
+ interface GenerationSettingsProps {
23
+ capabilities: ModelCapabilities;
24
+ /** The request being edited (controlled). */
25
+ value: GenerationRequest;
26
+ onChange: (next: GenerationRequest) => void;
27
+ /** A plan computed elsewhere; otherwise one is computed with `strategy`. */
28
+ plan?: GenerationPlan;
29
+ /** Strategy for the built-in plan (default `nearest`). */
30
+ strategy?: PlanStrategy;
31
+ /** List plan adjustments and errors under the controls (default `true`). */
32
+ showAdjustments?: boolean;
33
+ /** Shows an "Add" button per reference role; you pick the asset and call `onChange`. */
34
+ onAddReference?: (role: ReferenceRole) => void;
35
+ /** Custom rendering of a reference chip (default: its id). */
36
+ renderReference?: (reference: GenerationReference) => React__default.ReactNode;
37
+ className?: string;
38
+ }
39
+ /**
40
+ * Headless-styled settings form generated from a model's capabilities:
41
+ * selects for choices, sliders/number inputs for ranges, text areas for
42
+ * negative/system prompts, checkboxes for boolean params, reference slots by
43
+ * role, and the plan's adjustments and errors. Controlled via `value` / `onChange`.
44
+ */
45
+ declare const GenerationSettings: React__default.FC<GenerationSettingsProps>;
46
+
47
+ interface JobProgressProps extends UseJobProgressOptions {
48
+ /** Text shown before the time label, e.g. the model name. */
49
+ title?: string;
50
+ /** Extra classes for the root. */
51
+ className?: string;
52
+ }
53
+ /**
54
+ * Headless-styled progress bar for a generation job that reports no progress
55
+ * of its own: time-based percent (held at 95% until `done`) with a
56
+ * "~2m left" / "Almost done…" label. Exposes `role="progressbar"`.
57
+ */
58
+ declare const JobProgress: React__default.FC<JobProgressProps>;
59
+
60
+ export { GenerationSettings, type GenerationSettingsProps, JobProgress, type JobProgressProps, type UseJobProgressOptions, useGenerationPlan, useJobProgress };
@@ -0,0 +1,60 @@
1
+ import { GenerationRequest, ModelCapabilities, PlanOptions, GenerationPlan, JobProgressEstimate, PlanStrategy, ReferenceRole, GenerationReference } from '@pixerate/editor/generation';
2
+ import React__default from 'react';
3
+
4
+ /**
5
+ * Plans `request` against `capabilities` (see `planGenerationRequest`) and
6
+ * returns the adjusted request, adjustments and errors. Recomputed only when
7
+ * the request, capabilities or options change by value, so inline objects are fine.
8
+ */
9
+ declare function useGenerationPlan(request: GenerationRequest, capabilities: ModelCapabilities, options?: PlanOptions): GenerationPlan;
10
+ interface UseJobProgressOptions {
11
+ startedAt: number | Date | string;
12
+ expectedMs?: number;
13
+ done?: boolean;
14
+ /** Fixed current time (disables ticking; useful for SSR and tests). */
15
+ now?: number | Date | string;
16
+ /** Re-render interval while running in ms (default 1000). */
17
+ intervalMs?: number;
18
+ }
19
+ /** Ticking `estimateJobProgress` for a running job; stops ticking when `done`. */
20
+ declare function useJobProgress(options: UseJobProgressOptions): JobProgressEstimate;
21
+
22
+ interface GenerationSettingsProps {
23
+ capabilities: ModelCapabilities;
24
+ /** The request being edited (controlled). */
25
+ value: GenerationRequest;
26
+ onChange: (next: GenerationRequest) => void;
27
+ /** A plan computed elsewhere; otherwise one is computed with `strategy`. */
28
+ plan?: GenerationPlan;
29
+ /** Strategy for the built-in plan (default `nearest`). */
30
+ strategy?: PlanStrategy;
31
+ /** List plan adjustments and errors under the controls (default `true`). */
32
+ showAdjustments?: boolean;
33
+ /** Shows an "Add" button per reference role; you pick the asset and call `onChange`. */
34
+ onAddReference?: (role: ReferenceRole) => void;
35
+ /** Custom rendering of a reference chip (default: its id). */
36
+ renderReference?: (reference: GenerationReference) => React__default.ReactNode;
37
+ className?: string;
38
+ }
39
+ /**
40
+ * Headless-styled settings form generated from a model's capabilities:
41
+ * selects for choices, sliders/number inputs for ranges, text areas for
42
+ * negative/system prompts, checkboxes for boolean params, reference slots by
43
+ * role, and the plan's adjustments and errors. Controlled via `value` / `onChange`.
44
+ */
45
+ declare const GenerationSettings: React__default.FC<GenerationSettingsProps>;
46
+
47
+ interface JobProgressProps extends UseJobProgressOptions {
48
+ /** Text shown before the time label, e.g. the model name. */
49
+ title?: string;
50
+ /** Extra classes for the root. */
51
+ className?: string;
52
+ }
53
+ /**
54
+ * Headless-styled progress bar for a generation job that reports no progress
55
+ * of its own: time-based percent (held at 95% until `done`) with a
56
+ * "~2m left" / "Almost done…" label. Exposes `role="progressbar"`.
57
+ */
58
+ declare const JobProgress: React__default.FC<JobProgressProps>;
59
+
60
+ export { GenerationSettings, type GenerationSettingsProps, JobProgress, type JobProgressProps, type UseJobProgressOptions, useGenerationPlan, useJobProgress };
@@ -0,0 +1,13 @@
1
+ import {
2
+ GenerationSettings,
3
+ JobProgress,
4
+ useGenerationPlan,
5
+ useJobProgress
6
+ } from "../chunk-7SPRQZ6H.js";
7
+ export {
8
+ GenerationSettings,
9
+ JobProgress,
10
+ useGenerationPlan,
11
+ useJobProgress
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}