mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-02 01:40:19 +08:00
16 lines
1.1 KiB
JavaScript
16 lines
1.1 KiB
JavaScript
// The browser source is bundled before Hermes; shared implementation remains ordinary TS.
|
|
import { createRequire } from 'node:module';
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
import { fileURLToPath } from 'node:url';
|
|
const require = createRequire(new URL('../apps/desktop/package.json', import.meta.url));
|
|
const { build } = require('esbuild');
|
|
const entry = fileURLToPath(new URL('../packages/device-link/src/directWebViewRuntime.ts', import.meta.url));
|
|
const destination = new URL('../packages/device-link/src/directRuntimeSource.ts', import.meta.url);
|
|
const output = await build({ entryPoints: [entry], bundle: true, write: false, format: 'iife',
|
|
globalName: 'CindyDirectLink', target: 'es2020', minify: true });
|
|
const content = '// Generated by node scripts/direct-link-runtime.mjs. Do not edit.\n'
|
|
+ 'export const DIRECT_LINK_RUNTIME_SOURCE = ' + JSON.stringify(output.outputFiles[0].text) + ';\n';
|
|
if (process.argv.includes('--check')) {
|
|
if (await readFile(destination, 'utf8') !== content) throw new Error('Run node scripts/direct-link-runtime.mjs');
|
|
} else await writeFile(destination, content);
|