2017-12-20 21:46:01 +00:00
|
|
|
declare module 'resin-device-init' {
|
2018-01-04 16:17:43 +00:00
|
|
|
import * as Promise from 'bluebird';
|
2018-01-04 14:07:55 +00:00
|
|
|
import { EventEmitter } from 'events';
|
2017-12-20 21:46:01 +00:00
|
|
|
|
|
|
|
interface OperationState {
|
2018-01-09 15:05:24 +00:00
|
|
|
operation:
|
|
|
|
| CopyOperation
|
|
|
|
| ReplaceOperation
|
|
|
|
| RunScriptOperation
|
|
|
|
| BurnOperation;
|
2017-12-20 21:46:01 +00:00
|
|
|
percentage: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Operation {
|
|
|
|
command: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CopyOperation extends Operation {
|
|
|
|
command: 'copy';
|
|
|
|
from: { path: string };
|
|
|
|
to: { path: string };
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ReplaceOperation extends Operation {
|
|
|
|
command: 'replace';
|
|
|
|
copy: string;
|
|
|
|
replace: string;
|
|
|
|
file: {
|
|
|
|
path: string;
|
2018-01-04 14:07:55 +00:00
|
|
|
};
|
2017-12-20 21:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface RunScriptOperation extends Operation {
|
|
|
|
command: 'run-script';
|
|
|
|
script: string;
|
|
|
|
arguments?: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
interface BurnOperation extends Operation {
|
|
|
|
command: 'burn';
|
|
|
|
image?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface BurnProgress {
|
|
|
|
type: 'write' | 'check';
|
|
|
|
percentage: number;
|
|
|
|
transferred: number;
|
|
|
|
length: number;
|
|
|
|
remaining: number;
|
|
|
|
eta: number;
|
|
|
|
runtime: number;
|
|
|
|
delta: number;
|
|
|
|
speed: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface InitializeEmitter {
|
|
|
|
on(event: 'stdout', callback: (msg: string) => void): void;
|
|
|
|
on(event: 'stderr', callback: (msg: string) => void): void;
|
|
|
|
on(event: 'state', callback: (state: OperationState) => void): void;
|
|
|
|
on(event: 'burn', callback: (state: BurnProgress) => void): void;
|
|
|
|
}
|
|
|
|
|
2018-01-09 15:05:24 +00:00
|
|
|
export function initialize(
|
|
|
|
image: string,
|
|
|
|
deviceType: string,
|
|
|
|
config: {},
|
|
|
|
): Promise<InitializeEmitter>;
|
2017-12-20 21:46:01 +00:00
|
|
|
}
|