@cratis/event-models 0.316.0 → 0.317.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.
@@ -1,19 +1,19 @@
1
- import { a as V, i as _, l as J, n as I, o as R, r as O, s as Q, t as j } from "./defaultStructuredEditorStrings-Ch1I0Lci.js";
1
+ import { a as V, i as _, l as R, n as I, o as J, r as O, s as Q, t as j } from "./defaultStructuredEditorStrings-Ch1I0Lci.js";
2
2
  import { c as w } from "./structuredValue-vqCZttsk.js";
3
3
  import { t as D } from "./StructuredValueEditor-DUSATTWd.js";
4
4
  import { useEffect as K, useRef as E, useState as F } from "react";
5
5
  import { Fragment as x, jsx as t, jsxs as i } from "react/jsx-runtime";
6
- import { BindingSourceKind as d, PropertyValueType as C } from "@cratis/scene.model";
6
+ import { BindingSourceKind as c, PropertyValueType as P } from "@cratis/scene.model";
7
7
  var u = /* @__PURE__ */ (function(e) {
8
8
  return e.String = "string", e.Number = "number", e.Boolean = "boolean", e.Null = "null", e.Json = "json", e;
9
- })(u || {}), $ = ({ property: e, sources: l, strings: s, disabled: c, onChange: p }) => {
9
+ })(u || {}), $ = ({ property: e, sources: l, strings: s, disabled: d, onChange: p }) => {
10
10
  const r = s.properties.binding, h = Q(e.effectiveValue) ? e.effectiveValue : void 0, m = h ? void 0 : T(e.effectiveValue), f = V(e), o = h ?? f, y = L(o, e.descriptor.acceptedBindingKinds?.length ? e.descriptor.acceptedBindingKinds : I, l, r), b = o.query ? l.queryResults.find((n) => n.id === o.query || n.name === o.query) : void 0, v = o.componentId ? l.componentOutputs.find((n) => n.componentId === o.componentId) : void 0, a = (n) => p(A({
11
11
  ...o,
12
12
  ...n
13
- })), P = () => p(void 0);
13
+ })), C = () => p(void 0);
14
14
  return m !== void 0 ? /* @__PURE__ */ i("fieldset", {
15
15
  className: "studio-editor-binding",
16
- disabled: c,
16
+ disabled: d,
17
17
  children: [
18
18
  /* @__PURE__ */ t("legend", { children: e.descriptor.label }),
19
19
  /* @__PURE__ */ i("div", {
@@ -29,21 +29,21 @@ var u = /* @__PURE__ */ (function(e) {
29
29
  children: r.replaceUnsupported
30
30
  }), /* @__PURE__ */ t("button", {
31
31
  type: "button",
32
- onClick: P,
32
+ onClick: C,
33
33
  children: r.clear
34
34
  })]
35
35
  })
36
36
  ]
37
37
  }) : /* @__PURE__ */ i("fieldset", {
38
38
  className: "studio-editor-binding",
39
- disabled: c,
39
+ disabled: d,
40
40
  children: [
41
41
  /* @__PURE__ */ t("legend", { children: e.descriptor.label }),
42
42
  /* @__PURE__ */ i("div", {
43
43
  className: "studio-editor-binding__row",
44
44
  children: [
45
45
  /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.source }), /* @__PURE__ */ t("select", {
46
- value: o.kind ?? d.DataContext,
46
+ value: o.kind ?? c.DataContext,
47
47
  onChange: (n) => a(M(n.target.value, o)),
48
48
  children: y.map((n) => /* @__PURE__ */ t("option", {
49
49
  value: n.kind,
@@ -79,7 +79,7 @@ var u = /* @__PURE__ */ (function(e) {
79
79
  children: [/* @__PURE__ */ t("option", {
80
80
  value: "",
81
81
  children: r.inferType
82
- }), R.map((n) => /* @__PURE__ */ t("option", {
82
+ }), J.map((n) => /* @__PURE__ */ t("option", {
83
83
  value: n,
84
84
  children: n
85
85
  }, n))]
@@ -94,14 +94,14 @@ var u = /* @__PURE__ */ (function(e) {
94
94
  n.reason
95
95
  ]
96
96
  }, `${n.kind}:reason`)),
97
- g(o) === d.DataContext && /* @__PURE__ */ t(S, {
97
+ g(o) === c.DataContext && /* @__PURE__ */ t(S, {
98
98
  id: `${e.descriptor.path}-data-context-paths`,
99
99
  label: r.path,
100
100
  value: o.path,
101
101
  options: l.dataContextPaths,
102
102
  onChange: (n) => a({ path: n })
103
103
  }),
104
- g(o) === d.QueryResult && /* @__PURE__ */ i(x, { children: [
104
+ g(o) === c.QueryResult && /* @__PURE__ */ i(x, { children: [
105
105
  /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.query }), /* @__PURE__ */ i("select", {
106
106
  value: o.query ?? "",
107
107
  onChange: (n) => a({
@@ -136,7 +136,7 @@ var u = /* @__PURE__ */ (function(e) {
136
136
  children: r.missingQuery(o.query)
137
137
  })
138
138
  ] }),
139
- g(o) === d.ComponentProperty && /* @__PURE__ */ i(x, { children: [
139
+ g(o) === c.ComponentProperty && /* @__PURE__ */ i(x, { children: [
140
140
  /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.component }), /* @__PURE__ */ i("select", {
141
141
  value: o.componentId ?? "",
142
142
  onChange: (n) => a({
@@ -180,7 +180,7 @@ var u = /* @__PURE__ */ (function(e) {
180
180
  children: r.missingComponent(o.componentId)
181
181
  })
182
182
  ] }),
183
- g(o) === d.Literal && /* @__PURE__ */ t(k, {
183
+ g(o) === c.Literal && /* @__PURE__ */ t(k, {
184
184
  value: o.value,
185
185
  descriptor: e.descriptor,
186
186
  targetType: o.expectedValueType ?? e.descriptor.valueType,
@@ -193,12 +193,12 @@ var u = /* @__PURE__ */ (function(e) {
193
193
  }, N(o.value, o.expectedValueType ?? e.descriptor.valueType)),
194
194
  h && /* @__PURE__ */ t("button", {
195
195
  type: "button",
196
- onClick: P,
196
+ onClick: C,
197
197
  children: r.clear
198
198
  })
199
199
  ]
200
200
  });
201
- }, S = ({ id: e, label: l, value: s, options: c, onChange: p }) => /* @__PURE__ */ i("label", { children: [
201
+ }, S = ({ id: e, label: l, value: s, options: d, onChange: p }) => /* @__PURE__ */ i("label", { children: [
202
202
  /* @__PURE__ */ t("span", { children: l }),
203
203
  /* @__PURE__ */ t("input", {
204
204
  list: e,
@@ -207,9 +207,9 @@ var u = /* @__PURE__ */ (function(e) {
207
207
  }),
208
208
  /* @__PURE__ */ t("datalist", {
209
209
  id: e,
210
- children: c.map((r) => /* @__PURE__ */ t("option", { value: r }, r))
210
+ children: d.map((r) => /* @__PURE__ */ t("option", { value: r }, r))
211
211
  })
212
- ] }), k = ({ value: e, descriptor: l, targetType: s, strings: c, structured: p, onChange: r }) => {
212
+ ] }), k = ({ value: e, descriptor: l, targetType: s, strings: d, structured: p, onChange: r }) => {
213
213
  const h = q(e, s), m = N(e, s), f = E(m), [o, y] = F(h);
214
214
  K(() => {
215
215
  const a = N(e, s);
@@ -217,13 +217,13 @@ var u = /* @__PURE__ */ (function(e) {
217
217
  }, [e, s]);
218
218
  const b = (a) => {
219
219
  y(a);
220
- const P = B(a);
221
- f.current = N(P, s), r(P);
220
+ const C = B(a);
221
+ f.current = N(C, s), r(C);
222
222
  }, v = w(l);
223
223
  return /* @__PURE__ */ i("div", {
224
224
  className: "studio-editor-binding__literal",
225
225
  children: [
226
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: c.literalType }), /* @__PURE__ */ i("select", {
226
+ /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalType }), /* @__PURE__ */ i("select", {
227
227
  value: o,
228
228
  onChange: (a) => b(a.target.value),
229
229
  children: [
@@ -245,20 +245,20 @@ var u = /* @__PURE__ */ (function(e) {
245
245
  }),
246
246
  (v || o === u.Json) && /* @__PURE__ */ t("option", {
247
247
  value: u.Json,
248
- children: c.literalStructured
248
+ children: d.literalStructured
249
249
  })
250
250
  ]
251
251
  })] }),
252
- o === u.String && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: c.literalValue }), /* @__PURE__ */ t("input", {
252
+ o === u.String && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ t("input", {
253
253
  value: typeof e == "string" ? e : "",
254
254
  onChange: (a) => r(a.target.value)
255
255
  })] }),
256
- o === u.Number && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: c.literalValue }), /* @__PURE__ */ t("input", {
256
+ o === u.Number && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ t("input", {
257
257
  type: "number",
258
258
  value: typeof e == "number" ? String(e) : "",
259
259
  onChange: (a) => r(a.target.value === "" ? void 0 : Number(a.target.value))
260
260
  })] }),
261
- o === u.Boolean && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: c.literalValue }), /* @__PURE__ */ i("select", {
261
+ o === u.Boolean && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ i("select", {
262
262
  value: e === !0 ? "true" : "false",
263
263
  onChange: (a) => r(a.target.value === "true"),
264
264
  children: [/* @__PURE__ */ t("option", {
@@ -269,7 +269,7 @@ var u = /* @__PURE__ */ (function(e) {
269
269
  children: "false"
270
270
  })]
271
271
  })] }),
272
- o === u.Null && /* @__PURE__ */ t("p", { children: c.literalNull }),
272
+ o === u.Null && /* @__PURE__ */ t("p", { children: d.literalNull }),
273
273
  o === u.Json && v && /* @__PURE__ */ t(D, {
274
274
  descriptor: l,
275
275
  value: e,
@@ -281,25 +281,25 @@ var u = /* @__PURE__ */ (function(e) {
281
281
  o === u.Json && !v && /* @__PURE__ */ t("p", {
282
282
  className: "studio-editor-binding__missing",
283
283
  role: "alert",
284
- children: c.literalNoEditor
284
+ children: d.literalNoEditor
285
285
  })
286
286
  ]
287
287
  });
288
288
  };
289
- function L(e, l, s, c) {
289
+ function L(e, l, s, d) {
290
290
  const p = g(e);
291
291
  return I.map((r) => {
292
- const h = l.includes(r), m = r === d.QueryResult && s.queryResults.length === 0 || r === d.ComponentProperty && s.componentOutputs.length === 0;
292
+ const h = l.includes(r), m = r === c.QueryResult && s.queryResults.length === 0 || r === c.ComponentProperty && s.componentOutputs.length === 0;
293
293
  return {
294
294
  kind: r,
295
- label: z(r, c.sources),
295
+ label: z(r, d.sources),
296
296
  disabled: r !== p && (!h || m),
297
- reason: h ? m ? c.unavailableSource : void 0 : c.incompatibleSource
297
+ reason: h ? m ? d.unavailableSource : void 0 : d.incompatibleSource
298
298
  };
299
299
  });
300
300
  }
301
301
  function g(e) {
302
- return e.kind ?? d.DataContext;
302
+ return e.kind ?? c.DataContext;
303
303
  }
304
304
  function T(e) {
305
305
  if (!(!e || typeof e != "object" || Array.isArray(e)))
@@ -314,7 +314,7 @@ function T(e) {
314
314
  }
315
315
  function A(e) {
316
316
  switch (g(e)) {
317
- case d.Literal:
317
+ case c.Literal:
318
318
  return {
319
319
  ...e,
320
320
  path: "",
@@ -322,21 +322,22 @@ function A(e) {
322
322
  componentId: void 0,
323
323
  componentPropertyPath: void 0
324
324
  };
325
- case d.QueryResult:
325
+ case c.QueryResult:
326
326
  return {
327
327
  ...e,
328
328
  componentId: void 0,
329
329
  componentPropertyPath: void 0,
330
330
  value: void 0
331
331
  };
332
- case d.ComponentProperty:
332
+ case c.ComponentProperty:
333
333
  return {
334
334
  ...e,
335
335
  query: void 0,
336
336
  value: void 0,
337
337
  path: e.componentPropertyPath ?? e.path
338
338
  };
339
- case d.DataContext:
339
+ case c.DataContext:
340
+ case c.CommandResponse:
340
341
  return {
341
342
  ...e,
342
343
  query: void 0,
@@ -348,26 +349,27 @@ function A(e) {
348
349
  }
349
350
  function M(e, l) {
350
351
  switch (e) {
351
- case d.Literal:
352
+ case c.Literal:
352
353
  return {
353
354
  kind: e,
354
355
  path: "",
355
356
  value: l.value ?? ""
356
357
  };
357
- case d.QueryResult:
358
+ case c.QueryResult:
358
359
  return {
359
360
  kind: e,
360
361
  query: l.query,
361
362
  path: l.path
362
363
  };
363
- case d.ComponentProperty:
364
+ case c.ComponentProperty:
364
365
  return {
365
366
  kind: e,
366
367
  componentId: l.componentId,
367
368
  componentPropertyPath: l.componentPropertyPath ?? l.path,
368
369
  path: l.componentPropertyPath ?? l.path
369
370
  };
370
- case d.DataContext:
371
+ case c.DataContext:
372
+ case c.CommandResponse:
371
373
  return {
372
374
  kind: e,
373
375
  path: l.path
@@ -375,7 +377,7 @@ function M(e, l) {
375
377
  }
376
378
  }
377
379
  function q(e, l) {
378
- return e === null ? u.Null : typeof e == "number" ? u.Number : typeof e == "boolean" ? u.Boolean : typeof e == "object" ? u.Json : l === C.Number ? u.Number : l === C.Boolean ? u.Boolean : l === C.Object || l === C.Collection || l === C.Json ? u.Json : u.String;
380
+ return e === null ? u.Null : typeof e == "number" ? u.Number : typeof e == "boolean" ? u.Boolean : typeof e == "object" ? u.Json : l === P.Number ? u.Number : l === P.Boolean ? u.Boolean : l === P.Object || l === P.Collection || l === P.Json ? u.Json : u.String;
379
381
  }
380
382
  function N(e, l) {
381
383
  return JSON.stringify({
@@ -399,24 +401,26 @@ function B(e) {
399
401
  }
400
402
  function z(e, l) {
401
403
  switch (e) {
402
- case d.DataContext:
404
+ case c.DataContext:
403
405
  return l.dataContext;
404
- case d.QueryResult:
406
+ case c.QueryResult:
405
407
  return l.queryResult;
406
- case d.ComponentProperty:
408
+ case c.ComponentProperty:
407
409
  return l.componentProperty;
408
- case d.Literal:
410
+ case c.Literal:
409
411
  return l.literal;
412
+ case c.CommandResponse:
413
+ return l.commandResponse;
410
414
  }
411
415
  }
412
416
  var Z = ({ onChange: e, context: l, disabled: s }) => {
413
- const { session: c } = l;
414
- if (!c) return null;
415
- const { controller: p, environment: r } = c, h = J(p.document, p.composition.roots, p.context, r.availableSources, r.queryCandidates);
417
+ const { session: d } = l;
418
+ if (!d) return null;
419
+ const { controller: p, environment: r } = d, h = R(p.document, p.composition.roots, p.context, r.availableSources, r.queryCandidates);
416
420
  return /* @__PURE__ */ t($, {
417
- property: c.property,
421
+ property: d.property,
418
422
  sources: h,
419
- strings: c.screenStrings,
423
+ strings: d.screenStrings,
420
424
  disabled: s === !0,
421
425
  onChange: e
422
426
  });
@@ -28,3 +28,6 @@ export type SceneScreenDraftPreparation = {
28
28
  problem: string;
29
29
  prepared?: never;
30
30
  };
31
+ export declare class SceneScreenDraftRefusal extends Error {
32
+ constructor(message: string);
33
+ }
@@ -0,0 +1,2 @@
1
+ import type { SceneScreenDraftStrings } from './SceneScreenDraftStrings';
2
+ export declare const sceneScreenDraftGenerationProblem: (error: unknown, text: SceneScreenDraftStrings) => string;
@@ -1,5 +1,10 @@
1
+ import type { SceneScreenDraftStrings } from '../Drafting/SceneScreenDraftStrings';
1
2
  import type { ScreenEditorController } from './ScreenEditorController';
2
3
  import type { OpenedSubject } from './openSubject';
3
4
  import type { ScreenEditorEnvironment } from './ScreenEditorHost';
4
5
  export type ComponentInsertedListener = (key: string) => void;
5
- export declare function useScreenEditor(opened: OpenedSubject, authoringTemplate: string | undefined, environment: ScreenEditorEnvironment, onInserted?: ComponentInsertedListener): ScreenEditorController;
6
+ export interface ScreenEditorSessionOptions {
7
+ draftStrings: SceneScreenDraftStrings | undefined;
8
+ onInserted?: ComponentInsertedListener;
9
+ }
10
+ export declare function useScreenEditor(opened: OpenedSubject, authoringTemplate: string | undefined, environment: ScreenEditorEnvironment, options: ScreenEditorSessionOptions): ScreenEditorController;
@@ -225,6 +225,7 @@ export interface ScreenEditorStrings {
225
225
  queryResult: string;
226
226
  componentProperty: string;
227
227
  literal: string;
228
+ commandResponse: string;
228
229
  };
229
230
  path: string;
230
231
  query: string;