#!/usr/bin/env node // Verify a generated Daevix.Script SVG still carries its message: run the // handoff bundle's own Daevix.decodeScript over the file and compare. // // Usage: node hack/check-script.js --svg --message 'use strict'; const fs = require('fs'); const path = require('path'); function arg(name) { const i = process.argv.indexOf('--' + name); return i < 0 ? undefined : process.argv[i + 1]; } const svgPath = arg('svg'); const want = arg('message'); if (!svgPath || want === undefined) { console.error('usage: check-script.js --svg --message '); process.exit(2); } global.window = global; global.React = require(path.join(__dirname, 'vendor', 'react.production.min.js')); require(path.join(__dirname, 'vendor', 'bundle.js')); const svg = fs.readFileSync(svgPath, 'utf8'); const got = global.window.Daevix.decodeScript(svg); if (!got || got.text !== want) { console.error('FAIL ' + svgPath + ': decodeScript returned ' + (got ? JSON.stringify(got.text) : 'null') + ', want ' + JSON.stringify(want)); process.exit(1); } console.log('ok ' + svgPath + ' -> ' + JSON.stringify(got.text) + ' (' + got.cols + 'x' + got.rows + ', capacity ' + got.capacity + ' bytes)');