@cosmicdrift/kumiko-renderer-puppeteer-client 0.386.0 → 0.388.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.
package/LICENSE CHANGED
@@ -1,57 +1,21 @@
1
- Business Source License 1.1
2
-
3
- Parameters
4
-
5
- Licensor: Marc Frost
6
-
7
- Licensed Work: @cosmicdrift/kumiko-renderer-puppeteer-client
8
- The Licensed Work is © 2026 Marc Frost.
9
-
10
- Additional Use Grant:
11
- You may use the Licensed Work in production for any purpose, including
12
- commercially, EXCEPT for the Restricted Use.
13
-
14
- "Restricted Use" is defined as using the Licensed Work to provide a platform
15
- or service to third parties that allows them to host, deploy, or run their
16
- own applications built with the Licensed Work. This includes, but is not
17
- limited to: managed hosting services, software-as-a-service (SaaS) platforms,
18
- platform-as-a-service (PaaS), developer platforms, or any multi-tenant
19
- managed offering of the Licensed Work.
20
-
21
- This restriction does not apply to the Licensor, any entity controlled by,
22
- controlling, or under common control with the Licensor ("Affiliates"), or
23
- contractors acting on their behalf. The Licensor remains free to use the
24
- Licensed Work for any purpose, including for the operation of kumiko.rocks.
25
-
26
- Change Date: 2030-05-05
27
- Change License: Apache License, Version 2.0
28
-
29
-
30
- Terms
31
-
32
- The Licensor hereby grants you the right to copy, modify, create derivative works,
33
- redistribute, and make non-production use of the Licensed Work. The Licensor may
34
- make an Additional Use Grant, above, permitting limited production use.
35
-
36
- Effective on the Change Date, or the fourth anniversary of the first publicly
37
- available distribution of the Licensed Work under this License, whichever comes
38
- first, this License will convert to the Change License.
39
-
40
- This Business Source License governs use of the Licensed Work in all cases, except
41
- as to any use that is explicitly granted in the Additional Use Grant above or
42
- under the Change License after the Change Date.
43
-
44
- If your use of the Licensed Work does not comply with the requirements of this
45
- License, you must cease use of the Licensed Work immediately.
46
-
47
- All copies of the Licensed Work, and all derivative works thereof, must include
48
- this License.
49
-
50
- This License does not grant you any right, title, or interest in any trademark,
51
- logo, or branding of the Licensor, except as required to comply with this License.
52
-
53
- TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
54
- “AS IS” BASIS. LICENSOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
55
- WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
56
- TITLE, AND NON-INFRINGEMENT. IN NO EVENT WILL LICENSOR BE LIABLE FOR ANY DAMAGES
57
- ARISING OUT OF OR RELATED TO THIS LICENSE OR THE USE OF THE LICENSED WORK.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Marc Frost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -10,6 +10,7 @@ import { collectRegionResourceKeys, compileDocumentSource, createDocumentHandleb
10
10
  const LINE_BREAKS = /[\r\n]+/g;
11
11
  const IMAGE_CONTENT_TYPE_PREFIX = "image/";
12
12
  const MAX_RECORD_IMAGES = 24;
13
+ const MAX_RECORD_IMAGE_LOOKUPS = 100;
13
14
  const MAX_RECORD_IMAGES_TOTAL_BYTES = 20 * 1024 * 1024;
14
15
  const PREVIEW_PAGE_NUMBER = "1";
15
16
  const EMPTY_CHROMIUM_REGION = "<span></span>";
@@ -176,8 +177,10 @@ async function loadRecordImageDataUris(ctx, variables, imageVariableNames) {
176
177
  for (const fileRefId of fileRefIdsOf(variables[name])) {
177
178
  if (seenIds.has(fileRefId))
178
179
  continue;
180
+ if (seenIds.size >= MAX_RECORD_IMAGE_LOOKUPS)
181
+ break;
179
182
  seenIds.add(fileRefId);
180
- if (loadedCount >= MAX_RECORD_IMAGES)
183
+ if (loadedCount >= MAX_RECORD_IMAGES || loadedBytes >= MAX_RECORD_IMAGES_TOTAL_BYTES)
181
184
  break;
182
185
  const image = await readRecordImage(ctx, filesForTenant, fileRefId, Math.min(maxBytes, MAX_RECORD_IMAGES_TOTAL_BYTES - loadedBytes));
183
186
  if (image === null)
@@ -190,10 +193,22 @@ async function loadRecordImageDataUris(ctx, variables, imageVariableNames) {
190
193
  }
191
194
  return dataUrisByVariable;
192
195
  }
193
- // Text context without images variables: their value is file ids, which no placeholder,
194
- // title or file name pattern may print.
195
- function withoutImageVariables(variables, definitions) {
196
- return Object.fromEntries(Object.entries(variables).filter(([name]) => !(Object.hasOwn(definitions, name) && definitions[name]?.type === "images")));
196
+ function isImagesVariable(definitions, name) {
197
+ return Object.hasOwn(definitions, name) && definitions[name]?.type === "images";
198
+ }
199
+ // An images variable's value is file ids, which no placeholder, title or file name pattern
200
+ // may print; the text context carries only whether images exist, so a condition on it works.
201
+ function imagesAsPresenceFlags(variables, definitions, recordImages, recordImageUris) {
202
+ const hasImages = (name) => {
203
+ if (recordImages === "placeholder")
204
+ return true;
205
+ const resolved = recordImageUris.get(name);
206
+ return resolved !== undefined ? resolved.length > 0 : fileRefIdsOf(variables[name]).length > 0;
207
+ };
208
+ return Object.fromEntries(Object.entries(variables).map(([name, value]) => [
209
+ name,
210
+ isImagesVariable(definitions, name) ? hasImages(name) : value,
211
+ ]));
197
212
  }
198
213
  function renderRegion(hbs, region, context, resourceSrc) {
199
214
  if (region.trim() === "")
@@ -304,17 +319,17 @@ async function assembleDocument(input, ctx, markers, recordImages = "placeholder
304
319
  ]);
305
320
  const hbs = createDocumentHandlebars(format);
306
321
  const variableDefinitions = resolveTemplateVariables(ctx.registry, slug, template.variableSchema);
322
+ const recordImageUris = recordImages === "resolve"
323
+ ? await loadRecordImageDataUris(ctx, variables, collectDocumentImageVariables(template.content).filter((name) => isImagesVariable(variableDefinitions, name)))
324
+ : new Map();
307
325
  const context = {
308
- ...withoutImageVariables(variables, variableDefinitions),
326
+ ...imagesAsPresenceFlags(variables, variableDefinitions, recordImages, recordImageUris),
309
327
  tenantName,
310
328
  signature: "",
311
329
  imprint: "",
312
330
  page: "",
313
331
  pages: "",
314
332
  };
315
- const recordImageUris = recordImages === "resolve"
316
- ? await loadRecordImageDataUris(ctx, variables, collectDocumentImageVariables(template.content))
317
- : new Map();
318
333
  const bodyKeys = collectDocumentResourceKeys(template.content);
319
334
  const layoutKeys = collectRegionResourceKeys(layout.regions);
320
335
  const bodyRefs = await resolveResourceFileRefs(tplApi, ctx, template, bodyKeys);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-renderer-puppeteer-client",
3
- "version": "0.386.0",
3
+ "version": "0.388.0",
4
4
  "description": "Renderer-Foundation plugin: HTTP client for puppeteer-service (PDF + image snapshot via remote browser).",
5
- "license": "BUSL-1.1",
5
+ "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
7
7
  "type": "module",
8
8
  "kumiko": {
@@ -19,13 +19,13 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@cosmicdrift/kumiko-bundled-features": "0.386.0",
23
- "@cosmicdrift/kumiko-framework": "0.386.0",
24
- "@cosmicdrift/kumiko-renderer-mail-html": "0.386.0",
25
- "@cosmicdrift/kumiko-types": "0.386.0"
22
+ "@cosmicdrift/kumiko-bundled-features": "0.388.0",
23
+ "@cosmicdrift/kumiko-framework": "0.388.0",
24
+ "@cosmicdrift/kumiko-renderer-mail-html": "0.388.0",
25
+ "@cosmicdrift/kumiko-types": "0.388.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cosmicdrift/kumiko-testing": "0.386.0"
28
+ "@cosmicdrift/kumiko-testing": "0.388.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
package/src/changes.json CHANGED
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.388.0",
4
+ "type": "fix",
5
+ "title": "Conditions on images variables work in the PDF render",
6
+ "detail": "A data-condition on an images variable now shows its block when the record has resolvable images, instead of never. Record image loading stops once the byte budget is used up, caps the number of looked-up ids, and ignores image blocks whose variable is not declared as images."
7
+ },
2
8
  {
3
9
  "version": "0.379.0",
4
10
  "type": "improvement",