any2orca 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/LICENSE +21 -0
- package/NOTICE +28 -0
- package/README.md +96 -3
- package/dist/archive/adaptModelSettings.d.ts +1 -0
- package/dist/archive/adaptModelSettings.js +50 -0
- package/dist/archive/filamentColorNames.d.ts +8 -0
- package/dist/archive/filamentColorNames.js +760 -0
- package/dist/archive/fmtNum.d.ts +14 -0
- package/dist/archive/fmtNum.js +21 -0
- package/dist/archive/internal/escapeRegExp.d.ts +2 -0
- package/dist/archive/internal/escapeRegExp.js +5 -0
- package/dist/archive/lookupFilamentColorName.d.ts +45 -0
- package/dist/archive/lookupFilamentColorName.js +57 -0
- package/dist/archive/objectWorldBboxXY.d.ts +2 -0
- package/dist/archive/objectWorldBboxXY.js +123 -0
- package/dist/archive/parseItemPositions.d.ts +6 -0
- package/dist/archive/parseItemPositions.js +17 -0
- package/dist/archive/parseObjectMetadata.d.ts +10 -0
- package/dist/archive/parseObjectMetadata.js +97 -0
- package/dist/archive/parsePlateAssignments.d.ts +6 -0
- package/dist/archive/parsePlateAssignments.js +18 -0
- package/dist/archive/parseVertices.d.ts +7 -0
- package/dist/archive/parseVertices.js +12 -0
- package/dist/archive/paths.d.ts +5 -0
- package/dist/archive/paths.js +6 -0
- package/dist/archive/recenterAssembleItems.d.ts +9 -0
- package/dist/archive/recenterAssembleItems.js +53 -0
- package/dist/archive/recenterBuildItems.d.ts +15 -0
- package/dist/archive/recenterBuildItems.js +51 -0
- package/dist/archive/safeUnzip.d.ts +26 -0
- package/dist/archive/safeUnzip.js +126 -0
- package/dist/archive/setApplicationMetadata.d.ts +13 -0
- package/dist/archive/setApplicationMetadata.js +18 -0
- package/dist/archive/shouldDropFromBambu.d.ts +29 -0
- package/dist/archive/shouldDropFromBambu.js +39 -0
- package/dist/archive/streamObjectVertices.d.ts +19 -0
- package/dist/archive/streamObjectVertices.js +57 -0
- package/dist/archive/tolerantJsonParse.d.ts +20 -0
- package/dist/archive/tolerantJsonParse.js +71 -0
- package/dist/archive/transform.d.ts +21 -0
- package/dist/archive/transform.js +39 -0
- package/dist/archive/unwrapBundle.d.ts +24 -0
- package/dist/archive/unwrapBundle.js +41 -0
- package/dist/archive/xmlBlocks.d.ts +10 -0
- package/dist/archive/xmlBlocks.js +31 -0
- package/dist/archive/zip.d.ts +29 -0
- package/dist/archive/zip.js +141 -0
- package/dist/cli/archiveMove.d.ts +15 -0
- package/dist/cli/archiveMove.js +41 -0
- package/dist/cli/commands/convert.d.ts +89 -0
- package/dist/cli/commands/convert.js +311 -0
- package/dist/cli/commands/diff.d.ts +21 -0
- package/dist/cli/commands/diff.js +112 -0
- package/dist/cli/commands/presets.d.ts +51 -0
- package/dist/cli/commands/presets.js +280 -0
- package/dist/cli/commands/profiles.d.ts +5 -0
- package/dist/cli/commands/profiles.js +26 -0
- package/dist/cli/commands/telemetry.d.ts +6 -0
- package/dist/cli/commands/telemetry.js +45 -0
- package/dist/cli/config.d.ts +18 -0
- package/dist/cli/config.js +50 -0
- package/dist/cli/expandWildcards.d.ts +17 -0
- package/dist/cli/expandWildcards.js +81 -0
- package/dist/cli/logger.d.ts +17 -0
- package/dist/cli/logger.js +36 -0
- package/dist/cli/main.d.ts +24 -0
- package/dist/cli/main.js +598 -0
- package/dist/cli/sameFile.d.ts +9 -0
- package/dist/cli/sameFile.js +40 -0
- package/dist/cli/stats.d.ts +34 -0
- package/dist/cli/stats.js +137 -0
- package/dist/cli/table.d.ts +8 -0
- package/dist/cli/table.js +18 -0
- package/dist/cli/terminalText.d.ts +7 -0
- package/dist/cli/terminalText.js +22 -0
- package/dist/cli/updateCheck.d.ts +14 -0
- package/dist/cli/updateCheck.js +78 -0
- package/dist/cli/watchState.d.ts +18 -0
- package/dist/cli/watchState.js +33 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +10 -0
- package/dist/diff/diffSettings.d.ts +81 -0
- package/dist/diff/diffSettings.js +259 -0
- package/dist/diff/reference.d.ts +14 -0
- package/dist/diff/reference.js +22 -0
- package/dist/diff/settingsCatalog.d.ts +28 -0
- package/dist/diff/settingsCatalog.js +605 -0
- package/dist/diff/valueLayout.d.ts +20 -0
- package/dist/diff/valueLayout.js +65 -0
- package/dist/engine/aboveStock.d.ts +20 -0
- package/dist/engine/aboveStock.js +89 -0
- package/dist/engine/applyFilamentComplianceMode.d.ts +40 -0
- package/dist/engine/applyFilamentComplianceMode.js +68 -0
- package/dist/engine/applyFilamentFlowVariants.d.ts +42 -0
- package/dist/engine/applyFilamentFlowVariants.js +109 -0
- package/dist/engine/applyHighFlowHotends.d.ts +52 -0
- package/dist/engine/applyHighFlowHotends.js +115 -0
- package/dist/engine/applyPresetChanges.d.ts +12 -0
- package/dist/engine/applyPresetChanges.js +23 -0
- package/dist/engine/bedCenter.d.ts +19 -0
- package/dist/engine/bedCenter.js +34 -0
- package/dist/engine/buildFilamentConfigs.d.ts +18 -0
- package/dist/engine/buildFilamentConfigs.js +49 -0
- package/dist/engine/buildProjectSettings.d.ts +24 -0
- package/dist/engine/buildProjectSettings.js +164 -0
- package/dist/engine/carrySourceLayerHeight.d.ts +15 -0
- package/dist/engine/carrySourceLayerHeight.js +41 -0
- package/dist/engine/clampColorPenetration.d.ts +12 -0
- package/dist/engine/clampColorPenetration.js +28 -0
- package/dist/engine/clampToMachineLimits.d.ts +21 -0
- package/dist/engine/clampToMachineLimits.js +84 -0
- package/dist/engine/coerceValue.d.ts +15 -0
- package/dist/engine/coerceValue.js +56 -0
- package/dist/engine/collapseNozzleVariants.d.ts +31 -0
- package/dist/engine/collapseNozzleVariants.js +63 -0
- package/dist/engine/computeShifts.d.ts +12 -0
- package/dist/engine/computeShifts.js +339 -0
- package/dist/engine/constants.d.ts +11 -0
- package/dist/engine/constants.js +12 -0
- package/dist/engine/detectNozzleDiameter.d.ts +15 -0
- package/dist/engine/detectNozzleDiameter.js +29 -0
- package/dist/engine/detectVariantIndex.d.ts +39 -0
- package/dist/engine/detectVariantIndex.js +80 -0
- package/dist/engine/extractFilamentSlots.d.ts +18 -0
- package/dist/engine/extractFilamentSlots.js +88 -0
- package/dist/engine/filamentComplianceNames.d.ts +84 -0
- package/dist/engine/filamentComplianceNames.js +87 -0
- package/dist/engine/filamentVariantLayout.d.ts +29 -0
- package/dist/engine/filamentVariantLayout.js +38 -0
- package/dist/engine/fillFilamentSlots.d.ts +16 -0
- package/dist/engine/fillFilamentSlots.js +26 -0
- package/dist/engine/internal/jsonEqual.d.ts +2 -0
- package/dist/engine/internal/jsonEqual.js +5 -0
- package/dist/engine/parseTierName.d.ts +15 -0
- package/dist/engine/parseTierName.js +21 -0
- package/dist/engine/pickNearestProfile.d.ts +21 -0
- package/dist/engine/pickNearestProfile.js +24 -0
- package/dist/engine/pickProfile.d.ts +49 -0
- package/dist/engine/pickProfile.js +67 -0
- package/dist/engine/policy.d.ts +14 -0
- package/dist/engine/policy.js +266 -0
- package/dist/engine/remapBrimType.d.ts +30 -0
- package/dist/engine/remapBrimType.js +34 -0
- package/dist/engine/reshapeToCount.d.ts +15 -0
- package/dist/engine/reshapeToCount.js +27 -0
- package/dist/engine/resizeFlushVolumes.d.ts +27 -0
- package/dist/engine/resizeFlushVolumes.js +57 -0
- package/dist/engine/resolveMinIfLower.d.ts +21 -0
- package/dist/engine/resolveMinIfLower.js +59 -0
- package/dist/engine/runConvertPipeline.d.ts +79 -0
- package/dist/engine/runConvertPipeline.js +281 -0
- package/dist/engine/stripBambuOnlyNozzleVariantKeys.d.ts +2 -0
- package/dist/engine/stripBambuOnlyNozzleVariantKeys.js +35 -0
- package/dist/engine/types.d.ts +2 -0
- package/dist/engine/types.js +1 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +9 -0
- package/dist/explain/whatChanged.d.ts +102 -0
- package/dist/explain/whatChanged.js +197 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +33 -0
- package/dist/inspect.d.ts +63 -0
- package/dist/inspect.js +103 -0
- package/dist/node.d.ts +11 -0
- package/dist/node.js +50 -0
- package/dist/plainText.d.ts +10 -0
- package/dist/plainText.js +14 -0
- package/dist/presets/extractPreset.d.ts +13 -0
- package/dist/presets/extractPreset.js +87 -0
- package/dist/presets/preset.d.ts +124 -0
- package/dist/presets/preset.js +289 -0
- package/dist/presets/presetKeys.d.ts +5 -0
- package/dist/presets/presetKeys.js +42 -0
- package/dist/profiles.d.ts +184 -0
- package/dist/profiles.js +314 -0
- package/dist/project.d.ts +146 -0
- package/dist/project.js +342 -0
- package/dist/schema.d.ts +103 -0
- package/dist/schema.js +87 -0
- package/dist/stamp.d.ts +45 -0
- package/dist/stamp.js +111 -0
- package/dist/telemetry.d.ts +101 -0
- package/dist/telemetry.js +94 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/dist/worker-entry.d.ts +1 -0
- package/dist/worker-entry.js +142 -0
- package/dist/worker.d.ts +86 -0
- package/dist/worker.js +97 -0
- package/dist/workerProtocol.d.ts +91 -0
- package/dist/workerProtocol.js +1 -0
- package/package.json +78 -12
- package/index.js +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a float the way Bambu/Orca 3MF transform strings expect: 6
|
|
3
|
+
* decimal places, trailing zeros and a trailing bare "." stripped, with
|
|
4
|
+
* "-0"/empty collapsed to "0".
|
|
5
|
+
*
|
|
6
|
+
* Six decimals with trailing zeros and a trailing "." removed, then the
|
|
7
|
+
* same `-0`/empty fallback. Must stay byte-stable, since this directly
|
|
8
|
+
* determines the output 3MF's transform attribute text and so the output's
|
|
9
|
+
* reproducibility. `toFixed(6)` always emits a literal "."
|
|
10
|
+
* followed by exactly 6 digits for any finite number, so a trailing-zero
|
|
11
|
+
* regex anchored at the string's end can never accidentally reach into
|
|
12
|
+
* the integer part (it always stops at that ".").
|
|
13
|
+
*/
|
|
14
|
+
export declare function fmtNum(val: number): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* Format a float the way Bambu/Orca 3MF transform strings expect: 6
|
|
4
|
+
* decimal places, trailing zeros and a trailing bare "." stripped, with
|
|
5
|
+
* "-0"/empty collapsed to "0".
|
|
6
|
+
*
|
|
7
|
+
* Six decimals with trailing zeros and a trailing "." removed, then the
|
|
8
|
+
* same `-0`/empty fallback. Must stay byte-stable, since this directly
|
|
9
|
+
* determines the output 3MF's transform attribute text and so the output's
|
|
10
|
+
* reproducibility. `toFixed(6)` always emits a literal "."
|
|
11
|
+
* followed by exactly 6 digits for any finite number, so a trailing-zero
|
|
12
|
+
* regex anchored at the string's end can never accidentally reach into
|
|
13
|
+
* the integer part (it always stops at that ".").
|
|
14
|
+
*/
|
|
15
|
+
export function fmtNum(val) {
|
|
16
|
+
const s = val
|
|
17
|
+
.toFixed(6)
|
|
18
|
+
.replace(/0+$/, "")
|
|
19
|
+
.replace(/\.$/, "");
|
|
20
|
+
return s === "" || s === "-0" ? "0" : s;
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** One (vendor, product line, hex) -> real product color name entry. */
|
|
2
|
+
export interface FilamentColorEntry {
|
|
3
|
+
vendor: "bambu" | "polymaker";
|
|
4
|
+
/** The product line as the vendor names it, e.g. "PLA Matte" or "Panchroma™ Matte PLA". */
|
|
5
|
+
type: string;
|
|
6
|
+
hex: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FilamentColorMatch {
|
|
10
|
+
vendor: FilamentColorEntry["vendor"];
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the product-line string from a Bambu-style `filament_settings_id`
|
|
15
|
+
* (e.g. `"Bambu PLA Matte @BBL P1S 0.4 nozzle"` -> `"PLA Matte"`), which is
|
|
16
|
+
* the only piece needed to disambiguate colors that collide across product
|
|
17
|
+
* lines (see lookupFilamentColorName). Strips a leading "Bambu " vendor
|
|
18
|
+
* prefix (Bambu's own naming convention, confirmed against real exported
|
|
19
|
+
* files) and everything from " @" onward (the printer/nozzle scope).
|
|
20
|
+
*
|
|
21
|
+
* Third-party filament profiles (e.g. Polymaker) don't share one fixed
|
|
22
|
+
* naming convention the way Bambu's own presets do, so this only strips the
|
|
23
|
+
* "Bambu " prefix specifically -- for anything else, the string is returned
|
|
24
|
+
* with just the " @..." suffix trimmed, which is enough to match this
|
|
25
|
+
* package's own Polymaker `type` values directly since none of them use an
|
|
26
|
+
* "@printer" scope. Returns null for an empty/unparseable input.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseFilamentType(filamentSettingsId: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Looks up the real vendor product name for a filament slot, given its
|
|
31
|
+
* `filament_settings_id` (used to identify the product line) and
|
|
32
|
+
* `filament_colour` hex. Matches on **both** product line and hex, never
|
|
33
|
+
* hex alone -- the same hex (e.g. `#000000`) is a genuinely different
|
|
34
|
+
* product across lines (Bambu's own "PLA Basic" ships it as "Basic Black",
|
|
35
|
+
* "PLA Matte" as "Matte Charcoal"), so hex-only matching would either be
|
|
36
|
+
* ambiguous or silently pick the wrong one.
|
|
37
|
+
*
|
|
38
|
+
* Returns `null` on no exact match rather than guessing a close color --
|
|
39
|
+
* callers should fall back to showing the raw hex code in that case, same
|
|
40
|
+
* as if this function didn't exist. Coverage is a curated snapshot (see
|
|
41
|
+
* see NOTICE for provenance),
|
|
42
|
+
* not exhaustive -- a miss just means "not in the snapshot yet," not "not
|
|
43
|
+
* a real product."
|
|
44
|
+
*/
|
|
45
|
+
export declare function lookupFilamentColorName(filamentSettingsId: string, hex: string): FilamentColorMatch | null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { FILAMENT_COLOR_ROWS } from "./filamentColorNames.js";
|
|
3
|
+
const ENTRIES = FILAMENT_COLOR_ROWS.map(([vendor, type, hex, name]) => ({ vendor, type, hex, name }));
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the product-line string from a Bambu-style `filament_settings_id`
|
|
6
|
+
* (e.g. `"Bambu PLA Matte @BBL P1S 0.4 nozzle"` -> `"PLA Matte"`), which is
|
|
7
|
+
* the only piece needed to disambiguate colors that collide across product
|
|
8
|
+
* lines (see lookupFilamentColorName). Strips a leading "Bambu " vendor
|
|
9
|
+
* prefix (Bambu's own naming convention, confirmed against real exported
|
|
10
|
+
* files) and everything from " @" onward (the printer/nozzle scope).
|
|
11
|
+
*
|
|
12
|
+
* Third-party filament profiles (e.g. Polymaker) don't share one fixed
|
|
13
|
+
* naming convention the way Bambu's own presets do, so this only strips the
|
|
14
|
+
* "Bambu " prefix specifically -- for anything else, the string is returned
|
|
15
|
+
* with just the " @..." suffix trimmed, which is enough to match this
|
|
16
|
+
* package's own Polymaker `type` values directly since none of them use an
|
|
17
|
+
* "@printer" scope. Returns null for an empty/unparseable input.
|
|
18
|
+
*/
|
|
19
|
+
export function parseFilamentType(filamentSettingsId) {
|
|
20
|
+
const withoutScope = filamentSettingsId.split(" @")[0]?.trim();
|
|
21
|
+
if (!withoutScope)
|
|
22
|
+
return null;
|
|
23
|
+
const withoutBambuPrefix = withoutScope.replace(/^Bambu\s+/, "");
|
|
24
|
+
return withoutBambuPrefix || null;
|
|
25
|
+
}
|
|
26
|
+
function normalizeHex(hex) {
|
|
27
|
+
const trimmed = hex.trim().toUpperCase();
|
|
28
|
+
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
29
|
+
}
|
|
30
|
+
function normalizeType(type) {
|
|
31
|
+
return type.trim().toLowerCase().replace(/\s+/g, " ");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Looks up the real vendor product name for a filament slot, given its
|
|
35
|
+
* `filament_settings_id` (used to identify the product line) and
|
|
36
|
+
* `filament_colour` hex. Matches on **both** product line and hex, never
|
|
37
|
+
* hex alone -- the same hex (e.g. `#000000`) is a genuinely different
|
|
38
|
+
* product across lines (Bambu's own "PLA Basic" ships it as "Basic Black",
|
|
39
|
+
* "PLA Matte" as "Matte Charcoal"), so hex-only matching would either be
|
|
40
|
+
* ambiguous or silently pick the wrong one.
|
|
41
|
+
*
|
|
42
|
+
* Returns `null` on no exact match rather than guessing a close color --
|
|
43
|
+
* callers should fall back to showing the raw hex code in that case, same
|
|
44
|
+
* as if this function didn't exist. Coverage is a curated snapshot (see
|
|
45
|
+
* see NOTICE for provenance),
|
|
46
|
+
* not exhaustive -- a miss just means "not in the snapshot yet," not "not
|
|
47
|
+
* a real product."
|
|
48
|
+
*/
|
|
49
|
+
export function lookupFilamentColorName(filamentSettingsId, hex) {
|
|
50
|
+
const type = parseFilamentType(filamentSettingsId);
|
|
51
|
+
if (!type)
|
|
52
|
+
return null;
|
|
53
|
+
const normalizedType = normalizeType(type);
|
|
54
|
+
const normalizedHex = normalizeHex(hex);
|
|
55
|
+
const match = ENTRIES.find((e) => normalizeType(e.type) === normalizedType && e.hex === normalizedHex);
|
|
56
|
+
return match ? { vendor: match.vendor, name: match.name } : null;
|
|
57
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { escapeRegExp } from "./internal/escapeRegExp.js";
|
|
3
|
+
import { parseVertices } from "./parseVertices.js";
|
|
4
|
+
import { forEachObjectVertex, LARGE_PART_BYTES } from "./streamObjectVertices.js";
|
|
5
|
+
import { applyTransform, compose, parseMatrix } from "./transform.js";
|
|
6
|
+
const utf8Decoder = new TextDecoder("utf-8");
|
|
7
|
+
/**
|
|
8
|
+
* Compute the true world-space X/Y bounding box of a top-level object's
|
|
9
|
+
* placed geometry, composing the item's plate-placement transform with
|
|
10
|
+
* each part's own transform. Needed because objects assembled from
|
|
11
|
+
* rotated multi-color/cut sub-parts (`<component>`) can have a visual
|
|
12
|
+
* center nowhere near their stored item transform's translation -- the
|
|
13
|
+
* only way to know the real center is to transform the actual mesh
|
|
14
|
+
* vertices.
|
|
15
|
+
*
|
|
16
|
+
* @param zipEntries the full decompressed zip contents (e.g. fflate's
|
|
17
|
+
* `unzipSync` output) -- this function reads component part files by
|
|
18
|
+
* path directly out of it.
|
|
19
|
+
* @param partFileCache memoizes decoded part-file text across many calls
|
|
20
|
+
* within one conversion pass (mutated in place by design: a cross-call
|
|
21
|
+
* memoization cache, not incidental state).
|
|
22
|
+
* @returns `[minX, maxX, minY, maxY]`, or `null` if nothing could be found.
|
|
23
|
+
*/
|
|
24
|
+
/** Finds the `<object id="...">...</object>` block for `objectId` in `text`, or null. */
|
|
25
|
+
function findObjectBlock(objectId, text) {
|
|
26
|
+
const match = new RegExp(`<object id="${escapeRegExp(objectId)}"[^>]*>[\\s\\S]*?</object>`).exec(text);
|
|
27
|
+
return match ? match[0] : null;
|
|
28
|
+
}
|
|
29
|
+
/** Order-independent single-attribute lookup within one `<component .../>` tag. */
|
|
30
|
+
function componentAttr(tag, name) {
|
|
31
|
+
const match = new RegExp(`${escapeRegExp(name)}="([^"]*)"`).exec(tag);
|
|
32
|
+
return match ? match[1] : null;
|
|
33
|
+
}
|
|
34
|
+
export function objectWorldBboxXY(objectId, topModelText, partFileCache, zipEntries) {
|
|
35
|
+
const objBlock = findObjectBlock(objectId, topModelText);
|
|
36
|
+
const itemMatch = new RegExp(`<item objectid="${escapeRegExp(objectId)}"[^>]*transform="([^"]+)"`).exec(topModelText);
|
|
37
|
+
if (!objBlock || !itemMatch)
|
|
38
|
+
return null;
|
|
39
|
+
const [itemR, itemT] = parseMatrix(itemMatch[1]);
|
|
40
|
+
let minX = Infinity;
|
|
41
|
+
let maxX = -Infinity;
|
|
42
|
+
let minY = Infinity;
|
|
43
|
+
let maxY = -Infinity;
|
|
44
|
+
let count = 0;
|
|
45
|
+
// Attribute order isn't fixed by the 3MF spec, so each attribute is
|
|
46
|
+
// pulled independently rather than matched positionally. `p:path` is
|
|
47
|
+
// absent for components referencing an <object> defined in this same
|
|
48
|
+
// model file (a legitimate "assembled from local sub-parts" case, not
|
|
49
|
+
// just the "split across separate part files" one) -- when absent,
|
|
50
|
+
// resolve objectid against topModelText itself instead of an external part.
|
|
51
|
+
const componentTags = [...objBlock.matchAll(/<component\b[^>]*\/>/g)].map((m) => m[0]);
|
|
52
|
+
const include = ([wx, wy]) => {
|
|
53
|
+
if (wx < minX)
|
|
54
|
+
minX = wx;
|
|
55
|
+
if (wx > maxX)
|
|
56
|
+
maxX = wx;
|
|
57
|
+
if (wy < minY)
|
|
58
|
+
minY = wy;
|
|
59
|
+
if (wy > maxY)
|
|
60
|
+
maxY = wy;
|
|
61
|
+
count++;
|
|
62
|
+
};
|
|
63
|
+
if (componentTags.length > 0) {
|
|
64
|
+
for (const tag of componentTags) {
|
|
65
|
+
const path = componentAttr(tag, "p:path");
|
|
66
|
+
const subObjId = componentAttr(tag, "objectid");
|
|
67
|
+
const transform = componentAttr(tag, "transform");
|
|
68
|
+
if (!subObjId || !transform)
|
|
69
|
+
continue;
|
|
70
|
+
const [compR, compT] = parseMatrix(transform);
|
|
71
|
+
const [R, T] = compose(itemR, itemT, compR, compT);
|
|
72
|
+
let subBlock;
|
|
73
|
+
if (path) {
|
|
74
|
+
const key = path.replace(/^\/+/, "");
|
|
75
|
+
const bytes = zipEntries[key];
|
|
76
|
+
// A very large mesh is scanned from its bytes: decoding it whole can exceed the engine's longest string.
|
|
77
|
+
if (bytes && bytes.length > LARGE_PART_BYTES) {
|
|
78
|
+
// Kept aside until the block is known to close, as the whole-file path only uses a closed block.
|
|
79
|
+
let [aMinX, aMaxX, aMinY, aMaxY, aCount] = [Infinity, -Infinity, Infinity, -Infinity, 0];
|
|
80
|
+
const closed = forEachObjectVertex(bytes, subObjId, (v) => {
|
|
81
|
+
const [wx, wy] = applyTransform(v, R, T);
|
|
82
|
+
if (wx < aMinX)
|
|
83
|
+
aMinX = wx;
|
|
84
|
+
if (wx > aMaxX)
|
|
85
|
+
aMaxX = wx;
|
|
86
|
+
if (wy < aMinY)
|
|
87
|
+
aMinY = wy;
|
|
88
|
+
if (wy > aMaxY)
|
|
89
|
+
aMaxY = wy;
|
|
90
|
+
aCount++;
|
|
91
|
+
});
|
|
92
|
+
if (closed && aCount > 0) {
|
|
93
|
+
minX = Math.min(minX, aMinX);
|
|
94
|
+
maxX = Math.max(maxX, aMaxX);
|
|
95
|
+
minY = Math.min(minY, aMinY);
|
|
96
|
+
maxY = Math.max(maxY, aMaxY);
|
|
97
|
+
count += aCount;
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!partFileCache.has(key)) {
|
|
102
|
+
partFileCache.set(key, bytes ? utf8Decoder.decode(bytes) : "");
|
|
103
|
+
}
|
|
104
|
+
subBlock = findObjectBlock(subObjId, partFileCache.get(key));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
subBlock = findObjectBlock(subObjId, topModelText);
|
|
108
|
+
}
|
|
109
|
+
if (!subBlock)
|
|
110
|
+
continue;
|
|
111
|
+
for (const v of parseVertices(subBlock))
|
|
112
|
+
include(applyTransform(v, R, T));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Direct mesh in the same object definition (no components at all).
|
|
117
|
+
for (const v of parseVertices(objBlock))
|
|
118
|
+
include(applyTransform(v, itemR, itemT));
|
|
119
|
+
}
|
|
120
|
+
if (count === 0)
|
|
121
|
+
return null;
|
|
122
|
+
return [minX, maxX, minY, maxY];
|
|
123
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* Return `{objectid: [tx, ty]}` for every top-level `<item>` in `<build>`
|
|
4
|
+
* whose transform has exactly 12 tokens.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export function parseItemPositions(modelXmlText) {
|
|
8
|
+
const positions = {};
|
|
9
|
+
for (const m of modelXmlText.matchAll(/<item objectid="(\d+)"[^>]*transform="([^"]+)"/g)) {
|
|
10
|
+
const oid = m[1];
|
|
11
|
+
const tokens = m[2].split(/\s+/).filter(Boolean);
|
|
12
|
+
if (tokens.length === 12) {
|
|
13
|
+
positions[oid] = [Number(tokens[9]), Number(tokens[10])];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return positions;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract object names, sequence numbers, and assembly status for each object id from
|
|
3
|
+
* `3D/3dmodel.model` and `Metadata/model_settings.config`.
|
|
4
|
+
*/
|
|
5
|
+
export interface ObjectMetadata {
|
|
6
|
+
name?: string;
|
|
7
|
+
sequence?: number;
|
|
8
|
+
isAssembly: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseObjectMetadata(topModelText: string, modelSettingsText?: string): Record<string, ObjectMetadata>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { xmlBlocks } from "./xmlBlocks.js";
|
|
3
|
+
export function parseObjectMetadata(topModelText, modelSettingsText) {
|
|
4
|
+
const result = {};
|
|
5
|
+
// Helper to extract an attribute value regardless of position or quote style
|
|
6
|
+
function getAttr(attrString, attrName) {
|
|
7
|
+
const match = new RegExp(`\\b${attrName}=["']([^"']+)["']`, "i").exec(attrString);
|
|
8
|
+
return match ? match[1].trim() : undefined;
|
|
9
|
+
}
|
|
10
|
+
// 1. Parse top-level <object> blocks from 3D/3dmodel.model
|
|
11
|
+
for (const { attrs, body } of xmlBlocks(topModelText, "object")) {
|
|
12
|
+
const id = getAttr(attrs, "id");
|
|
13
|
+
if (!id)
|
|
14
|
+
continue;
|
|
15
|
+
// Check if it's an assembly (has <component> children)
|
|
16
|
+
const hasComponents = /<component\s/i.test(body);
|
|
17
|
+
// Check name in attribute: name="..." or <metadata name="name">...</metadata>
|
|
18
|
+
let name = getAttr(attrs, "name");
|
|
19
|
+
if (!name) {
|
|
20
|
+
const metaNameMatch = body.match(/<metadata\s+[^>]*?name="name"[^>]*>([^<]+)<\/metadata>/i);
|
|
21
|
+
if (metaNameMatch) {
|
|
22
|
+
name = metaNameMatch[1].trim();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
result[id] = {
|
|
26
|
+
name,
|
|
27
|
+
isAssembly: hasComponents,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// 2. Parse Metadata/model_settings.config
|
|
31
|
+
if (modelSettingsText) {
|
|
32
|
+
// Check <object id="..."> blocks containing <metadata key="name" value="..."/>
|
|
33
|
+
for (const { attrs, body } of xmlBlocks(modelSettingsText, "object")) {
|
|
34
|
+
const id = getAttr(attrs, "id");
|
|
35
|
+
if (!id)
|
|
36
|
+
continue;
|
|
37
|
+
let name = getAttr(attrs, "name");
|
|
38
|
+
if (!name) {
|
|
39
|
+
for (const metaMatch of body.matchAll(/<metadata\s+([^>]*?)\/?>/g)) {
|
|
40
|
+
const metaAttrs = metaMatch[1];
|
|
41
|
+
const key = getAttr(metaAttrs, "key") || getAttr(metaAttrs, "name");
|
|
42
|
+
const val = getAttr(metaAttrs, "value");
|
|
43
|
+
if (key === "name" || key === "object_name") {
|
|
44
|
+
name = val;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (name) {
|
|
50
|
+
if (result[id]) {
|
|
51
|
+
result[id].name = name;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
result[id] = { name, isAssembly: false };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Check <plate> blocks to assign 1-based sequence order per plate
|
|
59
|
+
for (const { body: plateBlock } of xmlBlocks(modelSettingsText, "plate")) {
|
|
60
|
+
let seqIndex = 1;
|
|
61
|
+
for (const { body: block } of xmlBlocks(plateBlock, "model_instance")) {
|
|
62
|
+
let objectId;
|
|
63
|
+
let instName;
|
|
64
|
+
for (const metaMatch of block.matchAll(/<metadata\s+([^>]*?)\/?>/g)) {
|
|
65
|
+
const metaAttrs = metaMatch[1];
|
|
66
|
+
const key = getAttr(metaAttrs, "key") || getAttr(metaAttrs, "name");
|
|
67
|
+
const val = getAttr(metaAttrs, "value");
|
|
68
|
+
if (!key || !val)
|
|
69
|
+
continue;
|
|
70
|
+
if (key === "object_id") {
|
|
71
|
+
objectId = val;
|
|
72
|
+
}
|
|
73
|
+
else if (key === "name" || key === "object_name") {
|
|
74
|
+
instName = val;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (objectId) {
|
|
78
|
+
const seq = seqIndex++;
|
|
79
|
+
if (result[objectId]) {
|
|
80
|
+
result[objectId].sequence = seq;
|
|
81
|
+
if (instName && !result[objectId].name) {
|
|
82
|
+
result[objectId].name = instName;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
result[objectId] = {
|
|
87
|
+
name: instName,
|
|
88
|
+
sequence: seq,
|
|
89
|
+
isAssembly: false,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { xmlBlocks } from "./xmlBlocks.js";
|
|
3
|
+
/**
|
|
4
|
+
* Map objectid -> plate index (1-based) from `<plate><model_instance>`
|
|
5
|
+
* metadata in `model_settings.config`.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export function parsePlateAssignments(modelSettingsText) {
|
|
9
|
+
const plates = [...xmlBlocks(modelSettingsText, "plate")].map((block) => block.body);
|
|
10
|
+
const assignment = {};
|
|
11
|
+
plates.forEach((plate, i) => {
|
|
12
|
+
const plateIndex = i + 1;
|
|
13
|
+
for (const m of plate.matchAll(/key="object_id" value="(\d+)"/g)) {
|
|
14
|
+
assignment[m[1]] = plateIndex;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return assignment;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex-extract every `<vertex x=".." y=".." z=".."/>` from an XML
|
|
3
|
+
* fragment.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export function parseVertices(meshXmlFragment) {
|
|
7
|
+
const vertices = [];
|
|
8
|
+
for (const m of meshXmlFragment.matchAll(/<vertex x="([^"]+)" y="([^"]+)" z="([^"]+)"/g)) {
|
|
9
|
+
vertices.push([Number(m[1]), Number(m[2]), Number(m[3])]);
|
|
10
|
+
}
|
|
11
|
+
return vertices;
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const PROJECT_SETTINGS_PATH = "Metadata/project_settings.config";
|
|
2
|
+
export declare const MODEL_SETTINGS_PATH = "Metadata/model_settings.config";
|
|
3
|
+
export declare const TOP_MODEL_PATH = "3D/3dmodel.model";
|
|
4
|
+
/** Files pulled from the Bambu source .3mf and merged/adapted specially, rather than copied verbatim. */
|
|
5
|
+
export declare const SPECIAL_HANDLING: Set<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
export const PROJECT_SETTINGS_PATH = "Metadata/project_settings.config";
|
|
3
|
+
export const MODEL_SETTINGS_PATH = "Metadata/model_settings.config";
|
|
4
|
+
export const TOP_MODEL_PATH = "3D/3dmodel.model";
|
|
5
|
+
/** Files pulled from the Bambu source .3mf and merged/adapted specially, rather than copied verbatim. */
|
|
6
|
+
export const SPECIAL_HANDLING = new Set([PROJECT_SETTINGS_PATH, MODEL_SETTINGS_PATH, TOP_MODEL_PATH]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Same idea as `recenterBuildItems`, but for `<assemble_item>` entries
|
|
3
|
+
* inside `<assemble>` in `model_settings.config`. Only shifts items that
|
|
4
|
+
* carry an `instance_id` attribute (matched to `shifts` by
|
|
5
|
+
* `object_id="(\d+)"`); items without one are left untouched.
|
|
6
|
+
*
|
|
7
|
+
* Same regex-surgery-not-DOM caveat as `recenterBuildItems` applies.
|
|
8
|
+
*/
|
|
9
|
+
export declare function recenterAssembleItems(configXmlText: string, shifts: Readonly<Record<string, readonly [number, number]>>, warnings: string[]): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { fmtNum } from "./fmtNum.js";
|
|
3
|
+
/**
|
|
4
|
+
* Same idea as `recenterBuildItems`, but for `<assemble_item>` entries
|
|
5
|
+
* inside `<assemble>` in `model_settings.config`. Only shifts items that
|
|
6
|
+
* carry an `instance_id` attribute (matched to `shifts` by
|
|
7
|
+
* `object_id="(\d+)"`); items without one are left untouched.
|
|
8
|
+
*
|
|
9
|
+
* Same regex-surgery-not-DOM caveat as `recenterBuildItems` applies.
|
|
10
|
+
*/
|
|
11
|
+
export function recenterAssembleItems(configXmlText, shifts, warnings) {
|
|
12
|
+
const start = configXmlText.indexOf("<assemble>");
|
|
13
|
+
if (start === -1)
|
|
14
|
+
return configXmlText;
|
|
15
|
+
const end = configXmlText.indexOf("</assemble>", start);
|
|
16
|
+
if (end === -1)
|
|
17
|
+
return configXmlText;
|
|
18
|
+
const section = configXmlText.slice(start, end);
|
|
19
|
+
let shifted = 0;
|
|
20
|
+
let skippedRelative = 0;
|
|
21
|
+
const newSection = section.replace(/<assemble_item\s+[^>]*>/g, (fullTag) => {
|
|
22
|
+
if (!fullTag.includes("instance_id")) {
|
|
23
|
+
skippedRelative++;
|
|
24
|
+
return fullTag;
|
|
25
|
+
}
|
|
26
|
+
const oidMatch = fullTag.match(/object_id="(\d+)"/);
|
|
27
|
+
const transMatch = fullTag.match(/transform="([^"]+)"/);
|
|
28
|
+
if (!transMatch)
|
|
29
|
+
return fullTag;
|
|
30
|
+
const oid = oidMatch ? oidMatch[1] : null;
|
|
31
|
+
const [dx, dy] = oid !== null ? (shifts[oid] ?? [0, 0]) : [0, 0];
|
|
32
|
+
const transformStr = transMatch[1];
|
|
33
|
+
const tokens = transformStr.split(/\s+/).filter(Boolean);
|
|
34
|
+
if (tokens.length !== 12) {
|
|
35
|
+
warnings.push(` WARN: unexpected assemble transform format on object ${oid}`);
|
|
36
|
+
return fullTag;
|
|
37
|
+
}
|
|
38
|
+
const tx = Number(tokens[9]);
|
|
39
|
+
const ty = Number(tokens[10]);
|
|
40
|
+
tokens[9] = fmtNum(tx + dx);
|
|
41
|
+
tokens[10] = fmtNum(ty + dy);
|
|
42
|
+
shifted++;
|
|
43
|
+
const newTransform = tokens.join(" ");
|
|
44
|
+
return fullTag.replace(`transform="${transformStr}"`, `transform="${newTransform}"`);
|
|
45
|
+
});
|
|
46
|
+
if (shifted) {
|
|
47
|
+
warnings.push(` Recentered ${shifted} assemble_item(s) in model_settings.config.`);
|
|
48
|
+
}
|
|
49
|
+
if (skippedRelative) {
|
|
50
|
+
warnings.push(` Left ${skippedRelative} assemble_item(s) untouched.`);
|
|
51
|
+
}
|
|
52
|
+
return configXmlText.slice(0, start) + newSection + configXmlText.slice(end);
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrite every `<item ...transform="...">` in the `<build>` section of
|
|
3
|
+
* `3dmodel.model`, adding `(dx, dy)` from `shifts[objectid]` to the
|
|
4
|
+
* translation components (tokens 9 and 10 of the 12-number transform).
|
|
5
|
+
*
|
|
6
|
+
* Deliberately uses regex substitution directly on raw XML text rather
|
|
7
|
+
* than a parsed DOM + re-serialize -- this preserves untouched
|
|
8
|
+
* attributes' exact order/whitespace/quoting byte-for-byte, which a
|
|
9
|
+
* DOM round-trip would not. Do not "upgrade" this to a DOM-based
|
|
10
|
+
* approach; it would silently change bytes that should stay identical.
|
|
11
|
+
*
|
|
12
|
+
* Operates on already-decoded text, not bytes (see `adaptModelSettings`'s
|
|
13
|
+
* doc comment for why).
|
|
14
|
+
*/
|
|
15
|
+
export declare function recenterBuildItems(modelXmlText: string, shifts: Readonly<Record<string, readonly [number, number]>>, warnings: string[]): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { fmtNum } from "./fmtNum.js";
|
|
3
|
+
/**
|
|
4
|
+
* Rewrite every `<item ...transform="...">` in the `<build>` section of
|
|
5
|
+
* `3dmodel.model`, adding `(dx, dy)` from `shifts[objectid]` to the
|
|
6
|
+
* translation components (tokens 9 and 10 of the 12-number transform).
|
|
7
|
+
*
|
|
8
|
+
* Deliberately uses regex substitution directly on raw XML text rather
|
|
9
|
+
* than a parsed DOM + re-serialize -- this preserves untouched
|
|
10
|
+
* attributes' exact order/whitespace/quoting byte-for-byte, which a
|
|
11
|
+
* DOM round-trip would not. Do not "upgrade" this to a DOM-based
|
|
12
|
+
* approach; it would silently change bytes that should stay identical.
|
|
13
|
+
*
|
|
14
|
+
* Operates on already-decoded text, not bytes (see `adaptModelSettings`'s
|
|
15
|
+
* doc comment for why).
|
|
16
|
+
*/
|
|
17
|
+
export function recenterBuildItems(modelXmlText, shifts, warnings) {
|
|
18
|
+
const buildStart = modelXmlText.indexOf("<build");
|
|
19
|
+
if (buildStart === -1)
|
|
20
|
+
return modelXmlText;
|
|
21
|
+
const buildEnd = modelXmlText.indexOf("</build>", buildStart);
|
|
22
|
+
if (buildEnd === -1)
|
|
23
|
+
return modelXmlText;
|
|
24
|
+
const buildSection = modelXmlText.slice(buildStart, buildEnd);
|
|
25
|
+
let itemCount = 0;
|
|
26
|
+
const newBuildSection = buildSection.replace(/<item\s+[^>]*>/g, (fullTag) => {
|
|
27
|
+
const oidMatch = fullTag.match(/objectid="(\d+)"/);
|
|
28
|
+
const transMatch = fullTag.match(/transform="([^"]+)"/);
|
|
29
|
+
if (!oidMatch || !transMatch)
|
|
30
|
+
return fullTag;
|
|
31
|
+
const oid = oidMatch[1];
|
|
32
|
+
const transformStr = transMatch[1];
|
|
33
|
+
const [dx, dy] = shifts[oid] ?? [0, 0];
|
|
34
|
+
const tokens = transformStr.split(/\s+/).filter(Boolean);
|
|
35
|
+
if (tokens.length !== 12) {
|
|
36
|
+
warnings.push(` WARN: unexpected transform format on object ${oid}`);
|
|
37
|
+
return fullTag;
|
|
38
|
+
}
|
|
39
|
+
const tx = Number(tokens[9]);
|
|
40
|
+
const ty = Number(tokens[10]);
|
|
41
|
+
tokens[9] = fmtNum(tx + dx);
|
|
42
|
+
tokens[10] = fmtNum(ty + dy);
|
|
43
|
+
itemCount++;
|
|
44
|
+
const newTransform = tokens.join(" ");
|
|
45
|
+
return fullTag.replace(`transform="${transformStr}"`, `transform="${newTransform}"`);
|
|
46
|
+
});
|
|
47
|
+
if (itemCount) {
|
|
48
|
+
warnings.push(` Recentered ${itemCount} object placement(s) in 3D/3dmodel.model.`);
|
|
49
|
+
}
|
|
50
|
+
return modelXmlText.slice(0, buildStart) + newBuildSection + modelXmlText.slice(buildEnd);
|
|
51
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Unzipped } from "fflate";
|
|
2
|
+
/**
|
|
3
|
+
* The most a project may unpack to by default: above the largest real
|
|
4
|
+
* projects seen (1.5GB), and as much as a browser tab reliably holds while
|
|
5
|
+
* converting (about twice the unpacked size at the peak).
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_MAX_UNPACKED_BYTES: number;
|
|
8
|
+
/** The most `maxUnpackedBytes` can raise the limit to, for the command line and Node. */
|
|
9
|
+
export declare const MAX_UNPACKED_BYTES_LIMIT: number;
|
|
10
|
+
/** Above this, opening a project warns that converting it takes a lot of memory. */
|
|
11
|
+
export declare const LARGE_PROJECT_BYTES: number;
|
|
12
|
+
/**
|
|
13
|
+
* Rejects zip-slip shaped entry names: parent-directory segments, absolute
|
|
14
|
+
* or drive-letter paths, backslashes and NUL. Nothing here writes entries
|
|
15
|
+
* to disk by name, but output filenames for a bundle's nested files come
|
|
16
|
+
* from these names, and a name like that has no legitimate use in a 3MF.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isSafeEntryName(name: string): boolean;
|
|
19
|
+
/** "2 GB", "1.5 GB", "512 MB": a size for a message. */
|
|
20
|
+
export declare function formatSize(bytes: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Unzips a project in memory, refusing what looks crafted (see above).
|
|
23
|
+
* `maxUnpackedBytes` raises or lowers the size limit; the default suits a
|
|
24
|
+
* browser tab.
|
|
25
|
+
*/
|
|
26
|
+
export declare function safeUnzipSync(fileBytes: Uint8Array, maxUnpackedBytes?: number): Unzipped;
|