mirror of
https://github.com/wekan/wekan.git
synced 2026-12-04 22:49:48 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a371e59995 | ||
|
|
999c178b3e | ||
|
|
a592656118 | ||
|
|
14fd0a6f63 | ||
|
|
91df1c8a6b | ||
|
|
79ecea1e1a | ||
|
|
9165a9f8e2 | ||
|
|
bef927891a | ||
|
|
69cbd5a846 | ||
|
|
fea1134b26 | ||
|
|
3ec1a9f7ea | ||
|
|
fd746df6ce | ||
|
|
a9ce2a628c | ||
|
|
3b6660ea4d | ||
|
|
e26c948455 | ||
|
|
28768b0079 | ||
|
|
9bf4f1ad48 | ||
|
|
1e7fc04784 | ||
|
|
4edacc0199 | ||
|
|
736989b185 | ||
|
|
a9215115f0 | ||
|
|
7425f4ddd7 | ||
|
|
fb85b50a51 | ||
|
|
3c836d16c1 | ||
|
|
f0309a8036 | ||
|
|
f560b3de05 |
No files matched your search
@@ -97,6 +97,92 @@ Which databases WeKan supports
|
||||
|
||||
</details>
|
||||
|
||||
# v13.44 2026-12-04 WeKan ® release
|
||||
|
||||
**In short:** Opened cards show thumbnails for PDFs, Word documents, Excel
|
||||
sheets, PowerPoint slides and OpenDocument attachments. IFC building models
|
||||
keep their original extensions when WeKan detects their STEP file format.
|
||||
|
||||
This release adds the following new features:
|
||||
|
||||
<details>
|
||||
<summary><a href="https://github.com/wekan/wekan/commit/14fd0a6f639ed31ebb3c7a55f05431d03b31c1ff">Show document thumbnails on cards</a>. Thanks to SylcoDev and xet7.</summary>
|
||||
|
||||
Card attachment tiles use cached WebP previews for the first PDF or Word page,
|
||||
the first PowerPoint slide and the first Excel worksheet. OpenDocument tiles
|
||||
use the embedded preview when present or render the initial text or cell
|
||||
values. Thumbnails retain attachment permissions and follow the board's
|
||||
attachment preview setting. Unavailable previews show the file extension.
|
||||
|
||||
[Issue #6992](https://github.com/wekan/wekan/issues/6992).
|
||||
|
||||
</details>
|
||||
|
||||
and fixes the following bugs:
|
||||
|
||||
<details>
|
||||
<summary><a href="https://github.com/wekan/wekan/commit/79ecea1e1a34008b7837c796a3a0eb20a6b680a8">Preserve IFC attachment extensions</a>. Thanks to SylcoDev and xet7.</summary>
|
||||
|
||||
WeKan recognizes `.ifc` as a valid extension for STEP-formatted IFC models
|
||||
and preserves the original case. A different detected format can still
|
||||
correct a mislabeled attachment.
|
||||
|
||||
[Issue #6991](https://github.com/wekan/wekan/issues/6991).
|
||||
|
||||
</details>
|
||||
|
||||
Thanks to above GitHub users for their contributions and translators for their translations.
|
||||
|
||||
# v13.43 2026-12-04 WeKan ® release
|
||||
|
||||
**In short:** CAD and CNC attachments keep their original extensions when file
|
||||
detection identifies only plain text, XML or ZIP. Files such as `flange.nc` and
|
||||
`flange.tap` keep distinct names.
|
||||
|
||||
This release fixes the following bugs:
|
||||
|
||||
<details>
|
||||
<summary><a href="https://github.com/wekan/wekan/commit/4edacc01998b55b8f62ba05a0773f49a187214a7">Preserve custom attachment extensions</a>. Thanks to SylcoDev and xet7.</summary>
|
||||
|
||||
Generic file detection preserves custom extensions such as `.stl`, `.SPF`,
|
||||
`.sym` and `.zzx`. WeKan still corrects misleading executable or script
|
||||
extensions and mismatches with specifically identified formats, such as a PDF
|
||||
named with a `.png` suffix.
|
||||
|
||||
[Issue #6990](https://github.com/wekan/wekan/issues/6990).
|
||||
|
||||
</details>
|
||||
|
||||
Thanks to above GitHub users for their contributions and translators for their translations.
|
||||
|
||||
# v13.42 2026-12-03 WeKan ® release
|
||||
|
||||
**In short:** The bulk card API now skips cards with invalid parent IDs and
|
||||
continues processing valid cards in the same request. **DOMPurify** has been
|
||||
updated to 3.4.18.
|
||||
|
||||
This release updates the following dependencies:
|
||||
|
||||
- [DOMPurify 3.4.17 → 3.4.18](https://github.com/wekan/wekan/commit/f560b3de0525c3b240b783634b601485f17ceaec) — HTML sanitizer.
|
||||
|
||||
Thanks to dependabot.
|
||||
|
||||
and fixes the following bugs:
|
||||
|
||||
<details>
|
||||
<summary><a href="https://github.com/wekan/wekan/commit/f0309a80366d811d1a841b6bf5db01f7b1dc6ff4">Validate parent IDs in bulk card creation</a>. Thanks to AhmedLukman and xet7.</summary>
|
||||
|
||||
The bulk card endpoint returns an error for each card whose parent ID is a
|
||||
number, boolean, object or array and continues processing the batch. The API
|
||||
regression test checks that invalid cards are skipped and that a valid child
|
||||
is saved with the requested parent.
|
||||
|
||||
[PR #6989](https://github.com/wekan/wekan/pull/6989).
|
||||
|
||||
</details>
|
||||
|
||||
Thanks to above GitHub users for their contributions and translators for their translations.
|
||||
|
||||
# v13.41 2026-12-03 WeKan ® release
|
||||
|
||||
**In short:** IGES attachments keep their .igs or .iges extension when uploaded.
|
||||
|
||||
+24
-39
@@ -5,6 +5,30 @@ each one changed and the project status are in
|
||||
Written by `node releases/changelog-short.mjs` from CHANGELOG-big.md:
|
||||
make changes there.
|
||||
|
||||
# v13.44 2026-12-04 WeKan ® release
|
||||
|
||||
Opened cards show thumbnails for PDFs, Word documents, Excel
|
||||
sheets, PowerPoint slides and OpenDocument attachments. IFC building models
|
||||
keep their original extensions when WeKan detects their STEP file format.
|
||||
|
||||
[All changes in v13.44](CHANGELOG-big.md#v1344-2026-12-04-wekan--release)
|
||||
|
||||
# v13.43 2026-12-04 WeKan ® release
|
||||
|
||||
CAD and CNC attachments keep their original extensions when file
|
||||
detection identifies only plain text, XML or ZIP. Files such as `flange.nc` and
|
||||
`flange.tap` keep distinct names.
|
||||
|
||||
[All changes in v13.43](CHANGELOG-big.md#v1343-2026-12-04-wekan--release)
|
||||
|
||||
# v13.42 2026-12-03 WeKan ® release
|
||||
|
||||
The bulk card API now skips cards with invalid parent IDs and
|
||||
continues processing valid cards in the same request. **DOMPurify** has been
|
||||
updated to 3.4.18.
|
||||
|
||||
[All changes in v13.42](CHANGELOG-big.md#v1342-2026-12-03-wekan--release)
|
||||
|
||||
# v13.41 2026-12-03 WeKan ® release
|
||||
|
||||
IGES attachments keep their .igs or .iges extension when uploaded.
|
||||
@@ -26,42 +50,3 @@ formatting. List Sync can also read and update Jira start dates. The
|
||||
**Univention App Center** package starts with the shell-free WeKan image.
|
||||
|
||||
[All changes in v13.40](CHANGELOG-big.md#v1340-2026-12-02-wekan--release)
|
||||
|
||||
# v13.39 2026-12-02 WeKan ® release
|
||||
|
||||
The export menu sends selected WeKan cards to a chosen **Jira**
|
||||
project and issue type, including start and due dates, labels, dependencies and
|
||||
subtasks
|
||||
where Jira supports them. Direct **OpenProject** exports can preserve parent
|
||||
relationships and supported dependencies between exported cards. **Checkboxes**
|
||||
use the same style in Legal Pages, board settings, and other forms. **Planka**
|
||||
List Sync sends new checklists and tasks to Planka and synchronizes edits and
|
||||
deletions in both directions. The **REST API** can update several cards in one
|
||||
request while checking each card’s revision. Administrators can set a default
|
||||
board template per feature profile.
|
||||
|
||||
[All changes in v13.39](CHANGELOG-big.md#v1339-2026-12-02-wekan--release)
|
||||
|
||||
# v13.38 2026-12-02 WeKan ® release
|
||||
|
||||
**Jira**, **OpenProject**, **Redmine**, **Asana**, **ClickUp**
|
||||
and **Linear** imports and List Sync carry more planning details, comments,
|
||||
files and dependencies. **REST** supports board-wide card sync and threaded
|
||||
comments, and hides deleted lists and cards. **History** shows archive and
|
||||
restore statuses, **Docker** checks application and database readiness, and
|
||||
**LDAP** supports ordered fallback servers. **Workload** uses each
|
||||
assignee’s remaining effort. **Auto-archive** keeps recently active subtasks.
|
||||
|
||||
[All changes in v13.38](CHANGELOG-big.md#v1338-2026-12-02-wekan--release)
|
||||
|
||||
# v13.37 2026-11-30 WeKan ® release
|
||||
|
||||
Jira imports from **Jira Server and Data Center** as formatted
|
||||
text, with its people, watchers, worklogs and attachments, checked against
|
||||
**OpenProject's Jira Migrator**. A list can be synced with **OpenProject**,
|
||||
**Microsoft To Do**, **Google Tasks**, **KanbanFlow**, **Planka** and **Trello**
|
||||
too. The Problems panel shows the latest History integrity check and opens
|
||||
Data health findings for review. Todoist projects can be imported, and
|
||||
their active tasks can sync into a WeKan list.
|
||||
|
||||
[All changes in v13.37](CHANGELOG-big.md#v1337-2026-11-30-wekan--release)
|
||||
+1
-1
@@ -62,7 +62,7 @@ FROM --platform=$BUILDPLATFORM debian:trixie AS bundle
|
||||
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
ARG VERSION=13.41
|
||||
ARG VERSION=13.44
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY --chmod=755 releases/check-telemetry.py /tmp/check-telemetry.py
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
appId: wekan-public/apps/77b94f60-dec9-0136-304e-16ff53095928
|
||||
appVersion: "v13.41.0"
|
||||
appVersion: "v13.44.0"
|
||||
files:
|
||||
userUploads:
|
||||
- README.md
|
||||
|
||||
@@ -66,6 +66,10 @@ video.attachment-thumbnail {
|
||||
object-position: center;
|
||||
background: transparent;
|
||||
}
|
||||
.attachment-document-thumbnail[hidden],
|
||||
.attachment-document-fallback[hidden] {
|
||||
display: none;
|
||||
}
|
||||
/* My Attachments (client/components/main/myAttachments.jade) uses the same
|
||||
classes on a plain div; it keeps its previous sizing. */
|
||||
div.attachment-thumbnail-container {
|
||||
|
||||
@@ -110,6 +110,9 @@ template(name="attachmentGallery")
|
||||
else if link
|
||||
if(isImage)
|
||||
img.attachment-thumbnail(src="{{attachmentPreviewUrl this}}" title="{{cleanFilename name}}" alt="{{cleanFilename name}}" loading="lazy")
|
||||
else if documentThumbnailUrl this
|
||||
img.attachment-thumbnail.attachment-document-thumbnail(src="{{documentThumbnailUrl this}}" title="{{cleanFilename name}}" alt="" loading="lazy")
|
||||
span.attachment-thumbnail-text.attachment-document-fallback(hidden)= extension
|
||||
else if($eq extension 'svg')
|
||||
img.attachment-thumbnail(src="{{link}}" title="{{cleanFilename name}}" alt="{{cleanFilename name}}" type="image/svg+xml")
|
||||
else if($eq extension 'mp3')
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import '/client/components/cards/attachments.jade';
|
||||
import { attachmentKind, attachmentRichKind, attachmentCodeLanguage, attachmentCanPreview } from '/models/lib/attachmentKind';
|
||||
import { generateUniversalAttachmentUrl } from '/models/lib/universalUrlGenerator';
|
||||
import { canThumbnail, thumbnailUrl } from '/models/lib/attachmentThumbnail';
|
||||
import { canThumbnail, documentThumbnailKind, thumbnailUrl } from '/models/lib/attachmentThumbnail';
|
||||
import { liveAttachments } from '/models/lib/attachmentSoftDelete';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { sanitizeHTML } from '/imports/lib/secureDOMPurify';
|
||||
@@ -488,6 +488,12 @@ Template.registerHelper('attachmentPreviewUrl', attachmentPreviewUrl);
|
||||
// cover and the open-card cover (error events do not bubble).
|
||||
export function previewFallback(img) {
|
||||
if (!img || img.dataset.previewFellBack === '1') return;
|
||||
if (img.classList?.contains('attachment-document-thumbnail')) {
|
||||
img.hidden = true;
|
||||
const fallback = img.nextElementSibling;
|
||||
if (fallback) fallback.hidden = false;
|
||||
return;
|
||||
}
|
||||
const src = img.getAttribute('src') || '';
|
||||
const original = src.replace(/\/thumbnail(?=\?|$)/, '');
|
||||
if (!original || original === src) return;
|
||||
@@ -519,6 +525,10 @@ Template.attachmentGallery.onCreated(function () {
|
||||
});
|
||||
|
||||
Template.attachmentGallery.helpers({
|
||||
documentThumbnailUrl(file) {
|
||||
return file?._id && documentThumbnailKind(file)
|
||||
? thumbnailUrl(generateUniversalAttachmentUrl(file._id)) : '';
|
||||
},
|
||||
// #6870: the "+" button - a card the user may edit, unless uploads are blocked site-wide
|
||||
canAddAttachment() {
|
||||
return Utils.canModifyCard() && !attachmentUploadsBlocked();
|
||||
@@ -530,7 +540,8 @@ Template.attachmentGallery.helpers({
|
||||
const board = ReactiveCache.getBoard(file.meta?.boardId) || Utils.getCurrentBoard();
|
||||
const link = typeof file.link === 'function' ? file.link() : file.link;
|
||||
return attachmentTileCompact({
|
||||
isImage: file.isImage, extension: file.extension, hasLink: !!link,
|
||||
isImage: file.isImage, documentThumbnail: !!documentThumbnailKind(file),
|
||||
extension: file.extension, hasLink: !!link,
|
||||
}, board?.allowsAttachmentPreviewsOnCard);
|
||||
},
|
||||
attachedCards() {
|
||||
|
||||
@@ -10,7 +10,7 @@ This is without container (without Docker or Snap).
|
||||
|
||||
Right click and download files 1-4:
|
||||
|
||||
1. [wekan-13.41-win64.zip](https://github.com/wekan/wekan/releases/download/v13.41/wekan-13.41-win64.zip) or newest available at https://github.com/wekan/wekan/releases/
|
||||
1. [wekan-13.44-win64.zip](https://github.com/wekan/wekan/releases/download/v13.44/wekan-13.44-win64.zip) or newest available at https://github.com/wekan/wekan/releases/
|
||||
|
||||
2. [node.exe](https://nodejs.org/dist/latest-v26.x/win-x64/node.exe)
|
||||
|
||||
@@ -22,7 +22,7 @@ Right click and download files 1-4:
|
||||
|
||||
6. Double click `mongodb-windows-x86_64-7.0.34-signed.msi` . In installer, uncheck downloading MongoDB compass.
|
||||
|
||||
7. Unzip `wekan-13.41-win64.zip` , inside it is directory `bundle`, to it copy other files:
|
||||
7. Unzip `wekan-13.44-win64.zip` , inside it is directory `bundle`, to it copy other files:
|
||||
|
||||
```
|
||||
bundle (directory)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Deploy WeKan on your own server with [Appdonia](https://appdonia.com):
|
||||
|
||||
[](https://appdonia.com/self-host/wekan)
|
||||
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="202" height="40" viewBox="0 0 202 40" role="img" aria-label="Deploy on Appdonia">
|
||||
<title>Deploy on Appdonia</title>
|
||||
<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#7650D1"/><stop offset="1" stop-color="#5E38B5"/></linearGradient></defs>
|
||||
<rect width="202" height="40" rx="6" fill="url(#g)"/>
|
||||
<rect x="40" y="0" width="1" height="40" fill="#FFFFFF" fill-opacity=".22"/>
|
||||
<rect x="10.00" y="10.00" width="9.2" height="9.2" rx="2.5" fill="#FFFFFF"/><rect x="20.80" y="10.00" width="9.2" height="9.2" rx="2.5" fill="#F0997B"/><rect x="10.00" y="20.80" width="9.2" height="9.2" rx="2.5" fill="#FFFFFF"/><rect x="20.80" y="20.80" width="9.2" height="9.2" rx="2.5" fill="#FFFFFF"/>
|
||||
<path fill="#FFFFFF" d="M54.2 25.07V14.92H57.39Q58.89 14.92 60.04 15.57Q61.2 16.22 61.85 17.36Q62.51 18.51 62.51 20Q62.51 21.48 61.85 22.62Q61.2 23.77 60.04 24.42Q58.89 25.07 57.39 25.07ZM55.88 23.5H57.39Q58.11 23.5 58.73 23.24Q59.35 22.97 59.81 22.49Q60.28 22.01 60.54 21.38Q60.8 20.74 60.8 20Q60.8 19.26 60.54 18.62Q60.28 17.99 59.81 17.51Q59.35 17.03 58.73 16.76Q58.11 16.5 57.39 16.5H55.88ZM67.21 25.25Q66.15 25.25 65.33 24.76Q64.51 24.28 64.04 23.42Q63.57 22.57 63.57 21.45Q63.57 20.33 64.05 19.48Q64.53 18.62 65.36 18.14Q66.19 17.65 67.27 17.65Q68.24 17.65 69.02 18.15Q69.8 18.65 70.26 19.59Q70.71 20.53 70.71 21.84H65.25Q65.32 22.75 65.93 23.27Q66.53 23.8 67.36 23.8Q68.02 23.8 68.46 23.5Q68.9 23.2 69.14 22.72L70.57 23.33Q70.27 23.92 69.8 24.35Q69.33 24.79 68.68 25.02Q68.03 25.25 67.21 25.25ZM65.35 20.6H68.96Q68.92 20.08 68.66 19.74Q68.4 19.39 68.02 19.22Q67.64 19.04 67.22 19.04Q66.82 19.04 66.41 19.21Q65.99 19.38 65.7 19.73Q65.41 20.07 65.35 20.6ZM72.04 27.98V17.82H73.56L73.63 18.93Q74.02 18.32 74.6 17.99Q75.19 17.65 75.95 17.65Q76.94 17.65 77.67 18.12Q78.41 18.59 78.82 19.44Q79.23 20.3 79.23 21.45Q79.23 22.59 78.82 23.45Q78.41 24.31 77.67 24.78Q76.94 25.25 75.95 25.25Q75.2 25.25 74.62 24.92Q74.04 24.59 73.66 24V27.98ZM75.55 23.77Q76.13 23.77 76.58 23.47Q77.03 23.17 77.3 22.65Q77.56 22.13 77.56 21.45Q77.56 20.77 77.3 20.25Q77.05 19.73 76.6 19.43Q76.15 19.14 75.56 19.14Q75.01 19.14 74.58 19.43Q74.14 19.73 73.9 20.25Q73.66 20.77 73.66 21.45Q73.66 22.13 73.9 22.65Q74.14 23.18 74.57 23.47Q75 23.77 75.55 23.77ZM80.62 25.07V14.92H82.24V25.07ZM87.38 25.25Q86.28 25.25 85.44 24.76Q84.6 24.28 84.12 23.42Q83.64 22.57 83.64 21.45Q83.64 20.33 84.11 19.48Q84.58 18.62 85.43 18.14Q86.27 17.65 87.35 17.65Q88.44 17.65 89.28 18.14Q90.13 18.62 90.6 19.48Q91.07 20.33 91.07 21.45Q91.07 22.57 90.6 23.42Q90.13 24.28 89.29 24.76Q88.46 25.25 87.38 25.25ZM87.38 23.76Q87.98 23.76 88.44 23.46Q88.9 23.17 89.16 22.65Q89.42 22.13 89.42 21.45Q89.42 20.77 89.16 20.25Q88.89 19.73 88.42 19.44Q87.95 19.14 87.35 19.14Q86.75 19.14 86.28 19.44Q85.82 19.73 85.55 20.25Q85.29 20.77 85.29 21.45Q85.29 22.13 85.56 22.65Q85.83 23.17 86.3 23.46Q86.77 23.76 87.38 23.76ZM93.33 28.15Q92.98 28.15 92.56 28.02Q92.13 27.88 91.75 27.69L92.35 26.36Q92.63 26.5 92.86 26.58Q93.09 26.65 93.24 26.65Q93.58 26.65 93.82 26.47Q94.07 26.29 94.21 25.94L94.59 25.01L91.39 17.82H93.14L95.36 23.16L97.51 17.82H99.28L95.91 25.85Q95.62 26.54 95.31 27.06Q94.99 27.58 94.53 27.87Q94.07 28.15 93.33 28.15ZM107.08 25.25Q105.99 25.25 105.15 24.76Q104.3 24.28 103.83 23.42Q103.35 22.57 103.35 21.45Q103.35 20.33 103.82 19.48Q104.29 18.62 105.13 18.14Q105.97 17.65 107.05 17.65Q108.15 17.65 108.99 18.14Q109.83 18.62 110.3 19.48Q110.77 20.33 110.77 21.45Q110.77 22.57 110.3 23.42Q109.83 24.28 109 24.76Q108.16 25.25 107.08 25.25ZM107.08 23.76Q107.69 23.76 108.14 23.46Q108.6 23.17 108.86 22.65Q109.13 22.13 109.13 21.45Q109.13 20.77 108.86 20.25Q108.6 19.73 108.13 19.44Q107.66 19.14 107.06 19.14Q106.45 19.14 105.99 19.44Q105.52 19.73 105.26 20.25Q105 20.77 105 21.45Q105 22.13 105.26 22.65Q105.53 23.17 106 23.46Q106.48 23.76 107.08 23.76ZM112.18 25.07V17.82H113.7L113.77 18.85Q114.12 18.27 114.68 17.96Q115.24 17.65 115.96 17.65Q116.82 17.65 117.44 18Q118.06 18.34 118.39 19.08Q118.72 19.81 118.71 20.99V25.07H117.09V21.36Q117.09 20.5 116.89 20.03Q116.69 19.55 116.34 19.36Q115.98 19.17 115.52 19.17Q114.69 19.16 114.24 19.71Q113.79 20.26 113.79 21.29V25.07ZM123.07 25.07 127.13 14.92H128.91L132.96 25.07H131.18L130.19 22.58H125.85L124.86 25.07ZM126.41 21.09H129.62L128.02 17.03ZM134.06 27.98V17.82H135.58L135.65 18.93Q136.03 18.32 136.62 17.99Q137.21 17.65 137.96 17.65Q138.95 17.65 139.69 18.12Q140.43 18.59 140.83 19.44Q141.24 20.3 141.24 21.45Q141.24 22.59 140.83 23.45Q140.43 24.31 139.69 24.78Q138.95 25.25 137.96 25.25Q137.21 25.25 136.64 24.92Q136.06 24.59 135.67 24V27.98ZM137.57 23.77Q138.15 23.77 138.6 23.47Q139.05 23.17 139.31 22.65Q139.57 22.13 139.57 21.45Q139.57 20.77 139.32 20.25Q139.07 19.73 138.62 19.43Q138.17 19.14 137.58 19.14Q137.03 19.14 136.59 19.43Q136.16 19.73 135.92 20.25Q135.67 20.77 135.67 21.45Q135.67 22.13 135.92 22.65Q136.16 23.18 136.59 23.47Q137.01 23.77 137.57 23.77ZM142.71 27.98V17.82H144.24L144.31 18.93Q144.69 18.32 145.28 17.99Q145.86 17.65 146.62 17.65Q147.61 17.65 148.35 18.12Q149.08 18.59 149.49 19.44Q149.9 20.3 149.9 21.45Q149.9 22.59 149.49 23.45Q149.08 24.31 148.35 24.78Q147.61 25.25 146.62 25.25Q145.87 25.25 145.29 24.92Q144.71 24.59 144.33 24V27.98ZM146.22 23.77Q146.81 23.77 147.26 23.47Q147.71 23.17 147.97 22.65Q148.23 22.13 148.23 21.45Q148.23 20.77 147.98 20.25Q147.72 19.73 147.27 19.43Q146.82 19.14 146.24 19.14Q145.68 19.14 145.25 19.43Q144.82 19.73 144.57 20.25Q144.33 20.77 144.33 21.45Q144.33 22.13 144.57 22.65Q144.82 23.18 145.24 23.47Q145.67 23.77 146.22 23.77ZM154.17 25.25Q153.18 25.25 152.45 24.78Q151.71 24.31 151.3 23.45Q150.89 22.59 150.89 21.45Q150.89 20.3 151.3 19.44Q151.71 18.59 152.45 18.12Q153.18 17.65 154.17 17.65Q154.92 17.65 155.5 17.98Q156.09 18.31Line truncated
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.9 KiB |
@@ -43,10 +43,32 @@ function canThumbnail(attachment) {
|
||||
return name.includes('.') || attachment.extension ? RASTER_EXTENSIONS.has(extension) : false;
|
||||
}
|
||||
|
||||
const DOCUMENT_TYPES = new Map([
|
||||
['pdf', 'application/pdf'],
|
||||
['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
['odt', 'application/vnd.oasis.opendocument.text'],
|
||||
['ods', 'application/vnd.oasis.opendocument.spreadsheet'],
|
||||
['odp', 'application/vnd.oasis.opendocument.presentation'],
|
||||
]);
|
||||
|
||||
function documentThumbnailKind(attachment) {
|
||||
if (!attachment) return null;
|
||||
const type = String(attachment.type || attachment.mime || '').toLowerCase().split(';')[0].trim();
|
||||
for (const [kind, mime] of DOCUMENT_TYPES) if (type === mime) return kind;
|
||||
const ext = String(attachment.extension || /\.([^./]+)$/.exec(attachment.name || '')?.[1] || '')
|
||||
.replace(/^\./, '').toLowerCase();
|
||||
if (!DOCUMENT_TYPES.has(ext)) return null;
|
||||
if (!type || type === 'application/octet-stream' || type === 'binary/octet-stream'
|
||||
|| (ext !== 'pdf' && type === 'application/zip')) return ext;
|
||||
return null;
|
||||
}
|
||||
|
||||
// The thumbnail URL for an attachment URL as built by
|
||||
// models/lib/universalUrlGenerator.js ("<root>/cdn/storage/attachments/<id>").
|
||||
function thumbnailUrl(attachmentUrl) {
|
||||
return attachmentUrl ? `${String(attachmentUrl).replace(/\/+$/, '')}/thumbnail` : '';
|
||||
}
|
||||
|
||||
module.exports = { THUMBNAIL_EDGE, THUMBNAIL_TYPE, isThumbnailPath, canThumbnail, thumbnailUrl };
|
||||
module.exports = { THUMBNAIL_EDGE, THUMBNAIL_TYPE, isThumbnailPath, canThumbnail, documentThumbnailKind, thumbnailUrl };
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
const PREVIEW_EXTENSIONS = new Set(['svg', 'mp3', 'ogg', 'webm', 'mp4']);
|
||||
|
||||
function attachmentHasVisualPreview({ isImage, extension, hasLink } = {}) {
|
||||
function attachmentHasVisualPreview({ isImage, documentThumbnail, extension, hasLink } = {}) {
|
||||
if (!hasLink) return false;
|
||||
if (isImage) return true;
|
||||
if (isImage || documentThumbnail) return true;
|
||||
return PREVIEW_EXTENSIONS.has(String(extension || '').toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +55,27 @@ function mimeSaysNothing(mimeType) {
|
||||
return !t || UNINFORMATIVE_MIME.has(t);
|
||||
}
|
||||
|
||||
const STEP_EXTENSIONS = ['.step', '.stp', '.p21', '.ifc'];
|
||||
const FORMAT_EXTENSIONS = {
|
||||
'message/rfc822': ['.eml'],
|
||||
'model/iges': ['.igs', '.iges'],
|
||||
'model/step': ['.step', '.stp', '.p21'],
|
||||
'model/step': STEP_EXTENSIONS,
|
||||
'application/x-step': STEP_EXTENSIONS,
|
||||
'image/vnd.dxf': ['.dxf'],
|
||||
'application/x-dxf': ['.dxf'],
|
||||
'application/x-zip-compressed': ['.zip'],
|
||||
};
|
||||
const GENERIC_TEXT_EXTENSIONS = new Set(['.eml', '.step', '.stp', '.p21', '.x_t', '.dxf', '.igs', '.iges']);
|
||||
const GENERIC_CONTAINER_MIMES = new Set([
|
||||
'text/plain', 'text/xml', 'application/xml', 'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
]);
|
||||
const ACTIVE_EXTENSIONS = new Set([
|
||||
'.html', '.htm', '.xhtml', '.shtml', '.svg', '.svgz', '.hta',
|
||||
'.js', '.jse', '.mjs', '.cjs', '.vbs', '.vbe', '.wsf', '.wsh',
|
||||
'.exe', '.com', '.scr', '.msi', '.bat', '.cmd', '.ps1', '.sh',
|
||||
'.php', '.phtml', '.asp', '.aspx', '.jsp', '.lnk', '.url', '.desktop',
|
||||
]);
|
||||
const KNOWN_FORMAT_EXTENSIONS = new Set([...Object.values(FORMAT_EXTENSIONS).flat(), '.x_t']);
|
||||
|
||||
// The correct extension (with leading dot) for a MIME type, or '' if unknown.
|
||||
function extensionForMime(mimeType) {
|
||||
@@ -101,8 +114,8 @@ function sanitizeUploadFileName(name, mimeType) {
|
||||
// whitespace. This is the same normalization used to DISPLAY names, so the
|
||||
// stored name matches what users see.
|
||||
let n = cleanFileName(name);
|
||||
let wantExt = extensionForMime(mimeType);
|
||||
const wantMime = String(mimeType || '').toLowerCase();
|
||||
const wantMime = String(mimeType || '').toLowerCase().trim();
|
||||
let wantExt = extensionForMime(wantMime);
|
||||
const originalExt = /(?:^|[^.])(\.[^.]+)$/.exec(n);
|
||||
// Online Gantt stores JSON under its application-owned .gantt extension.
|
||||
// A generic JSON detector describes the serialization, not the program that
|
||||
@@ -119,19 +132,23 @@ function sanitizeUploadFileName(name, mimeType) {
|
||||
if (wantExt) {
|
||||
const dot = n.lastIndexOf('.');
|
||||
const curExt = dot > 0 ? n.slice(dot).toLowerCase() : '';
|
||||
// Plain text, XML and ZIP describe the representation. A custom suffix
|
||||
// can still identify the application that opens the file.
|
||||
if (curExt && GENERIC_CONTAINER_MIMES.has(wantMime)) {
|
||||
return ACTIVE_EXTENSIONS.has(curExt) ? n.slice(0, dot) + wantExt : n;
|
||||
}
|
||||
const curMime = mime.lookup(n); // false when there is no recognized extension
|
||||
// JFIF is JPEG content, but many desktop file associations (and the
|
||||
// mime-types database used here) do not recognize .jfif. Use the portable
|
||||
// canonical extension instead of producing "photo.jfif.jpeg".
|
||||
if (curExt === wantExt || FORMAT_EXTENSIONS[wantMime]?.includes(curExt) ||
|
||||
(wantMime === 'text/plain' && GENERIC_TEXT_EXTENSIONS.has(curExt))) {
|
||||
if (curExt === wantExt || FORMAT_EXTENSIONS[wantMime]?.includes(curExt)) {
|
||||
// Custom/application-owned extensions may not exist in mime-types, but a
|
||||
// content-aware override above has already established the right suffix.
|
||||
} else if (wantMime === 'image/jpeg' && curExt === '.jfif') {
|
||||
n = n.slice(0, dot) + wantExt;
|
||||
} else if (curMime === wantMime) {
|
||||
// extension already matches the type (handles .jpg vs .jpeg) — keep it
|
||||
} else if (curMime || GENERIC_TEXT_EXTENSIONS.has(curExt)) {
|
||||
} else if (curMime || KNOWN_FORMAT_EXTENSIONS.has(curExt)) {
|
||||
// recognized but WRONG extension -> replace it
|
||||
n = n.slice(0, n.lastIndexOf('.')) + wantExt;
|
||||
} else {
|
||||
|
||||
@@ -6,8 +6,8 @@ is <https://github.com/yukiyokotani/office-open-xml-viewer> at release v0.85.2
|
||||
(commit `9756f5e`). The source npm tarball SHA256 is
|
||||
`7dd3995b65e45adfab9d7686e1a2eb69d4c5a9851cbd025e63aaf97869110831`.
|
||||
|
||||
Only the three browser viewer entry graphs, their WebAssembly parsers and their
|
||||
render workers are retained. The upstream Node API, MCP server, VS Code
|
||||
The three browser viewer entry graphs, their WebAssembly parsers, render
|
||||
workers and the Node thumbnail entry graph are retained. The MCP server, VS Code
|
||||
extension, examples, site, source toolchain, type declarations and optional
|
||||
MathJax, ChartEx, region-map and TIFF entry points are excluded. This package
|
||||
has no npm dependencies or lifecycle scripts.
|
||||
|
||||
+1323
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,67 @@
|
||||
import { t as e } from "./chunk-DmhlhrBa.js";
|
||||
//#region packages/node/src/render.ts
|
||||
var t = /* @__PURE__ */ e({
|
||||
installImageBitmapShim: () => i,
|
||||
installOffscreenCanvasShim: () => r,
|
||||
renderSlideNode: () => o,
|
||||
withNodeCanvasRuntime: () => a
|
||||
}), n = Promise.resolve();
|
||||
function r(e) {
|
||||
let t = globalThis, n = t.OffscreenCanvas, r = Object.prototype.hasOwnProperty.call(globalThis, "OffscreenCanvas");
|
||||
if (n !== void 0) return () => {};
|
||||
class i {
|
||||
constructor(t, n) {
|
||||
return e.createCanvas(t, n);
|
||||
}
|
||||
}
|
||||
return t.OffscreenCanvas = i, () => {
|
||||
r ? t.OffscreenCanvas = n : delete t.OffscreenCanvas;
|
||||
};
|
||||
}
|
||||
function i(e) {
|
||||
let t = globalThis, n = t.createImageBitmap;
|
||||
return t.createImageBitmap = async (t, n) => {
|
||||
if (t && typeof t.getContext == "function") return t;
|
||||
let r;
|
||||
if (t instanceof Uint8Array || t instanceof ArrayBuffer) r = t;
|
||||
else if (typeof t.arrayBuffer == "function") r = await t.arrayBuffer();
|
||||
else throw Error("createImageBitmap shim: unsupported source type");
|
||||
let i = n?.resizeWidth, a = n?.resizeHeight, o = typeof i == "number" && i > 0 ? { width: i } : typeof a == "number" && a > 0 ? { height: a } : void 0, s = await e.loadImage(r, o);
|
||||
if (!o || o.width !== void 0 && s.width === o.width || o.height !== void 0 && s.height === o.height) return s;
|
||||
let c = o.width === void 0 ? typeof o.height == "number" ? o.height / s.height : 1 : o.width / s.width, l = Math.max(1, Math.round(s.width * c)), u = Math.max(1, Math.round(s.height * c)), d = e.createCanvas(l, u), f = d.getContext("2d");
|
||||
return typeof f.drawImage == "function" ? (f.drawImage(s, 0, 0, l, u), s.close?.(), d) : s;
|
||||
}, () => {
|
||||
t.createImageBitmap = n;
|
||||
};
|
||||
}
|
||||
function a(e, t) {
|
||||
let a = async () => {
|
||||
let n = typeof globalThis.createImageBitmap == "function" ? () => void 0 : i(e), a = r(e);
|
||||
try {
|
||||
return await t();
|
||||
} finally {
|
||||
a(), n();
|
||||
}
|
||||
}, o = n.then(a, a);
|
||||
return n = o.then(() => void 0, () => void 0), o;
|
||||
}
|
||||
async function o(e, t, n, r = {}) {
|
||||
let { renderSlide: i } = await import("./session-BmP4lcEo.js").then((e) => e.t), o = t.slides[n];
|
||||
if (!o) throw Error(`Slide index ${n} out of range`);
|
||||
let s = r.width ?? 960, c = r.dpr ?? 2, l = r.fetchImage ?? (async () => new Blob([])), u = async () => {
|
||||
await i(e, o, t.slideWidth, t.slideHeight, {
|
||||
width: s,
|
||||
dpr: c,
|
||||
defaultTextColor: t.defaultTextColor,
|
||||
majorFont: t.majorFont,
|
||||
minorFont: t.minorFont,
|
||||
hlinkColor: t.hlinkColor ?? null,
|
||||
fetchMedia: r.fetchMedia ?? (async () => new Blob([])),
|
||||
fetchImage: l,
|
||||
skipMediaControls: !0
|
||||
});
|
||||
};
|
||||
await (r.factory ? a(r.factory, u) : u());
|
||||
}
|
||||
//#endregion
|
||||
export { a, t as i, r as n, o as r, i as t };
|
||||
@@ -0,0 +1,743 @@
|
||||
import { t as e } from "./chunk-DmhlhrBa.js";
|
||||
import { a as t, u as n } from "./slide-pull-client-RTwQbJiy.js";
|
||||
import { B as r, F as i, G as a, H as o, I as s, K as c, P as l, Q as u, R as d, U as f, W as p, X as m, Xt as h, Y as g, Z as _, cn as v, q as y } from "./line-metrics-BGtFM-ec.js";
|
||||
import { t as b } from "./transfer-mIj7E7NB.js";
|
||||
//#region packages/pptx/src/slide-cursor-operation.ts
|
||||
function x(e) {
|
||||
try {
|
||||
return f(e((e) => e.slide_cursor_resource_usage()));
|
||||
} catch (e) {
|
||||
if (String(e).includes("slide cursor usage is unavailable")) return;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
function ee(e, t, n, r, i) {
|
||||
let a, o;
|
||||
try {
|
||||
if (i) {
|
||||
if (!r) throw Error("slide payload is missing before acknowledgement");
|
||||
let t = i(n, r, x(e));
|
||||
typeof t == "function" ? a = t : t && ({rollback: a, commit: o} = t);
|
||||
}
|
||||
e((e) => e.acknowledge_slide(t.operationId, t.generation)), o?.();
|
||||
} catch (e) {
|
||||
try {
|
||||
a?.();
|
||||
} catch {}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
//#region packages/pptx/src/slide-pull-worker.ts
|
||||
var te = "ooxml-pull-resetting", ne = "ooxml-pull-reset-failed", re = class {
|
||||
coordinatorGeneration = new s();
|
||||
sessions = /* @__PURE__ */ new Map();
|
||||
pendingOpens = /* @__PURE__ */ new Map();
|
||||
operationTail = Promise.resolve();
|
||||
resourceFailure;
|
||||
lifecycleState = "ready";
|
||||
resetBarrier;
|
||||
resetIdentities = /* @__PURE__ */ new Map();
|
||||
constructor(e, t, n = (e) => e(this.requireArchive())) {
|
||||
this.archive = e, this.acceptSlide = t, this.executeArchive = n;
|
||||
}
|
||||
get coordinator() {
|
||||
return this.coordinatorGeneration;
|
||||
}
|
||||
reserveOpen(e) {
|
||||
if (this.assertReady(), S(e), this.pendingOpens.has(e.sessionId) || this.sessions.has(e.sessionId)) throw Error("slide pull session id is already reserved");
|
||||
this.pendingOpens.set(e.sessionId, {
|
||||
identity: e,
|
||||
canceled: !1
|
||||
});
|
||||
}
|
||||
abandonOpen(e) {
|
||||
this.pendingOpens.delete(e);
|
||||
}
|
||||
get pendingOpenCount() {
|
||||
return this.pendingOpens.size;
|
||||
}
|
||||
async open(e, t) {
|
||||
if (this.assertReady(), this.resourceFailure) throw this.resourceFailure;
|
||||
if (!Number.isSafeInteger(e) || e < 0) throw RangeError("slide index must be a non-negative safe integer");
|
||||
let n = this.pendingOpens.get(t.sessionId);
|
||||
if (!n || !C(n.identity, t)) throw Error("slide pull session open reservation is stale or missing");
|
||||
let r, a = new Promise((e) => {
|
||||
r = e;
|
||||
}), o = this.operationTail.then(() => this.coordinator.enqueue(async () => {
|
||||
if (n.canceled) throw Error("slide pull session open was canceled");
|
||||
let a, o = !1, s = new i({
|
||||
...t,
|
||||
maxByteCredit: h,
|
||||
coordinator: this.coordinator,
|
||||
driver: {
|
||||
pull: (n) => {
|
||||
let r;
|
||||
try {
|
||||
r = this.executeArchive((r) => r.pull_slide(e, t.operationId, t.generation, n));
|
||||
} catch (e) {
|
||||
throw y(e, n, h) || (this.latchResourceFailure(e), e);
|
||||
}
|
||||
let i = b(r);
|
||||
return this.acceptSlide && (a = JSON.parse(new TextDecoder().decode(new Uint8Array(i)))), o = !0, {
|
||||
payload: i,
|
||||
byteLength: i.byteLength,
|
||||
done: !0,
|
||||
transfer: [i]
|
||||
};
|
||||
},
|
||||
measureChunk: ({ payload: e }) => e.byteLength,
|
||||
acknowledge: () => {
|
||||
if (!o) throw Error("slide unit is not awaiting acknowledgement");
|
||||
try {
|
||||
ee(this.executeArchive, t, e, a, this.acceptSlide);
|
||||
} catch (e) {
|
||||
throw this.latchResourceFailure(e), e;
|
||||
}
|
||||
o = !1, a = void 0, this.sessions.delete(t.sessionId), r();
|
||||
},
|
||||
cancel: async () => {
|
||||
try {
|
||||
this.archive() && await this.executeArchive((e) => e.cancel_slide());
|
||||
} finally {
|
||||
a = void 0, o = !1, this.sessions.delete(t.sessionId), r();
|
||||
}
|
||||
},
|
||||
close: async () => {
|
||||
try {
|
||||
this.archive() && await this.executeArchive((e) => e.cancel_slide());
|
||||
} finally {
|
||||
a = void 0, o = !1, this.sessions.delete(t.sessionId), r();
|
||||
}
|
||||
},
|
||||
resourceUsage: () => {
|
||||
try {
|
||||
return this.readResourceUsage();
|
||||
} catch (e) {
|
||||
throw this.latchResourceFailure(e), e;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.sessions.set(t.sessionId, {
|
||||
host: s,
|
||||
identity: t
|
||||
}), this.pendingOpens.delete(t.sessionId);
|
||||
}));
|
||||
this.operationTail = o.then(() => a, () => void 0);
|
||||
try {
|
||||
await o;
|
||||
} catch (e) {
|
||||
throw this.pendingOpens.delete(t.sessionId), r(), e;
|
||||
}
|
||||
}
|
||||
async postOpenedSafely(e, t, n) {
|
||||
if (this.lifecycleState !== "ready") {
|
||||
try {
|
||||
n(this.lifecycleError());
|
||||
} catch {}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
t();
|
||||
} catch (t) {
|
||||
await this.closeIdentity(e);
|
||||
try {
|
||||
n(t);
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
dispatch(e, t) {
|
||||
if (this.lifecycleState !== "ready") return t(this.responseDuringReset(e)), Promise.resolve();
|
||||
let n = this.sessions.get(e.sessionId);
|
||||
if (n) return n.host.dispatch(e, t);
|
||||
let r = this.pendingOpens.get(e.sessionId);
|
||||
if (r && (e.kind === "cancel" || e.kind === "close")) {
|
||||
let n = C(r.identity, e);
|
||||
return n && (r.canceled = !0), t(n ? {
|
||||
protocol: l,
|
||||
kind: "accepted",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
command: e.kind
|
||||
} : this.staleLifecycleResponse(e)), Promise.resolve();
|
||||
}
|
||||
return e.kind === "cancel" || e.kind === "close" ? (t({
|
||||
protocol: l,
|
||||
kind: "accepted",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
command: e.kind
|
||||
}), Promise.resolve()) : (t({
|
||||
protocol: l,
|
||||
kind: "error",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
error: c(/* @__PURE__ */ Error("slide pull session is not open"))
|
||||
}), Promise.resolve());
|
||||
}
|
||||
async dispatchSafely(e, t) {
|
||||
try {
|
||||
await this.dispatch(e, t);
|
||||
} catch (n) {
|
||||
try {
|
||||
t({
|
||||
protocol: l,
|
||||
kind: "error",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
error: c(n)
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
run(e) {
|
||||
if (this.lifecycleState !== "ready") return Promise.reject(this.lifecycleError());
|
||||
let t = this.operationTail.then(() => this.coordinator.enqueue(async () => {
|
||||
if (this.resourceFailure) throw this.resourceFailure;
|
||||
return e();
|
||||
})).catch((e) => {
|
||||
throw this.latchResourceFailure(e), e;
|
||||
});
|
||||
return this.operationTail = t.then(() => void 0, () => void 0), t;
|
||||
}
|
||||
reset() {
|
||||
if (this.resetBarrier) return this.resetBarrier;
|
||||
this.lifecycleState = "resetting", this.captureResetIdentities();
|
||||
let e = this.performReset().then(() => {
|
||||
this.resetIdentities.clear(), this.lifecycleState = "ready";
|
||||
}, (e) => {
|
||||
throw this.lifecycleState = "reset-failed", e;
|
||||
}).finally(() => {
|
||||
this.resetBarrier === e && (this.resetBarrier = void 0);
|
||||
});
|
||||
return this.resetBarrier = e, e;
|
||||
}
|
||||
async performReset() {
|
||||
for (let e of this.pendingOpens.values()) e.canceled = !0;
|
||||
let e = 1;
|
||||
for (let { host: t, identity: n } of [...this.sessions.values()]) {
|
||||
let r;
|
||||
if (await t.dispatch({
|
||||
protocol: l,
|
||||
kind: "close",
|
||||
...n,
|
||||
requestId: e++
|
||||
}, (e) => {
|
||||
e.kind === "error" && (r = p(e.error));
|
||||
}), r) throw r;
|
||||
}
|
||||
this.sessions.clear(), await this.operationTail, this.pendingOpens.clear(), this.archive() && await this.executeArchive((e) => e.close_presentation_session()), this.coordinatorGeneration = new s(), this.resourceFailure = void 0;
|
||||
}
|
||||
assertReady() {
|
||||
if (this.lifecycleState !== "ready") throw this.lifecycleError();
|
||||
}
|
||||
lifecycleError() {
|
||||
let e = this.lifecycleState === "reset-failed", t = /* @__PURE__ */ Error(e ? "slide pull worker reset failed; retry reset before new work" : "slide pull worker reset is in progress");
|
||||
return t.name = "PullSessionLifecycleError", Object.assign(t, { code: e ? ne : te });
|
||||
}
|
||||
captureResetIdentities() {
|
||||
for (let { identity: e } of this.sessions.values()) this.resetIdentities.set(e.sessionId, e);
|
||||
for (let { identity: e } of this.pendingOpens.values()) this.resetIdentities.set(e.sessionId, e);
|
||||
}
|
||||
responseDuringReset(e) {
|
||||
if (e.kind === "cancel" || e.kind === "close") {
|
||||
let t = this.resetIdentities.get(e.sessionId);
|
||||
return t && !C(t, e) ? this.staleLifecycleResponse(e) : {
|
||||
protocol: l,
|
||||
kind: "accepted",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
command: e.kind
|
||||
};
|
||||
}
|
||||
return {
|
||||
protocol: l,
|
||||
kind: "error",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
error: c(this.lifecycleError())
|
||||
};
|
||||
}
|
||||
requireArchive() {
|
||||
let e = this.archive();
|
||||
if (!e) throw Error("Presentation not loaded");
|
||||
return e;
|
||||
}
|
||||
async closeIdentity(e) {
|
||||
if (this.lifecycleState !== "ready") return;
|
||||
let t = this.sessions.get(e.sessionId);
|
||||
if (t) {
|
||||
await t.host.dispatch({
|
||||
protocol: l,
|
||||
kind: "close",
|
||||
...e,
|
||||
requestId: 1
|
||||
}, () => void 0);
|
||||
return;
|
||||
}
|
||||
let n = this.pendingOpens.get(e.sessionId);
|
||||
n && C(n.identity, e) && (n.canceled = !0);
|
||||
}
|
||||
readResourceUsage() {
|
||||
return x(this.executeArchive);
|
||||
}
|
||||
latchResourceFailure(e) {
|
||||
let t = e instanceof v ? e : a(e);
|
||||
t && (this.resourceFailure ??= t);
|
||||
}
|
||||
staleLifecycleResponse(e) {
|
||||
return {
|
||||
protocol: l,
|
||||
kind: "error",
|
||||
sessionId: e.sessionId,
|
||||
operationId: e.operationId,
|
||||
generation: e.generation,
|
||||
requestId: e.requestId,
|
||||
error: {
|
||||
message: "stale lifecycle targets another slide operation",
|
||||
errorName: "PullSessionProtocolError",
|
||||
code: "ooxml-stale-lifecycle"
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
function S(e) {
|
||||
if (!Number.isSafeInteger(e.sessionId) || e.sessionId <= 0) throw RangeError("session id must be a positive safe integer");
|
||||
if (!Number.isSafeInteger(e.operationId) || e.operationId <= 0) throw RangeError("operation id must be a positive safe integer");
|
||||
if (!Number.isSafeInteger(e.generation) || e.generation <= 0) throw RangeError("generation must be a positive safe integer");
|
||||
}
|
||||
function C(e, t) {
|
||||
return e.sessionId === t.sessionId && e.operationId === t.operationId && e.generation === t.generation;
|
||||
}
|
||||
//#endregion
|
||||
//#region packages/core/src/internal/wasm-runtime-generation.ts
|
||||
function ie(e) {
|
||||
return _(e) ? new g(`WASM parser trapped and was recycled: ${e instanceof Error ? e.message : String(e)}`) : null;
|
||||
}
|
||||
var w = class {
|
||||
realm;
|
||||
live = /* @__PURE__ */ new Set();
|
||||
constructor(e, t) {
|
||||
this.realm = new u(() => e.initSync({ module: t }), () => e.reinit({ module_or_path: t }), ie), this.realm.onPoison((e) => {
|
||||
for (let t of this.live) t.poison(e);
|
||||
this.live.clear();
|
||||
});
|
||||
}
|
||||
async open(e, t) {
|
||||
for (;;) {
|
||||
this.throwIfOpenAborted(t), await this.awaitReadyOrAbort(t), this.throwIfOpenAborted(t);
|
||||
let n = this.realm.tryRunReady(e);
|
||||
if (!n.current) continue;
|
||||
let r = new ae(this, n.value, n.generation);
|
||||
if (this.live.add(r), t?.signal?.aborted) throw r.close(t.disposeOnAbort), t.abortError?.() ?? new DOMException("The operation was aborted", "AbortError");
|
||||
return r;
|
||||
}
|
||||
}
|
||||
async awaitReadyOrAbort(e) {
|
||||
let t = e?.signal;
|
||||
if (!t) {
|
||||
await this.realm.ensureReady();
|
||||
return;
|
||||
}
|
||||
this.throwIfOpenAborted(e), await new Promise((n, r) => {
|
||||
let i = () => r(e?.abortError?.() ?? new DOMException("The operation was aborted", "AbortError"));
|
||||
t.addEventListener("abort", i, { once: !0 }), this.realm.ensureReady().then(n, r).finally(() => {
|
||||
t.removeEventListener("abort", i);
|
||||
});
|
||||
});
|
||||
}
|
||||
throwIfOpenAborted(e) {
|
||||
if (e?.signal?.aborted) throw e.abortError?.() ?? new DOMException("The operation was aborted", "AbortError");
|
||||
}
|
||||
async ensureReady() {
|
||||
await this.realm.ensureReady();
|
||||
}
|
||||
run(e, t) {
|
||||
let n = e.requireLive(this.realm);
|
||||
return this.realm.run(() => t(n));
|
||||
}
|
||||
close(e, t) {
|
||||
let n = e.detachForClose();
|
||||
this.live.delete(e), n && this.realm.run(() => t(n));
|
||||
}
|
||||
}, ae = class {
|
||||
archive;
|
||||
failure;
|
||||
proxy;
|
||||
constructor(e, t, n) {
|
||||
this.host = e, this.generation = n, this.archive = t, this.proxy = new Proxy(t, { get: (e, t) => {
|
||||
let n = this.host.run(this, (e) => Reflect.get(e, t, e));
|
||||
return typeof n == "function" ? (...e) => this.host.run(this, (n) => {
|
||||
let r = Reflect.get(n, t, n);
|
||||
return Reflect.apply(r, n, e);
|
||||
}) : n;
|
||||
} });
|
||||
}
|
||||
run(e) {
|
||||
return this.host.run(this, e);
|
||||
}
|
||||
close(e) {
|
||||
this.host.close(this, e);
|
||||
}
|
||||
requireLive(e) {
|
||||
if (this.failure) throw this.failure;
|
||||
if (e.assertCurrent(this.generation), !this.archive) throw Error("WASM archive session belongs to a discarded runtime generation");
|
||||
return this.archive;
|
||||
}
|
||||
detachForClose() {
|
||||
let e = this.archive;
|
||||
return this.archive = void 0, this.failure ? void 0 : e;
|
||||
}
|
||||
poison(e) {
|
||||
let t = this.archive;
|
||||
this.failure = e, this.archive = void 0, m(t);
|
||||
}
|
||||
}, oe = /* @__PURE__ */ e({
|
||||
PptxArchive: () => T,
|
||||
default: () => Y,
|
||||
extract_font: () => se,
|
||||
extract_image: () => ce,
|
||||
extract_media: () => E,
|
||||
initSync: () => ue,
|
||||
parse_pptx: () => D,
|
||||
pptx_to_markdown: () => O,
|
||||
reinit: () => de
|
||||
}), T = class {
|
||||
__destroy_into_raw() {
|
||||
let e = this.__wbg_ptr;
|
||||
return this.__wbg_ptr = 0, A.unregister(this), e;
|
||||
}
|
||||
free() {
|
||||
let e = this.__destroy_into_raw();
|
||||
q.__wbg_pptxarchive_free(e, 0);
|
||||
}
|
||||
acknowledge_slide(e, t) {
|
||||
let n = q.pptxarchive_acknowledge_slide(this.__wbg_ptr, e, t);
|
||||
if (n[1]) throw B(n[0]);
|
||||
}
|
||||
assert_healthy() {
|
||||
let e = q.pptxarchive_assert_healthy(this.__wbg_ptr);
|
||||
if (e[1]) throw B(e[0]);
|
||||
}
|
||||
cancel_slide() {
|
||||
q.pptxarchive_cancel_slide(this.__wbg_ptr);
|
||||
}
|
||||
close_presentation_session() {
|
||||
q.pptxarchive_close_presentation_session(this.__wbg_ptr);
|
||||
}
|
||||
extract_font(e) {
|
||||
let t = z(e, q.__wbindgen_malloc, q.__wbindgen_realloc), n = K, r = q.pptxarchive_extract_font(this.__wbg_ptr, t, n);
|
||||
if (r[3]) throw B(r[2]);
|
||||
var i = j(r[0], r[1]).slice();
|
||||
return q.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
||||
}
|
||||
extract_image(e) {
|
||||
let t = z(e, q.__wbindgen_malloc, q.__wbindgen_realloc), n = K, r = q.pptxarchive_extract_image(this.__wbg_ptr, t, n);
|
||||
if (r[3]) throw B(r[2]);
|
||||
var i = j(r[0], r[1]).slice();
|
||||
return q.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
||||
}
|
||||
extract_media(e) {
|
||||
let t = z(e, q.__wbindgen_malloc, q.__wbindgen_realloc), n = K, r = q.pptxarchive_extract_media(this.__wbg_ptr, t, n);
|
||||
if (r[3]) throw B(r[2]);
|
||||
var i = j(r[0], r[1]).slice();
|
||||
return q.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
||||
}
|
||||
constructor(e, t, n, r) {
|
||||
let i = R(e, q.__wbindgen_malloc), a = K, o = q.pptxarchive_new(i, a, !L(t), L(t) ? BigInt(0) : t, !L(n), L(n) ? BigInt(0) : n, !L(r), L(r) ? BigInt(0) : r);
|
||||
if (o[2]) throw B(o[1]);
|
||||
return this.__wbg_ptr = o[0] >>> 0, A.register(this, this.__wbg_ptr, this), this;
|
||||
}
|
||||
parse() {
|
||||
let e = q.pptxarchive_parse(this.__wbg_ptr);
|
||||
if (e[3]) throw B(e[2]);
|
||||
var t = j(e[0], e[1]).slice();
|
||||
return q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
||||
}
|
||||
presentation_bootstrap() {
|
||||
let e = q.pptxarchive_presentation_bootstrap(this.__wbg_ptr);
|
||||
if (e[3]) throw B(e[2]);
|
||||
var t = j(e[0], e[1]).slice();
|
||||
return q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
||||
}
|
||||
pull_slide(e, t, n, r) {
|
||||
let i = q.pptxarchive_pull_slide(this.__wbg_ptr, e, t, n, r);
|
||||
if (i[3]) throw B(i[2]);
|
||||
var a = j(i[0], i[1]).slice();
|
||||
return q.__wbindgen_free(i[0], i[1] * 1, 1), a;
|
||||
}
|
||||
resource_usage() {
|
||||
let e = q.pptxarchive_resource_usage(this.__wbg_ptr);
|
||||
if (e[3]) throw B(e[2]);
|
||||
var t = j(e[0], e[1]).slice();
|
||||
return q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
||||
}
|
||||
slide_cursor_resource_usage() {
|
||||
let e = q.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);
|
||||
if (e[3]) throw B(e[2]);
|
||||
var t = j(e[0], e[1]).slice();
|
||||
return q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
||||
}
|
||||
to_markdown() {
|
||||
let e, t;
|
||||
try {
|
||||
let i = q.pptxarchive_to_markdown(this.__wbg_ptr);
|
||||
var n = i[0], r = i[1];
|
||||
if (i[3]) throw n = 0, r = 0, B(i[2]);
|
||||
return e = n, t = r, P(n, r);
|
||||
} finally {
|
||||
q.__wbindgen_free(e, t, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
Symbol.dispose && (T.prototype[Symbol.dispose] = T.prototype.free);
|
||||
function se(e, t, n, r) {
|
||||
let i = R(e, q.__wbindgen_malloc), a = K, o = z(t, q.__wbindgen_malloc, q.__wbindgen_realloc), s = K, c = q.extract_font(i, a, o, s, !L(n), L(n) ? BigInt(0) : n, !L(r), L(r) ? BigInt(0) : r);
|
||||
if (c[3]) throw B(c[2]);
|
||||
var l = j(c[0], c[1]).slice();
|
||||
return q.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
||||
}
|
||||
function ce(e, t, n, r) {
|
||||
let i = R(e, q.__wbindgen_malloc), a = K, o = z(t, q.__wbindgen_malloc, q.__wbindgen_realloc), s = K, c = q.extract_image(i, a, o, s, !L(n), L(n) ? BigInt(0) : n, !L(r), L(r) ? BigInt(0) : r);
|
||||
if (c[3]) throw B(c[2]);
|
||||
var l = j(c[0], c[1]).slice();
|
||||
return q.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
||||
}
|
||||
function E(e, t, n, r) {
|
||||
let i = R(e, q.__wbindgen_malloc), a = K, o = z(t, q.__wbindgen_malloc, q.__wbindgen_realloc), s = K, c = q.extract_media(i, a, o, s, !L(n), L(n) ? BigInt(0) : n, !L(r), L(r) ? BigInt(0) : r);
|
||||
if (c[3]) throw B(c[2]);
|
||||
var l = j(c[0], c[1]).slice();
|
||||
return q.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
||||
}
|
||||
function D(e, t, n) {
|
||||
let r = R(e, q.__wbindgen_malloc), i = K, a = q.parse_pptx(r, i, !L(t), L(t) ? BigInt(0) : t, !L(n), L(n) ? BigInt(0) : n);
|
||||
if (a[3]) throw B(a[2]);
|
||||
var o = j(a[0], a[1]).slice();
|
||||
return q.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
||||
}
|
||||
function O(e, t, n) {
|
||||
let r, i;
|
||||
try {
|
||||
let s = R(e, q.__wbindgen_malloc), c = K, l = q.pptx_to_markdown(s, c, !L(t), L(t) ? BigInt(0) : t, !L(n), L(n) ? BigInt(0) : n);
|
||||
var a = l[0], o = l[1];
|
||||
if (l[3]) throw a = 0, o = 0, B(l[2]);
|
||||
return r = a, i = o, P(a, o);
|
||||
} finally {
|
||||
q.__wbindgen_free(r, i, 1);
|
||||
}
|
||||
}
|
||||
function k() {
|
||||
return {
|
||||
__proto__: null,
|
||||
"./pptx_parser_bg.js": {
|
||||
__proto__: null,
|
||||
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
||||
throw Error(P(e, t));
|
||||
},
|
||||
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
||||
let n, r;
|
||||
try {
|
||||
n = e, r = t, console.error(P(e, t));
|
||||
} finally {
|
||||
q.__wbindgen_free(n, r, 1);
|
||||
}
|
||||
},
|
||||
__wbg_new_227d7c05414eb861: function() {
|
||||
return /* @__PURE__ */ Error();
|
||||
},
|
||||
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
||||
let n = t.stack, r = z(n, q.__wbindgen_malloc, q.__wbindgen_realloc), i = K;
|
||||
N().setInt32(e + 4, i, !0), N().setInt32(e + 0, r, !0);
|
||||
},
|
||||
__wbindgen_cast_0000000000000001: function(e, t) {
|
||||
return P(e, t);
|
||||
},
|
||||
__wbindgen_init_externref_table: function() {
|
||||
let e = q.__wbindgen_externrefs, t = e.grow(4);
|
||||
e.set(0, void 0), e.set(t + 0, void 0), e.set(t + 1, null), e.set(t + 2, !0), e.set(t + 3, !1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
var A = typeof FinalizationRegistry > "u" ? {
|
||||
register: () => {},
|
||||
unregister: () => {}
|
||||
} : new FinalizationRegistry((e) => q.__wbg_pptxarchive_free(e >>> 0, 1));
|
||||
function j(e, t) {
|
||||
return e >>>= 0, I().subarray(e / 1, e / 1 + t);
|
||||
}
|
||||
var M = null;
|
||||
function N() {
|
||||
return (M === null || M.buffer.detached === !0 || M.buffer.detached === void 0 && M.buffer !== q.memory.buffer) && (M = new DataView(q.memory.buffer)), M;
|
||||
}
|
||||
function P(e, t) {
|
||||
return e >>>= 0, W(e, t);
|
||||
}
|
||||
var F = null;
|
||||
function I() {
|
||||
return (F === null || F.byteLength === 0) && (F = new Uint8Array(q.memory.buffer)), F;
|
||||
}
|
||||
function L(e) {
|
||||
return e == null;
|
||||
}
|
||||
function R(e, t) {
|
||||
let n = t(e.length * 1, 1) >>> 0;
|
||||
return I().set(e, n / 1), K = e.length, n;
|
||||
}
|
||||
function z(e, t, n) {
|
||||
if (n === void 0) {
|
||||
let n = G.encode(e), r = t(n.length, 1) >>> 0;
|
||||
return I().subarray(r, r + n.length).set(n), K = n.length, r;
|
||||
}
|
||||
let r = e.length, i = t(r, 1) >>> 0, a = I(), o = 0;
|
||||
for (; o < r; o++) {
|
||||
let t = e.charCodeAt(o);
|
||||
if (t > 127) break;
|
||||
a[i + o] = t;
|
||||
}
|
||||
if (o !== r) {
|
||||
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
||||
let t = I().subarray(i + o, i + r), a = G.encodeInto(e, t);
|
||||
o += a.written, i = n(i, r, o, 1) >>> 0;
|
||||
}
|
||||
return K = o, i;
|
||||
}
|
||||
function B(e) {
|
||||
let t = q.__wbindgen_externrefs.get(e);
|
||||
return q.__externref_table_dealloc(e), t;
|
||||
}
|
||||
var V = new TextDecoder("utf-8", {
|
||||
ignoreBOM: !0,
|
||||
fatal: !0
|
||||
});
|
||||
V.decode();
|
||||
var H = 2146435072, U = 0;
|
||||
function W(e, t) {
|
||||
return U += t, U >= H && (V = new TextDecoder("utf-8", {
|
||||
ignoreBOM: !0,
|
||||
fatal: !0
|
||||
}), V.decode(), U = t), V.decode(I().subarray(e, e + t));
|
||||
}
|
||||
var G = new TextEncoder();
|
||||
"encodeInto" in G || (G.encodeInto = function(e, t) {
|
||||
let n = G.encode(e);
|
||||
return t.set(n), {
|
||||
read: e.length,
|
||||
written: n.length
|
||||
};
|
||||
});
|
||||
var K = 0, q;
|
||||
function J(e, t) {
|
||||
return q = e.exports, M = null, F = null, q.__wbindgen_start(), q;
|
||||
}
|
||||
async function le(e, t) {
|
||||
if (typeof Response == "function" && e instanceof Response) {
|
||||
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
||||
return await WebAssembly.instantiateStreaming(e, t);
|
||||
} catch (t) {
|
||||
if (e.ok && n(e.type) && e.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t);
|
||||
else throw t;
|
||||
}
|
||||
let r = await e.arrayBuffer();
|
||||
return await WebAssembly.instantiate(r, t);
|
||||
} else {
|
||||
let n = await WebAssembly.instantiate(e, t);
|
||||
return n instanceof WebAssembly.Instance ? {
|
||||
instance: n,
|
||||
module: e
|
||||
} : n;
|
||||
}
|
||||
function n(e) {
|
||||
switch (e) {
|
||||
case "basic":
|
||||
case "cors":
|
||||
case "default": return !0;
|
||||
}
|
||||
return !1;
|
||||
}
|
||||
}
|
||||
function ue(e) {
|
||||
if (q !== void 0) return q;
|
||||
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
||||
let t = k();
|
||||
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), J(new WebAssembly.Instance(e, t), e);
|
||||
}
|
||||
async function Y(e) {
|
||||
if (q !== void 0) return q;
|
||||
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module_or_path: e} = e : console.warn("using deprecated parameters for the initialization function; pass a single object instead"));
|
||||
let t = k();
|
||||
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
||||
let { instance: n, module: r } = await le(await e, t);
|
||||
return J(n, r);
|
||||
}
|
||||
async function de(e) {
|
||||
return q = void 0, M = null, F = null, Y(e);
|
||||
}
|
||||
//#endregion
|
||||
//#region packages/pptx/src/internal/node-acquisition.ts
|
||||
var X, Z;
|
||||
function fe(e) {
|
||||
if (!Z) X = e, Z = new w(oe, e);
|
||||
else if (X !== e) throw Error("PPTX runtime was already initialized with another WebAssembly.Module");
|
||||
return Z;
|
||||
}
|
||||
async function pe(e, n, i = {}) {
|
||||
let s = r(i), c = new d({
|
||||
enabled: s.debug || s.onResourceMetrics !== void 0,
|
||||
format: "pptx",
|
||||
mode: "node",
|
||||
scope: "session",
|
||||
policy: s.policy,
|
||||
onMetrics: s.onResourceMetrics,
|
||||
emitToConsole: s.debug
|
||||
});
|
||||
c.setSourceBytes(e.byteLength);
|
||||
let l;
|
||||
try {
|
||||
Q(i.signal);
|
||||
let [r, a, u] = o(s.policy), d = T;
|
||||
l = await fe(n).open(() => new d(e, r, a, u), {
|
||||
signal: i.signal,
|
||||
abortError: $,
|
||||
disposeOnAbort: (e) => e.free()
|
||||
}), Q(i.signal);
|
||||
let f = l.proxy, p = t(JSON.parse(new TextDecoder().decode(f.presentation_bootstrap())));
|
||||
return c.checkpoint("presentation bootstrap ready"), {
|
||||
archive: f,
|
||||
bootstrap: p,
|
||||
metrics: c,
|
||||
closeArchive: () => l?.close((e) => e.free())
|
||||
};
|
||||
} catch (e) {
|
||||
try {
|
||||
l?.close((e) => e.free());
|
||||
} catch {}
|
||||
let t = a(e) ?? e;
|
||||
throw c.fail(t), t;
|
||||
}
|
||||
}
|
||||
function Q(e) {
|
||||
if (e?.aborted) throw $();
|
||||
}
|
||||
function $() {
|
||||
let e = /* @__PURE__ */ Error("PPTX presentation session was aborted");
|
||||
return e.name = "AbortError", e;
|
||||
}
|
||||
//#endregion
|
||||
//#region packages/pptx/src/internal/session.ts
|
||||
var me = /* @__PURE__ */ e({ renderSlide: () => n });
|
||||
//#endregion
|
||||
export { x as a, re as i, pe as n, w as r, me as t };
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@wekan/office-open-xml-viewer",
|
||||
"version": "0.85.2-wekan.1",
|
||||
"description": "Minimal browser-only OOXML viewer fork for WeKan attachments",
|
||||
"description": "Minimal OOXML viewer fork for WeKan attachments",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
@@ -9,7 +9,8 @@
|
||||
"exports": {
|
||||
"./docx": "./dist/docx.mjs",
|
||||
"./xlsx": "./dist/xlsx.mjs",
|
||||
"./pptx": "./dist/pptx.mjs"
|
||||
"./pptx": "./dist/pptx.mjs",
|
||||
"./node": "./dist/node.mjs"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "wekan",
|
||||
"version": "v13.41.0",
|
||||
"version": "v13.44.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wekan",
|
||||
"version": "v13.41.0",
|
||||
"version": "v13.44.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -41,7 +41,7 @@
|
||||
"bson": "^7.3.1",
|
||||
"chart.js": "^4.6.2",
|
||||
"dhtmlx-gantt": "^10.0.3",
|
||||
"dompurify": "^3.4.17",
|
||||
"dompurify": "^3.4.18",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"fflate": "^0.8.3",
|
||||
"file-type": "^22.2.0",
|
||||
@@ -7602,9 +7602,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.4.17",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz",
|
||||
"integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==",
|
||||
"version": "3.4.18",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.18.tgz",
|
||||
"integrity": "sha512-ofe3wI/uNm68HInABYFJYqQxRw1EaKAjNdrFVKqjUY+UZurvNd2L/HuQe097s/4RivWiZyP6tT7aoT8atjfhwg==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wekan",
|
||||
"version": "v13.41.0",
|
||||
"version": "v13.44.0",
|
||||
"description": "Open-Source kanban",
|
||||
"private": true,
|
||||
"repository": {
|
||||
@@ -89,7 +89,7 @@
|
||||
"bson": "^7.3.1",
|
||||
"chart.js": "^4.6.2",
|
||||
"dhtmlx-gantt": "^10.0.3",
|
||||
"dompurify": "^3.4.17",
|
||||
"dompurify": "^3.4.18",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"fflate": "^0.8.3",
|
||||
"file-type": "^22.2.0",
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
|
||||
const { workerData, parentPort } = require('node:worker_threads');
|
||||
const { createRequire } = require('node:module');
|
||||
const path = require('node:path');
|
||||
const { pathToFileURL } = require('node:url');
|
||||
|
||||
const { kind, input, rows, edge } = workerData;
|
||||
const load = createRequire(path.join(process.cwd(), 'npm', 'package.json'));
|
||||
const pdfRoot = path.dirname(load.resolve('pdfjs-dist/package.json'));
|
||||
const { createCanvas, loadImage } = createRequire(path.join(pdfRoot, 'package.json'))('@napi-rs/canvas');
|
||||
const sharp = load('sharp');
|
||||
|
||||
const officeOptions = {
|
||||
resourceLimits: { maxArchiveEntryBytes: 16 * 1024 * 1024, maxTotalInflatedBytes: 64 * 1024 * 1024, maxArchiveEntries: 2048 },
|
||||
factory: {
|
||||
createCanvas(width, height) {
|
||||
if (!Number.isFinite(width * height) || width < 1 || height < 1 || width * height > 4_000_000) {
|
||||
throw new Error('Document canvas exceeds the conversion limit');
|
||||
}
|
||||
return createCanvas(width, height);
|
||||
},
|
||||
async loadImage(bytes, target) {
|
||||
let image = sharp(Buffer.from(bytes), { limitInputPixels: 4_000_000, failOn: 'error' });
|
||||
if (target?.width && target?.height) {
|
||||
image = image.resize(Math.min(edge, Math.ceil(target.width)), Math.min(edge, Math.ceil(target.height)),
|
||||
{ fit: 'inside', withoutEnlargement: true });
|
||||
}
|
||||
return loadImage(await image.png().toBuffer());
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async function renderPdf() {
|
||||
const { getDocument, AnnotationMode, VerbosityLevel } = await import(
|
||||
pathToFileURL(load.resolve('pdfjs-dist/legacy/build/pdf.mjs')).href);
|
||||
const local = dir => path.join(pdfRoot, dir) + path.sep;
|
||||
const document = getDocument({
|
||||
data: input, verbosity: VerbosityLevel.ERRORS, useSystemFonts: false, useWorkerFetch: false,
|
||||
cMapUrl: local('cmaps'), cMapPacked: true, standardFontDataUrl: local('standard_fonts'),
|
||||
wasmUrl: local('wasm'), canvasMaxAreaInBytes: 16_000_000, maxImageSize: 16_000_000,
|
||||
});
|
||||
try {
|
||||
const page = await (await document.promise).getPage(1);
|
||||
const original = page.getViewport({ scale: 1 });
|
||||
const viewport = page.getViewport({ scale: edge / Math.max(original.width, original.height) });
|
||||
const canvas = officeOptions.factory.createCanvas(Math.max(1, Math.ceil(viewport.width)),
|
||||
Math.max(1, Math.ceil(viewport.height)));
|
||||
await page.render({ canvas, canvasContext: canvas.getContext('2d'), viewport,
|
||||
annotationMode: AnnotationMode.DISABLE }).promise;
|
||||
return canvas;
|
||||
} finally {
|
||||
await document.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
function drawRows(rows, sheet) {
|
||||
const canvas = createCanvas(edge, sheet ? 320 : edge);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
ctx.font = '17px sans-serif';
|
||||
let y = 16;
|
||||
for (const row of rows) {
|
||||
if (y + 22 > canvas.height) break;
|
||||
const values = sheet ? row.slice(0, 6) : [row.join(' ')];
|
||||
const width = sheet ? 80 : edge - 24;
|
||||
for (let col = 0; col < values.length; col += 1) {
|
||||
const x = 12 + col * width;
|
||||
if (sheet) {
|
||||
ctx.strokeStyle = '#ccd2da';
|
||||
ctx.strokeRect(x, y, width, 22);
|
||||
}
|
||||
ctx.fillStyle = '#202832';
|
||||
ctx.fillText(String(values[col] ?? '').slice(0, 100), x + 3, y + 17, width - 6);
|
||||
}
|
||||
y += 22;
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
|
||||
async function renderOffice() {
|
||||
const { openDocxDocument, openXlsxWorkbook, openPptxPresentation } = await import(
|
||||
pathToFileURL(load.resolve('@wekan/office-open-xml-viewer/node')).href);
|
||||
if (kind === 'docx') {
|
||||
const doc = await openDocxDocument(input, officeOptions);
|
||||
try {
|
||||
const { widthPt, heightPt } = doc.pageSize(0);
|
||||
return await doc.renderPage(0, { width: Math.max(1, Math.floor(edge * widthPt / Math.max(widthPt, heightPt))), dpr: 1 });
|
||||
} finally { await doc.close(); }
|
||||
}
|
||||
if (kind === 'pptx') {
|
||||
const doc = await openPptxPresentation(input, officeOptions);
|
||||
try {
|
||||
const width = Math.max(1, Math.floor(edge * doc.slideWidth / Math.max(doc.slideWidth, doc.slideHeight)));
|
||||
const canvas = createCanvas(1, 1);
|
||||
for await (const slide of doc.slides()) {
|
||||
await doc.renderSlide(canvas, slide, { width, dpr: 1, factory: officeOptions.factory });
|
||||
return canvas;
|
||||
}
|
||||
throw new Error('Presentation has no slides');
|
||||
} finally { await doc.close(); }
|
||||
}
|
||||
const doc = await openXlsxWorkbook(input, officeOptions);
|
||||
try {
|
||||
const grid = [];
|
||||
for await (const chunk of doc.worksheetRows(0)) {
|
||||
if (chunk.kind !== 'rows') break;
|
||||
for (const row of chunk.rows) {
|
||||
if (row.hidden) continue;
|
||||
const cells = Array(6).fill('');
|
||||
for (const { col, value } of row.cells) {
|
||||
if (col < 0 || col >= cells.length) continue;
|
||||
cells[col] = value.text ?? value.number ?? value.bool ?? value.error
|
||||
?? doc.workbookIndex.sharedStrings[value.si]?.text ?? '';
|
||||
}
|
||||
grid.push(cells);
|
||||
if (grid.length === 13) break;
|
||||
}
|
||||
if (grid.length === 13) break;
|
||||
}
|
||||
return drawRows(grid, true);
|
||||
} finally { await doc.close(); }
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let image;
|
||||
if (kind === 'embedded') image = Buffer.from(input);
|
||||
else {
|
||||
const canvas = kind === 'pdf' ? await renderPdf()
|
||||
: rows ? drawRows(rows, kind === 'ods') : await renderOffice();
|
||||
image = canvas.toBuffer('image/png');
|
||||
}
|
||||
const webp = await sharp(image, { limitInputPixels: 4_000_000, failOn: 'error' })
|
||||
.flatten({ background: '#fff' }).resize(edge, edge, { fit: 'inside', withoutEnlargement: true })
|
||||
.webp({ quality: 80 }).toBuffer();
|
||||
parentPort.postMessage(webp);
|
||||
})().catch(error => parentPort.postMessage({ error: error.message }));
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf8" />
|
||||
<title>WeKan REST API v13.41</title>
|
||||
<title>WeKan REST API v13.44</title>
|
||||
<!-- needed for adaptive design -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
@@ -498,11 +498,11 @@ data-styled.g662[id="sc-hFhjrW"]{content:"gelAUe,"}/*!sc*/
|
||||
|
||||
<body>
|
||||
|
||||
<div id="redoc"><div class="sc-dPmKWx eXwHqO redoc light" style="--navbar-height:0px;--navbar-stack-height:0px"><div hidden=""><script>try{var r=document.querySelectorAll(".redoc");r=r[r.length-1];var h=document.documentElement,p=h.classList,a=[h.getAttribute("data-bs-theme"),h.getAttribute("data-theme")];var m=p.contains("dark")||a.indexOf("dark")>-1?"dark":p.contains("light")||a.indexOf("light")>-1?"light":localStorage.getItem("redoc.colorMode");if(m!=="light"&&m!=="dark")m=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";r.classList.remove("light","dark");r.classList.add(m)}catch(e){}</script></div><div class="sc-hHttOM iMkNMJ menu-content"><div class="sc-jokKPH fejYuX"><div data-testid="search-trigger" class="sc-cRcubC kWLWEm"><div class="sc-gzhUzI ejGLvh"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" data-component-name="icons/SearchIcon/SearchIcon" class="sc-bUAICN hRyRtS"><path d="M14.5 13.7931L10.724 10.017C11.6313 8.9277 12.0838 7.5305 11.9872 6.11608C11.8907 4.70165 11.2525 3.37891 10.2055 2.423C9.15857 1.4671 7.78336 0.951637 6.36602 0.983845C4.94867 1.01605 3.5983 1.59345 2.59582 2.59593C1.59335 3.5984 1.01595 4.94877 0.983738 6.36612C0.95153 7.78347 1.46699 9.15867 2.4229 10.2057C3.3788 11.2526 4.70155 11.8908 6.11597 11.9873C7.53039 12.0839 8.92759 11.6314 10.0169 10.7241L13.793 14.5001L14.5 13.7931ZM2.00001 6.50012C2.00001 5.6101 2.26393 4.74007 2.7584 4.00005C3.25286 3.26003 3.95567 2.68325 4.77794 2.34266C5.6002 2.00207 6.505 1.91295 7.37792 2.08658C8.25083 2.26022 9.05266 2.6888 9.68199 3.31814C10.3113 3.94747 10.7399 4.7493 10.9135 5.62221C11.0872 6.49513 10.9981 7.39993 10.6575 8.22219C10.3169 9.04446 9.7401 9.74726 9.00008 10.2417C8.26006 10.7362 7.39003 11.0001 6.50001 11.0001C5.30694 10.9988 4.16312 10.5243 3.31949 9.68064C2.47587 8.83701 2.00133 7.69319 2.00001 6.50012Z"></path></svg><span>Loading...</span></div></div></div><div class="sc-gpABuY dGxToZ"><ul data-component-name="Menu/Menu" class="sc-llaQDn gIDdEs"><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-default" role="listitem"><a class="sc-bcyEQV eSomNa" href="/" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="true" class="sc-iMaYoB kYPxgQ"><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="WeKan REST API" class="sc-cKRyZE edpvXG">WeKan REST API</span></span></div></li></a></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-default" role="listitem"><a class="sc-bcyEQV eSomNa" href="/section/production-security-concerns" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB dpiTia"><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="Production Security Concerns" class="sc-cKRyZE cXpWdQ">Production Security Concerns</span></span></div></li></a></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/login" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-default" data-component-name="icons/ChevronRightIcon/ChevronRightIcon" class="sc-hiunUN kPiUFd"><path d="M11 8L6.00002 13L5.30002 12.3L9.60002 8L5.30002 3.7L6.00002 3L11 8Z"></path></svg></div><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="Login" class="sc-cKRyZE cXpWdQ">Login</span></span></div></li></a><div style="display:none;height:0px;overflow:hidden" class="sc-boLXHU DecdG"></div></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/attachmentstoragesettings" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-default" data-component-name="icons/ChevronRightIcon/ChevronRightIcon" class="sc-hiunUN kPiUFd"><path d="M11 8L6.00002 13L5.30002 12.3L9.60002 8L5.30002 3.7L6.00002 3L11 8Z"></path></svg></div><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="AttachmentStorageSettings" class="sc-cKRyZE cXpWdQ">AttachmentStorageSettings</span></span></div></li></a><div style="display:none;height:0px;overflow:hidden" class="sc-boLXHU DecdG"></div></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/settings" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-Line truncated
|
||||
<div id="redoc"><div class="sc-dPmKWx eXwHqO redoc light" style="--navbar-height:0px;--navbar-stack-height:0px"><div hidden=""><script>try{var r=document.querySelectorAll(".redoc");r=r[r.length-1];var h=document.documentElement,p=h.classList,a=[h.getAttribute("data-bs-theme"),h.getAttribute("data-theme")];var m=p.contains("dark")||a.indexOf("dark")>-1?"dark":p.contains("light")||a.indexOf("light")>-1?"light":localStorage.getItem("redoc.colorMode");if(m!=="light"&&m!=="dark")m=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";r.classList.remove("light","dark");r.classList.add(m)}catch(e){}</script></div><div class="sc-hHttOM iMkNMJ menu-content"><div class="sc-jokKPH fejYuX"><div data-testid="search-trigger" class="sc-cRcubC kWLWEm"><div class="sc-gzhUzI ejGLvh"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" data-component-name="icons/SearchIcon/SearchIcon" class="sc-bUAICN hRyRtS"><path d="M14.5 13.7931L10.724 10.017C11.6313 8.9277 12.0838 7.5305 11.9872 6.11608C11.8907 4.70165 11.2525 3.37891 10.2055 2.423C9.15857 1.4671 7.78336 0.951637 6.36602 0.983845C4.94867 1.01605 3.5983 1.59345 2.59582 2.59593C1.59335 3.5984 1.01595 4.94877 0.983738 6.36612C0.95153 7.78347 1.46699 9.15867 2.4229 10.2057C3.3788 11.2526 4.70155 11.8908 6.11597 11.9873C7.53039 12.0839 8.92759 11.6314 10.0169 10.7241L13.793 14.5001L14.5 13.7931ZM2.00001 6.50012C2.00001 5.6101 2.26393 4.74007 2.7584 4.00005C3.25286 3.26003 3.95567 2.68325 4.77794 2.34266C5.6002 2.00207 6.505 1.91295 7.37792 2.08658C8.25083 2.26022 9.05266 2.6888 9.68199 3.31814C10.3113 3.94747 10.7399 4.7493 10.9135 5.62221C11.0872 6.49513 10.9981 7.39993 10.6575 8.22219C10.3169 9.04446 9.7401 9.74726 9.00008 10.2417C8.26006 10.7362 7.39003 11.0001 6.50001 11.0001C5.30694 10.9988 4.16312 10.5243 3.31949 9.68064C2.47587 8.83701 2.00133 7.69319 2.00001 6.50012Z"></path></svg><span>Loading...</span></div></div></div><div class="sc-gpABuY dGxToZ"><ul data-component-name="Menu/Menu" class="sc-llaQDn gIDdEs"><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-default" role="listitem"><a class="sc-bcyEQV eSomNa" href="/" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="true" class="sc-iMaYoB kYPxgQ"><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="WeKan REST API" class="sc-cKRyZE edpvXG">WeKan REST API</span></span></div></li></a></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-default" role="listitem"><a class="sc-bcyEQV eSomNa" href="/section/production-security-concerns" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB dpiTia"><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="Production Security Concerns" class="sc-cKRyZE cXpWdQ">Production Security Concerns</span></span></div></li></a></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/login" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-default" data-component-name="icons/ChevronRightIcon/ChevronRightIcon" class="sc-hiunUN kPiUFd"><path d="M11 8L6.00002 13L5.30002 12.3L9.60002 8L5.30002 3.7L6.00002 3L11 8Z"></path></svg></div><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="Login" class="sc-cKRyZE cXpWdQ">Login</span></span></div></li></a><div style="display:none;height:0px;overflow:hidden" class="sc-boLXHU DecdG"></div></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/attachmentstoragesettings" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-default" data-component-name="icons/ChevronRightIcon/ChevronRightIcon" class="sc-hiunUN kPiUFd"><path d="M11 8L6.00002 13L5.30002 12.3L9.60002 8L5.30002 3.7L6.00002 3L11 8Z"></path></svg></div><div class="sc-bmzNle dAAsRD"><span class="sc-amuuf fiYZDR"><span data-text="AttachmentStorageSettings" class="sc-cKRyZE cXpWdQ">AttachmentStorageSettings</span></span></div></li></a><div style="display:none;height:0px;overflow:hidden" class="sc-boLXHU DecdG"></div></div><div data-component-name="Menu/MenuItem" class="sc-epufQc jNyRbY menu-item-type-group" role="listitem"><a class="sc-bcyEQV eSomNa" href="/settings" data-discover="true"><li role="none" data-testid="menu-item-label" data-active="false" class="sc-iMaYoB buxibf"><div class="sc-hgJgCR fyVeNP"><svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" color="--tree-content-color-Line truncated
|
||||
<script type="module">
|
||||
import { hydrate } from "https://cdn.redocly.com/redoc/v3.2.0/bundles/redoc.standalone.js";
|
||||
|
||||
const __redoc_definition = {"openapi":"3.2.0","info":{"title":"WeKan REST API","version":"v13.41","description":"The REST API allows you to control and extend WeKan with ease.\n\nIf you are an end-user and not a dev or a tester, [create an issue](https://github.com/wekan/wekan/issues/new) to request new APIs.\n\n> All API calls in the documentation are made using `curl`. However, you are free to use Java / Python / PHP / Golang / Ruby / Swift / Objective-C / Rust / Scala / C# or any other programming languages.\n\n# Production Security Concerns\nWhen calling a production WeKan server, ensure it is running via HTTPS and has a valid SSL Certificate. The login method requires you to post your username and password in plaintext, which is why we highly suggest only calling the REST login api over HTTPS. Also, few things to note:\n\n* Only call via HTTPS\n* Implement a timed authorization token expiration strategy\n* Ensure the calling user only has permissions for what they are calling and no more\n"},"paths":{"/users/login":{"post":{"operationId":"login","summary":"Login with REST API","tags":["Login"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["username","password"],"properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"}}}},"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["username","password"],"properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"}}}}},"description":"Login credentials","required":true},"responses":{"200":{"description":"Successful authentication","content":{"*/*":{"schema":{"type":"object","required":["id","token","tokenExpires"],"properties":{"id":{"type":"string","description":"User ID"},"token":{"type":"string","description":"Authentication token\n"},"tokenExpires":{"type":"string","format":"date-time","description":"Token expiration date\n"}}}}}},"400":{"description":"Error in authentication\n","content":{"*/*":{"schema":{"type":"object","properties":{"error":{"type":"string"},"reason":{"type":"string"}}}}}},"default":{"description":"Error in authentication\n"}}}},"/users/register":{"post":{"operationId":"register","summary":"Register with REST API","description":"Notes:\n - You will need to provide the token for any of the authenticated methods.\n","tags":["Login"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"},"email":{"description":"Your email\n","type":"string"}},"required":["username","password","email"]}}},"required":true},"responses":{"200":{"description":"Successful registration","content":{"*/*":{"schema":{"items":{"properties":{"id":{"type":"string"},"token":{"type":"string"},"tokenExpires":{"type":"string"}}}}}}},"400":{"description":"Error in registration\n","content":{"*/*":{"schema":{"items":{"properties":{"error":{"type":"number"},"reason":{"type":"string"}}}}}}},"default":{"description":"Error in registration\n"}}}},"/api/admin/attachment-settings":{"get":{"operationId":"get_attachment_settings","summary":"Get the attachment storage / upload-block settings (GlobalAdmin)","description":"Only the global admin can call this. Returns the Admin Panel >\n Attachments settings document, including `limitSettings.attachmentsUploadBlocked`\n and `limitSettings.avatarsUploadBlocked` plus the size limits. Cloud-storage\n secret keys (S3 secretAccessKey, Azure accountKey/connectionString, GCS\n credentials) are masked and never returned; a boolean `\u003cfield>Set` marker\n shows whether a value exists.\n","tags":["AttachmentStorageSettings","Settings"],"security":[{"UserSecurity":[]}],"responses":{"200":{"description":"200 response","content":{"application/json":{"schema":{"type":"Object"}}}}}},"put":{"operationId":"update_attachment_settings","summary":"Update the attachment storage / upload-block settings (GlobalAdmin)","description":"Only the global admin can call this. The request body is a\n partial settings object (for example\n `{\"limitSettings\": {\"avatarsUploadBlocked\": true}}`). It is applied through\n the same update path as the `updateAttachmentStorageSettings` Meteor method,\n so validation and `$set` semantics are identical: cloud-storage secrets left\n blank are preserved. The masked, updated settings document is returned.\n","tags":["AttachmentStorageSettings","Settings"],"security":[{"UserSecurity":[]}],"responses":{"200":{"description":"200 response","content":{"application/json":{"schema":{"type":"Object"}}}}}}},"/api/admin/domains":{"get":{"operationId":"get_admin_domains","summary":"List email domains with their user counts (GlobalAdmin)","description":"Only the global admin can call this. CountsLine truncated
|
||||
const __redoc_definition = {"openapi":"3.2.0","info":{"title":"WeKan REST API","version":"v13.44","description":"The REST API allows you to control and extend WeKan with ease.\n\nIf you are an end-user and not a dev or a tester, [create an issue](https://github.com/wekan/wekan/issues/new) to request new APIs.\n\n> All API calls in the documentation are made using `curl`. However, you are free to use Java / Python / PHP / Golang / Ruby / Swift / Objective-C / Rust / Scala / C# or any other programming languages.\n\n# Production Security Concerns\nWhen calling a production WeKan server, ensure it is running via HTTPS and has a valid SSL Certificate. The login method requires you to post your username and password in plaintext, which is why we highly suggest only calling the REST login api over HTTPS. Also, few things to note:\n\n* Only call via HTTPS\n* Implement a timed authorization token expiration strategy\n* Ensure the calling user only has permissions for what they are calling and no more\n"},"paths":{"/users/login":{"post":{"operationId":"login","summary":"Login with REST API","tags":["Login"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["username","password"],"properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"}}}},"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["username","password"],"properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"}}}}},"description":"Login credentials","required":true},"responses":{"200":{"description":"Successful authentication","content":{"*/*":{"schema":{"type":"object","required":["id","token","tokenExpires"],"properties":{"id":{"type":"string","description":"User ID"},"token":{"type":"string","description":"Authentication token\n"},"tokenExpires":{"type":"string","format":"date-time","description":"Token expiration date\n"}}}}}},"400":{"description":"Error in authentication\n","content":{"*/*":{"schema":{"type":"object","properties":{"error":{"type":"string"},"reason":{"type":"string"}}}}}},"default":{"description":"Error in authentication\n"}}}},"/users/register":{"post":{"operationId":"register","summary":"Register with REST API","description":"Notes:\n - You will need to provide the token for any of the authenticated methods.\n","tags":["Login"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"username":{"description":"Your username\n","type":"string"},"password":{"description":"Your password\n","type":"string","format":"password"},"email":{"description":"Your email\n","type":"string"}},"required":["username","password","email"]}}},"required":true},"responses":{"200":{"description":"Successful registration","content":{"*/*":{"schema":{"items":{"properties":{"id":{"type":"string"},"token":{"type":"string"},"tokenExpires":{"type":"string"}}}}}}},"400":{"description":"Error in registration\n","content":{"*/*":{"schema":{"items":{"properties":{"error":{"type":"number"},"reason":{"type":"string"}}}}}}},"default":{"description":"Error in registration\n"}}}},"/api/admin/attachment-settings":{"get":{"operationId":"get_attachment_settings","summary":"Get the attachment storage / upload-block settings (GlobalAdmin)","description":"Only the global admin can call this. Returns the Admin Panel >\n Attachments settings document, including `limitSettings.attachmentsUploadBlocked`\n and `limitSettings.avatarsUploadBlocked` plus the size limits. Cloud-storage\n secret keys (S3 secretAccessKey, Azure accountKey/connectionString, GCS\n credentials) are masked and never returned; a boolean `\u003cfield>Set` marker\n shows whether a value exists.\n","tags":["AttachmentStorageSettings","Settings"],"security":[{"UserSecurity":[]}],"responses":{"200":{"description":"200 response","content":{"application/json":{"schema":{"type":"Object"}}}}}},"put":{"operationId":"update_attachment_settings","summary":"Update the attachment storage / upload-block settings (GlobalAdmin)","description":"Only the global admin can call this. The request body is a\n partial settings object (for example\n `{\"limitSettings\": {\"avatarsUploadBlocked\": true}}`). It is applied through\n the same update path as the `updateAttachmentStorageSettings` Meteor method,\n so validation and `$set` semantics are identical: cloud-storage secrets left\n blank are preserved. The masked, updated settings document is returned.\n","tags":["AttachmentStorageSettings","Settings"],"security":[{"UserSecurity":[]}],"responses":{"200":{"description":"200 response","content":{"application/json":{"schema":{"type":"Object"}}}}}}},"/api/admin/domains":{"get":{"operationId":"get_admin_domains","summary":"List email domains with their user counts (GlobalAdmin)","description":"Only the global admin can call this. CountsLine truncated
|
||||
const __redoc_options = {"skipBundle":true,"disableTelemetry":false};
|
||||
|
||||
hydrate(__redoc_definition, __redoc_options, document.getElementById('redoc'));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
swagger: '2.0'
|
||||
info:
|
||||
title: WeKan REST API
|
||||
version: v13.41
|
||||
version: v13.44
|
||||
description: |
|
||||
The REST API allows you to control and extend WeKan with ease.
|
||||
|
||||
@@ -2490,6 +2490,14 @@ paths:
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
'409':
|
||||
description: |-
|
||||
The domain changed during removal.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
/api/boards/{board}/export:
|
||||
get:
|
||||
operationId: exportJson
|
||||
|
||||
@@ -90,11 +90,9 @@ const POLICY = [
|
||||
dir === join(NPM, 'meteor', name, 'node_modules', 'core-js')),
|
||||
},
|
||||
{
|
||||
why: 'browser-only build inputs. Blockly and the Office viewer are imported '
|
||||
+ 'only by client code; meteor-node-stubs supplies browser polyfills. '
|
||||
+ 'Their compiled browser chunks ship separately in programs/web.browser.',
|
||||
test: dir => ['blockly', 'meteor-node-stubs'].includes(basename(dir))
|
||||
|| (basename(dir) === 'office-open-xml-viewer' && basename(dirname(dir)) === '@wekan'),
|
||||
why: 'Blockly and meteor-node-stubs compile into browser chunks. '
|
||||
+ 'The Office package also contains the Node document thumbnail renderer.',
|
||||
test: dir => ['blockly', 'meteor-node-stubs'].includes(basename(dir)),
|
||||
},
|
||||
{
|
||||
why: 'a TypeScript compiler. A devDependency of 196 packages in this tree '
|
||||
|
||||
@@ -22,10 +22,10 @@ const pkgdef :Spk.PackageDefinition = (
|
||||
appTitle = (defaultText = "Wekan"),
|
||||
# The name of the app as it is displayed to the user.
|
||||
|
||||
appVersion = 1341,
|
||||
appVersion = 1344,
|
||||
# Increment this for every release.
|
||||
|
||||
appMarketingVersion = (defaultText = "13.41~2026-12-03"),
|
||||
appMarketingVersion = (defaultText = "13.44~2026-12-04"),
|
||||
# Human-readable presentation of the app version.
|
||||
|
||||
minUpgradableAppVersion = 0,
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { inflateRawSync } from 'node:zlib';
|
||||
import { Worker } from 'node:worker_threads';
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { ZipDirectory } from '../../models/lib/zipDirectory.js';
|
||||
import { OdfBlocks } from '../../models/lib/odfBlocks.js';
|
||||
import thumbnailRules from '../../models/lib/attachmentThumbnail.js';
|
||||
import previewStore from './attachmentPreviewStore.js';
|
||||
import { boundedStreamBuffer } from './imageGif.js';
|
||||
|
||||
const { THUMBNAIL_EDGE } = thumbnailRules;
|
||||
export const DOCUMENT_MAX_BYTES = 16 * 1024 * 1024;
|
||||
const ODF_PART_BYTES = 1024 * 1024;
|
||||
const MAX_PENDING = 24;
|
||||
const MAX_RUNNING = 2;
|
||||
const RENDER_TIMEOUT_MS = 15_000;
|
||||
const MAX_ROWS = 20;
|
||||
const building = new Map();
|
||||
const waiting = [];
|
||||
let active = 0;
|
||||
|
||||
async function odfInput(kind, data) {
|
||||
const zip = await new ZipDirectory({ size: data.length, bytes: (a, b) => data.subarray(a, b) }).open();
|
||||
if (zip.count > 2048) throw new Error('OpenDocument archive has too many entries');
|
||||
let content;
|
||||
for await (const entry of zip.entries()) {
|
||||
if (!['Thumbnails/thumbnail.png', 'content.xml'].includes(entry.name)
|
||||
|| entry.size > ODF_PART_BYTES || entry.compressedSize > ODF_PART_BYTES) continue;
|
||||
const start = await zip.dataStart(entry);
|
||||
const raw = data.subarray(start, start + entry.compressedSize);
|
||||
if (raw.length !== entry.compressedSize) continue;
|
||||
const bytes = entry.method === 0 ? raw
|
||||
: entry.method === 8 ? inflateRawSync(raw, { maxOutputLength: ODF_PART_BYTES }) : null;
|
||||
if (!bytes || bytes.length !== entry.size) continue;
|
||||
if (entry.name === 'Thumbnails/thumbnail.png'
|
||||
&& bytes.subarray(0, 8).equals(Buffer.from('89504e470d0a1a0a', 'hex'))) {
|
||||
return { kind: 'embedded', input: bytes };
|
||||
}
|
||||
if (entry.name === 'content.xml') content = bytes;
|
||||
}
|
||||
if (!content) throw new Error('OpenDocument has no readable first page');
|
||||
|
||||
const blocks = new OdfBlocks();
|
||||
const rows = [];
|
||||
let pages = 0;
|
||||
let stopped = false;
|
||||
const parser = new Parser({
|
||||
onopentag(name, attrs) {
|
||||
if (blocks.scopes.length >= 128) throw new Error('OpenDocument XML is too deeply nested');
|
||||
blocks.open(name, attrs);
|
||||
},
|
||||
ontext: text => blocks.addText(text),
|
||||
onclosetag(name) {
|
||||
blocks.close(name);
|
||||
for (let block = blocks.take(); block && rows.length < MAX_ROWS; block = blocks.take()) {
|
||||
if (block.kind === 'page') {
|
||||
pages += 1;
|
||||
if (kind !== 'odt' && pages > 1) stopped = true;
|
||||
} else if (block.kind === 'row') {
|
||||
rows.push(block.cells.slice(0, 6).map(text => text.slice(0, 100)));
|
||||
} else {
|
||||
rows.push([block.text.slice(0, 100)]);
|
||||
}
|
||||
if (stopped || rows.length === MAX_ROWS) break;
|
||||
}
|
||||
if (stopped || rows.length === MAX_ROWS) parser.pause();
|
||||
},
|
||||
}, { xmlMode: true, decodeEntities: true });
|
||||
parser.end(content.toString('utf8'));
|
||||
return { kind, rows };
|
||||
}
|
||||
|
||||
export async function renderDocumentThumbnail(kind, data, workerSource) {
|
||||
if (!Buffer.isBuffer(data) || data.length === 0 || data.length > DOCUMENT_MAX_BYTES) {
|
||||
throw new Error('Document exceeds the thumbnail conversion limit');
|
||||
}
|
||||
const parameters = ['odt', 'ods', 'odp'].includes(kind)
|
||||
? await odfInput(kind, data) : { kind, input: data };
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker(workerSource, {
|
||||
eval: true,
|
||||
execArgv: [],
|
||||
workerData: { ...parameters, edge: THUMBNAIL_EDGE },
|
||||
resourceLimits: { maxOldGenerationSizeMb: 128 },
|
||||
});
|
||||
const timer = setTimeout(() => {
|
||||
reject(new Error('Document thumbnail timed out'));
|
||||
void worker.terminate();
|
||||
}, RENDER_TIMEOUT_MS);
|
||||
worker.once('message', message => {
|
||||
clearTimeout(timer);
|
||||
if (message.error) reject(new Error(message.error));
|
||||
else resolve(Buffer.from(message));
|
||||
});
|
||||
worker.once('error', error => {
|
||||
clearTimeout(timer);
|
||||
reject(error);
|
||||
});
|
||||
worker.once('exit', code => {
|
||||
clearTimeout(timer);
|
||||
reject(new Error(`Document renderer exited before returning a thumbnail (${code})`));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function getDocumentThumbnail(attachment, key, kind, openStream, loadWorker) {
|
||||
const id = String(attachment._id).replace(/[^\w-]/g, '');
|
||||
const dir = previewStore.previewRoot();
|
||||
const file = path.join(dir, `${id}.thumb-v1-${key}.webp`);
|
||||
try {
|
||||
return await fs.readFile(file);
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT') throw error;
|
||||
}
|
||||
if (building.has(file)) return building.get(file);
|
||||
if (building.size >= MAX_PENDING) throw new Error('Document thumbnail queue is full');
|
||||
// Reserve the slot before yielding. On completion hand it directly to the
|
||||
// next waiter, so a new request cannot claim the same slot.
|
||||
const slot = active < MAX_RUNNING ? (active += 1, Promise.resolve())
|
||||
: new Promise(resolve => waiting.push(resolve));
|
||||
const result = (async () => {
|
||||
await slot;
|
||||
try {
|
||||
const source = await loadWorker();
|
||||
const contents = await boundedStreamBuffer(await openStream(), DOCUMENT_MAX_BYTES);
|
||||
const image = await renderDocumentThumbnail(kind, contents, source);
|
||||
// The file shares the attachment preview directory and deletion hook.
|
||||
const temp = `${file}.${process.pid}.tmp`;
|
||||
try {
|
||||
await fs.mkdir(dir, { recursive: true, mode: 0o700 });
|
||||
await fs.writeFile(temp, image, { mode: 0o600 });
|
||||
await fs.rename(temp, file);
|
||||
} catch (error) {
|
||||
await fs.rm(temp, { force: true }).catch(() => {});
|
||||
// Some installations provide read-only preview storage. The response
|
||||
// can still use the in-memory cache even if the derived file is absent.
|
||||
}
|
||||
return image;
|
||||
} finally {
|
||||
building.delete(file);
|
||||
const next = waiting.shift();
|
||||
if (next) next();
|
||||
else active -= 1;
|
||||
}
|
||||
})();
|
||||
building.set(file, result);
|
||||
return result;
|
||||
}
|
||||
+26
-11
@@ -1878,13 +1878,18 @@ WebApp.handlers.post('/api/boards/:boardId/domains', async function(req, res) {
|
||||
sendJsonResult(res, { code: 400, data: { error: `Invalid domain: ${rawDomain}` } });
|
||||
return;
|
||||
}
|
||||
const domains = (authBoard.domains || []).slice();
|
||||
if (!domains.some(d => d.domain === domain)) {
|
||||
domains.push({ domain, isActive: true });
|
||||
if (authBoard.domains === null) {
|
||||
await Boards.updateAsync({ _id: boardId, domains: null }, { $set: { domains: [] } });
|
||||
}
|
||||
// Reuse the existing setBoardDomains method (same auth + validation).
|
||||
await Meteor.callAsync('setBoardDomains', domains, boardId);
|
||||
await Boards.updateAsync(
|
||||
{ _id: boardId, $nor: [{ 'domains.domain': domain }] },
|
||||
{ $push: { domains: { domain, isActive: true } } },
|
||||
);
|
||||
const updated = await ReactiveCache.getBoard(boardId);
|
||||
if (!updated) {
|
||||
sendJsonResult(res, { code: 404, data: { error: 'Board not found' } });
|
||||
return;
|
||||
}
|
||||
sendJsonResult(res, { code: 200, data: updated.domains || [] });
|
||||
} catch (error) {
|
||||
sendJsonResult(res, publicErrorData(error));
|
||||
@@ -1905,6 +1910,7 @@ WebApp.handlers.post('/api/boards/:boardId/domains', async function(req, res) {
|
||||
* @param {string} domain the email domain to remove, e.g. "example.com"
|
||||
* @return_type [{domain: string, isActive: boolean}]
|
||||
* @response 404 {error: string} The board does not have that domain.
|
||||
* @response 409 {error: string} The domain changed during removal.
|
||||
*/
|
||||
WebApp.handlers.delete('/api/boards/:boardId/domains/:domain', async function(req, res) {
|
||||
try {
|
||||
@@ -1927,16 +1933,25 @@ WebApp.handlers.delete('/api/boards/:boardId/domains/:domain', async function(re
|
||||
return;
|
||||
}
|
||||
const normalized = String(req.params.domain || '').trim().toLowerCase();
|
||||
const filtered = (authBoard.domains || []).filter(d => d.domain !== normalized);
|
||||
// A domain the board does not have is 404, not a 200 for a removal that
|
||||
// removed nothing.
|
||||
if (filtered.length === (authBoard.domains || []).length) {
|
||||
const entries = (authBoard.domains || []).filter(entry => entry.domain === normalized);
|
||||
if (!entries.length) {
|
||||
sendJsonResult(res, { code: 404, data: { error: 'Domain not found' } });
|
||||
return;
|
||||
}
|
||||
// Reuse the existing setBoardDomains method (same auth + validation).
|
||||
await Meteor.callAsync('setBoardDomains', filtered, boardId);
|
||||
// Older FerretDB versions require the complete embedded documents to remove them.
|
||||
const removed = await Boards.updateAsync(
|
||||
{ _id: boardId, domains: { $all: entries } },
|
||||
{ $pullAll: { domains: entries } },
|
||||
);
|
||||
const updated = await ReactiveCache.getBoard(boardId);
|
||||
if (!removed) {
|
||||
if (!updated?.domains?.some(entry => entry.domain === normalized)) {
|
||||
sendJsonResult(res, { code: 404, data: { error: 'Domain not found' } });
|
||||
} else {
|
||||
sendJsonResult(res, { code: 409, data: { error: 'Domain changed during removal' } });
|
||||
}
|
||||
return;
|
||||
}
|
||||
sendJsonResult(res, { code: 200, data: updated.domains || [] });
|
||||
} catch (error) {
|
||||
sendJsonResult(res, publicErrorData(error));
|
||||
|
||||
@@ -1866,6 +1866,10 @@ WebApp.handlers.post(
|
||||
results.push({ index: i, error: 'authorId not found' });
|
||||
continue;
|
||||
}
|
||||
if (input.parentId !== undefined && input.parentId !== null && typeof input.parentId !== 'string') {
|
||||
results.push({ index: i, error: 'Invalid parentId' });
|
||||
continue;
|
||||
}
|
||||
// ParentBleed, bulk sibling: the parent check the single create makes.
|
||||
// Cards.direct skips the DDP deny rule, so this is the only guard here.
|
||||
try {
|
||||
|
||||
@@ -26,7 +26,8 @@ import path from 'path';
|
||||
import { DocumentPreviews, indexDocumentText } from '/server/lib/documentGif';
|
||||
import { boundedStreamBuffer, gifCacheKey } from '/server/lib/imageGif';
|
||||
import { convertImageBufferToThumbnail, cachedThumbnail, rememberThumbnail } from '/server/lib/imageThumbnail';
|
||||
const { isThumbnailPath, canThumbnail, THUMBNAIL_TYPE } = require('/models/lib/attachmentThumbnail');
|
||||
import { DOCUMENT_MAX_BYTES, getDocumentThumbnail } from '/server/lib/documentThumbnail';
|
||||
const { isThumbnailPath, canThumbnail, documentThumbnailKind, THUMBNAIL_TYPE } = require('/models/lib/attachmentThumbnail');
|
||||
const { previewPartOf } = require('/models/lib/attachmentPreviewPath');
|
||||
// CacheBleed (GHSA-w3qg-pf27-g68r): files are served after an access check, so never shared-cacheable.
|
||||
const { setPrivateFileCacheHeaders, privateFileCacheHeaders } = require('/models/lib/fileCacheHeaders');
|
||||
@@ -719,7 +720,8 @@ function sendThumbnail(req, res, attachment, key, buffer) {
|
||||
// already been applied, so a thumbnail is readable exactly when the
|
||||
// original is.
|
||||
const wantsThumbnail = isThumbnailPath((req.url || '').replace(/^\/cdn\/storage\/attachments(?=\/)/, ''));
|
||||
if (wantsThumbnail && !canThumbnail(attachment)) {
|
||||
const documentKind = wantsThumbnail && documentThumbnailKind(attachment);
|
||||
if (wantsThumbnail && !documentKind && !canThumbnail(attachment)) {
|
||||
res.writeHead(404);
|
||||
res.end('No thumbnail for this attachment');
|
||||
return;
|
||||
@@ -731,6 +733,23 @@ function sendThumbnail(req, res, attachment, key, buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (documentKind) {
|
||||
try {
|
||||
if (Number(attachment.size) > DOCUMENT_MAX_BYTES) throw new Error('Document is too large');
|
||||
const openStream = () => attachment.meta?.source === 'legacy'
|
||||
? getOldAttachmentStream(fileId)
|
||||
: attachmentStoreFactory.getFileStrategy(attachment, 'original').getReadStream();
|
||||
const thumbnail = await getDocumentThumbnail(attachment, thumbnailKey, documentKind, openStream,
|
||||
() => Assets.getTextAsync('document-thumbnail-worker.cjs'));
|
||||
rememberThumbnail(thumbnailKey, thumbnail);
|
||||
sendThumbnail(req, res, attachment, thumbnailKey, thumbnail);
|
||||
} catch (error) {
|
||||
res.writeHead(404, { 'Cache-Control': 'no-store' });
|
||||
res.end('No thumbnail for this document');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// #6745: a Range request (a video seek, a resumed download) streams only
|
||||
// the bytes asked for, from the storage backend itself. Legacy
|
||||
// CollectionFS files and thumbnails are always sent whole.
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@
|
||||
# base: core24 (not core26) · no build-base: devel · grade: stable
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
name: wekan
|
||||
version: '13.41'
|
||||
version: '13.44'
|
||||
base: core24
|
||||
confinement: strict
|
||||
grade: stable
|
||||
@@ -703,18 +703,18 @@ parts:
|
||||
armhf) WEKAN_ARCH="armhf" ;;
|
||||
*) echo "Unsupported architecture: ${CRAFT_ARCH_BUILD_FOR}"; exit 1 ;;
|
||||
esac
|
||||
WEKAN_ZIP="wekan-13.41-${WEKAN_ARCH}.zip"
|
||||
WEKAN_ZIP="wekan-13.44-${WEKAN_ARCH}.zip"
|
||||
echo "Cleaning environment first"
|
||||
rm -rf .build
|
||||
mkdir .build
|
||||
cd .build
|
||||
#wget https://github.com/wekan/wekan/releases/download/v13.41/wekan-13.41-amd64.zip
|
||||
#wget https://github.com/wekan/wekan/releases/download/v13.44/wekan-13.44-amd64.zip
|
||||
# Retry: a release asset can 404 for a short while right after it is
|
||||
# uploaded (CDN/propagation lag), and a plain wget treated that as
|
||||
# fatal. --retry-on-http-error covers the 404/5xx window; a genuinely
|
||||
# missing bundle still fails after the tries are spent.
|
||||
wget --tries=20 --waitretry=20 --retry-on-http-error=404,403,500,502,503 \
|
||||
"https://github.com/wekan/wekan/releases/download/v13.41/${WEKAN_ZIP}"
|
||||
"https://github.com/wekan/wekan/releases/download/v13.44/${WEKAN_ZIP}"
|
||||
unzip "${WEKAN_ZIP}"
|
||||
python3 ../releases/check-telemetry.py --bundle bundle
|
||||
rm "${WEKAN_ZIP}"
|
||||
|
||||
@@ -7,7 +7,7 @@ const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const sharp = require('sharp');
|
||||
const { isThumbnailPath, canThumbnail, thumbnailUrl, THUMBNAIL_EDGE } = require('../models/lib/attachmentThumbnail.js');
|
||||
const { isThumbnailPath, canThumbnail, documentThumbnailKind, thumbnailUrl, THUMBNAIL_EDGE } = require('../models/lib/attachmentThumbnail.js');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
const read = file => fs.readFileSync(path.join(ROOT, file), 'utf8');
|
||||
@@ -38,6 +38,11 @@ async function main() {
|
||||
assert.equal(thumbnailUrl(''), '');
|
||||
console.log(' ok - thumbnail paths and eligible files');
|
||||
|
||||
assert.equal(documentThumbnailKind({ type: 'application/pdf' }), 'pdf');
|
||||
assert.equal(documentThumbnailKind({ name: 'Report.DOCX', type: 'application/zip' }), 'docx');
|
||||
assert.equal(documentThumbnailKind({ name: 'report.pdf', type: 'text/html' }), null);
|
||||
assert.equal(documentThumbnailKind({ name: 'report.doc' }), null);
|
||||
|
||||
// Conversion: a WebP no larger than THUMBNAIL_EDGE, never enlarged.
|
||||
const lib = await loadImageLib();
|
||||
const big = await sharp({ create: { width: 3000, height: 1000, channels: 3, background: '#224488' } }).jpeg().toBuffer();
|
||||
@@ -52,6 +57,74 @@ async function main() {
|
||||
}
|
||||
console.log(' ok - conversion makes a bounded WebP and refuses non-images');
|
||||
|
||||
const { renderDocumentThumbnail, DOCUMENT_MAX_BYTES } = await import('../server/lib/documentThumbnail.js');
|
||||
const source = read('private/document-thumbnail-worker.cjs');
|
||||
const PDFDocument = require('pdfkit');
|
||||
const pdf = await new Promise((resolve, reject) => {
|
||||
const doc = new PDFDocument({ size: [400, 200], compress: false });
|
||||
const chunks = [];
|
||||
doc.on('data', chunk => chunks.push(chunk));
|
||||
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
doc.on('error', reject);
|
||||
doc.rect(0, 0, 400, 200).fill('#3366aa');
|
||||
doc.addPage({ size: [200, 400] }).rect(0, 0, 200, 400).fill('#aa6633');
|
||||
doc.end();
|
||||
});
|
||||
const firstPage = await renderDocumentThumbnail('pdf', pdf, source);
|
||||
const pdfMeta = await sharp(firstPage).metadata();
|
||||
assert.deepEqual([pdfMeta.format, pdfMeta.width, pdfMeta.height], ['webp', 512, 256]);
|
||||
const { r, b } = (await sharp(firstPage).stats()).dominant;
|
||||
assert.ok(b > r, 'the thumbnail shows the blue first page');
|
||||
const { zipSync, strToU8 } = require('fflate');
|
||||
const docx = Buffer.from(zipSync(Object.fromEntries(Object.entries({
|
||||
'[Content_Types].xml': '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/></Types>',
|
||||
'_rels/.rels': '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>',
|
||||
'word/document.xml': '<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>Document thumbnail</w:t></w:r></w:p><w:sectPr><w:pgSz w:w="12240" w:h="15840"/></w:sectPr></w:body></w:document>',
|
||||
}).map(([name, text]) => [name, strToU8(text)]))));
|
||||
const odt = Buffer.from(zipSync({
|
||||
'content.xml': strToU8('<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"><office:body><office:text><text:p>OpenDocument thumbnail</text:p></office:text></office:body></office:document-content>'),
|
||||
}));
|
||||
for (const [kind, input] of [['docx', docx], ['odt', odt],
|
||||
['xlsx', fs.readFileSync(path.join(ROOT, 'npm-packages/exceljs/test/data/simple_excel.xlsx'))]]) {
|
||||
const image = await renderDocumentThumbnail(kind, input, source);
|
||||
const info = await sharp(image).metadata();
|
||||
assert.equal(info.format, 'webp', kind);
|
||||
assert.ok(Math.max(info.width, info.height) <= THUMBNAIL_EDGE, kind);
|
||||
const stats = await sharp(image).stats();
|
||||
assert.ok(stats.channels.some(c => c.min < 128), `${kind} thumbnail contains document content`);
|
||||
}
|
||||
await assert.rejects(() => renderDocumentThumbnail('pdf', Buffer.from('not a PDF'), source));
|
||||
await assert.rejects(() => renderDocumentThumbnail('pdf', Buffer.alloc(DOCUMENT_MAX_BYTES + 1), source),
|
||||
/thumbnail conversion limit/);
|
||||
const embedded = Buffer.from(zipSync({ 'Thumbnails/thumbnail.png': await sharp(big).resize(92, 48).png().toBuffer() }));
|
||||
const embeddedMeta = await sharp(await renderDocumentThumbnail('odp', embedded, source)).metadata();
|
||||
assert.deepEqual([embeddedMeta.width, embeddedMeta.height], [92, 48]);
|
||||
|
||||
const { getDocumentThumbnail } = await import('../server/lib/documentThumbnail.js');
|
||||
const { removePreviews, previewRoot } = require('../server/lib/attachmentPreviewStore.js');
|
||||
const { Readable } = require('node:stream');
|
||||
const folder = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'wekan-doc-thumb-'));
|
||||
const writable = process.env.WRITABLE_PATH;
|
||||
process.env.WRITABLE_PATH = folder;
|
||||
try {
|
||||
let opens = 0;
|
||||
const fetch = () => getDocumentThumbnail({ _id: 'document-test' }, 'a'.repeat(64), 'pdf', () => {
|
||||
opens += 1;
|
||||
return Readable.from([pdf]);
|
||||
}, () => source);
|
||||
const [one, two] = await Promise.all([fetch(), fetch()]);
|
||||
assert.deepEqual(one, two);
|
||||
assert.deepEqual(await fetch(), one);
|
||||
assert.equal(opens, 1, 'concurrent and subsequent reads share the generated thumbnail');
|
||||
removePreviews('document-test');
|
||||
assert.deepEqual(fs.readdirSync(previewRoot()), [], 'attachment removal also clears its thumbnail');
|
||||
} finally {
|
||||
if (writable === undefined) delete process.env.WRITABLE_PATH;
|
||||
else process.env.WRITABLE_PATH = writable;
|
||||
fs.rmSync(folder, { recursive: true, force: true });
|
||||
}
|
||||
console.log(' ok - first page, Office and OpenDocument thumbnails render actual document content');
|
||||
|
||||
// Cache: bounded by count, least recently used out, keyed by file version.
|
||||
for (let i = 0; i < 510; i += 1) lib.rememberThumbnail(`k${i}`, Buffer.from([i % 256]));
|
||||
assert.equal(lib.cachedThumbnail('k0'), null, 'the oldest entries were evicted');
|
||||
@@ -79,7 +152,7 @@ async function main() {
|
||||
'attachmentDownloadLimits.maxBytes', 'isStorageReadEnabled(storageName)']) {
|
||||
assert.ok(at(check) < thumbnail, `${check} runs before a thumbnail is served`);
|
||||
}
|
||||
assert.match(handler, /if \(wantsThumbnail && !canThumbnail\(attachment\)\) \{\s*res\.writeHead\(404\);/);
|
||||
assert.match(handler, /if \(wantsThumbnail && !documentKind && !canThumbnail\(attachment\)\) \{\s*res\.writeHead\(404\);/);
|
||||
assert.match(handler, /convertImageBufferToThumbnail\(await boundedStreamBuffer\(readStream\)\)/);
|
||||
assert.match(handler, /res\.writeHead\(302, \{ Location: Meteor\.absoluteUrl\(`cdn\/storage\/attachments\/\$\{fileId\}`\)/);
|
||||
// CacheBleed (GHSA-w3qg-pf27-g68r): cached as the original is - private and
|
||||
|
||||
@@ -28,7 +28,7 @@ Module._resolveFilename = function(request, ...rest) {
|
||||
|
||||
const { HEADER_BYTES, ensureTempDir, streamHeaderToTemp, detectedFileMime } =
|
||||
require('../models/lib/fileTypeCorrection.js');
|
||||
const { numberedName } = require('../models/lib/uploadFileName.js');
|
||||
const { numberedName, sanitizeUploadFileName } = require('../models/lib/uploadFileName.js');
|
||||
|
||||
let passed = 0;
|
||||
async function check(name, fn) { await fn(); passed += 1; console.log(' ok -', name); }
|
||||
@@ -104,14 +104,18 @@ async function check(name, fn) { await fn(); passed += 1; console.log(' ok -',
|
||||
const fixtures = [
|
||||
['mail', 'X-Account-Key: account1\r\nX-UIDL: value\r\nX-Mozilla-Status: 0001\r\nFrom: sender@example.org\r\nDate: Tue, 1 Dec 2026 10:50:00 +0000\r\nSubject: Parts\r\n\r\n<html>Order</html>', 'message/rfc822'],
|
||||
['step', 'ISO-10303-21;\nHEADER;\nENDSEC;\nEND-ISO-10303-21;\n', 'model/step'],
|
||||
['dxf', ' 0\nSECTION\n 2\nHEADER\n 0\nENDSEC\n 0\nEOF\n', 'image/vnd.dxf'],
|
||||
['building.ifc', "ISO-10303-21;\nHEADER;\nFILE_SCHEMA(('IFC4'));\nENDSEC;\nDATA;\nENDSEC;\nEND-ISO-10303-21;\n", 'model/step', 'application/x-step'],
|
||||
['dxf', ' 0\nSECTION\n 2\nHEADER\n 0\nENDSEC\n 0\nEOF\n', 'image/vnd.dxf', 'application/x-dxf'],
|
||||
];
|
||||
const base = fs.mkdtempSync(path.join(os.tmpdir(), 'wekan-ft-'));
|
||||
try {
|
||||
for (const [file, contents, type] of fixtures) {
|
||||
for (const [file, contents, ...types] of fixtures) {
|
||||
const fixturePath = path.join(base, file);
|
||||
fs.writeFileSync(fixturePath, contents);
|
||||
assert.strictEqual(await detectedFileMime(fixturePath), type, file);
|
||||
const detected = await detectedFileMime(fixturePath);
|
||||
assert.ok(types.includes(detected), `${file}: ${detected}`);
|
||||
if (file === 'building.ifc') assert.strictEqual(sanitizeUploadFileName(file, detected), file);
|
||||
if (file === 'dxf') assert.strictEqual(sanitizeUploadFileName('part.txt', detected), 'part.dxf');
|
||||
}
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
|
||||
@@ -79,12 +79,12 @@ function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
||||
'a static import would put viewer engines in every initial browser load');
|
||||
});
|
||||
|
||||
test('the fork exposes only the three browser viewers', () => {
|
||||
test('the fork exposes the browser viewers and the Node thumbnail renderer', () => {
|
||||
const pkg = JSON.parse(read('npm-packages/office-open-xml-viewer/package.json'));
|
||||
assert.deepStrictEqual(Object.keys(pkg.exports).sort(), ['./docx', './pptx', './xlsx']);
|
||||
assert.deepStrictEqual(Object.keys(pkg.exports).sort(), ['./docx', './node', './pptx', './xlsx']);
|
||||
assert.strictEqual(pkg.dependencies, undefined);
|
||||
assert.strictEqual(pkg.scripts, undefined);
|
||||
for (const excluded of ['node.mjs', 'math.mjs', 'tiff.mjs', 'region-map.mjs']) {
|
||||
for (const excluded of ['math.mjs', 'tiff.mjs', 'region-map.mjs']) {
|
||||
assert.ok(!fs.existsSync(path.join(root,
|
||||
'npm-packages/office-open-xml-viewer/dist', excluded)), `${excluded} stays excluded`);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
||||
|
||||
test('every retained viewer import and asset reference resolves inside the fork', () => {
|
||||
const dist = path.join(root, 'npm-packages/office-open-xml-viewer/dist');
|
||||
const pending = ['docx.mjs', 'xlsx.mjs', 'pptx.mjs'];
|
||||
const pending = ['docx.mjs', 'xlsx.mjs', 'pptx.mjs', 'node.mjs'];
|
||||
const visited = new Set();
|
||||
while (pending.length) {
|
||||
const relative = pending.pop();
|
||||
|
||||
@@ -52,6 +52,32 @@ test.describe('Attachments & links', () => {
|
||||
expect(count).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
test('preserves the original names of IFC and CNC attachments', async ({
|
||||
boardPage,
|
||||
board,
|
||||
}) => {
|
||||
const bp = new BoardPage(boardPage);
|
||||
const cp = new CardPage(boardPage);
|
||||
await bp.clickCard(board.listIds[0], 'Alpha Card');
|
||||
await cp.waitForOpen();
|
||||
const card = db.findOne('cards', { boardId: board.boardId, title: 'Alpha Card' });
|
||||
await cp.openAttachmentPanel();
|
||||
const names = ['building.IFC', 'flange.nc', 'flange.tap'];
|
||||
const cnc = Buffer.from('%\nO1234 (FLANGE)\nG21 G90 G17 G40 G80\nM30\n%\n');
|
||||
const ifc = Buffer.from("ISO-10303-21;\nHEADER;\nFILE_SCHEMA(('IFC4'));\nENDSEC;\nDATA;\nENDSEC;\nEND-ISO-10303-21;\n");
|
||||
await boardPage.locator('.js-pop-over .js-attach-file').setInputFiles(
|
||||
names.map(name => ({
|
||||
name,
|
||||
mimeType: 'application/octet-stream',
|
||||
buffer: name.endsWith('.IFC') ? ifc : cnc,
|
||||
})),
|
||||
);
|
||||
|
||||
await expect.poll(() => db.find('attachments', { 'meta.cardId': card._id })
|
||||
.filter(attachment => attachment.uploadedAtOstrio)
|
||||
.map(attachment => attachment.name).sort(), { timeout: 30_000 }).toEqual(names);
|
||||
});
|
||||
|
||||
test('the attachment overlay provides native PDF and isolated Office previews', async ({
|
||||
boardPage,
|
||||
board,
|
||||
|
||||
@@ -140,3 +140,50 @@ test('a private attachment is private and revalidated in every response', async
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('the card displays a private PDF thumbnail and falls back for a damaged document', async ({
|
||||
boardPage: page, board, baseURL,
|
||||
}) => {
|
||||
const PDFDocument = require('pdfkit');
|
||||
const pdf = await new Promise((resolve, reject) => {
|
||||
const doc = new PDFDocument({ size: [400, 200] });
|
||||
const chunks = [];
|
||||
doc.on('data', chunk => chunks.push(chunk));
|
||||
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
doc.on('error', reject);
|
||||
doc.text('First page of the attachment');
|
||||
doc.end();
|
||||
});
|
||||
const id = `thumbpdf${Date.now()}`;
|
||||
const cleanups = [
|
||||
seed(board, id, 'document.pdf', 'application/pdf', pdf),
|
||||
seed(board, `${id}broken`, 'broken.pdf', 'application/pdf', Buffer.from('broken')),
|
||||
];
|
||||
try {
|
||||
const url = `/cdn/storage/attachments/${id}/thumbnail`;
|
||||
const response = await page.request.get(url);
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.headers()['content-type']).toBe('image/webp');
|
||||
expect(response.headers()['cache-control']).toBe('private, no-cache');
|
||||
expect((await page.request.get(`/cdn/storage/attachments/${id}broken/thumbnail`, { maxRedirects: 0 })).status()).toBe(404);
|
||||
|
||||
const anonymous = await playwrightRequest.newContext({ baseURL });
|
||||
try {
|
||||
expect((await anonymous.get(url)).status()).toBe(403);
|
||||
} finally { await anonymous.dispose(); }
|
||||
|
||||
await openBoard(page, board.boardId, board.slug);
|
||||
await page.locator('.minicard', { hasText: 'Alpha Card' }).first().locator('.minicard-title').click();
|
||||
const thumbnail = page.locator('img.attachment-document-thumbnail[title="document.pdf"]');
|
||||
await expect(thumbnail).toBeVisible();
|
||||
await expect.poll(() => thumbnail.evaluate(img => img.naturalWidth)).toBe(512);
|
||||
const broken = page.locator('.attachment-item', { hasText: 'broken.pdf' });
|
||||
await expect(broken.locator('.attachment-document-fallback')).toHaveText('pdf');
|
||||
await expect(broken.locator('.attachment-document-fallback')).toBeVisible();
|
||||
|
||||
db.updateOne('boards', { _id: board.boardId }, { $set: { allowsAttachmentPreviewsOnCard: false } });
|
||||
await openBoard(page, board.boardId, board.slug);
|
||||
await page.locator('.minicard', { hasText: 'Alpha Card' }).first().locator('.minicard-title').click();
|
||||
await expect(page.locator('img.attachment-document-thumbnail')).toHaveCount(0);
|
||||
} finally { cleanups.forEach(cleanup => cleanup()); }
|
||||
});
|
||||
@@ -11,6 +11,46 @@ const db = require('../helpers/db');
|
||||
const auth = token => ({ headers: { Authorization: `Bearer ${token}` } });
|
||||
const DOMAIN = 'partner-ghsa-r3c4.example';
|
||||
|
||||
test('a board admin can add the first domain to a missing or null domain list', async ({ request, user, board }) => {
|
||||
const selector = { _id: board.boardId };
|
||||
const domain = 'first.example';
|
||||
const expected = [{ domain, isActive: true }];
|
||||
for (const modifier of [{ $unset: { domains: '' } }, { $set: { domains: null } }]) {
|
||||
db.updateOne('boards', selector, modifier);
|
||||
const response = await request.post(`/api/boards/${board.boardId}/domains`, { ...auth(user.token), data: { domain } });
|
||||
expect(response.status()).toBe(200);
|
||||
expect(await response.json()).toEqual(expected);
|
||||
expect(db.findOne('boards', selector).domains).toEqual(expected);
|
||||
}
|
||||
});
|
||||
|
||||
test('a board admin can add a normalized domain without duplicating it', async ({ request, user, board }) => {
|
||||
const url = `/api/boards/${board.boardId}/domains`;
|
||||
const inactive = { domain: 'inactive.example', isActive: false };
|
||||
db.updateOne('boards', { _id: board.boardId }, { $set: { domains: [inactive] } });
|
||||
const expected = [inactive, { domain: 'partner.example', isActive: true }];
|
||||
|
||||
for (const domain of [' Partner.Example ', 'partner.example', 'inactive.example']) {
|
||||
const response = await request.post(url, { ...auth(user.token), data: { domain } });
|
||||
expect(response.status()).toBe(200);
|
||||
expect(await response.json()).toEqual(expected);
|
||||
}
|
||||
expect(db.findOne('boards', { _id: board.boardId }).domains).toEqual(expected);
|
||||
});
|
||||
|
||||
test('a site admin can remove a single board domain', async ({ request, adminUser, board }) => {
|
||||
const keep = { domain: 'keep.example', isActive: false };
|
||||
db.updateOne('boards', { _id: board.boardId }, {
|
||||
$set: { domains: [keep, { domain: 'partner.example', isActive: true }] },
|
||||
});
|
||||
const url = `/api/boards/${board.boardId}/domains/Partner.Example`;
|
||||
const response = await request.delete(url, auth(adminUser.token));
|
||||
expect(response.status()).toBe(200);
|
||||
expect(await response.json()).toEqual([keep]);
|
||||
expect(db.findOne('boards', { _id: board.boardId }).domains).toEqual([keep]);
|
||||
expect((await request.delete(url, auth(adminUser.token))).status()).toBe(404);
|
||||
});
|
||||
|
||||
test('only a site admin reads a board\'s domain sharing through /domains', async ({ request, adminUser, user }) => {
|
||||
const board = db.seedBoard({ ownerId: adminUser.id, title: 'GHSA-r3c4 private board' });
|
||||
const member = db.seedUser();
|
||||
|
||||
@@ -66,6 +66,30 @@ test('REST creation refuses non-string parents without inserting', async ({ requ
|
||||
}
|
||||
});
|
||||
|
||||
test('bulk creation skips cards with non-string parents and continues the batch', async ({ request, user, board }) => {
|
||||
const parent = db.findOne('cards', { boardId: board.boardId, title: 'Alpha Card' });
|
||||
const invalidParents = [0, false, true, 42, {}, []];
|
||||
const response = await request.post(`${cardsPath(board)}/bulk`, {
|
||||
headers: headers(user.token),
|
||||
data: {
|
||||
swimlaneId: board.swimlaneId,
|
||||
cards: [
|
||||
...invalidParents.map(parentId => ({ title: 'Invalid child', parentId })),
|
||||
{ title: 'Valid child', parentId: parent._id },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status()).toBe(200);
|
||||
expect(db.findOne('cards', { boardId: board.boardId, title: 'Invalid child' })).toBeNull();
|
||||
const child = db.findOne('cards', { boardId: board.boardId, title: 'Valid child' });
|
||||
expect(child).toMatchObject({ parentId: parent._id });
|
||||
expect(await response.json()).toEqual([
|
||||
...invalidParents.map((_, index) => ({ index, error: 'Invalid parentId' })),
|
||||
{ index: invalidParents.length, _id: child._id },
|
||||
]);
|
||||
});
|
||||
|
||||
test('REST creation refuses missing and invisible parents without inserting', async ({ request, user, user2, board }) => {
|
||||
const foreign = db.seedBoard({ ownerId: user2.id, cardTitlesPerList: [['Private parent']] });
|
||||
const privateParent = db.findOne('cards', { boardId: foreign.boardId });
|
||||
|
||||
@@ -241,19 +241,20 @@ test('it refuses a directory that is not a Meteor bundle (negative)', dir => {
|
||||
});
|
||||
|
||||
test('browser build inputs go only from the server dependency tree', dir => {
|
||||
const names = ['blockly', 'meteor-node-stubs', '@wekan/office-open-xml-viewer'];
|
||||
const names = ['blockly', 'meteor-node-stubs'];
|
||||
const bundle = makeBundle(dir, Object.assign(
|
||||
{ 'programs/server/app/app.js': '// no browser imports',
|
||||
'programs/web.browser/app/client.js': 'const viewer = "keep these browser bytes";' },
|
||||
...names.map(name => pkg(name)),
|
||||
...names.map(name => pkg(name)), pkg('@wekan/office-open-xml-viewer'),
|
||||
));
|
||||
const report = path.join(dir, 'report.json');
|
||||
prune(bundle, ['--dry-run', '--report-json', report]);
|
||||
for (const name of names) assert.ok(has(bundle, `${NM}/${name}`));
|
||||
const rows = JSON.parse(fs.readFileSync(report));
|
||||
assert.equal(rows.filter(row => row.action === 'remove').length, 3);
|
||||
assert.equal(rows.filter(row => row.action === 'remove').length, 2);
|
||||
prune(bundle);
|
||||
for (const name of names) assert.ok(!has(bundle, `${NM}/${name}`));
|
||||
assert.ok(has(bundle, `${NM}/@wekan/office-open-xml-viewer`), 'the server thumbnail worker loads Office');
|
||||
assert.equal(fs.readFileSync(path.join(bundle, 'programs/web.browser/app/client.js'), 'utf8'),
|
||||
'const viewer = "keep these browser bytes";');
|
||||
});
|
||||
|
||||
@@ -251,8 +251,36 @@ for (const [verb, body] of [['delete', {}], ['put', { color: 'red' }]]) {
|
||||
});
|
||||
}
|
||||
|
||||
test('board domain mutations require a board or site admin', async () => {
|
||||
const params = { boardId: 'b', domain: 'example.com' };
|
||||
const cache = { getBoard: () => ({ _id: 'b', domains: [{ domain: params.domain }] }) };
|
||||
const extra = () => ({ allowIsBoardAdmin: () => false });
|
||||
for (const [verb, route] of [
|
||||
['post', '/api/boards/:boardId/domains'],
|
||||
['delete', '/api/boards/:boardId/domains/:domain'],
|
||||
]) {
|
||||
const result = await call('server/models/boards.js', verb, route, { params, body: { domain: params.domain }, cache, extra });
|
||||
assert.equal(result.response.code, 403);
|
||||
assert.deepEqual(result.writes, []);
|
||||
}
|
||||
});
|
||||
|
||||
test('adding a domain returns 404 when the board disappears during the write', async () => {
|
||||
let board = { _id: 'b', domains: [] };
|
||||
const result = await call('server/models/boards.js', 'post', '/api/boards/:boardId/domains', {
|
||||
params: { boardId: 'b' }, body: { domain: 'example.com' },
|
||||
cache: { getBoard: () => board },
|
||||
extra: () => ({
|
||||
allowIsBoardAdmin: () => true,
|
||||
Boards: { async updateAsync() { board = undefined; return 0; } },
|
||||
}),
|
||||
});
|
||||
assert.deepEqual(result.response, { code: 404, data: { error: 'Board not found' } });
|
||||
});
|
||||
|
||||
test('domain deletion: a domain the board does not have is 404 and the domains are not rewritten', async () => {
|
||||
const board = { _id: 'b', domains: [{ domain: 'example.com' }] };
|
||||
const entry = { domain: 'example.com', isActive: true };
|
||||
const board = { _id: 'b', domains: [entry] };
|
||||
const extra = () => ({ allowIsBoardAdmin: () => true });
|
||||
const cache = { getBoard: () => board };
|
||||
const run = domain => call('server/models/boards.js', 'delete', '/api/boards/:boardId/domains/:domain', { params: { boardId: 'b', domain }, cache, extra });
|
||||
@@ -261,7 +289,25 @@ test('domain deletion: a domain the board does not have is 404 and the domains a
|
||||
assert.deepEqual(r.writes, []);
|
||||
const ok = await run('Example.COM');
|
||||
assert.equal(ok.response.code, 200, 'normalised as before');
|
||||
assert.deepEqual(ok.writes, [['Meteor', 'call', ['setBoardDomains', [], 'b']]]);
|
||||
assert.deepEqual(ok.writes, [['Boards', 'update', { _id: 'b', domains: { $all: [entry] } }, { $pullAll: { domains: [entry] } }]]);
|
||||
});
|
||||
|
||||
test('domain deletion reports a conflict if the matching entry changed before the write', async () => {
|
||||
const entry = { domain: 'example.com', isActive: true };
|
||||
const board = { _id: 'b', domains: [entry] };
|
||||
const extra = () => ({
|
||||
allowIsBoardAdmin: () => true,
|
||||
Boards: {
|
||||
async updateAsync() {
|
||||
board.domains = [{ ...entry, isActive: false }];
|
||||
return 0;
|
||||
},
|
||||
},
|
||||
});
|
||||
const result = await call('server/models/boards.js', 'delete', '/api/boards/:boardId/domains/:domain', {
|
||||
params: { boardId: 'b', domain: entry.domain }, cache: { getBoard: () => board }, extra,
|
||||
});
|
||||
assert.equal(result.response.code, 409);
|
||||
});
|
||||
|
||||
const FIELD = { _id: 'f', boardIds: ['b'], settings: { dropdownItems: [{ _id: 'item', name: 'One' }] } };
|
||||
|
||||
@@ -90,6 +90,15 @@ check('preserves long names and removes incompatible characters', () => {
|
||||
assert.strictEqual(sanitizeUploadFileName('door.STEP', 'image/png'), 'door.png');
|
||||
});
|
||||
|
||||
check('preserves IFC extensions for STEP content and corrects real mismatches', () => {
|
||||
for (const type of ['model/step', 'application/x-step']) {
|
||||
assert.strictEqual(sanitizeUploadFileName('building.ifc', type), 'building.ifc');
|
||||
assert.strictEqual(sanitizeUploadFileName('building.IFC', type), 'building.IFC');
|
||||
assert.strictEqual(sanitizeUploadFileName('building.html', type), 'building.step');
|
||||
}
|
||||
assert.strictEqual(sanitizeUploadFileName('building.ifc', 'application/pdf'), 'building.pdf');
|
||||
});
|
||||
|
||||
check('preserves IGES extensions when detected as IGES or generic text', () => {
|
||||
for (const name of ['Pipe DN150 Length 800.igs', 'Pipe DN150 Length 800.IGES']) {
|
||||
assert.strictEqual(sanitizeUploadFileName(name, 'text/plain'), name);
|
||||
@@ -99,6 +108,31 @@ check('preserves IGES extensions when detected as IGES or generic text', () => {
|
||||
assert.strictEqual(sanitizeUploadFileName('part.txt', 'model/iges'), 'part.igs');
|
||||
});
|
||||
|
||||
check('preserves custom suffixes when detection only identifies text or a container', () => {
|
||||
for (const ext of ['stl', 'obj', 'nc', 'tap', 'SPF', 'MPF', 'sat', 'vda',
|
||||
'gcode', 'anc', 'EIA', 'nc1', 'unregistered-format']) {
|
||||
const name = `flange.${ext}`;
|
||||
assert.strictEqual(sanitizeUploadFileName(name, 'text/plain'), name);
|
||||
}
|
||||
for (const type of ['application/xml', 'text/xml']) {
|
||||
assert.strictEqual(sanitizeUploadFileName('KUKLOS-A.sym', type), 'KUKLOS-A.sym');
|
||||
}
|
||||
assert.strictEqual(sanitizeUploadFileName('job.zzx', 'application/zip'), 'job.zzx');
|
||||
assert.strictEqual(sanitizeUploadFileName('job.zzx', 'application/octet-stream'), 'job.zzx');
|
||||
});
|
||||
|
||||
check('generic detection still corrects executable and active-content suffixes', () => {
|
||||
for (const ext of ['HTML', 'htm', 'svg', 'js', 'exe', 'cmd', 'ps1']) {
|
||||
assert.strictEqual(sanitizeUploadFileName(`part.${ext}`, 'text/plain'), 'part.txt');
|
||||
}
|
||||
assert.strictEqual(sanitizeUploadFileName('part.svg', 'application/xml'), 'part.xml');
|
||||
for (const type of ['application/zip', 'application/x-zip-compressed']) {
|
||||
assert.strictEqual(sanitizeUploadFileName('part.exe', type), 'part.zip');
|
||||
}
|
||||
assert.strictEqual(sanitizeUploadFileName('part.eml', 'text/html'), 'part.html');
|
||||
assert.strictEqual(sanitizeUploadFileName('part.png', 'application/pdf'), 'part.pdf');
|
||||
});
|
||||
|
||||
check('filenameLooksLikeExploit accepts normal names', () => {
|
||||
assert.strictEqual(filenameLooksLikeExploit('report.pdf'), false);
|
||||
assert.strictEqual(filenameLooksLikeExploit('Photo 2024.jpg'), false);
|
||||
|
||||
Reference in new issue
Block a user