@deepseek-ai/libreoffice-kit 0.0.2-rc9 → 0.0.3
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/NOTICE +0 -240
- package/README.md +53 -43
- package/README.zh.md +58 -35
- package/lib/cli.js +725 -132
- package/lib/index.js +757 -133
- package/lib/types/engine.d.ts +5 -5
- package/lib/types/font-loader.d.ts +18 -16
- package/lib/types/fonts.d.ts +38 -21
- package/lib/types/image-operations.d.ts +1 -1
- package/lib/types/index.d.ts +13 -7
- package/lib/types/native-image-renderer.d.ts +19 -0
- package/lib/types/native.d.ts +1 -1
- package/lib/types/options.d.ts +3 -1
- package/lib/types/wasm.d.ts +4 -1
- package/lib/types/worker.d.ts +2 -0
- package/lib/worker.js +420 -942
- package/package.json +13 -55
- package/assets/font-subset.json +0 -70
- package/assets/font-subset.wasm +0 -0
- package/lib/browser/assets.json +0 -10
- package/lib/browser/index.js +0 -626
- package/lib/browser/types/connection.d.ts +0 -42
- package/lib/browser/types/engine-rendering.d.ts +0 -3
- package/lib/browser/types/engine-types.d.ts +0 -17
- package/lib/browser/types/font-channel.d.ts +0 -36
- package/lib/browser/types/index.d.ts +0 -14
- package/lib/browser/types/office-engine.d.ts +0 -56
- package/lib/browser/types/office-types.d.ts +0 -166
- package/lib/browser/types/office.d.ts +0 -19
- package/lib/browser/types/preparation.d.ts +0 -13
- package/lib/browser/types/protocol.d.ts +0 -137
- package/lib/browser/types/rendering.d.ts +0 -4
- package/lib/browser/types/types.d.ts +0 -115
- package/lib/browser/types/worker.d.ts +0 -2
- package/lib/browser/worker.js +0 -3796
- package/lib/browser-assets.js +0 -119
- package/lib/document.js +0 -178
- package/lib/engine-rendering.js +0 -120
- package/lib/font-config.js +0 -46
- package/lib/font-source.js +0 -395
- package/lib/font-worker.js +0 -1481
- package/lib/rendering.js +0 -99
- package/lib/sheet-geometry.js +0 -111
- package/lib/types/browser-assets.d.ts +0 -15
- package/lib/types/default-fonts.d.ts +0 -3
- package/lib/types/font-config.d.ts +0 -24
- package/lib/types/font-preferences-data.d.ts +0 -16
- package/lib/types/font-preferences.d.ts +0 -29
- package/lib/types/font-request.d.ts +0 -12
- package/lib/types/font-source-types.d.ts +0 -95
- package/lib/types/font-source.d.ts +0 -10
- package/lib/types/font-subsets.d.ts +0 -39
- package/lib/types/font-worker.d.ts +0 -2
- package/lib/types/harfbuzz-subset.d.ts +0 -11
- package/lib/types/unicode-scripts.d.ts +0 -18
- package/licenses/font-subset/harfbuzz-COPYING +0 -42
- package/licenses/font-subset/harfbuzzjs-LICENSE +0 -19
- package/licenses/javascript/fflate-LICENSE +0 -21
- package/licenses/javascript/saxes-LICENSE +0 -64
- package/licenses/javascript/xmlchars-LICENSE +0 -18
- package/sources/browser/packages/browser/package.json +0 -22
- package/sources/browser/packages/browser/src/connection.ts +0 -237
- package/sources/browser/packages/browser/src/engine-rendering.ts +0 -2
- package/sources/browser/packages/browser/src/engine-types.ts +0 -14
- package/sources/browser/packages/browser/src/font-channel.ts +0 -169
- package/sources/browser/packages/browser/src/index.ts +0 -40
- package/sources/browser/packages/browser/src/office-engine.ts +0 -397
- package/sources/browser/packages/browser/src/office-types.ts +0 -128
- package/sources/browser/packages/browser/src/office.ts +0 -128
- package/sources/browser/packages/browser/src/preparation.ts +0 -41
- package/sources/browser/packages/browser/src/protocol.ts +0 -55
- package/sources/browser/packages/browser/src/rendering.ts +0 -3
- package/sources/browser/packages/browser/src/types.ts +0 -118
- package/sources/browser/packages/browser/src/worker.ts +0 -260
- package/sources/browser/packages/browser/tsconfig.json +0 -5
- package/sources/browser/packages/browser/tsdown.config.ts +0 -7
- package/sources/browser/scripts/build-browser.mjs +0 -86
- package/sources/font-subset/engine/font-subset/README.md +0 -23
- package/sources/font-subset/engine/font-subset/README.zh.md +0 -23
- package/sources/font-subset/engine/font-subset/source.json +0 -16
- package/sources/font-subset/harfbuzzjs/config-override-subset.h +0 -7
- package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +0 -34
- package/sources/font-subset/scripts/build-font-subset.mjs +0 -64
- package/sources/font-subset/scripts/pack-utils.mjs +0 -69
- package/sources/font-subset/scripts/platform-matrix.mjs +0 -100
- package/sources/font-subset/scripts/verify-artifacts.mjs +0 -260
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"algorithm": "harfbuzzjs-1.6.1-hb-36cb489-growth-v1",
|
|
4
|
-
"harfbuzzjs": {
|
|
5
|
-
"repository": "https://github.com/harfbuzz/harfbuzzjs.git",
|
|
6
|
-
"commit": "8aa047b90387790b255b118cf45ad11691a38910"
|
|
7
|
-
},
|
|
8
|
-
"harfbuzz": {
|
|
9
|
-
"repository": "https://github.com/harfbuzz/harfbuzz.git",
|
|
10
|
-
"commit": "36cb489cb02ce4b92099669ba9f9bea348eff93f"
|
|
11
|
-
},
|
|
12
|
-
"emsdk": {
|
|
13
|
-
"commit": "5eb0bde7585670252e8ba05e9d361627bffd08b5",
|
|
14
|
-
"version": "4.0.10"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
_hb_blob_create
|
|
2
|
-
_hb_blob_destroy
|
|
3
|
-
_hb_blob_get_data
|
|
4
|
-
_hb_blob_get_length
|
|
5
|
-
_hb_face_create
|
|
6
|
-
_hb_face_destroy
|
|
7
|
-
_hb_face_get_empty
|
|
8
|
-
_hb_face_reference_blob
|
|
9
|
-
_hb_set_add
|
|
10
|
-
_hb_set_clear
|
|
11
|
-
_hb_set_create
|
|
12
|
-
_hb_set_del
|
|
13
|
-
_hb_set_destroy
|
|
14
|
-
_hb_set_invert
|
|
15
|
-
_hb_set_union
|
|
16
|
-
_hb_subset_input_create_or_fail
|
|
17
|
-
_hb_subset_input_destroy
|
|
18
|
-
_hb_subset_input_get_flags
|
|
19
|
-
_hb_subset_input_get_user_data
|
|
20
|
-
_hb_subset_input_glyph_set
|
|
21
|
-
_hb_subset_input_pin_all_axes_to_default
|
|
22
|
-
_hb_subset_input_pin_axis_location
|
|
23
|
-
_hb_subset_input_pin_axis_to_default
|
|
24
|
-
_hb_subset_input_reference
|
|
25
|
-
_hb_subset_input_set
|
|
26
|
-
_hb_subset_input_set_axis_range
|
|
27
|
-
_hb_subset_input_set_flags
|
|
28
|
-
_hb_subset_input_set_user_data
|
|
29
|
-
_hb_subset_input_unicode_set
|
|
30
|
-
_hb_subset_input_keep_everything
|
|
31
|
-
_hb_subset_or_fail
|
|
32
|
-
_hb_subset_preprocess
|
|
33
|
-
_malloc
|
|
34
|
-
_free
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/** Build a pinned HarfBuzz subset module with a growing heap and stage its redistribution receipt. */
|
|
3
|
-
import { cpSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { join, resolve } from 'node:path';
|
|
5
|
-
import { parseArgs } from 'node:util';
|
|
6
|
-
import { isMain, readJson, root } from './platform-matrix.mjs';
|
|
7
|
-
import { run } from './pack-utils.mjs';
|
|
8
|
-
import { assert, regularFile, sha256 } from './verify-artifacts.mjs';
|
|
9
|
-
|
|
10
|
-
const specPath = 'engine/font-subset/source.json';
|
|
11
|
-
const spec = readJson(join(root, specPath));
|
|
12
|
-
const wasmPath = 'assets/font-subset.wasm';
|
|
13
|
-
const receiptPath = 'assets/font-subset.json';
|
|
14
|
-
const recipePath = 'scripts/build-font-subset.mjs';
|
|
15
|
-
const recipeFiles = [specPath, recipePath, 'scripts/platform-matrix.mjs', 'scripts/pack-utils.mjs', 'scripts/verify-artifacts.mjs', 'engine/font-subset/README.md', 'engine/font-subset/README.zh.md'];
|
|
16
|
-
const required = [wasmPath, ...recipeFiles.map(path => `sources/font-subset/${path}`),
|
|
17
|
-
'sources/font-subset/harfbuzzjs/config-override-subset.h', 'sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols',
|
|
18
|
-
'licenses/font-subset/harfbuzzjs-LICENSE', 'licenses/font-subset/harfbuzz-COPYING'];
|
|
19
|
-
|
|
20
|
-
/** Verify a staged subset module, recipe, exact source pins, and redistribution notices. */
|
|
21
|
-
export function verifyFontSubset(target = join(root, 'packages/entry')) {
|
|
22
|
-
const receipt = readJson(regularFile(target, receiptPath));
|
|
23
|
-
assert(receipt.schemaVersion === 1 && JSON.stringify(receipt.source) === JSON.stringify(spec), 'Font subset source receipt differs');
|
|
24
|
-
assert(receipt.recipe === sha256(join(root, recipePath)), 'Font subset build recipe changed; rebuild the module');
|
|
25
|
-
assert(JSON.stringify(Object.keys(receipt.files).sort()) === JSON.stringify(required.slice().sort()), 'Font subset receipt has an incomplete payload');
|
|
26
|
-
for (const path of required) {
|
|
27
|
-
const file = regularFile(target, path);
|
|
28
|
-
assert(receipt.files[path].bytes === statSync(file).size && receipt.files[path].sha256 === sha256(file), `Font subset payload checksum differs: ${path}`);
|
|
29
|
-
}
|
|
30
|
-
const module = new WebAssembly.Module(readFileSync(join(target, wasmPath)));
|
|
31
|
-
const names = new Set(WebAssembly.Module.exports(module).map(entry => entry.name));
|
|
32
|
-
for (const name of ['memory', '_initialize', 'malloc', 'hb_subset_or_fail', 'hb_subset_input_set']) assert(names.has(name), `Missing font subset export: ${name}`);
|
|
33
|
-
return receipt;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Compile explicit checked-out commits; this command never fetches or modifies upstream sources. */
|
|
37
|
-
export function buildFontSubset({ source = join(root, '.build/font-subset/harfbuzzjs'), emsdk = join(root, '.build/font-subset/emsdk'), target = join(root, 'packages/entry') } = {}) {
|
|
38
|
-
for (const [path, expected] of [[source, spec.harfbuzzjs.commit], [join(source, 'harfbuzz'), spec.harfbuzz.commit], [emsdk, spec.emsdk.commit]]) {
|
|
39
|
-
assert(run('git', ['rev-parse', 'HEAD'], { cwd: path }).trim() === expected, `Font subset checkout has the wrong commit: ${path}`);
|
|
40
|
-
assert(run('git', ['status', '--porcelain', '--untracked-files=no'], { cwd: path }).trim() === '', `Font subset checkout has tracked changes: ${path}`);
|
|
41
|
-
}
|
|
42
|
-
const invoke = (args) => run('bash', ['-c', 'set -e\nsource "$1" >/dev/null\nshift\nexec em++ "$@"', 'font-subset-build', join(emsdk, 'emsdk_env.sh'), ...args], { cwd: source });
|
|
43
|
-
assert(invoke(['--version']).split('\n')[0].includes(` ${spec.emsdk.version} `), 'Font subset Emscripten version differs');
|
|
44
|
-
mkdirSync(join(target, 'assets'), { recursive: true });
|
|
45
|
-
invoke(['-std=c++11', '-fno-exceptions', '-fno-rtti', '-fno-threadsafe-statics', '-fvisibility-inlines-hidden', '-Oz', '-I.',
|
|
46
|
-
'-DHB_TINY', '-DHB_USE_INTERNAL_QSORT', '-DHB_EXPERIMENTAL_API', '-DHB_CONFIG_OVERRIDE_H="config-override-subset.h"',
|
|
47
|
-
'--no-entry', '-sEXPORTED_FUNCTIONS=@harfbuzz-subset.symbols', '-sINITIAL_MEMORY=68157440',
|
|
48
|
-
'-sALLOW_MEMORY_GROWTH=1', '-sMAXIMUM_MEMORY=2147483648', '-sABORTING_MALLOC=0',
|
|
49
|
-
'-o', join(target, wasmPath), 'harfbuzz/src/harfbuzz-subset.cc']);
|
|
50
|
-
const copies = [...recipeFiles.map(path => [join(root, path), `sources/font-subset/${path}`]),
|
|
51
|
-
[join(source, 'config-override-subset.h'), 'sources/font-subset/harfbuzzjs/config-override-subset.h'],
|
|
52
|
-
[join(source, 'harfbuzz-subset.symbols'), 'sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols'],
|
|
53
|
-
[join(source, 'LICENSE'), 'licenses/font-subset/harfbuzzjs-LICENSE'], [join(source, 'harfbuzz/COPYING'), 'licenses/font-subset/harfbuzz-COPYING']];
|
|
54
|
-
for (const [from, path] of copies) { mkdirSync(join(target, path, '..'), { recursive: true }); cpSync(from, join(target, path)); }
|
|
55
|
-
const files = Object.fromEntries(required.map(path => [path, { bytes: statSync(join(target, path)).size, sha256: sha256(join(target, path)) }]));
|
|
56
|
-
writeFileSync(join(target, receiptPath), `${JSON.stringify({ schemaVersion: 1, source: spec, recipe: sha256(join(root, recipePath)), files }, null, 2)}\n`);
|
|
57
|
-
return verifyFontSubset(target);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isMain(import.meta.url)) {
|
|
61
|
-
const { values } = parseArgs({ options: { verify: { type: 'boolean' }, source: { type: 'string' }, emsdk: { type: 'string' }, target: { type: 'string' } } });
|
|
62
|
-
const options = Object.fromEntries(['source', 'emsdk', 'target'].filter(key => values[key]).map(key => [key, resolve(values[key])]));
|
|
63
|
-
console.log(JSON.stringify(values.verify ? verifyFontSubset(options.target) : buildFontSubset(options)));
|
|
64
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/** Local-only npm helpers shared by packaging and offline-install rehearsals. */
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
4
|
-
import { spawnSync } from 'node:child_process';
|
|
5
|
-
import { root } from './platform-matrix.mjs';
|
|
6
|
-
|
|
7
|
-
export function scratch(prefix = 'packaging-') {
|
|
8
|
-
const parent = join(root, '.cache');
|
|
9
|
-
mkdirSync(parent, { recursive: true });
|
|
10
|
-
return mkdtempSync(join(parent, prefix));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function run(command, args, options = {}) {
|
|
14
|
-
const result = spawnSync(command, args, { encoding: 'utf8', timeout: 180_000, maxBuffer: 16 * 1024 * 1024, ...options });
|
|
15
|
-
if (result.error) throw result.error;
|
|
16
|
-
if (result.status !== 0) throw new Error(`${command} exited ${result.status} (${result.signal ?? 'no signal'}):\n${result.stderr}\n${result.stdout}`);
|
|
17
|
-
return result.stdout;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Invoke npm's JS CLI directly, including on Windows; no command shell is used. */
|
|
21
|
-
export function npmCli() {
|
|
22
|
-
const directories = [dirname(process.execPath), dirname(realpathSync(process.execPath)), ...(process.env.PATH ?? '').split(delimiter)];
|
|
23
|
-
const candidates = [process.env.npm_execpath];
|
|
24
|
-
for (const directory of directories) {
|
|
25
|
-
candidates.push(join(directory, 'node_modules/npm/bin/npm-cli.js'), resolve(directory, '../lib/node_modules/npm/bin/npm-cli.js'));
|
|
26
|
-
const link = join(directory, 'npm');
|
|
27
|
-
if (existsSync(link)) candidates.push(realpathSync(link));
|
|
28
|
-
}
|
|
29
|
-
const found = candidates.find((file) => file && /(?:^|[\\/])npm-cli\.js$/.test(file) && existsSync(file));
|
|
30
|
-
if (!found) throw new Error('npm-cli.js was not found next to Node or on PATH');
|
|
31
|
-
return found;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function npmEnvironment(work) {
|
|
35
|
-
const config = join(work, 'empty.npmrc');
|
|
36
|
-
const globalConfig = join(work, 'empty-global.npmrc');
|
|
37
|
-
writeFileSync(config, '');
|
|
38
|
-
writeFileSync(globalConfig, '');
|
|
39
|
-
return {
|
|
40
|
-
...Object.fromEntries(Object.entries(process.env).filter(([key]) => !/KEY|TOKEN|SECRET|PASSWORD|^NODE_OPTIONS$|^NODE_PATH$|^NPM_CONFIG_/i.test(key))),
|
|
41
|
-
npm_config_cache: join(work, 'npm-cache'),
|
|
42
|
-
npm_config_userconfig: config,
|
|
43
|
-
npm_config_globalconfig: globalConfig,
|
|
44
|
-
npm_config_audit: 'false',
|
|
45
|
-
npm_config_fund: 'false',
|
|
46
|
-
npm_config_update_notifier: 'false',
|
|
47
|
-
npm_config_registry: 'http://127.0.0.1:9',
|
|
48
|
-
npm_config_offline: 'true',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function npm(args, cwd, work) {
|
|
53
|
-
return run(process.execPath, [npmCli(), ...args], { cwd, env: npmEnvironment(work) });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Resolve pnpm without invoking a Windows command shim through a shell. */
|
|
57
|
-
export function pnpmInvocation(args, environment = process.env, platform = process.platform) {
|
|
58
|
-
const entry = environment.npm_execpath;
|
|
59
|
-
if (entry && /(?:^|[\\/])pnpm\.[cm]?js$/i.test(entry)) return { command: process.execPath, args: [entry, ...args] };
|
|
60
|
-
if (entry && /(?:^|[\\/])pnpm(?:\.exe)?$/i.test(entry)) return { command: entry, args };
|
|
61
|
-
if (platform === 'win32') throw new Error('Invoke adapter builds and local packs through pnpm run on Windows.');
|
|
62
|
-
return { command: 'pnpm', args };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Run the pnpm lifecycle executable, retaining each argument without shell parsing. */
|
|
66
|
-
export function pnpm(args, options = {}) {
|
|
67
|
-
const invocation = pnpmInvocation(args);
|
|
68
|
-
return run(invocation.command, invocation.args, options);
|
|
69
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/** Package metadata shared by release tooling; runtime selection belongs to the adapter package. */
|
|
2
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
export const root = fileURLToPath(new URL('../', import.meta.url));
|
|
7
|
-
export const enginePrefix = '@deepseek-ai/libreoffice-kit';
|
|
8
|
-
/** Internal repository hosting qualified engine archives for application builds. */
|
|
9
|
-
export const releaseRepository = 'deepseek-harness/libreoffice-kit';
|
|
10
|
-
/** Repository maintaining the source and Actions builds referenced by release evidence. */
|
|
11
|
-
export const sourceRepository = releaseRepository;
|
|
12
|
-
export const wasmName = `${enginePrefix}-wasm`;
|
|
13
|
-
export const kitPackageName = '@deepseek-ai/libreoffice-kit';
|
|
14
|
-
export const nodeRange = '>=22.19.0';
|
|
15
|
-
export const targets = Object.freeze({
|
|
16
|
-
'darwin-arm64': { os: 'darwin', cpu: 'arm64', runner: 'macos-15' },
|
|
17
|
-
'darwin-x64': { os: 'darwin', cpu: 'x64', runner: 'macos-15-intel' },
|
|
18
|
-
'linux-arm64-glibc': { os: 'linux', cpu: 'arm64', libc: 'glibc', runner: 'ubuntu-24.04-arm' },
|
|
19
|
-
'linux-x64-glibc': { os: 'linux', cpu: 'x64', libc: 'glibc', runner: 'ubuntu-24.04' },
|
|
20
|
-
'win32-arm64': { os: 'win32', cpu: 'arm64', runner: 'windows-11-arm' },
|
|
21
|
-
'win32-x64': { os: 'win32', cpu: 'x64', runner: 'windows-2022' },
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export function readJson(file) {
|
|
25
|
-
return JSON.parse(readFileSync(file, 'utf8'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** The adapter package directory in this checkout; it declares this family's released engine targets. */
|
|
29
|
-
export function kitDirectory(repo = root) {
|
|
30
|
-
return join(repo, 'packages/entry');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** The adapter package manifest that declares this family's released engine targets. */
|
|
34
|
-
export function kitManifest(repo = root) {
|
|
35
|
-
return readJson(join(kitDirectory(repo), 'package.json'));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Release tags identify this standalone kit family. */
|
|
39
|
-
export function releaseTag(version) {
|
|
40
|
-
return `libreoffice-kit-v${version}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Versioned download URL for one engine archive attached to the family release.
|
|
45
|
-
* @param version - Engine family version.
|
|
46
|
-
* @param file - Release asset file name.
|
|
47
|
-
* @returns the asset URL, requiring authenticated build-time preparation for internal releases.
|
|
48
|
-
*/
|
|
49
|
-
export function releaseAssetUrl(version, file) {
|
|
50
|
-
return `https://github.com/${releaseRepository}/releases/download/${releaseTag(version)}/${encodeURIComponent(file)}`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Return the complete declared matrix, including targets without built assets. */
|
|
54
|
-
export function packageMatrix(repo = root) {
|
|
55
|
-
return readdirSync(join(repo, 'packages'), { withFileTypes: true })
|
|
56
|
-
.filter((entry) => entry.isDirectory() && !['entry', 'browser', 'fonts'].includes(entry.name))
|
|
57
|
-
.sort((a, b) => a.name.localeCompare(b.name))
|
|
58
|
-
.map((entry) => {
|
|
59
|
-
const dir = join(repo, 'packages', entry.name);
|
|
60
|
-
return { dir, manifest: readJson(join(dir, 'package.json')), prebuild: readJson(join(dir, 'prebuilds.json')) };
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** An unrecognized Linux libc is deliberately not treated as glibc. */
|
|
65
|
-
export function hostTarget(platform = process.platform, arch = process.arch, report = process.report?.getReport()) {
|
|
66
|
-
if (platform !== 'linux') return Object.hasOwn(targets, `${platform}-${arch}`) ? `${platform}-${arch}` : undefined;
|
|
67
|
-
if (!report?.header?.glibcVersionRuntime) return undefined;
|
|
68
|
-
const candidate = `${platform}-${arch}-glibc`;
|
|
69
|
-
return Object.hasOwn(targets, candidate) ? candidate : undefined;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** The adapter declares released native packages; targets also contains unfinished build recipes. */
|
|
73
|
-
export function kitNativeTargets(manifest) {
|
|
74
|
-
return Object.keys(manifest.optionalDependencies ?? {}).filter(name => name !== wasmName).map((name) => {
|
|
75
|
-
const platform = name.slice(enginePrefix.length + 1);
|
|
76
|
-
if (!name.startsWith(`${enginePrefix}-`) || !Object.hasOwn(targets, platform)) throw new Error(`Unknown native optional dependency: ${name}`);
|
|
77
|
-
return platform;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Explicit development scopes may select a build recipe; defaults use the adapter's release declaration. */
|
|
82
|
-
export function releaseTargets(args, nativeTargets = kitNativeTargets(kitManifest())) {
|
|
83
|
-
const wasmOnly = args.includes('--wasm-only');
|
|
84
|
-
const index = args.indexOf('--platform');
|
|
85
|
-
if (wasmOnly && index !== -1) throw new Error('--wasm-only and --platform are mutually exclusive');
|
|
86
|
-
if (index !== -1) {
|
|
87
|
-
const platform = args[index + 1];
|
|
88
|
-
if (!Object.hasOwn(targets, platform)) throw new Error(`Unknown native platform: ${platform}`);
|
|
89
|
-
return [platform, 'wasm'];
|
|
90
|
-
}
|
|
91
|
-
return wasmOnly ? ['wasm'] : [...nativeTargets, 'wasm'];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function tarballName(manifest) {
|
|
95
|
-
return `${manifest.name.replace(/^@/, '').replace('/', '-')}-${manifest.version}.tgz`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function isMain(url) {
|
|
99
|
-
return process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(url);
|
|
100
|
-
}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/** Validate staged or installed engine packages without compiling or downloading. */
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { closeSync, lstatSync, openSync, readdirSync, readFileSync, readSync, statSync } from 'node:fs';
|
|
4
|
-
import { join, resolve } from 'node:path';
|
|
5
|
-
import { enginePrefix, isMain, nodeRange, readJson, targets } from './platform-matrix.mjs';
|
|
6
|
-
|
|
7
|
-
const hashPattern = /^[a-f0-9]{64}$/;
|
|
8
|
-
const payloadRoots = ['assets', 'bin', 'program', 'sources', 'licenses'];
|
|
9
|
-
|
|
10
|
-
export function assert(condition, message) {
|
|
11
|
-
if (!condition) throw new Error(message);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function sha256(file) {
|
|
15
|
-
const hash = createHash('sha256');
|
|
16
|
-
const fd = openSync(file, 'r');
|
|
17
|
-
const chunk = Buffer.alloc(1024 * 1024);
|
|
18
|
-
try {
|
|
19
|
-
for (let count; (count = readSync(fd, chunk)) !== 0;) hash.update(chunk.subarray(0, count));
|
|
20
|
-
} finally { closeSync(fd); }
|
|
21
|
-
return hash.digest('hex');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Manifest paths are POSIX relative paths on every host, including Windows. */
|
|
25
|
-
export function safePath(value) {
|
|
26
|
-
assert(typeof value === 'string' && value.length > 0 && !/[\\:\x00-\x1f]/.test(value)
|
|
27
|
-
&& !value.split('/').some((part) => part === '' || part === '.' || part === '..'), `Unsafe package path: ${value}`);
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function regularFile(dir, relative) {
|
|
32
|
-
safePath(relative);
|
|
33
|
-
const parts = relative.split('/');
|
|
34
|
-
for (let index = 1; index <= parts.length; index++) {
|
|
35
|
-
const file = join(dir, ...parts.slice(0, index));
|
|
36
|
-
let stat;
|
|
37
|
-
try { stat = lstatSync(file); }
|
|
38
|
-
catch (error) {
|
|
39
|
-
if (error.code !== 'ENOENT') throw error;
|
|
40
|
-
throw new Error(`Missing package artifact: ${relative}`, { cause: error });
|
|
41
|
-
}
|
|
42
|
-
assert(index === parts.length ? stat.isFile() : stat.isDirectory(), `Not a regular package file/directory: ${relative}`);
|
|
43
|
-
}
|
|
44
|
-
return join(dir, ...parts);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function inventory(dir, prefix) {
|
|
48
|
-
let entries;
|
|
49
|
-
try { entries = readdirSync(join(dir, prefix), { withFileTypes: true }); }
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (error.code === 'ENOENT') return [];
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
assert(lstatSync(join(dir, prefix)).isDirectory(), `Not a regular payload directory: ${prefix}`);
|
|
55
|
-
return entries.flatMap((entry) => {
|
|
56
|
-
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
57
|
-
assert(entry.isFile() || entry.isDirectory(), `Symlink or special payload file: ${name}`);
|
|
58
|
-
return entry.isDirectory() ? inventory(dir, name) : [name];
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function verifyNoInstallHooks(manifest, allowWorkspace = false) {
|
|
63
|
-
for (const hook of ['preinstall', 'install', 'postinstall', 'prepare']) {
|
|
64
|
-
assert(!Object.hasOwn(manifest.scripts ?? {}, hook), `${manifest.name}: forbidden install lifecycle ${hook}`);
|
|
65
|
-
}
|
|
66
|
-
assert(manifest.gypfile !== true && manifest.bin === undefined, `${manifest.name}: engine packages must not register install builds or CLI bins`);
|
|
67
|
-
for (const field of ['dependencies', 'optionalDependencies', 'peerDependencies']) {
|
|
68
|
-
for (const [name, version] of Object.entries(manifest[field] ?? {})) {
|
|
69
|
-
assert(/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(version) || (allowWorkspace && name.startsWith(`${enginePrefix}-`) && version === 'workspace:*'), `${manifest.name}: ${field} must pin a published version: ${name}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Validate metadata independently of whether the target has been built. */
|
|
75
|
-
export function verifyEngineMetadata(manifest, prebuild) {
|
|
76
|
-
verifyNoInstallHooks(manifest);
|
|
77
|
-
assert(manifest.type === 'module' && manifest.engines?.node === nodeRange, 'Engine package requires ESM and the declared Node baseline');
|
|
78
|
-
assert(manifest.exports?.['./prebuilds.json'] === './prebuilds.json'
|
|
79
|
-
&& manifest.exports?.['./package.json'] === './package.json', 'Engine package must export prebuilds.json and package.json');
|
|
80
|
-
assert(prebuild.schemaVersion === 1 && ['unbuilt', 'built'].includes(prebuild.status), 'Unsupported engine schema/status');
|
|
81
|
-
assert(prebuild.version === manifest.version && manifest.name === `${enginePrefix}-${prebuild.platform}`, 'Engine package identity/version mismatch');
|
|
82
|
-
const target = targets[prebuild.platform];
|
|
83
|
-
const engine = prebuild.engine;
|
|
84
|
-
if (engine?.glibcMinimum !== undefined) {
|
|
85
|
-
assert(target?.libc === 'glibc' && typeof engine.glibcMinimum === 'string'
|
|
86
|
-
&& /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/.test(engine.glibcMinimum)
|
|
87
|
-
&& engine.glibcMinimum.split('.').every(part => Number.isSafeInteger(Number(part))), 'Invalid native glibcMinimum');
|
|
88
|
-
}
|
|
89
|
-
const exact = (actual, expected) => JSON.stringify(actual) === JSON.stringify(expected);
|
|
90
|
-
if (prebuild.platform === 'wasm') {
|
|
91
|
-
assert(manifest.os === undefined && manifest.cpu === undefined && manifest.libc === undefined, 'WASM package must install across operating systems, CPUs and libc variants');
|
|
92
|
-
assert(engine?.kind === 'wasm' && engine.loader === 'assets/soffice.cjs' && engine.wasm === 'assets/dsh-office.wasm'
|
|
93
|
-
&& engine.data === 'assets/soffice.data' && engine.metadata === 'assets/soffice.data.js.metadata'
|
|
94
|
-
&& engine.programDirectory === '/instdir/program', 'Unsupported WASM engine paths');
|
|
95
|
-
} else {
|
|
96
|
-
assert(target && exact(manifest.os, [target.os]) && exact(manifest.cpu, [target.cpu])
|
|
97
|
-
&& (target.libc ? exact(manifest.libc, [target.libc]) : manifest.libc === undefined), 'Native platform disagrees with package os/cpu/libc');
|
|
98
|
-
assert(engine?.kind === 'native' && engine.executable === `bin/libreoffice-kit${target.os === 'win32' ? '.exe' : ''}`
|
|
99
|
-
&& typeof engine.programDirectory === 'string' && (engine.programDirectory === 'program' || engine.programDirectory.startsWith('program/')), 'Unsupported native engine paths');
|
|
100
|
-
safePath(engine.programDirectory);
|
|
101
|
-
}
|
|
102
|
-
assert(prebuild.files && typeof prebuild.files === 'object' && !Array.isArray(prebuild.files), 'Engine files must be a hash inventory');
|
|
103
|
-
for (const [file, hash] of Object.entries(prebuild.files)) {
|
|
104
|
-
safePath(file);
|
|
105
|
-
assert(payloadRoots.includes(file.split('/')[0]) && hashPattern.test(hash), `Invalid file inventory entry: ${file}`);
|
|
106
|
-
}
|
|
107
|
-
assert(Array.isArray(prebuild.licenses), 'Engine licenses must be an array');
|
|
108
|
-
if (prebuild.status === 'unbuilt') {
|
|
109
|
-
assert(Object.keys(prebuild.files).length === 0 && prebuild.source === null && prebuild.licenses.length === 0,
|
|
110
|
-
'Unbuilt target must not claim built files or source/license receipts');
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const source = prebuild.source;
|
|
114
|
-
assert(source && /^https:\/\//.test(source.repository) && /^[a-f0-9]{40}$/.test(source.revision)
|
|
115
|
-
&& typeof source.version === 'string' && source.version.length > 0 && Array.isArray(source.files) && source.files.length > 0,
|
|
116
|
-
'Built engine requires source repository, full revision, version, and packaged build inputs');
|
|
117
|
-
assert(new Set(source.files).size === source.files.length, 'Duplicate source manifest paths');
|
|
118
|
-
for (const file of source.files) assert(file.startsWith('sources/') && Object.hasOwn(prebuild.files, file), `Missing hashed source: ${file}`);
|
|
119
|
-
assert(prebuild.licenses.some((license) => license.component === 'LibreOffice' && license.spdx === 'MPL-2.0'), 'Missing LibreOffice MPL-2.0 license');
|
|
120
|
-
for (const license of prebuild.licenses) {
|
|
121
|
-
assert(typeof license.component === 'string' && license.component.length > 0 && typeof license.spdx === 'string' && license.spdx.length > 0
|
|
122
|
-
&& typeof license.path === 'string' && license.path.startsWith('licenses/') && Object.hasOwn(prebuild.files, license.path), 'Missing hashed redistribution license');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Header-only checks accept minimal test fixtures; they are not release validation. */
|
|
127
|
-
export function verifyNativeHeader(bytes, platform, shared = false) {
|
|
128
|
-
const target = targets[platform];
|
|
129
|
-
assert(target, `Unknown native target: ${platform}`);
|
|
130
|
-
if (target.os === 'linux') {
|
|
131
|
-
assert(bytes.length >= 64 && bytes.readUInt32LE(0) === 0x464c457f && bytes[4] === 2 && bytes[5] === 1, 'Expected little-endian ELF64 image');
|
|
132
|
-
assert(bytes.readUInt16LE(18) === (target.cpu === 'x64' ? 62 : 183), 'Wrong ELF architecture');
|
|
133
|
-
assert((shared ? [3] : [2, 3]).includes(bytes.readUInt16LE(16)), 'Wrong ELF executable/library type');
|
|
134
|
-
} else if (target.os === 'darwin') {
|
|
135
|
-
assert(bytes.length >= 32 && bytes.readUInt32LE(0) === 0xfeedfacf, 'Expected thin Mach-O 64-bit image');
|
|
136
|
-
assert(bytes.readUInt32LE(4) === (target.cpu === 'x64' ? 0x01000007 : 0x0100000c), 'Wrong Mach-O architecture');
|
|
137
|
-
assert((shared ? [6, 8] : [2]).includes(bytes.readUInt32LE(12)), 'Wrong Mach-O executable/library type');
|
|
138
|
-
} else {
|
|
139
|
-
assert(bytes.length >= 64 && bytes.readUInt16LE(0) === 0x5a4d, 'Expected PE executable');
|
|
140
|
-
const pe = bytes.readUInt32LE(60);
|
|
141
|
-
assert(pe >= 64 && pe + 26 <= bytes.length && bytes.readUInt32LE(pe) === 0x4550, 'Truncated or invalid PE header');
|
|
142
|
-
assert(bytes.readUInt16LE(pe + 4) === (target.cpu === 'x64' ? 0x8664 : 0xaa64), 'Wrong PE architecture');
|
|
143
|
-
assert(bytes.readUInt16LE(pe + 24) === 0x20b && (bytes.readUInt16LE(pe + 22) & 0x2002) === (shared ? 0x2002 : 2), 'Wrong PE32+ executable/DLL type');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** Require executable code records in addition to the format/architecture header. */
|
|
148
|
-
export function verifyNativeImage(file, platform, shared = false) {
|
|
149
|
-
const bytes = readFileSync(file);
|
|
150
|
-
verifyNativeHeader(bytes, platform, shared);
|
|
151
|
-
const target = targets[platform];
|
|
152
|
-
if (process.platform !== 'win32' && target.os !== 'win32') assert((statSync(file).mode & 0o111) !== 0, 'Native engine is not executable');
|
|
153
|
-
if (target.os === 'linux') {
|
|
154
|
-
const offset = Number(bytes.readBigUInt64LE(32));
|
|
155
|
-
const width = bytes.readUInt16LE(54);
|
|
156
|
-
const count = bytes.readUInt16LE(56);
|
|
157
|
-
assert((shared || bytes.readBigUInt64LE(24) !== 0n) && width >= 56 && count > 0 && offset >= 64 && offset + width * count <= bytes.length, 'ELF image has no executable program table');
|
|
158
|
-
let code = false;
|
|
159
|
-
let interpreter;
|
|
160
|
-
for (let index = 0; index < count; index++) {
|
|
161
|
-
const record = offset + index * width;
|
|
162
|
-
const kind = bytes.readUInt32LE(record);
|
|
163
|
-
const start = Number(bytes.readBigUInt64LE(record + 8));
|
|
164
|
-
const size = Number(bytes.readBigUInt64LE(record + 32));
|
|
165
|
-
assert(start >= 0 && size >= 0 && start + size <= bytes.length, 'ELF segment outside image');
|
|
166
|
-
if (kind === 1 && (bytes.readUInt32LE(record + 4) & 1) && size > 0) code = true;
|
|
167
|
-
if (kind === 3) interpreter = bytes.subarray(start, start + size).toString('utf8').replace(/\0.*$/, '');
|
|
168
|
-
}
|
|
169
|
-
assert(code, 'ELF image has no executable segment');
|
|
170
|
-
if (interpreter) assert(/ld-linux/.test(interpreter), 'ELF interpreter disagrees with declared libc');
|
|
171
|
-
} else if (target.os === 'darwin') {
|
|
172
|
-
const count = bytes.readUInt32LE(16);
|
|
173
|
-
const size = bytes.readUInt32LE(20);
|
|
174
|
-
assert(count > 0 && size >= count * 8 && 32 + size <= bytes.length, 'Mach-O image has no load commands');
|
|
175
|
-
let offset = 32;
|
|
176
|
-
let code = false;
|
|
177
|
-
for (let index = 0; index < count; index++) {
|
|
178
|
-
assert(offset + 8 <= 32 + size, 'Truncated Mach-O load command');
|
|
179
|
-
const command = bytes.readUInt32LE(offset);
|
|
180
|
-
const length = bytes.readUInt32LE(offset + 4);
|
|
181
|
-
assert(length >= 8 && offset + length <= 32 + size, 'Invalid Mach-O load command');
|
|
182
|
-
if (command === 0x19 && length >= 72) {
|
|
183
|
-
const start = Number(bytes.readBigUInt64LE(offset + 40));
|
|
184
|
-
const lengthOnDisk = Number(bytes.readBigUInt64LE(offset + 48));
|
|
185
|
-
assert(start + lengthOnDisk <= bytes.length, 'Mach-O segment outside image');
|
|
186
|
-
if ((bytes.readUInt32LE(offset + 60) & 4) && lengthOnDisk > 0) code = true;
|
|
187
|
-
}
|
|
188
|
-
offset += length;
|
|
189
|
-
}
|
|
190
|
-
assert(code && offset === 32 + size, 'Mach-O image has no complete executable segment');
|
|
191
|
-
} else {
|
|
192
|
-
const pe = bytes.readUInt32LE(60);
|
|
193
|
-
const count = bytes.readUInt16LE(pe + 6);
|
|
194
|
-
const optionalSize = bytes.readUInt16LE(pe + 20);
|
|
195
|
-
const sections = pe + 24 + optionalSize;
|
|
196
|
-
assert(optionalSize >= 112 && count > 0 && sections + count * 40 <= bytes.length && (shared || bytes.readUInt32LE(pe + 40) !== 0), 'PE image has no executable sections');
|
|
197
|
-
let code = false;
|
|
198
|
-
for (let index = 0; index < count; index++) {
|
|
199
|
-
const record = sections + index * 40;
|
|
200
|
-
const size = bytes.readUInt32LE(record + 16);
|
|
201
|
-
const start = bytes.readUInt32LE(record + 20);
|
|
202
|
-
assert(start + size <= bytes.length, 'PE section outside image');
|
|
203
|
-
if ((bytes.readUInt32LE(record + 36) & 0x20000000) && size > 0) code = true;
|
|
204
|
-
}
|
|
205
|
-
assert(code, 'PE image has no executable code');
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function verifyPayload(dir, prebuild, actual) {
|
|
210
|
-
const declared = Object.keys(prebuild.files).sort();
|
|
211
|
-
actual.sort();
|
|
212
|
-
assert(JSON.stringify(declared) === JSON.stringify(actual), 'Payload inventory contains missing or undeclared files');
|
|
213
|
-
for (const file of declared) assert(sha256(regularFile(dir, file)) === prebuild.files[file], `Artifact checksum mismatch: ${file}`);
|
|
214
|
-
for (const license of prebuild.licenses) assert(readFileSync(regularFile(dir, license.path), 'utf8').trim().length > 0, `Empty license: ${license.path}`);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** Full payload gate: checksums, source/license closure, resources, and real engine exports. */
|
|
218
|
-
export function verifyEnginePackage(dir) {
|
|
219
|
-
const manifest = readJson(regularFile(dir, 'package.json'));
|
|
220
|
-
const prebuild = readJson(regularFile(dir, 'prebuilds.json'));
|
|
221
|
-
verifyEngineMetadata(manifest, prebuild);
|
|
222
|
-
assert(prebuild.status === 'built', `${prebuild.platform}: unbuilt target cannot be packed or released`);
|
|
223
|
-
verifyPayload(dir, prebuild, payloadRoots.flatMap((prefix) => inventory(dir, prefix)));
|
|
224
|
-
const declared = Object.keys(prebuild.files);
|
|
225
|
-
const engine = prebuild.engine;
|
|
226
|
-
if (engine.kind === 'native') {
|
|
227
|
-
verifyNativeImage(regularFile(dir, engine.executable), prebuild.platform);
|
|
228
|
-
assert(declared.some((file) => file.startsWith(`${engine.programDirectory}/`)), 'Native engine has no program resources');
|
|
229
|
-
} else {
|
|
230
|
-
for (const key of ['loader', 'wasm', 'data', 'metadata']) regularFile(dir, engine[key]);
|
|
231
|
-
const module = new WebAssembly.Module(readFileSync(join(dir, engine.wasm)));
|
|
232
|
-
const exports = new Set(WebAssembly.Module.exports(module).filter((entry) => entry.kind === 'function').map((entry) => entry.name.replace(/^_/, '')));
|
|
233
|
-
for (const name of ['dsh_lok_initialize', 'dsh_lok_document_load', 'dsh_lok_document_save_pdf', 'dsh_lok_document_export', 'dsh_lok_document_destroy', 'dsh_lok_destroy', 'dsh_lok_error', 'malloc', 'free']) {
|
|
234
|
-
assert(exports.has(name), `WASM engine missing conversion export: ${name}`);
|
|
235
|
-
}
|
|
236
|
-
const dataSize = statSync(join(dir, engine.data)).size;
|
|
237
|
-
const metadata = readJson(join(dir, engine.metadata));
|
|
238
|
-
assert(dataSize > 0 && Array.isArray(metadata.files) && metadata.files.length > 0, 'WASM data has no packaged resources');
|
|
239
|
-
const names = new Set();
|
|
240
|
-
const ranges = [];
|
|
241
|
-
for (const file of metadata.files) {
|
|
242
|
-
assert(typeof file.filename === 'string' && (file.filename.startsWith('/instdir/')
|
|
243
|
-
|| ['/android/default-document/example.odt', '/android/default-document/example_test.ods'].includes(file.filename))
|
|
244
|
-
&& !names.has(file.filename), 'Invalid or duplicate WASM resource path');
|
|
245
|
-
safePath(file.filename.slice(1));
|
|
246
|
-
names.add(file.filename);
|
|
247
|
-
assert(Number.isSafeInteger(file.start) && Number.isSafeInteger(file.end) && file.start >= 0 && file.end >= file.start && file.end <= dataSize, 'WASM resource outside data file');
|
|
248
|
-
ranges.push([file.start, file.end]);
|
|
249
|
-
}
|
|
250
|
-
ranges.sort((a, b) => a[0] - b[0]);
|
|
251
|
-
assert(ranges.every((range, index) => index === 0 || ranges[index - 1][1] <= range[0]), 'Overlapping WASM data ranges');
|
|
252
|
-
assert([...names].some((name) => name.startsWith(`${engine.programDirectory}/`)), 'WASM data lacks program resources');
|
|
253
|
-
assert(/\bmodule\[?[^;]*exports|\bmodule\.exports/.test(readFileSync(join(dir, engine.loader), 'utf8')), 'WASM loader must provide a Node CommonJS factory');
|
|
254
|
-
}
|
|
255
|
-
return { name: manifest.name, platform: prebuild.platform, files: declared.length };
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (isMain(import.meta.url)) {
|
|
259
|
-
console.log(JSON.stringify(verifyEnginePackage(resolve(process.argv[2] ?? '.'))));
|
|
260
|
-
}
|