@treasuryspatial/render-kit 0.1.4 → 0.1.8

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.
@@ -14,6 +14,7 @@ export type PostcardText = {
14
14
  };
15
15
  type DecorationOptions = {
16
16
  postcard?: PostcardText | null;
17
+ skipBadges?: boolean;
17
18
  };
18
19
  export declare function decoratePostcardImage(imageDataUrl: string, options?: DecorationOptions): Promise<string>;
19
20
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"postcard.d.ts","sourceRoot":"","sources":["../src/postcard.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,eAAe,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,EAKrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAAyB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAChC,CAAC;AA4HF,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAsJjB"}
1
+ {"version":3,"file":"postcard.d.ts","sourceRoot":"","sources":["../src/postcard.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,eAAe,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,EAKrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAAyB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA4HF,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAwJjB"}
package/dist/postcard.js CHANGED
@@ -122,8 +122,8 @@ export async function decoratePostcardImage(imageDataUrl, options = {}) {
122
122
  try {
123
123
  const [baseImage, leftBadge, rightBadge] = await Promise.all([
124
124
  loadImageNoCache(imageDataUrl),
125
- loadBadge(BADGE_LEFT_SRC, BADGE_LEFT_SRC.replace(/\.svg$/i, '.png')),
126
- loadBadge(BADGE_RIGHT_SRC, BADGE_RIGHT_SRC.replace(/\.svg$/i, '.png')),
125
+ options.skipBadges ? Promise.resolve(null) : loadBadge(BADGE_LEFT_SRC, BADGE_LEFT_SRC.replace(/\.svg$/i, '.png')),
126
+ options.skipBadges ? Promise.resolve(null) : loadBadge(BADGE_RIGHT_SRC, BADGE_RIGHT_SRC.replace(/\.svg$/i, '.png')),
127
127
  ]);
128
128
  const canvas = document.createElement('canvas');
129
129
  canvas.width = baseImage.width;
@@ -135,23 +135,25 @@ export async function decoratePostcardImage(imageDataUrl, options = {}) {
135
135
  const pad = Math.round(Math.min(canvas.width, canvas.height) * 0.02);
136
136
  const badgeMaxWidth = canvas.width * BADGE_SCALE;
137
137
  const badgeMaxHeight = canvas.height * BADGE_SCALE;
138
- const leftSize = scaleToFit(leftBadge.width, leftBadge.height, badgeMaxWidth, badgeMaxHeight);
139
- const rightSize = scaleToFit(rightBadge.width, rightBadge.height, badgeMaxWidth, badgeMaxHeight);
140
- const [leftBounds, rightBounds] = await Promise.all([
141
- getOpaqueBounds(leftBadge, BADGE_LEFT_SRC),
142
- getOpaqueBounds(rightBadge, BADGE_RIGHT_SRC),
143
- ]);
144
- const baselineY = canvas.height - pad;
145
- const leftScaleX = leftSize.width / leftBadge.width;
146
- const leftScaleY = leftSize.height / leftBadge.height;
147
- const rightScaleX = rightSize.width / rightBadge.width;
148
- const rightScaleY = rightSize.height / rightBadge.height;
149
- const leftX = pad - leftBounds.minX * leftScaleX;
150
- const leftY = baselineY - leftBounds.maxY * leftScaleY;
151
- const rightX = canvas.width - pad - rightBounds.maxX * rightScaleX;
152
- const rightY = baselineY - rightBounds.maxY * rightScaleY;
153
- ctx.drawImage(leftBadge, leftX, leftY, leftSize.width, leftSize.height);
154
- ctx.drawImage(rightBadge, rightX, rightY, rightSize.width, rightSize.height);
138
+ if (!options.skipBadges && leftBadge && rightBadge) {
139
+ const leftSize = scaleToFit(leftBadge.width, leftBadge.height, badgeMaxWidth, badgeMaxHeight);
140
+ const rightSize = scaleToFit(rightBadge.width, rightBadge.height, badgeMaxWidth, badgeMaxHeight);
141
+ const [leftBounds, rightBounds] = await Promise.all([
142
+ getOpaqueBounds(leftBadge, BADGE_LEFT_SRC),
143
+ getOpaqueBounds(rightBadge, BADGE_RIGHT_SRC),
144
+ ]);
145
+ const baselineY = canvas.height - pad;
146
+ const leftScaleX = leftSize.width / leftBadge.width;
147
+ const leftScaleY = leftSize.height / leftBadge.height;
148
+ const rightScaleX = rightSize.width / rightBadge.width;
149
+ const rightScaleY = rightSize.height / rightBadge.height;
150
+ const leftX = pad - leftBounds.minX * leftScaleX;
151
+ const leftY = baselineY - leftBounds.maxY * leftScaleY;
152
+ const rightX = canvas.width - pad - rightBounds.maxX * rightScaleX;
153
+ const rightY = baselineY - rightBounds.maxY * rightScaleY;
154
+ ctx.drawImage(leftBadge, leftX, leftY, leftSize.width, leftSize.height);
155
+ ctx.drawImage(rightBadge, rightX, rightY, rightSize.width, rightSize.height);
156
+ }
155
157
  if (options.postcard) {
156
158
  const { to, from, greeting, font } = options.postcard;
157
159
  const fontFamily = resolveFontFamily(font);
@@ -1,4 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './builder';
3
3
  export * from './sources';
4
+ export * from './packs';
5
+ export * from './registry';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt-pack/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt-pack/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export * from './types';
2
2
  export * from './builder';
3
3
  export * from './sources';
4
+ export * from './packs';
5
+ export * from './registry';
@@ -0,0 +1,491 @@
1
+ export declare const courtyardBasePack: {
2
+ id: string;
3
+ version: string;
4
+ label: string;
5
+ description: string;
6
+ blockOrder: string[];
7
+ assembly: {
8
+ strategy: string;
9
+ updateBlocks: string[];
10
+ includeUserPrompt: boolean;
11
+ };
12
+ task: {
13
+ variants: {
14
+ imagine: string[];
15
+ design: string[];
16
+ map: string[];
17
+ };
18
+ };
19
+ fields: {
20
+ "form.perimeter": {
21
+ id: string;
22
+ type: string;
23
+ label: string;
24
+ options: {
25
+ value: string;
26
+ label: string;
27
+ promptLines: string[];
28
+ }[];
29
+ };
30
+ "form.geometry": {
31
+ id: string;
32
+ type: string;
33
+ label: string;
34
+ options: ({
35
+ value: string;
36
+ label: string;
37
+ prompt: string;
38
+ promptExtra: string[];
39
+ tags?: undefined;
40
+ } | {
41
+ value: string;
42
+ label: string;
43
+ prompt: string;
44
+ tags: string[];
45
+ promptExtra?: undefined;
46
+ })[];
47
+ };
48
+ "form.diversity": {
49
+ id: string;
50
+ type: string;
51
+ label: string;
52
+ options: {
53
+ value: string;
54
+ label: string;
55
+ prompt: string;
56
+ tags: string[];
57
+ }[];
58
+ };
59
+ "form.height": {
60
+ id: string;
61
+ type: string;
62
+ label: string;
63
+ options: {
64
+ value: string;
65
+ label: string;
66
+ prompt: string;
67
+ }[];
68
+ };
69
+ "form.dimensions": {
70
+ id: string;
71
+ type: string;
72
+ label: string;
73
+ options: {
74
+ value: string;
75
+ label: string;
76
+ prompt: string;
77
+ }[];
78
+ };
79
+ "view.viewpoint": {
80
+ id: string;
81
+ type: string;
82
+ label: string;
83
+ options: {
84
+ value: string;
85
+ label: string;
86
+ prompt: string;
87
+ tags: string[];
88
+ meta: {
89
+ group: string;
90
+ };
91
+ }[];
92
+ };
93
+ "view.variation": {
94
+ id: string;
95
+ type: string;
96
+ label: string;
97
+ options: {
98
+ value: string;
99
+ label: string;
100
+ prompt: string;
101
+ }[];
102
+ };
103
+ "view.composition": {
104
+ id: string;
105
+ type: string;
106
+ label: string;
107
+ options: {
108
+ value: string;
109
+ label: string;
110
+ prompt: string;
111
+ }[];
112
+ };
113
+ "style.roofType": {
114
+ id: string;
115
+ type: string;
116
+ label: string;
117
+ options: {
118
+ value: string;
119
+ label: string;
120
+ prompt: string;
121
+ }[];
122
+ };
123
+ "style.roofscape": {
124
+ id: string;
125
+ type: string;
126
+ label: string;
127
+ options: {
128
+ value: string;
129
+ label: string;
130
+ prompt: string;
131
+ }[];
132
+ };
133
+ "style.roofMaterials": {
134
+ id: string;
135
+ type: string;
136
+ label: string;
137
+ options: {
138
+ value: string;
139
+ label: string;
140
+ prompt: string;
141
+ }[];
142
+ };
143
+ "style.facadePrimary": {
144
+ id: string;
145
+ type: string;
146
+ label: string;
147
+ options: {
148
+ value: string;
149
+ label: string;
150
+ prompt: string;
151
+ }[];
152
+ };
153
+ "style.facadeGround": {
154
+ id: string;
155
+ type: string;
156
+ label: string;
157
+ ui: string;
158
+ promptOn: string;
159
+ };
160
+ "style.facadeUpper": {
161
+ id: string;
162
+ type: string;
163
+ label: string;
164
+ ui: string;
165
+ promptOn: string;
166
+ };
167
+ "style.facadeVariation": {
168
+ id: string;
169
+ type: string;
170
+ label: string;
171
+ ui: string;
172
+ promptOn: string;
173
+ };
174
+ "style.facadeBays": {
175
+ id: string;
176
+ type: string;
177
+ label: string;
178
+ ui: string;
179
+ promptOn: string;
180
+ };
181
+ "program.building": {
182
+ id: string;
183
+ type: string;
184
+ label: string;
185
+ options: {
186
+ value: string;
187
+ label: string;
188
+ prompt: string;
189
+ promptExtra: string[];
190
+ }[];
191
+ };
192
+ "program.courtyard": {
193
+ id: string;
194
+ type: string;
195
+ label: string;
196
+ options: ({
197
+ value: string;
198
+ label: string;
199
+ prompt: string;
200
+ tags?: undefined;
201
+ } | {
202
+ value: string;
203
+ label: string;
204
+ prompt: string;
205
+ tags: string[];
206
+ })[];
207
+ };
208
+ "program.street": {
209
+ id: string;
210
+ type: string;
211
+ label: string;
212
+ options: ({
213
+ value: string;
214
+ label: string;
215
+ prompt: string;
216
+ tags: string[];
217
+ } | {
218
+ value: string;
219
+ label: string;
220
+ prompt: string;
221
+ tags?: undefined;
222
+ })[];
223
+ };
224
+ "toggle.landscaping": {
225
+ id: string;
226
+ type: string;
227
+ label: string;
228
+ ui: string;
229
+ promptOn: string;
230
+ };
231
+ "toggle.people": {
232
+ id: string;
233
+ type: string;
234
+ label: string;
235
+ ui: string;
236
+ promptOn: string;
237
+ };
238
+ "toggle.bicycles": {
239
+ id: string;
240
+ type: string;
241
+ label: string;
242
+ ui: string;
243
+ promptOn: string;
244
+ };
245
+ "toggle.cars": {
246
+ id: string;
247
+ type: string;
248
+ label: string;
249
+ ui: string;
250
+ promptOn: string;
251
+ };
252
+ "toggle.trams": {
253
+ id: string;
254
+ type: string;
255
+ label: string;
256
+ ui: string;
257
+ promptOn: string;
258
+ };
259
+ "toggle.tech": {
260
+ id: string;
261
+ type: string;
262
+ label: string;
263
+ ui: string;
264
+ promptOn: string;
265
+ };
266
+ "context.location": {
267
+ id: string;
268
+ type: string;
269
+ label: string;
270
+ optionSource: string;
271
+ promptTemplate: string;
272
+ ensureSentence: boolean;
273
+ };
274
+ "context.timeOfDay": {
275
+ id: string;
276
+ type: string;
277
+ label: string;
278
+ options: {
279
+ value: string;
280
+ label: string;
281
+ meta: {
282
+ detail: string;
283
+ };
284
+ }[];
285
+ promptTemplate: string;
286
+ };
287
+ "context.imageStyle": {
288
+ id: string;
289
+ type: string;
290
+ label: string;
291
+ neutralizeWhen: {
292
+ not: {
293
+ field: string;
294
+ equals: string;
295
+ };
296
+ };
297
+ options: {
298
+ value: string;
299
+ label: string;
300
+ prompt: string;
301
+ promptNeutral: string;
302
+ }[];
303
+ };
304
+ "context.styleReference": {
305
+ id: string;
306
+ type: string;
307
+ label: string;
308
+ promptTemplate: string;
309
+ ensureSentence: boolean;
310
+ };
311
+ };
312
+ blocks: {
313
+ task: {
314
+ id: string;
315
+ };
316
+ form: {
317
+ id: string;
318
+ fields: string[];
319
+ footerLines: ({
320
+ text: string;
321
+ when: {
322
+ any: {
323
+ field: string;
324
+ hasTag: string;
325
+ }[];
326
+ field?: undefined;
327
+ isTruthy?: undefined;
328
+ };
329
+ } | {
330
+ text: string;
331
+ when: {
332
+ field: string;
333
+ isTruthy: boolean;
334
+ any?: undefined;
335
+ };
336
+ })[];
337
+ };
338
+ view: {
339
+ id: string;
340
+ fields: string[];
341
+ lines: never[];
342
+ footerLines: ({
343
+ text: string;
344
+ when: {
345
+ field: string;
346
+ isTruthy: boolean;
347
+ any?: undefined;
348
+ all?: undefined;
349
+ };
350
+ } | {
351
+ text: string;
352
+ when: {
353
+ any: {
354
+ field: string;
355
+ equals: string;
356
+ }[];
357
+ field?: undefined;
358
+ isTruthy?: undefined;
359
+ all?: undefined;
360
+ };
361
+ } | {
362
+ text: string;
363
+ when: {
364
+ all: ({
365
+ any: {
366
+ field: string;
367
+ equals: string;
368
+ }[];
369
+ field?: undefined;
370
+ equals?: undefined;
371
+ } | {
372
+ field: string;
373
+ equals: string;
374
+ any?: undefined;
375
+ })[];
376
+ field?: undefined;
377
+ isTruthy?: undefined;
378
+ any?: undefined;
379
+ };
380
+ })[];
381
+ };
382
+ style: {
383
+ id: string;
384
+ fields: string[];
385
+ footerLines: ({
386
+ text: string;
387
+ when: {
388
+ any: {
389
+ field: string;
390
+ isTruthy: boolean;
391
+ }[];
392
+ field?: undefined;
393
+ isTruthy?: undefined;
394
+ };
395
+ } | {
396
+ text: string;
397
+ when: {
398
+ field: string;
399
+ isTruthy: boolean;
400
+ any?: undefined;
401
+ };
402
+ })[];
403
+ };
404
+ program: {
405
+ id: string;
406
+ fields: string[];
407
+ footerLines: ({
408
+ text: string;
409
+ when: {
410
+ all: ({
411
+ field: string;
412
+ equals: string;
413
+ any?: undefined;
414
+ } | {
415
+ any: {
416
+ field: string;
417
+ isTruthy: boolean;
418
+ }[];
419
+ field?: undefined;
420
+ equals?: undefined;
421
+ })[];
422
+ any?: undefined;
423
+ field?: undefined;
424
+ hasTag?: undefined;
425
+ };
426
+ } | {
427
+ text: string;
428
+ when: {
429
+ any: {
430
+ field: string;
431
+ isTruthy: boolean;
432
+ }[];
433
+ all?: undefined;
434
+ field?: undefined;
435
+ hasTag?: undefined;
436
+ };
437
+ } | {
438
+ text: string;
439
+ when: {
440
+ field: string;
441
+ hasTag: string;
442
+ all?: undefined;
443
+ any?: undefined;
444
+ };
445
+ })[];
446
+ };
447
+ context: {
448
+ id: string;
449
+ fields: string[];
450
+ footerLines: {
451
+ text: string;
452
+ when: {
453
+ field: string;
454
+ isTruthy: boolean;
455
+ };
456
+ }[];
457
+ };
458
+ };
459
+ sections: ({
460
+ id: string;
461
+ label: string;
462
+ blocks: string[];
463
+ fields: string[];
464
+ groups?: undefined;
465
+ } | {
466
+ id: string;
467
+ label: string;
468
+ blocks: string[];
469
+ fields: string[];
470
+ groups: {
471
+ label: string;
472
+ fields: string[];
473
+ }[];
474
+ })[];
475
+ warnings: {
476
+ id: string;
477
+ message: string;
478
+ when: {
479
+ all: ({
480
+ field: string;
481
+ equals: string;
482
+ hasTag?: undefined;
483
+ } | {
484
+ field: string;
485
+ hasTag: string;
486
+ equals?: undefined;
487
+ })[];
488
+ };
489
+ }[];
490
+ };
491
+ //# sourceMappingURL=courtyard.base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"courtyard.base.d.ts","sourceRoot":"","sources":["../../../src/prompt-pack/packs/courtyard.base.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwiD7B,CAAC"}