@playabl/sdk 1.0.0 → 1.1.0-beta.1

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/dist/layout.js ADDED
@@ -0,0 +1,648 @@
1
+ // ../sdk-runtime/src/types/index.ts
2
+ var CONTENT_VERB_TYPES = [
3
+ "content-add",
4
+ "content-duplicate",
5
+ "content-delete",
6
+ "content-move",
7
+ "place",
8
+ "content-move-instance",
9
+ "content-remove-instance",
10
+ "content-set-field",
11
+ "content-set-payload",
12
+ "content-undo",
13
+ "content-redo",
14
+ "content-group-add",
15
+ "content-group-rename",
16
+ "content-group-delete"
17
+ ];
18
+ var CREATOR_COMMAND_TYPES = [
19
+ "hello",
20
+ "set-mode",
21
+ "step",
22
+ "set-time-scale",
23
+ "restart",
24
+ "goto-level",
25
+ "goto-screen",
26
+ "set-run-state",
27
+ "select",
28
+ "request-scene",
29
+ ...CONTENT_VERB_TYPES
30
+ ];
31
+ var DEVTOOLS_MESSAGE_TYPES = [
32
+ "devtools-ready",
33
+ "catalog",
34
+ "state",
35
+ "scene",
36
+ "instance",
37
+ "layout-wiring",
38
+ "devtools-error",
39
+ "content",
40
+ "content-refused",
41
+ "command-ack",
42
+ "command-refused"
43
+ ];
44
+ var OUTBOUND_TYPES = [
45
+ "ready",
46
+ "score",
47
+ "tweaks-initialize",
48
+ "tweaks-rejected",
49
+ "assets-register",
50
+ "assets-update-applied",
51
+ "state-save",
52
+ "state-load",
53
+ "state-clear",
54
+ ...DEVTOOLS_MESSAGE_TYPES
55
+ ];
56
+ var INBOUND_TYPES = [
57
+ "ready-ack",
58
+ "score-ack",
59
+ "error",
60
+ "tweaks-initialize-ack",
61
+ "tweaks-update",
62
+ "assets-register-ack",
63
+ "assets-update",
64
+ "assets-reset",
65
+ "assets-reset-all",
66
+ // Optional ack for `assets-update-applied`. The runtime sends the applied
67
+ // notification fire-and-forget — the swap already happened live, with no
68
+ // reload — so the host is not required to respond; this type exists only
69
+ // to satisfy the `requestResponse` contract.
70
+ "assets-update-applied-ack",
71
+ "state-save-ack",
72
+ "state-load-ack",
73
+ "state-clear-ack",
74
+ // Game-defined command ids are dispatched by string and are deliberately
75
+ // not enumerated here.
76
+ ...CREATOR_COMMAND_TYPES
77
+ ];
78
+ var PROTOCOL_MESSAGE_TYPES = /* @__PURE__ */ new Set([
79
+ ...OUTBOUND_TYPES,
80
+ ...INBOUND_TYPES
81
+ ]);
82
+
83
+ // ../sdk-runtime/src/assets/types.ts
84
+ function humanise(id) {
85
+ const words = id.replace(/[:_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().split(/\s+/).filter(Boolean);
86
+ if (words.length === 0) return id;
87
+ return words.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(" ");
88
+ }
89
+
90
+ // ../sdk-runtime/src/utils/plain.ts
91
+ var isPlainObject = (v) => {
92
+ if (typeof v !== "object" || v === null) return false;
93
+ const proto = Object.getPrototypeOf(v);
94
+ return proto === Object.prototype || proto === null;
95
+ };
96
+ function describeValue(value) {
97
+ if (value === null) return "null";
98
+ if (value === void 0) return "undefined";
99
+ if (typeof value === "string") return JSON.stringify(value.slice(0, 40));
100
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint")
101
+ return String(value);
102
+ if (Array.isArray(value)) return `an array of ${value.length}`;
103
+ return `a ${typeof value}`;
104
+ }
105
+
106
+ // ../sdk-runtime/src/tweaks/manager.ts
107
+ var HEX_COLOR = /^#[0-9a-fA-F]{6}$/;
108
+ var isFiniteNumber = (v) => typeof v === "number" && Number.isFinite(v);
109
+ function wrapAngle(value) {
110
+ if (!isFiniteNumber(value) || value > -180 && value <= 180) return value;
111
+ const wrapped = ((value + 180) % 360 + 360) % 360 - 180;
112
+ return wrapped === -180 ? 180 : wrapped;
113
+ }
114
+ function isValid(item, v) {
115
+ switch (item.type) {
116
+ case "number":
117
+ return typeof v === "number" && Number.isFinite(v) && (item.min === void 0 || v >= item.min) && (item.max === void 0 || v <= item.max);
118
+ case "boolean":
119
+ return typeof v === "boolean";
120
+ case "text":
121
+ return typeof v === "string";
122
+ case "enum":
123
+ return typeof v === "string" && item.options.includes(v);
124
+ case "color":
125
+ return typeof v === "string" && HEX_COLOR.test(v);
126
+ }
127
+ }
128
+ function describeInvalid(item, v) {
129
+ switch (item.type) {
130
+ case "number": {
131
+ if (typeof v !== "number" || !Number.isFinite(v)) return "expected a finite number";
132
+ if (item.min !== void 0 && item.max !== void 0) {
133
+ return `expected a number between ${item.min} and ${item.max}`;
134
+ }
135
+ if (item.min !== void 0) return `expected a number >= ${item.min}`;
136
+ return `expected a number <= ${item.max}`;
137
+ }
138
+ case "boolean":
139
+ return "expected a boolean";
140
+ case "text":
141
+ return "expected a string";
142
+ case "enum":
143
+ return `expected one of: ${item.options.join(", ")}`;
144
+ case "color":
145
+ return "expected a #RRGGBB colour";
146
+ }
147
+ }
148
+
149
+ // ../sdk-runtime/src/tweaks/layout.ts
150
+ var LAYOUT_ROLES = Object.freeze([
151
+ "anchor",
152
+ "x",
153
+ "y",
154
+ "w",
155
+ "h",
156
+ "rotation",
157
+ "scale",
158
+ "opacity",
159
+ "z",
160
+ "fontSize",
161
+ "fontWeight",
162
+ "align",
163
+ "font",
164
+ "padding",
165
+ "radius",
166
+ "text",
167
+ "color",
168
+ "background",
169
+ "visible"
170
+ ]);
171
+ var LAYOUT_ANCHORS = Object.freeze([
172
+ "top-left",
173
+ "top-center",
174
+ "top-right",
175
+ "center-left",
176
+ "center",
177
+ "center-right",
178
+ "bottom-left",
179
+ "bottom-center",
180
+ "bottom-right"
181
+ ]);
182
+ var LAYOUT_WEIGHTS = Object.freeze(["400", "600", "800"]);
183
+ var LAYOUT_ALIGNS = Object.freeze(["left", "center", "right"]);
184
+ var DEFAULT_FRAME = Object.freeze({ w: 390, h: 844 });
185
+ var ENTRY_FIELDS = Object.freeze([
186
+ "label",
187
+ "prefix",
188
+ "fonts",
189
+ "canvas"
190
+ ]);
191
+ var DEF_ID_RE = /^def:[a-z0-9]+(-[a-z0-9]+)*$/;
192
+ var PREFIX_RE = /^[a-z][A-Za-z0-9]*$/;
193
+ var FONT_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9 ._-]*$/;
194
+ var MAX_LABEL = 40;
195
+ var WHERE = "[Playabl] layout.json";
196
+ var defaultWarn = (message) => {
197
+ console.warn(message);
198
+ };
199
+ function layoutKey(prefix, role) {
200
+ return prefix + role.charAt(0).toUpperCase() + role.slice(1);
201
+ }
202
+ function defaultPrefix(id) {
203
+ const [first = "", ...rest] = id.slice("def:".length).split("-");
204
+ return first + rest.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
205
+ }
206
+ var PX = { control: "stepper", unit: " px" };
207
+ var ROLE_SPECS = {
208
+ anchor: {
209
+ type: "text",
210
+ suffix: "Anchor",
211
+ options: LAYOUT_ANCHORS,
212
+ ui: { control: "anchor", options: [...LAYOUT_ANCHORS] },
213
+ describe: (l) => `Which corner, edge, or the centre of the frame ${l} is pinned to.`
214
+ },
215
+ x: {
216
+ type: "number",
217
+ suffix: "Offset X",
218
+ range: (f) => ({ min: -f.w, max: f.w }),
219
+ step: 1,
220
+ grows: "both",
221
+ ui: PX,
222
+ describe: (l) => `How far ${l} sits sideways from the edge or centre line its anchor pins, in pixels.`
223
+ },
224
+ y: {
225
+ type: "number",
226
+ suffix: "Offset Y",
227
+ range: (f) => ({ min: -f.h, max: f.h }),
228
+ step: 1,
229
+ grows: "both",
230
+ ui: PX,
231
+ describe: (l) => `How far ${l} sits up or down from the edge or centre line its anchor pins, in pixels.`
232
+ },
233
+ w: {
234
+ type: "number",
235
+ suffix: "Width",
236
+ range: (f) => ({ min: 1, max: f.w }),
237
+ step: 1,
238
+ grows: "max",
239
+ ui: PX,
240
+ describe: (l) => `How wide ${l} draws, in pixels.`
241
+ },
242
+ h: {
243
+ type: "number",
244
+ suffix: "Height",
245
+ range: (f) => ({ min: 1, max: f.h }),
246
+ step: 1,
247
+ grows: "max",
248
+ ui: PX,
249
+ describe: (l) => `How tall ${l} draws, in pixels.`
250
+ },
251
+ rotation: {
252
+ type: "number",
253
+ suffix: "Rotation",
254
+ range: () => ({ min: -180, max: 180 }),
255
+ step: 1,
256
+ angle: true,
257
+ ui: { control: "angle", unit: "\xB0" },
258
+ describe: (l) => `How far ${l} turns around its centre, in degrees: positive is clockwise.`
259
+ },
260
+ scale: {
261
+ type: "number",
262
+ suffix: "Scale",
263
+ range: () => ({ min: 0.5, max: 3 }),
264
+ step: 0.05,
265
+ ui: {
266
+ control: "scrubber",
267
+ unit: "\xD7",
268
+ presets: [
269
+ { label: "Small", value: 0.75 },
270
+ { label: "Normal", value: 1 },
271
+ { label: "Large", value: 1.5 }
272
+ ]
273
+ },
274
+ describe: (l) => `How much larger or smaller ${l} draws, around its centre.`
275
+ },
276
+ opacity: {
277
+ type: "number",
278
+ suffix: "Opacity",
279
+ range: () => ({ min: 0, max: 1 }),
280
+ step: 0.05,
281
+ ui: {
282
+ control: "scrubber",
283
+ unit: "%",
284
+ presets: [
285
+ { label: "Faint", value: 0.25 },
286
+ { label: "Half", value: 0.5 },
287
+ { label: "Solid", value: 1 }
288
+ ]
289
+ },
290
+ describe: (l) => `How solid ${l} draws, from clear to fully opaque.`
291
+ },
292
+ z: {
293
+ type: "number",
294
+ suffix: "Layer",
295
+ range: () => ({ min: 0, max: 20 }),
296
+ step: 1,
297
+ ui: { control: "stepper" },
298
+ describe: (l) => `Which elements ${l} draws in front of when they overlap; higher is nearer.`
299
+ },
300
+ fontSize: {
301
+ type: "number",
302
+ suffix: "Text size",
303
+ range: () => ({ min: 8, max: 96 }),
304
+ step: 1,
305
+ ui: {
306
+ control: "stepper",
307
+ unit: " px",
308
+ presets: [
309
+ { label: "Small", value: 12 },
310
+ { label: "Normal", value: 18 },
311
+ { label: "Large", value: 32 }
312
+ ]
313
+ },
314
+ describe: (l) => `How big the text in ${l} is, in pixels.`
315
+ },
316
+ fontWeight: {
317
+ type: "text",
318
+ suffix: "Weight",
319
+ options: LAYOUT_WEIGHTS,
320
+ ui: { control: "segmented", options: [...LAYOUT_WEIGHTS] },
321
+ describe: (l) => `How bold the text in ${l} is.`
322
+ },
323
+ align: {
324
+ type: "text",
325
+ suffix: "Alignment",
326
+ options: LAYOUT_ALIGNS,
327
+ ui: { control: "align", options: [...LAYOUT_ALIGNS] },
328
+ describe: (l) => `Where the text sits inside ${l}'s box: left, centre, or right.`
329
+ },
330
+ font: {
331
+ type: "text",
332
+ suffix: "Font",
333
+ ui: { control: "font" },
334
+ describe: (l) => `The typeface of the text in ${l}.`
335
+ },
336
+ padding: {
337
+ type: "number",
338
+ suffix: "Padding",
339
+ range: () => ({ min: 0, max: 40 }),
340
+ step: 1,
341
+ ui: PX,
342
+ describe: (l) => `The space between the edge of ${l} and its content, in pixels.`
343
+ },
344
+ radius: {
345
+ type: "number",
346
+ suffix: "Corner radius",
347
+ range: () => ({ min: 0, max: 40 }),
348
+ step: 1,
349
+ ui: PX,
350
+ describe: (l) => `How rounded the corners of ${l} are, in pixels.`
351
+ },
352
+ text: {
353
+ type: "text",
354
+ suffix: "Text",
355
+ ui: { control: "text" },
356
+ describe: (l) => `The words ${l} shows; double-click it on the board to edit them.`
357
+ },
358
+ color: {
359
+ type: "color",
360
+ suffix: "Colour",
361
+ ui: { control: "swatches" },
362
+ describe: (l) => `The colour of the text in ${l}.`
363
+ },
364
+ background: {
365
+ type: "color",
366
+ suffix: "Background",
367
+ ui: { control: "swatches" },
368
+ describe: (l) => `The colour that fills ${l}'s box behind its content.`
369
+ },
370
+ visible: {
371
+ type: "boolean",
372
+ suffix: "Visible",
373
+ ui: { control: "toggle" },
374
+ describe: (l) => `Whether ${l} shows at all.`
375
+ }
376
+ };
377
+ function synthesiseLayout(layout, schema, creatorValues, frame, warn = defaultWarn) {
378
+ const items = /* @__PURE__ */ Object.create(null);
379
+ const entries = /* @__PURE__ */ new Map();
380
+ const synthesised = /* @__PURE__ */ new Set();
381
+ const softBounds = /* @__PURE__ */ new Map();
382
+ const angles = /* @__PURE__ */ new Set();
383
+ const allowed = /* @__PURE__ */ new Map();
384
+ const declined = /* @__PURE__ */ new Set();
385
+ const canvas = /* @__PURE__ */ new Set();
386
+ const skipped = /* @__PURE__ */ new Set();
387
+ const result = {
388
+ items,
389
+ entries,
390
+ synthesised,
391
+ softBounds,
392
+ angles,
393
+ allowed,
394
+ declined,
395
+ canvas,
396
+ skipped,
397
+ declared: false
398
+ };
399
+ if (layout === void 0) return result;
400
+ if (!isPlainObject(layout)) {
401
+ warn(`${WHERE} is ignored: expected an object keyed by def: catalog ids`);
402
+ for (const key of Object.keys(creatorValues)) {
403
+ if (!Object.hasOwn(schema, key)) declined.add(key);
404
+ }
405
+ return result;
406
+ }
407
+ result.declared = true;
408
+ const owners = /* @__PURE__ */ new Map();
409
+ for (const [id, raw] of Object.entries(layout)) {
410
+ if (!DEF_ID_RE.test(id)) {
411
+ warn(`${WHERE} "${id}" is ignored: keys are def: catalog ids, such as def:hud-score`);
412
+ const own = isPlainObject(raw) ? raw.prefix : void 0;
413
+ decline(declined, typeof own === "string" && PREFIX_RE.test(own) ? own : prefixFromKey(id));
414
+ continue;
415
+ }
416
+ if (!isPlainObject(raw)) {
417
+ warn(`${WHERE} "${id}" is ignored: expected an object of roles`);
418
+ const derived = defaultPrefix(id);
419
+ if (PREFIX_RE.test(derived)) decline(declined, derived);
420
+ continue;
421
+ }
422
+ const prefix = readPrefix(id, raw, warn);
423
+ if (prefix === null) {
424
+ if (Object.hasOwn(raw, "prefix")) {
425
+ decline(declined, defaultPrefix(id));
426
+ if (typeof raw.prefix === "string") decline(declined, camelCasePrefix(raw.prefix));
427
+ }
428
+ continue;
429
+ }
430
+ for (const field of Object.keys(raw)) {
431
+ if (!ENTRY_FIELDS.includes(field) && !LAYOUT_ROLES.includes(field)) {
432
+ warn(`${WHERE} "${id}".${field} is ignored: not a layout role`);
433
+ }
434
+ }
435
+ const label = readLabel(id, raw, warn);
436
+ const fonts = readFonts(id, raw, warn);
437
+ if (readCanvas(id, raw, warn)) canvas.add(id);
438
+ const map = {};
439
+ let index = highestIndex(schema, id);
440
+ for (const role of LAYOUT_ROLES) {
441
+ if (!Object.hasOwn(raw, role)) continue;
442
+ const spec = ROLE_SPECS[role];
443
+ const key = layoutKey(prefix, role);
444
+ const at = `${WHERE} "${id}".${role}`;
445
+ const declared = raw[role];
446
+ const why = checkValue(spec, role, declared, fonts, frame);
447
+ if (why !== null) {
448
+ warn(`${at} is ignored: ${why}`);
449
+ declined.add(key);
450
+ continue;
451
+ }
452
+ const owner = owners.get(key);
453
+ if (owner !== void 0) {
454
+ warn(`${at} is ignored: "${key}" already belongs to "${owner}"`);
455
+ continue;
456
+ }
457
+ if (Object.hasOwn(schema, key)) {
458
+ const existing = schema[key];
459
+ if (existing.type === spec.type) {
460
+ owners.set(key, id);
461
+ map[role] = key;
462
+ warn(`${at} uses tweaks.json's own "${key}"; its range and default stay the game's`);
463
+ } else if (isTypedSet(existing, spec)) {
464
+ owners.set(key, id);
465
+ map[role] = key;
466
+ } else {
467
+ warn(
468
+ `${at} is ignored: tweaks.json already has "${key}" as ${article(existing.type)} ${existing.type} tweak`
469
+ );
470
+ }
471
+ continue;
472
+ }
473
+ owners.set(key, id);
474
+ index += 1;
475
+ items[key] = buildItem(spec, role, declared, {
476
+ id,
477
+ label,
478
+ fonts,
479
+ index,
480
+ frame,
481
+ saved: creatorValues[key]
482
+ });
483
+ synthesised.add(key);
484
+ if (spec.grows) softBounds.set(key, spec.grows);
485
+ if (spec.angle) angles.add(key);
486
+ if (spec.options) allowed.set(key, spec.options);
487
+ else if (role === "font") allowed.set(key, fonts ?? [declared]);
488
+ map[role] = key;
489
+ }
490
+ entries.set(id, map);
491
+ }
492
+ for (const id of Object.keys(layout)) {
493
+ if (!entries.has(id)) skipped.add(id);
494
+ }
495
+ return result;
496
+ }
497
+ function readCanvas(id, raw, warn) {
498
+ if (!Object.hasOwn(raw, "canvas")) return false;
499
+ if (typeof raw.canvas === "boolean") return raw.canvas;
500
+ warn(`${WHERE} "${id}".canvas is ignored: expected true or false`);
501
+ return false;
502
+ }
503
+ function readLabel(id, raw, warn) {
504
+ const fallback = humanise(id.slice("def:".length));
505
+ if (!Object.hasOwn(raw, "label")) {
506
+ warn(`${WHERE} "${id}".label is missing; using "${fallback}"`);
507
+ return fallback;
508
+ }
509
+ const label = raw.label;
510
+ const length = typeof label === "string" ? [...label].length : 0;
511
+ if (typeof label === "string" && length >= 1 && length <= MAX_LABEL) return label;
512
+ warn(
513
+ `${WHERE} "${id}".label is ignored: expected 1 to ${MAX_LABEL} characters; using "${fallback}"`
514
+ );
515
+ return fallback;
516
+ }
517
+ function readPrefix(id, raw, warn) {
518
+ if (Object.hasOwn(raw, "prefix")) {
519
+ const prefix = raw.prefix;
520
+ if (typeof prefix === "string" && PREFIX_RE.test(prefix)) return prefix;
521
+ warn(
522
+ `${WHERE} "${id}" is ignored: its prefix ${describeValue(prefix)} is not camelCase, such as hudScore`
523
+ );
524
+ return null;
525
+ }
526
+ const derived = defaultPrefix(id);
527
+ if (PREFIX_RE.test(derived)) return derived;
528
+ warn(
529
+ `${WHERE} "${id}" is ignored: its key prefix "${derived}" is not camelCase; set prefix, such as player2`
530
+ );
531
+ return null;
532
+ }
533
+ function decline(declined, prefix) {
534
+ if (prefix === "") return;
535
+ for (const role of LAYOUT_ROLES) declined.add(layoutKey(prefix, role));
536
+ }
537
+ function camelCasePrefix(prefix) {
538
+ const letters = prefix.replace(/[^A-Za-z0-9]/g, "");
539
+ return letters.charAt(0).toLowerCase() + letters.slice(1);
540
+ }
541
+ function prefixFromKey(key) {
542
+ const words = key.replace(/^[^:]*:/, "").split(/[^A-Za-z0-9]+/).filter((word) => word !== "");
543
+ return words.map(
544
+ (word, i) => (i === 0 ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1)
545
+ ).join("");
546
+ }
547
+ function article(word) {
548
+ return /^[aeiou]/.test(word) ? "an" : "a";
549
+ }
550
+ function isTypedSet(existing, spec) {
551
+ const set = spec.options;
552
+ return set !== void 0 && existing.type === "enum" && Array.isArray(existing.options) && existing.options.every((option) => set.includes(option));
553
+ }
554
+ function readFonts(id, raw, warn) {
555
+ if (!Object.hasOwn(raw, "fonts")) return void 0;
556
+ const fonts = raw.fonts;
557
+ if (Array.isArray(fonts) && fonts.length > 0 && fonts.every((f) => typeof f === "string" && FONT_NAME_RE.test(f)) && new Set(fonts).size === fonts.length) {
558
+ return [...fonts];
559
+ }
560
+ warn(`${WHERE} "${id}".fonts is ignored: expected a list of distinct font names`);
561
+ return void 0;
562
+ }
563
+ function highestIndex(schema, id) {
564
+ let top = 0;
565
+ for (const item of Object.values(schema)) {
566
+ if (item.group === id && Number.isInteger(item.index) && item.index > top) {
567
+ top = item.index;
568
+ }
569
+ }
570
+ return top;
571
+ }
572
+ function checkValue(spec, role, value, fonts, frame) {
573
+ const probe = probeItem(spec, frame);
574
+ if (!isValid(probe, value)) return describeInvalid(probe, value);
575
+ if (role === "font") {
576
+ const name = value;
577
+ if (!FONT_NAME_RE.test(name)) return "expected a font name";
578
+ if (fonts && !fonts.includes(name)) return `expected one of fonts: ${fonts.join(", ")}`;
579
+ }
580
+ return null;
581
+ }
582
+ function roleLimits(role) {
583
+ const probe = probeItem(ROLE_SPECS[role], DEFAULT_FRAME);
584
+ if (probe.type !== "number") return void 0;
585
+ const limits = {};
586
+ if (probe.min !== void 0) limits.min = probe.min;
587
+ if (probe.max !== void 0) limits.max = probe.max;
588
+ return limits;
589
+ }
590
+ function probeItem(spec, frame) {
591
+ switch (spec.type) {
592
+ case "number": {
593
+ const { min, max } = spec.range(frame);
594
+ if (spec.grows === "both") return { type: "number", value: 0 };
595
+ if (spec.grows === "max") return { type: "number", value: min, min };
596
+ return { type: "number", value: min, min, max };
597
+ }
598
+ case "text":
599
+ return spec.options ? { type: "enum", value: spec.options[0], options: [...spec.options] } : { type: "text", value: "" };
600
+ case "color":
601
+ return { type: "color", value: "#000000" };
602
+ case "boolean":
603
+ return { type: "boolean", value: false };
604
+ }
605
+ }
606
+ function buildItem(spec, role, value, at) {
607
+ const ui = structuredClone(spec.ui);
608
+ if (role === "font") ui.options = at.fonts ? [...at.fonts] : [value];
609
+ const item = {
610
+ type: spec.type,
611
+ value: spec.angle ? wrapAngle(value) : value
612
+ };
613
+ if (spec.type === "number") {
614
+ let { min, max } = spec.range(at.frame);
615
+ if (spec.grows) {
616
+ const saved = typeof at.saved === "number" && Number.isFinite(at.saved) ? at.saved : void 0;
617
+ const held = [value];
618
+ if (saved !== void 0 && (spec.grows === "both" || saved >= min)) held.push(saved);
619
+ if (spec.grows === "both") min = Math.min(min, ...held);
620
+ max = Math.max(max, ...held);
621
+ }
622
+ item.min = min;
623
+ item.max = max;
624
+ item.step = spec.step;
625
+ }
626
+ item.name = `${at.label} \xB7 ${spec.suffix}`;
627
+ item.description = spec.describe(at.label);
628
+ item.group = at.id;
629
+ item.index = at.index;
630
+ item.ui = ui;
631
+ return item;
632
+ }
633
+
634
+ // src/layout.ts
635
+ var synthesiseLayout2 = synthesiseLayout;
636
+ export {
637
+ DEFAULT_FRAME,
638
+ ENTRY_FIELDS,
639
+ LAYOUT_ALIGNS,
640
+ LAYOUT_ANCHORS,
641
+ LAYOUT_ROLES,
642
+ LAYOUT_WEIGHTS,
643
+ defaultPrefix,
644
+ layoutKey,
645
+ roleLimits,
646
+ synthesiseLayout2 as synthesiseLayout
647
+ };
648
+ //# sourceMappingURL=layout.js.map
package/package.json CHANGED
@@ -1,19 +1,30 @@
1
1
  {
2
2
  "name": "@playabl/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-beta.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
+ "publishConfig": {
8
+ "tag": "beta"
9
+ },
7
10
  "files": [
8
11
  "dist/index.js",
9
12
  "dist/index.d.ts",
13
+ "dist/layout.js",
14
+ "dist/layout.d.ts",
10
15
  "README.md"
11
16
  ],
12
17
  "exports": {
13
18
  ".": {
14
19
  "types": "./dist/index.d.ts",
15
20
  "import": "./dist/index.js"
16
- }
21
+ },
22
+ "./layout": {
23
+ "types": "./dist/layout.d.ts",
24
+ "import": "./dist/layout.js",
25
+ "default": "./dist/layout.js"
26
+ },
27
+ "./package.json": "./package.json"
17
28
  },
18
29
  "sideEffects": [
19
30
  "./dist/index.js"