@s8fy/xdoc 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ PolyForm Noncommercial License 1.0.0
2
+ https://polyformproject.org/licenses/noncommercial/1.0.0
3
+
4
+ Required Notice: Copyright (c) 2025-PRESENT hustcer
5
+
6
+ This module is source-available, not open source. No commercial use is granted
7
+ to third parties under this module's default license unless separately
8
+ licensed.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # `@s8fy/xdoc`
2
+
3
+ Install the native `xdoc` CLI through npm:
4
+
5
+ ```sh
6
+ npm install --global @s8fy/xdoc
7
+ xdoc --version
8
+ ```
9
+
10
+ The base package selects an exact, platform-specific optional dependency. No
11
+ binary is downloaded by an install script.
12
+
13
+ ## Supported platforms
14
+
15
+ | Operating system | Architecture | Binary package |
16
+ | ----------------- | ------------ | ------------------------ |
17
+ | Linux | arm64 | `@s8fy/xdoc-linux-arm64` |
18
+ | Linux | x64 | `@s8fy/xdoc-linux-x64` |
19
+ | macOS 26 or newer | arm64 | `@s8fy/xdoc-macos-arm64` |
20
+ | Windows | x64 | `@s8fy/xdoc-windows-x64` |
21
+
22
+ Installation fails with an actionable error on any unsupported operating
23
+ system, architecture, or operating system version. The minimum supported
24
+ Node.js version is 22. The macOS requirement reflects the deployment target of
25
+ the current upstream native binary.
26
+
27
+ The locked v0.3.10 macOS asset predates the native deployment-target fix and
28
+ must not be published as compatible with older macOS releases. The npm
29
+ preflight and smoke jobs intentionally run on macOS 15, so this asset will fail
30
+ closed. Cut a new upstream xdoc release with `MACOSX_DEPLOYMENT_TARGET=13.0`,
31
+ then update `minimumOsVersion` to `13.0` and `minimumKernelMajor` to `22` in
32
+ `platforms.json` together with the version and release lock. macOS 13 is the
33
+ current lower bound because the statically linked PDFium archive has a macOS
34
+ 13 deployment target.
35
+
36
+ ## Source and issue reporting
37
+
38
+ This directory contains only the npm packaging and release automation. The
39
+ native binaries come from the private `hustcer/pptx` repository and are locked
40
+ to reviewed GitHub Release SHA-256 digests in `release-lock.json`.
41
+
42
+ - Report npm installation, package selection, or launcher issues in the
43
+ [`hustcer/workers` issue tracker](https://github.com/hustcer/workers/issues).
44
+ - Report native `xdoc` behavior through the upstream project's normal support
45
+ channel.
46
+
47
+ Each platform package preserves the upstream `LICENSE` and all bundled PDFium
48
+ third-party license notices. This software is distributed under the PolyForm
49
+ Noncommercial License 1.0.0 unless separately licensed.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { assertRuntimeSupport } = require("./platform.cjs");
5
+
6
+ try {
7
+ assertRuntimeSupport();
8
+ } catch (error) {
9
+ const message = error instanceof Error ? error.message : String(error);
10
+ console.error(`xdoc install error: ${message}`);
11
+ process.exitCode = 1;
12
+ }
package/lib/index.cjs ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const { constants } = require("node:os");
6
+ const { resolveBinaryPath } = require("./platform.cjs");
7
+
8
+ function execute(
9
+ args = process.argv.slice(2),
10
+ { os = process.platform, cpu = process.arch, resolve = require.resolve, spawn = spawnSync } = {},
11
+ ) {
12
+ const executable = resolveBinaryPath({ os, cpu, resolve });
13
+ const result = spawn(executable, args, { stdio: "inherit" });
14
+
15
+ if (result.error) {
16
+ throw new Error(`Failed to start the xdoc binary: ${result.error.message}`, {
17
+ cause: result.error,
18
+ });
19
+ }
20
+
21
+ if (typeof result.status === "number") {
22
+ return { exitCode: result.status, signal: null };
23
+ }
24
+
25
+ if (result.signal) {
26
+ const signalNumber = constants.signals[result.signal];
27
+ return {
28
+ exitCode: typeof signalNumber === "number" ? 128 + signalNumber : 1,
29
+ signal: result.signal,
30
+ };
31
+ }
32
+
33
+ return { exitCode: 1, signal: null };
34
+ }
35
+
36
+ function main() {
37
+ try {
38
+ const result = execute();
39
+
40
+ if (result.signal && process.platform !== "win32") {
41
+ try {
42
+ process.kill(process.pid, result.signal);
43
+ } catch (cause) {
44
+ const message = cause instanceof Error ? cause.message : String(cause);
45
+ console.error(`xdoc launcher warning: failed to propagate ${result.signal}: ${message}`);
46
+ }
47
+ }
48
+
49
+ process.exitCode = result.exitCode;
50
+ } catch (error) {
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ console.error(`xdoc launcher error: ${message}`);
53
+ process.exitCode = 1;
54
+ }
55
+ }
56
+
57
+ if (require.main === module) {
58
+ main();
59
+ }
60
+
61
+ module.exports = { execute, main };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ const { release: systemRelease } = require("node:os");
4
+ const platformsDocument = require("../platforms.json");
5
+
6
+ const platforms = Object.freeze(
7
+ platformsDocument.platforms.map((platform) => Object.freeze({ ...platform })),
8
+ );
9
+
10
+ function platformId(os = process.platform, cpu = process.arch) {
11
+ const osName = os === "darwin" ? "macos" : os === "win32" ? "windows" : os;
12
+ return `${osName}-${cpu}`;
13
+ }
14
+
15
+ function supportedPlatformIds() {
16
+ return platforms.map((platform) => platform.id);
17
+ }
18
+
19
+ function getPlatform(os = process.platform, cpu = process.arch) {
20
+ const id = platformId(os, cpu);
21
+ const platform = platforms.find((candidate) => candidate.id === id);
22
+
23
+ if (!platform) {
24
+ throw new Error(
25
+ `@s8fy/xdoc does not support ${os}/${cpu} (${id}). Supported platforms: ${supportedPlatformIds().join(", ")}.`,
26
+ );
27
+ }
28
+
29
+ return platform;
30
+ }
31
+
32
+ function assertRuntimeSupport({
33
+ os = process.platform,
34
+ cpu = process.arch,
35
+ kernelRelease = systemRelease(),
36
+ } = {}) {
37
+ const platform = getPlatform(os, cpu);
38
+ if (platform.minimumKernelMajor !== undefined) {
39
+ const kernelMajor = Number.parseInt(kernelRelease, 10);
40
+ if (!Number.isInteger(kernelMajor)) {
41
+ throw new Error(
42
+ `Unable to determine whether ${os}/${cpu} meets the minimum operating system version.`,
43
+ );
44
+ }
45
+ if (kernelMajor < platform.minimumKernelMajor) {
46
+ throw new Error(
47
+ `@s8fy/xdoc ${platform.id} requires macOS ${platform.minimumOsVersion} or newer.`,
48
+ );
49
+ }
50
+ }
51
+ return platform;
52
+ }
53
+
54
+ function resolveBinaryPath({
55
+ os = process.platform,
56
+ cpu = process.arch,
57
+ resolve = require.resolve,
58
+ kernelRelease = systemRelease(),
59
+ } = {}) {
60
+ const platform = assertRuntimeSupport({ os, cpu, kernelRelease });
61
+ const request = `${platform.packageName}/bin/${platform.binaryName}`;
62
+
63
+ try {
64
+ return resolve(request);
65
+ } catch (cause) {
66
+ throw new Error(
67
+ `The xdoc binary package "${platform.packageName}" is missing. Reinstall @s8fy/xdoc with optional dependencies enabled and without --omit=optional.`,
68
+ { cause },
69
+ );
70
+ }
71
+ }
72
+
73
+ module.exports = {
74
+ assertRuntimeSupport,
75
+ getPlatform,
76
+ platformId,
77
+ platforms,
78
+ resolveBinaryPath,
79
+ supportedPlatformIds,
80
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ function containsExactVersion(output, expectedVersion) {
4
+ const escaped = expectedVersion.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ return new RegExp(`(^|\\s)v?${escaped}(?=\\s|$)`).test(output);
6
+ }
7
+
8
+ module.exports = { containsExactVersion };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@s8fy/xdoc",
3
+ "version": "0.3.12",
4
+ "description": "The xdoc CLI packaged for installation through npm.",
5
+ "keywords": [
6
+ "cli",
7
+ "document",
8
+ "pdf",
9
+ "pptx",
10
+ "xdoc"
11
+ ],
12
+ "homepage": "https://github.com/hustcer/workers/tree/main/xdoc-npm#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/hustcer/workers/issues"
15
+ },
16
+ "license": "PolyForm-Noncommercial-1.0.0",
17
+ "author": "hustcer",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/hustcer/workers.git",
21
+ "directory": "xdoc-npm"
22
+ },
23
+ "bin": {
24
+ "xdoc": "lib/index.cjs"
25
+ },
26
+ "files": [
27
+ "lib",
28
+ "platforms.json"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "provenance": true,
33
+ "registry": "https://registry.npmjs.org"
34
+ },
35
+ "scripts": {
36
+ "preinstall": "node lib/check-platform.cjs",
37
+ "test": "node --test tests/*.test.cjs"
38
+ },
39
+ "optionalDependencies": {
40
+ "@s8fy/xdoc-linux-arm64": "0.3.12",
41
+ "@s8fy/xdoc-linux-x64": "0.3.12",
42
+ "@s8fy/xdoc-macos-arm64": "0.3.12",
43
+ "@s8fy/xdoc-windows-x64": "0.3.12"
44
+ },
45
+ "engines": {
46
+ "node": ">=22.0.0"
47
+ },
48
+ "preferUnplugged": true,
49
+ "xdoc": {
50
+ "releaseTag": "v0.3.12",
51
+ "sourceRepository": "hustcer/pptx"
52
+ }
53
+ }
package/platforms.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "schemaVersion": "xdoc-npm-platforms/v1",
3
+ "platforms": [
4
+ {
5
+ "id": "linux-arm64",
6
+ "os": "linux",
7
+ "cpu": "arm64",
8
+ "packageName": "@s8fy/xdoc-linux-arm64",
9
+ "assetName": "xdoc-linux-arm64.tar.gz",
10
+ "archiveType": "tar.gz",
11
+ "binaryName": "xdoc"
12
+ },
13
+ {
14
+ "id": "linux-x64",
15
+ "os": "linux",
16
+ "cpu": "x64",
17
+ "packageName": "@s8fy/xdoc-linux-x64",
18
+ "assetName": "xdoc-linux-x64.tar.gz",
19
+ "archiveType": "tar.gz",
20
+ "binaryName": "xdoc"
21
+ },
22
+ {
23
+ "id": "macos-arm64",
24
+ "os": "darwin",
25
+ "cpu": "arm64",
26
+ "packageName": "@s8fy/xdoc-macos-arm64",
27
+ "assetName": "xdoc-macos-arm64.tar.gz",
28
+ "archiveType": "tar.gz",
29
+ "binaryName": "xdoc",
30
+ "minimumOsVersion": "13.0",
31
+ "minimumKernelMajor": 22
32
+ },
33
+ {
34
+ "id": "windows-x64",
35
+ "os": "win32",
36
+ "cpu": "x64",
37
+ "packageName": "@s8fy/xdoc-windows-x64",
38
+ "assetName": "xdoc-windows-x64.zip",
39
+ "archiveType": "zip",
40
+ "binaryName": "xdoc.exe"
41
+ }
42
+ ]
43
+ }