@cratis/scene 0.106.0 → 0.108.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.
@@ -0,0 +1 @@
1
+ export declare const exposePrototypeHostModules: (target?: Record<string, unknown>) => void;
@@ -1,4 +1,4 @@
1
- import { l as n, o as A, p as q } from "../PrototypeComponentRegistry-FLUzIk5a.js";
1
+ import { c as N, f as n, k as q } from "../Scene-DaQtzf1e.js";
2
2
  import { createContext as M, useContext as P } from "react";
3
3
  import { Fragment as x, jsx as i, jsxs as f } from "react/jsx-runtime";
4
4
  var W = { prototypeThumbnail: {
@@ -89,8 +89,8 @@ var W = { prototypeThumbnail: {
89
89
  transformOrigin: "top left",
90
90
  ...F(r)
91
91
  },
92
- children: e.filter(Boolean).map((L) => {
93
- const o = A(L), y = String(o.id), g = $(o), a = U(o), u = E ? {
92
+ children: e.filter(Boolean).map((A) => {
93
+ const o = N(A), y = String(o.id), g = $(o), a = U(o), u = E ? {
94
94
  position: "relative",
95
95
  width: H ? "100%" : a.width,
96
96
  height: a.height,
@@ -113,9 +113,9 @@ var W = { prototypeThumbnail: {
113
113
  label: o.label
114
114
  })
115
115
  }, y);
116
- const N = "type" in o && typeof o.type == "string" ? ` prototype-thumbnail-element--${o.type}` : "";
116
+ const L = "type" in o && typeof o.type == "string" ? ` prototype-thumbnail-element--${o.type}` : "";
117
117
  return /* @__PURE__ */ i("div", {
118
- className: `prototype-thumbnail-element${N}`,
118
+ className: `prototype-thumbnail-element${L}`,
119
119
  style: u
120
120
  }, y);
121
121
  })
@@ -0,0 +1,449 @@
1
+ import * as U from "@cratis/fundamentals";
2
+ import { DerivedType as w, Guid as j, derivedType as M, field as o } from "@cratis/fundamentals";
3
+ import * as K from "react";
4
+ import * as q from "react/jsx-runtime";
5
+ var T = Object.defineProperty, Y = (e, n) => {
6
+ let i = {};
7
+ for (var s in e)
8
+ T(i, s, {
9
+ get: e[s],
10
+ enumerable: !0
11
+ });
12
+ return n || T(i, Symbol.toStringTag, { value: "Module" }), i;
13
+ };
14
+ function r(e, n) {
15
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, n);
16
+ }
17
+ function t(e, n, i, s) {
18
+ var p = arguments.length, a = p < 3 ? n : s === null ? s = Object.getOwnPropertyDescriptor(n, i) : s, m;
19
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, n, i, s);
20
+ else for (var g = e.length - 1; g >= 0; g--) (m = e[g]) && (a = (p < 3 ? m(a) : p > 3 ? m(n, i, a) : m(n, i)) || a);
21
+ return p > 3 && a && Object.defineProperty(n, i, a), a;
22
+ }
23
+ var z = class {
24
+ name;
25
+ };
26
+ t([o(String), r("design:type", String)], z.prototype, "name", void 0);
27
+ var k = class {
28
+ name;
29
+ };
30
+ t([o(String), r("design:type", String)], k.prototype, "name", void 0);
31
+ var F = /* @__PURE__ */ (function(e) {
32
+ return e[e.left = 0] = "left", e[e.center = 1] = "center", e[e.right = 2] = "right", e[e.stretch = 3] = "stretch", e;
33
+ })({}), y = class {
34
+ left;
35
+ top;
36
+ right;
37
+ bottom;
38
+ };
39
+ t([o(Number), r("design:type", Number)], y.prototype, "left", void 0);
40
+ t([o(Number), r("design:type", Number)], y.prototype, "top", void 0);
41
+ t([o(Number), r("design:type", Number)], y.prototype, "right", void 0);
42
+ t([o(Number), r("design:type", Number)], y.prototype, "bottom", void 0);
43
+ var _ = /* @__PURE__ */ (function(e) {
44
+ return e[e.none = 0] = "none", e[e.top = 1] = "top", e[e.right = 2] = "right", e[e.bottom = 4] = "bottom", e[e.left = 8] = "left", e;
45
+ })({}), ge = 15, x = class {
46
+ id;
47
+ properties;
48
+ };
49
+ t([o(j), r("design:type", typeof j > "u" ? Object : j)], x.prototype, "id", void 0);
50
+ t([o(Object), r("design:type", typeof Record > "u" ? Object : Record)], x.prototype, "properties", void 0);
51
+ var I = /* @__PURE__ */ (function(e) {
52
+ return e[e.visible = 0] = "visible", e[e.hidden = 1] = "hidden", e[e.collapsed = 2] = "collapsed", e;
53
+ })({}), c = class extends x {
54
+ visibility;
55
+ isEnabled;
56
+ opacity;
57
+ width;
58
+ height;
59
+ ZIndex;
60
+ anchoring;
61
+ };
62
+ t([o(Number), r("design:type", typeof I > "u" ? Object : I)], c.prototype, "visibility", void 0);
63
+ t([o(Boolean), r("design:type", Boolean)], c.prototype, "isEnabled", void 0);
64
+ t([o(Number), r("design:type", Number)], c.prototype, "opacity", void 0);
65
+ t([o(Number), r("design:type", Number)], c.prototype, "width", void 0);
66
+ t([o(Number), r("design:type", Number)], c.prototype, "height", void 0);
67
+ t([o(Number), r("design:type", Number)], c.prototype, "ZIndex", void 0);
68
+ t([o(Number), r("design:type", typeof _ > "u" ? Object : _)], c.prototype, "anchoring", void 0);
69
+ var L = /* @__PURE__ */ (function(e) {
70
+ return e[e.top = 0] = "top", e[e.center = 1] = "center", e[e.bottom = 2] = "bottom", e[e.stretch = 3] = "stretch", e;
71
+ })({}), l = class extends c {
72
+ name;
73
+ minWidth;
74
+ maxWidth;
75
+ minHeight;
76
+ maxHeight;
77
+ margin;
78
+ horizontalAlignment;
79
+ verticalAlignment;
80
+ };
81
+ t([o(String), r("design:type", String)], l.prototype, "name", void 0);
82
+ t([o(Number), r("design:type", Number)], l.prototype, "minWidth", void 0);
83
+ t([o(Number), r("design:type", Number)], l.prototype, "maxWidth", void 0);
84
+ t([o(Number), r("design:type", Number)], l.prototype, "minHeight", void 0);
85
+ t([o(Number), r("design:type", Number)], l.prototype, "maxHeight", void 0);
86
+ t([o(y), r("design:type", typeof y > "u" ? Object : y)], l.prototype, "margin", void 0);
87
+ t([o(Number), r("design:type", typeof F > "u" ? Object : F)], l.prototype, "horizontalAlignment", void 0);
88
+ t([o(Number), r("design:type", typeof L > "u" ? Object : L)], l.prototype, "verticalAlignment", void 0);
89
+ var u = class extends l {
90
+ background;
91
+ foreground;
92
+ borderBrush;
93
+ borderThickness;
94
+ padding;
95
+ fontFamily;
96
+ fontSize;
97
+ fontWeight;
98
+ tabIndex;
99
+ };
100
+ t([o(String), r("design:type", String)], u.prototype, "background", void 0);
101
+ t([o(String), r("design:type", String)], u.prototype, "foreground", void 0);
102
+ t([o(String), r("design:type", String)], u.prototype, "borderBrush", void 0);
103
+ t([o(y), r("design:type", typeof y > "u" ? Object : y)], u.prototype, "borderThickness", void 0);
104
+ t([o(y), r("design:type", typeof y > "u" ? Object : y)], u.prototype, "padding", void 0);
105
+ t([o(String), r("design:type", String)], u.prototype, "fontFamily", void 0);
106
+ t([o(Number), r("design:type", Number)], u.prototype, "fontSize", void 0);
107
+ t([o(String), r("design:type", String)], u.prototype, "fontWeight", void 0);
108
+ t([o(Number), r("design:type", Number)], u.prototype, "tabIndex", void 0);
109
+ var S = class extends u {
110
+ content;
111
+ };
112
+ t([o(c), r("design:type", typeof c > "u" ? Object : c)], S.prototype, "content", void 0);
113
+ S = t([M("contentControl")], S);
114
+ var h = class extends l {
115
+ componentName;
116
+ slots;
117
+ };
118
+ t([o(String), r("design:type", String)], h.prototype, "componentName", void 0);
119
+ t([o(Object), r("design:type", typeof Record > "u" ? Object : Record)], h.prototype, "slots", void 0);
120
+ h = t([M("externalComponent")], h);
121
+ var W = class extends h {
122
+ initialSize = {
123
+ width: 220,
124
+ height: 72
125
+ };
126
+ resizeBehavior = "both";
127
+ acceptsChildren = !1;
128
+ constructor() {
129
+ super();
130
+ let e = "";
131
+ Object.defineProperty(this, "id", {
132
+ get() {
133
+ return e;
134
+ },
135
+ set(n) {
136
+ e = String(n ?? "");
137
+ },
138
+ enumerable: !0,
139
+ configurable: !0
140
+ });
141
+ }
142
+ get label() {
143
+ return this.name ?? "";
144
+ }
145
+ set label(e) {
146
+ this.name = e;
147
+ }
148
+ get position() {
149
+ const e = this.properties?.canvas ?? {};
150
+ return {
151
+ x: e.x ?? 0,
152
+ y: e.y ?? 0
153
+ };
154
+ }
155
+ set position(e) {
156
+ this.properties = {
157
+ ...this.properties ?? {},
158
+ canvas: {
159
+ x: e.x,
160
+ y: e.y
161
+ }
162
+ };
163
+ }
164
+ get size() {
165
+ return {
166
+ width: this.width ?? 0,
167
+ height: this.height ?? 0
168
+ };
169
+ }
170
+ set size(e) {
171
+ this.width = Math.trunc(e.width), this.height = Math.trunc(e.height);
172
+ }
173
+ get children() {
174
+ return this.slots?.children ?? [];
175
+ }
176
+ set children(e) {
177
+ this.slots = {
178
+ ...this.slots ?? {},
179
+ children: e
180
+ };
181
+ }
182
+ get type() {
183
+ const e = this.componentName ?? "", n = e.split(".").pop() ?? e;
184
+ return this.library ? `${this.library}.${n}` : n;
185
+ }
186
+ initialize(e) {
187
+ return e.id !== void 0 && (this.id = e.id), e.label !== void 0 && (this.label = e.label), e.position !== void 0 && (this.position = e.position), e.size !== void 0 && (this.size = e.size), e.ZIndex !== void 0 && (this.ZIndex = e.ZIndex), e.anchoring !== void 0 && (this.anchoring = e.anchoring), e.children !== void 0 && (this.children = e.children), this.name || (this.name = this.componentName), e.size || (this.size = { ...this.initialSize }), this.componentName = this.type, this;
188
+ }
189
+ };
190
+ o(String)(W.prototype, "id");
191
+ var J = class {
192
+ }, b = class extends l {
193
+ children;
194
+ background;
195
+ };
196
+ t([o(c, !0), r("design:type", Array)], b.prototype, "children", void 0);
197
+ t([o(String), r("design:type", String)], b.prototype, "background", void 0);
198
+ var C = class extends u {
199
+ items;
200
+ itemsPanel;
201
+ };
202
+ t([o(c, !0), r("design:type", Array)], C.prototype, "items", void 0);
203
+ t([o(b), r("design:type", typeof b > "u" ? Object : b)], C.prototype, "itemsPanel", void 0);
204
+ C = t([M("itemsControl")], C);
205
+ var A = class {
206
+ }, v = class {
207
+ name;
208
+ namespace;
209
+ category;
210
+ library;
211
+ bundlePath;
212
+ type;
213
+ };
214
+ t([o(String), r("design:type", String)], v.prototype, "name", void 0);
215
+ t([o(String), r("design:type", String)], v.prototype, "namespace", void 0);
216
+ t([o(String), r("design:type", String)], v.prototype, "category", void 0);
217
+ t([o(String), r("design:type", String)], v.prototype, "library", void 0);
218
+ t([o(String), r("design:type", String)], v.prototype, "bundlePath", void 0);
219
+ t([o(String), r("design:type", String)], v.prototype, "type", void 0);
220
+ var Q = class {
221
+ }, N = class {
222
+ name;
223
+ components;
224
+ };
225
+ t([o(String), r("design:type", String)], N.prototype, "name", void 0);
226
+ t([o(v, !0), r("design:type", Array)], N.prototype, "components", void 0);
227
+ var O = class {
228
+ name;
229
+ bundlePath;
230
+ categories;
231
+ };
232
+ t([o(String), r("design:type", String)], O.prototype, "name", void 0);
233
+ t([o(String), r("design:type", String)], O.prototype, "bundlePath", void 0);
234
+ t([o(N, !0), r("design:type", Array)], O.prototype, "categories", void 0);
235
+ var X = /* @__PURE__ */ (function(e) {
236
+ return e[e.absolute = 0] = "absolute", e[e.flexRow = 1] = "flexRow", e[e.flexColumn = 2] = "flexColumn", e[e.grid = 3] = "grid", e;
237
+ })({}), G = {
238
+ "@cratis/fundamentals": "__cratisPrototypeHostFundamentals",
239
+ "@cratis/scene": "__cratisPrototypeHostScene",
240
+ react: "__cratisPrototypeHostReact",
241
+ "react/jsx-runtime": "__cratisPrototypeHostReactJsxRuntime"
242
+ }, V = () => ({
243
+ "@cratis/fundamentals": U,
244
+ "@cratis/scene": le,
245
+ react: K,
246
+ "react/jsx-runtime": q
247
+ }), ee = (e = globalThis) => {
248
+ const n = V();
249
+ for (const [i, s] of Object.entries(G)) e[s] ??= n[i];
250
+ }, B = () => (window.__cratisPrototypeComponents ??= {}, window.__cratisPrototypeComponents), te = () => (window.__cratisPrototypeBundleLoads ??= {}, window.__cratisPrototypeBundleLoads), oe = (e) => {
251
+ const n = [e], i = e.split(".").pop();
252
+ return i && i !== e && n.push(i), n;
253
+ }, P = (e, n) => {
254
+ if (typeof window > "u") return;
255
+ const i = B()[e];
256
+ if (i)
257
+ for (const s of oe(n)) {
258
+ const p = i[s];
259
+ if (p) return p;
260
+ }
261
+ }, re = (e, n) => {
262
+ B()[e] = n;
263
+ for (const [i, s] of Object.entries(n)) {
264
+ if (!i.includes(".")) continue;
265
+ w.set(s, i);
266
+ let p = Object.getPrototypeOf(s.prototype);
267
+ for (; p && p.constructor && p.constructor !== Object; )
268
+ w.set(s, i, p.constructor), p = Object.getPrototypeOf(p);
269
+ }
270
+ }, Z = (e) => {
271
+ if ("RenderPrototype" in e && typeof e.RenderPrototype == "function") return e;
272
+ const n = "_derivedTypeId" in e && typeof e._derivedTypeId == "string" && e._derivedTypeId.includes(".") ? e._derivedTypeId : "componentName" in e && typeof e.componentName == "string" ? e.componentName : "", i = n.indexOf(".");
273
+ if (i < 1) return e;
274
+ const s = P(n.slice(0, i), n.slice(i + 1));
275
+ if (!s) return e;
276
+ const p = Object.fromEntries(Object.entries(e).filter(([a]) => ![
277
+ "type",
278
+ "label",
279
+ "position",
280
+ "size",
281
+ "children"
282
+ ].includes(a)));
283
+ if ("slots" in e && e.slots && typeof e.slots == "object") {
284
+ let a;
285
+ for (const [m, g] of Object.entries(e.slots)) {
286
+ if (!Array.isArray(g)) continue;
287
+ let f;
288
+ for (const [H, E] of g.entries()) {
289
+ const D = Z(E);
290
+ D !== E && (f ??= g.slice(), f[H] = D);
291
+ }
292
+ f && (a ??= { ...e.slots }, a[m] = f);
293
+ }
294
+ a && (p.slots = a);
295
+ }
296
+ return Object.assign(new s(), p);
297
+ }, ne = (e, n) => {
298
+ const i = P(e, n);
299
+ return i ? new i() : void 0;
300
+ }, ie = (e, n, i) => {
301
+ const s = P(e, n);
302
+ if (!s) return;
303
+ const p = new s();
304
+ return typeof p.initialize == "function" ? p.initialize(i) : (Object.assign(p, i), p);
305
+ }, $ = async (e) => {
306
+ ee();
307
+ const n = te();
308
+ if (n[e]) {
309
+ await n[e];
310
+ return;
311
+ }
312
+ n[e] = new Promise((i, s) => {
313
+ const p = document.querySelector(`script[data-prototype-bundle="${e}"]`);
314
+ if (p) {
315
+ p.addEventListener("load", () => i(), { once: !0 }), p.addEventListener("error", () => s(/* @__PURE__ */ new Error(`Failed to load prototype bundle '${e}'.`)), { once: !0 });
316
+ return;
317
+ }
318
+ const a = document.createElement("script");
319
+ a.src = e, a.async = !0, a.dataset.prototypeBundle = e, a.onload = () => i(), a.onerror = () => s(/* @__PURE__ */ new Error(`Failed to load prototype bundle '${e}'.`)), document.head.appendChild(a);
320
+ }), await n[e];
321
+ }, se = async (e) => {
322
+ const n = [...new Set(e.filter(Boolean))];
323
+ await Promise.all(n.map($)), pe();
324
+ }, pe = () => {
325
+ const e = B();
326
+ for (const n of Object.values(e)) for (const [i, s] of Object.entries(n))
327
+ i.includes(".") && w.set(s, i, c);
328
+ }, R = (e) => {
329
+ const n = e, i = n.componentName;
330
+ if (!i) return e;
331
+ const s = i.indexOf(".");
332
+ if (s < 0) return e;
333
+ const p = i.substring(0, s), a = i.substring(s + 1), m = P(p, a);
334
+ if (!m) return e;
335
+ const g = new m();
336
+ Object.assign(g, e);
337
+ const f = n.slots;
338
+ return f?.children?.length && (g.slots = {
339
+ ...f,
340
+ children: f.children.map(R)
341
+ }), g;
342
+ }, ae = (e) => e.map(R), d = {
343
+ Layout: "Layout",
344
+ Containers: "Containers",
345
+ Form: "Form",
346
+ Button: "Button",
347
+ Buttons: "Buttons",
348
+ Data: "Data",
349
+ Panel: "Panel",
350
+ Panels: "Panels",
351
+ Overlay: "Overlay",
352
+ File: "File",
353
+ Menu: "Menu",
354
+ Menus: "Menus",
355
+ Chart: "Chart",
356
+ Charts: "Charts",
357
+ Messages: "Messages",
358
+ Media: "Media",
359
+ Misc: "Misc"
360
+ }, de = {
361
+ [d.Layout]: "pi pi-objects-column",
362
+ [d.Containers]: "pi pi-box",
363
+ [d.Form]: "pi pi-pencil",
364
+ [d.Button]: "pi pi-stop",
365
+ [d.Buttons]: "pi pi-stop",
366
+ [d.Data]: "pi pi-list",
367
+ [d.Panel]: "pi pi-table",
368
+ [d.Panels]: "pi pi-table",
369
+ [d.Overlay]: "pi pi-clone",
370
+ [d.File]: "pi pi-file",
371
+ [d.Menu]: "pi pi-bars",
372
+ [d.Menus]: "pi pi-bars",
373
+ [d.Chart]: "pi pi-chart-bar",
374
+ [d.Charts]: "pi pi-chart-bar",
375
+ [d.Messages]: "pi pi-envelope",
376
+ [d.Media]: "pi pi-image",
377
+ [d.Misc]: "pi pi-ellipsis-h"
378
+ }, ce = "pi pi-folder-open";
379
+ function ye(e) {
380
+ return de[e] ?? ce;
381
+ }
382
+ var le = /* @__PURE__ */ Y({
383
+ AnchorEdges: () => _,
384
+ CategoryAttribute: () => z,
385
+ Component: () => W,
386
+ ComponentLibraryAttribute: () => k,
387
+ ContentControl: () => S,
388
+ Control: () => u,
389
+ ExternalComponent: () => h,
390
+ FrameworkElement: () => l,
391
+ IPrototypeComponentDiscovery: () => J,
392
+ IUIElement: () => A,
393
+ ItemsControl: () => C,
394
+ Panel: () => b,
395
+ PrototypeComponentCategoryDescriptor: () => N,
396
+ PrototypeComponentDescriptor: () => v,
397
+ PrototypeComponentDiscovery: () => Q,
398
+ PrototypeComponentLibraryDescriptor: () => O,
399
+ PrototypeLayout: () => X,
400
+ SceneObject: () => x,
401
+ UIElement: () => c,
402
+ Visibility: () => I,
403
+ WellKnownCategories: () => d,
404
+ allAnchorEdges: () => 15,
405
+ createPrototypeComponentInstance: () => ie,
406
+ ensurePrototypeComponentBundle: () => $,
407
+ getCategoryIcon: () => ye,
408
+ getPrototypeComponent: () => ne,
409
+ hydrateElement: () => R,
410
+ hydrateElements: () => ae,
411
+ hydratePrototypeElement: () => Z,
412
+ loadPrototypeComponentLibraries: () => se,
413
+ prototypeHostGlobals: () => G,
414
+ registerPrototypeComponentLibrary: () => re
415
+ });
416
+ export {
417
+ ge as A,
418
+ S as C,
419
+ I as D,
420
+ c as E,
421
+ z as M,
422
+ x as O,
423
+ h as S,
424
+ l as T,
425
+ A as _,
426
+ ne as a,
427
+ J as b,
428
+ Z as c,
429
+ G as d,
430
+ X as f,
431
+ O as g,
432
+ Q as h,
433
+ $ as i,
434
+ k as j,
435
+ _ as k,
436
+ se as l,
437
+ v as m,
438
+ ye as n,
439
+ R as o,
440
+ N as p,
441
+ ie as r,
442
+ ae as s,
443
+ d as t,
444
+ re as u,
445
+ C as v,
446
+ u as w,
447
+ W as x,
448
+ b as y
449
+ };
package/dist/index.d.ts CHANGED
@@ -20,4 +20,5 @@ export * from './Layout/Visibility';
20
20
  export * from './Layout/PrototypeLayout';
21
21
  export * from './UIElement';
22
22
  export * from './PrototypeComponentRegistry';
23
+ export * from './prototypeHostGlobals';
23
24
  export * from './WellKnownCategories';
package/dist/index.js CHANGED
@@ -1,261 +1,35 @@
1
- import { a as O, c as I, d as j, f as E, g as o, h as t, i as B, l as F, m as L, n as k, o as z, p as D, r as _, s as w, t as W, u as a } from "./PrototypeComponentRegistry-FLUzIk5a.js";
2
- import { derivedType as l, field as i } from "@cratis/fundamentals";
3
- var S = class {
4
- name;
5
- };
6
- t([i(String), o("design:type", String)], S.prototype, "name", void 0);
7
- var C = class {
8
- name;
9
- };
10
- t([i(String), o("design:type", String)], C.prototype, "name", void 0);
11
- var b = /* @__PURE__ */ (function(e) {
12
- return e[e.left = 0] = "left", e[e.center = 1] = "center", e[e.right = 2] = "right", e[e.stretch = 3] = "stretch", e;
13
- })({}), n = class {
14
- left;
15
- top;
16
- right;
17
- bottom;
18
- };
19
- t([i(Number), o("design:type", Number)], n.prototype, "left", void 0);
20
- t([i(Number), o("design:type", Number)], n.prototype, "top", void 0);
21
- t([i(Number), o("design:type", Number)], n.prototype, "right", void 0);
22
- t([i(Number), o("design:type", Number)], n.prototype, "bottom", void 0);
23
- var f = /* @__PURE__ */ (function(e) {
24
- return e[e.top = 0] = "top", e[e.center = 1] = "center", e[e.bottom = 2] = "bottom", e[e.stretch = 3] = "stretch", e;
25
- })({}), p = class extends a {
26
- name;
27
- minWidth;
28
- maxWidth;
29
- minHeight;
30
- maxHeight;
31
- margin;
32
- horizontalAlignment;
33
- verticalAlignment;
34
- };
35
- t([i(String), o("design:type", String)], p.prototype, "name", void 0);
36
- t([i(Number), o("design:type", Number)], p.prototype, "minWidth", void 0);
37
- t([i(Number), o("design:type", Number)], p.prototype, "maxWidth", void 0);
38
- t([i(Number), o("design:type", Number)], p.prototype, "minHeight", void 0);
39
- t([i(Number), o("design:type", Number)], p.prototype, "maxHeight", void 0);
40
- t([i(n), o("design:type", typeof n > "u" ? Object : n)], p.prototype, "margin", void 0);
41
- t([i(Number), o("design:type", typeof b > "u" ? Object : b)], p.prototype, "horizontalAlignment", void 0);
42
- t([i(Number), o("design:type", typeof f > "u" ? Object : f)], p.prototype, "verticalAlignment", void 0);
43
- var s = class extends p {
44
- background;
45
- foreground;
46
- borderBrush;
47
- borderThickness;
48
- padding;
49
- fontFamily;
50
- fontSize;
51
- fontWeight;
52
- tabIndex;
53
- };
54
- t([i(String), o("design:type", String)], s.prototype, "background", void 0);
55
- t([i(String), o("design:type", String)], s.prototype, "foreground", void 0);
56
- t([i(String), o("design:type", String)], s.prototype, "borderBrush", void 0);
57
- t([i(n), o("design:type", typeof n > "u" ? Object : n)], s.prototype, "borderThickness", void 0);
58
- t([i(n), o("design:type", typeof n > "u" ? Object : n)], s.prototype, "padding", void 0);
59
- t([i(String), o("design:type", String)], s.prototype, "fontFamily", void 0);
60
- t([i(Number), o("design:type", Number)], s.prototype, "fontSize", void 0);
61
- t([i(String), o("design:type", String)], s.prototype, "fontWeight", void 0);
62
- t([i(Number), o("design:type", Number)], s.prototype, "tabIndex", void 0);
63
- var m = class extends s {
64
- content;
65
- };
66
- t([i(a), o("design:type", typeof a > "u" ? Object : a)], m.prototype, "content", void 0);
67
- m = t([l("contentControl")], m);
68
- var g = class extends p {
69
- componentName;
70
- slots;
71
- };
72
- t([i(String), o("design:type", String)], g.prototype, "componentName", void 0);
73
- t([i(Object), o("design:type", typeof Record > "u" ? Object : Record)], g.prototype, "slots", void 0);
74
- g = t([l("externalComponent")], g);
75
- var N = class extends g {
76
- initialSize = {
77
- width: 220,
78
- height: 72
79
- };
80
- resizeBehavior = "both";
81
- acceptsChildren = !1;
82
- constructor() {
83
- super();
84
- let e = "";
85
- Object.defineProperty(this, "id", {
86
- get() {
87
- return e;
88
- },
89
- set(h) {
90
- e = String(h ?? "");
91
- },
92
- enumerable: !0,
93
- configurable: !0
94
- });
95
- }
96
- get label() {
97
- return this.name ?? "";
98
- }
99
- set label(e) {
100
- this.name = e;
101
- }
102
- get position() {
103
- const e = this.properties?.canvas ?? {};
104
- return {
105
- x: e.x ?? 0,
106
- y: e.y ?? 0
107
- };
108
- }
109
- set position(e) {
110
- this.properties = {
111
- ...this.properties ?? {},
112
- canvas: {
113
- x: e.x,
114
- y: e.y
115
- }
116
- };
117
- }
118
- get size() {
119
- return {
120
- width: this.width ?? 0,
121
- height: this.height ?? 0
122
- };
123
- }
124
- set size(e) {
125
- this.width = Math.trunc(e.width), this.height = Math.trunc(e.height);
126
- }
127
- get children() {
128
- return this.slots?.children ?? [];
129
- }
130
- set children(e) {
131
- this.slots = {
132
- ...this.slots ?? {},
133
- children: e
134
- };
135
- }
136
- get type() {
137
- const e = this.componentName ?? "", h = e.split(".").pop() ?? e;
138
- return this.library ? `${this.library}.${h}` : h;
139
- }
140
- initialize(e) {
141
- return e.id !== void 0 && (this.id = e.id), e.label !== void 0 && (this.label = e.label), e.position !== void 0 && (this.position = e.position), e.size !== void 0 && (this.size = e.size), e.ZIndex !== void 0 && (this.ZIndex = e.ZIndex), e.anchoring !== void 0 && (this.anchoring = e.anchoring), e.children !== void 0 && (this.children = e.children), this.name || (this.name = this.componentName), e.size || (this.size = { ...this.initialSize }), this.componentName = this.type, this;
142
- }
143
- };
144
- i(String)(N.prototype, "id");
145
- var A = class {
146
- }, y = class extends p {
147
- children;
148
- background;
149
- };
150
- t([i(a, !0), o("design:type", Array)], y.prototype, "children", void 0);
151
- t([i(String), o("design:type", String)], y.prototype, "background", void 0);
152
- var c = class extends s {
153
- items;
154
- itemsPanel;
155
- };
156
- t([i(a, !0), o("design:type", Array)], c.prototype, "items", void 0);
157
- t([i(y), o("design:type", typeof y > "u" ? Object : y)], c.prototype, "itemsPanel", void 0);
158
- c = t([l("itemsControl")], c);
159
- var K = class {
160
- }, d = class {
161
- name;
162
- namespace;
163
- category;
164
- library;
165
- bundlePath;
166
- type;
167
- };
168
- t([i(String), o("design:type", String)], d.prototype, "name", void 0);
169
- t([i(String), o("design:type", String)], d.prototype, "namespace", void 0);
170
- t([i(String), o("design:type", String)], d.prototype, "category", void 0);
171
- t([i(String), o("design:type", String)], d.prototype, "library", void 0);
172
- t([i(String), o("design:type", String)], d.prototype, "bundlePath", void 0);
173
- t([i(String), o("design:type", String)], d.prototype, "type", void 0);
174
- var U = class {
175
- }, u = class {
176
- name;
177
- components;
178
- };
179
- t([i(String), o("design:type", String)], u.prototype, "name", void 0);
180
- t([i(d, !0), o("design:type", Array)], u.prototype, "components", void 0);
181
- var v = class {
182
- name;
183
- bundlePath;
184
- categories;
185
- };
186
- t([i(String), o("design:type", String)], v.prototype, "name", void 0);
187
- t([i(String), o("design:type", String)], v.prototype, "bundlePath", void 0);
188
- t([i(u, !0), o("design:type", Array)], v.prototype, "categories", void 0);
189
- var r = {
190
- Layout: "Layout",
191
- Containers: "Containers",
192
- Form: "Form",
193
- Button: "Button",
194
- Buttons: "Buttons",
195
- Data: "Data",
196
- Panel: "Panel",
197
- Panels: "Panels",
198
- Overlay: "Overlay",
199
- File: "File",
200
- Menu: "Menu",
201
- Menus: "Menus",
202
- Chart: "Chart",
203
- Charts: "Charts",
204
- Messages: "Messages",
205
- Media: "Media",
206
- Misc: "Misc"
207
- }, P = {
208
- [r.Layout]: "pi pi-objects-column",
209
- [r.Containers]: "pi pi-box",
210
- [r.Form]: "pi pi-pencil",
211
- [r.Button]: "pi pi-stop",
212
- [r.Buttons]: "pi pi-stop",
213
- [r.Data]: "pi pi-list",
214
- [r.Panel]: "pi pi-table",
215
- [r.Panels]: "pi pi-table",
216
- [r.Overlay]: "pi pi-clone",
217
- [r.File]: "pi pi-file",
218
- [r.Menu]: "pi pi-bars",
219
- [r.Menus]: "pi pi-bars",
220
- [r.Chart]: "pi pi-chart-bar",
221
- [r.Charts]: "pi pi-chart-bar",
222
- [r.Messages]: "pi pi-envelope",
223
- [r.Media]: "pi pi-image",
224
- [r.Misc]: "pi pi-ellipsis-h"
225
- }, x = "pi pi-folder-open";
226
- function Y(e) {
227
- return P[e] ?? x;
228
- }
1
+ import { A as t, C as e, D as r, E as a, M as n, O as s, S as p, T as y, _ as m, a as C, b as l, c as i, d as c, f as P, g as b, h as g, i as E, j as d, k as I, l as h, m as u, n as D, o as A, p as L, r as v, s as w, t as x, u as f, v as j, w as k, x as O, y as S } from "./Scene-DaQtzf1e.js";
229
2
  export {
230
- D as AnchorEdges,
231
- S as CategoryAttribute,
232
- N as Component,
233
- C as ComponentLibraryAttribute,
234
- m as ContentControl,
235
- s as Control,
236
- g as ExternalComponent,
237
- p as FrameworkElement,
238
- A as IPrototypeComponentDiscovery,
239
- K as IUIElement,
240
- c as ItemsControl,
241
- y as Panel,
242
- u as PrototypeComponentCategoryDescriptor,
243
- d as PrototypeComponentDescriptor,
244
- U as PrototypeComponentDiscovery,
245
- v as PrototypeComponentLibraryDescriptor,
246
- F as PrototypeLayout,
247
- E as SceneObject,
3
+ I as AnchorEdges,
4
+ n as CategoryAttribute,
5
+ O as Component,
6
+ d as ComponentLibraryAttribute,
7
+ e as ContentControl,
8
+ k as Control,
9
+ p as ExternalComponent,
10
+ y as FrameworkElement,
11
+ l as IPrototypeComponentDiscovery,
12
+ m as IUIElement,
13
+ j as ItemsControl,
14
+ S as Panel,
15
+ L as PrototypeComponentCategoryDescriptor,
16
+ u as PrototypeComponentDescriptor,
17
+ g as PrototypeComponentDiscovery,
18
+ b as PrototypeComponentLibraryDescriptor,
19
+ P as PrototypeLayout,
20
+ s as SceneObject,
248
21
  a as UIElement,
249
- j as Visibility,
250
- r as WellKnownCategories,
251
- L as allAnchorEdges,
252
- W as createPrototypeComponentInstance,
253
- k as ensurePrototypeComponentBundle,
254
- Y as getCategoryIcon,
255
- _ as getPrototypeComponent,
256
- B as hydrateElement,
257
- O as hydrateElements,
258
- z as hydratePrototypeElement,
259
- w as loadPrototypeComponentLibraries,
260
- I as registerPrototypeComponentLibrary
22
+ r as Visibility,
23
+ x as WellKnownCategories,
24
+ t as allAnchorEdges,
25
+ v as createPrototypeComponentInstance,
26
+ E as ensurePrototypeComponentBundle,
27
+ D as getCategoryIcon,
28
+ C as getPrototypeComponent,
29
+ A as hydrateElement,
30
+ w as hydrateElements,
31
+ i as hydratePrototypeElement,
32
+ h as loadPrototypeComponentLibraries,
33
+ c as prototypeHostGlobals,
34
+ f as registerPrototypeComponentLibrary
261
35
  };
@@ -0,0 +1,7 @@
1
+ export declare const prototypeHostGlobals: {
2
+ readonly '@cratis/fundamentals': '__cratisPrototypeHostFundamentals';
3
+ readonly '@cratis/scene': '__cratisPrototypeHostScene';
4
+ readonly react: '__cratisPrototypeHostReact';
5
+ readonly 'react/jsx-runtime': '__cratisPrototypeHostReactJsxRuntime';
6
+ };
7
+ export type PrototypeHostModule = keyof typeof prototypeHostGlobals;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene",
3
- "version": "0.106.0",
3
+ "version": "0.108.0",
4
4
  "description": "Cratis Scene: renders Studio prototypes as thumbnails and previews.",
5
5
  "license": "MIT",
6
6
  "author": "Cratis",
@@ -1,148 +0,0 @@
1
- import { DerivedType as v, Guid as y, field as d } from "@cratis/fundamentals";
2
- function a(e, o) {
3
- if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, o);
4
- }
5
- function p(e, o, t, n) {
6
- var r = arguments.length, i = r < 3 ? o : n === null ? n = Object.getOwnPropertyDescriptor(o, t) : n, c;
7
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(e, o, t, n);
8
- else for (var s = e.length - 1; s >= 0; s--) (c = e[s]) && (i = (r < 3 ? c(i) : r > 3 ? c(o, t, i) : c(o, t)) || i);
9
- return r > 3 && i && Object.defineProperty(o, t, i), i;
10
- }
11
- var O = /* @__PURE__ */ (function(e) {
12
- return e[e.none = 0] = "none", e[e.top = 1] = "top", e[e.right = 2] = "right", e[e.bottom = 4] = "bottom", e[e.left = 8] = "left", e;
13
- })({}), T = 15, b = class {
14
- id;
15
- properties;
16
- };
17
- p([d(y), a("design:type", typeof y > "u" ? Object : y)], b.prototype, "id", void 0);
18
- p([d(Object), a("design:type", typeof Record > "u" ? Object : Record)], b.prototype, "properties", void 0);
19
- var j = /* @__PURE__ */ (function(e) {
20
- return e[e.visible = 0] = "visible", e[e.hidden = 1] = "hidden", e[e.collapsed = 2] = "collapsed", e;
21
- })({}), u = class extends b {
22
- visibility;
23
- isEnabled;
24
- opacity;
25
- width;
26
- height;
27
- ZIndex;
28
- anchoring;
29
- };
30
- p([d(Number), a("design:type", typeof j > "u" ? Object : j)], u.prototype, "visibility", void 0);
31
- p([d(Boolean), a("design:type", Boolean)], u.prototype, "isEnabled", void 0);
32
- p([d(Number), a("design:type", Number)], u.prototype, "opacity", void 0);
33
- p([d(Number), a("design:type", Number)], u.prototype, "width", void 0);
34
- p([d(Number), a("design:type", Number)], u.prototype, "height", void 0);
35
- p([d(Number), a("design:type", Number)], u.prototype, "ZIndex", void 0);
36
- p([d(Number), a("design:type", typeof O > "u" ? Object : O)], u.prototype, "anchoring", void 0);
37
- var S = /* @__PURE__ */ (function(e) {
38
- return e[e.absolute = 0] = "absolute", e[e.flexRow = 1] = "flexRow", e[e.flexColumn = 2] = "flexColumn", e[e.grid = 3] = "grid", e;
39
- })({}), m = () => (window.__cratisPrototypeComponents ??= {}, window.__cratisPrototypeComponents), N = () => (window.__cratisPrototypeBundleLoads ??= {}, window.__cratisPrototypeBundleLoads), _ = (e) => {
40
- const o = [e], t = e.split(".").pop();
41
- return t && t !== e && o.push(t), o;
42
- }, l = (e, o) => {
43
- if (typeof window > "u") return;
44
- const t = m()[e];
45
- if (t)
46
- for (const n of _(o)) {
47
- const r = t[n];
48
- if (r) return r;
49
- }
50
- }, E = (e, o) => {
51
- m()[e] = o;
52
- for (const [t, n] of Object.entries(o)) {
53
- if (!t.includes(".")) continue;
54
- v.set(n, t);
55
- let r = Object.getPrototypeOf(n.prototype);
56
- for (; r && r.constructor && r.constructor !== Object; )
57
- v.set(n, t, r.constructor), r = Object.getPrototypeOf(r);
58
- }
59
- }, x = (e) => {
60
- if ("RenderPrototype" in e && typeof e.RenderPrototype == "function") return e;
61
- const o = "_derivedTypeId" in e && typeof e._derivedTypeId == "string" && e._derivedTypeId.includes(".") ? e._derivedTypeId : "componentName" in e && typeof e.componentName == "string" ? e.componentName : "", t = o.indexOf(".");
62
- if (t < 1) return e;
63
- const n = l(o.slice(0, t), o.slice(t + 1));
64
- if (!n) return e;
65
- const r = Object.fromEntries(Object.entries(e).filter(([i]) => ![
66
- "type",
67
- "label",
68
- "position",
69
- "size",
70
- "children"
71
- ].includes(i)));
72
- if ("slots" in e && e.slots && typeof e.slots == "object") {
73
- let i;
74
- for (const [c, s] of Object.entries(e.slots)) {
75
- if (!Array.isArray(s)) continue;
76
- let f;
77
- for (const [C, w] of s.entries()) {
78
- const g = x(w);
79
- g !== w && (f ??= s.slice(), f[C] = g);
80
- }
81
- f && (i ??= { ...e.slots }, i[c] = f);
82
- }
83
- i && (r.slots = i);
84
- }
85
- return Object.assign(new n(), r);
86
- }, P = (e, o) => {
87
- const t = l(e, o);
88
- return t ? new t() : void 0;
89
- }, z = (e, o, t) => {
90
- const n = l(e, o);
91
- if (!n) return;
92
- const r = new n();
93
- return typeof r.initialize == "function" ? r.initialize(t) : (Object.assign(r, t), r);
94
- }, R = async (e) => {
95
- const o = N();
96
- if (o[e]) {
97
- await o[e];
98
- return;
99
- }
100
- o[e] = new Promise((t, n) => {
101
- const r = document.querySelector(`script[data-prototype-bundle="${e}"]`);
102
- if (r) {
103
- r.addEventListener("load", () => t(), { once: !0 }), r.addEventListener("error", () => n(/* @__PURE__ */ new Error(`Failed to load prototype bundle '${e}'.`)), { once: !0 });
104
- return;
105
- }
106
- const i = document.createElement("script");
107
- i.src = e, i.async = !0, i.dataset.prototypeBundle = e, i.onload = () => t(), i.onerror = () => n(/* @__PURE__ */ new Error(`Failed to load prototype bundle '${e}'.`)), document.head.appendChild(i);
108
- }), await o[e];
109
- }, D = async (e) => {
110
- const o = [...new Set(e.filter(Boolean))];
111
- await Promise.all(o.map(R)), B();
112
- }, B = () => {
113
- const e = m();
114
- for (const o of Object.values(e)) for (const [t, n] of Object.entries(o))
115
- t.includes(".") && v.set(n, t, u);
116
- }, h = (e) => {
117
- const o = e, t = o.componentName;
118
- if (!t) return e;
119
- const n = t.indexOf(".");
120
- if (n < 0) return e;
121
- const r = t.substring(0, n), i = t.substring(n + 1), c = l(r, i);
122
- if (!c) return e;
123
- const s = new c();
124
- Object.assign(s, e);
125
- const f = o.slots;
126
- return f?.children?.length && (s.slots = {
127
- ...f,
128
- children: f.children.map(h)
129
- }), s;
130
- }, F = (e) => e.map(h);
131
- export {
132
- F as a,
133
- E as c,
134
- j as d,
135
- b as f,
136
- a as g,
137
- p as h,
138
- h as i,
139
- S as l,
140
- T as m,
141
- R as n,
142
- x as o,
143
- O as p,
144
- P as r,
145
- D as s,
146
- z as t,
147
- u
148
- };