Criada a API do site
This commit is contained in:
66
node_modules/run-applescript/index.d.ts
generated
vendored
Normal file
66
node_modules/run-applescript/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
export type Options = {
|
||||
/**
|
||||
Change the output style.
|
||||
|
||||
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
import {runAppleScript} from 'run-applescript';
|
||||
|
||||
const result = await runAppleScript('return "unicorn"', {humanReadableOutput: false});
|
||||
|
||||
console.log(result);
|
||||
//=> '"unicorn"'
|
||||
```
|
||||
*/
|
||||
readonly humanReadableOutput?: boolean;
|
||||
|
||||
/**
|
||||
An AbortSignal that can be used to cancel the AppleScript execution.
|
||||
|
||||
Only supported by the async function.
|
||||
*/
|
||||
readonly signal?: AbortSignal;
|
||||
};
|
||||
|
||||
/**
|
||||
Run AppleScript asynchronously.
|
||||
|
||||
@param script - The script to run.
|
||||
@returns The script result.
|
||||
|
||||
@example
|
||||
```
|
||||
import {runAppleScript} from 'run-applescript';
|
||||
|
||||
const result = await runAppleScript('return "unicorn"');
|
||||
|
||||
console.log(result);
|
||||
//=> 'unicorn'
|
||||
```
|
||||
*/
|
||||
export function runAppleScript(
|
||||
script: string,
|
||||
options?: Options
|
||||
): Promise<string>;
|
||||
|
||||
/**
|
||||
Run AppleScript synchronously.
|
||||
|
||||
@param script - The script to run.
|
||||
@returns The script result.
|
||||
|
||||
@example
|
||||
```
|
||||
import {runAppleScriptSync} from 'run-applescript';
|
||||
|
||||
const result = runAppleScriptSync('return "unicorn"');
|
||||
|
||||
console.log(result);
|
||||
//=> 'unicorn'
|
||||
```
|
||||
*/
|
||||
export function runAppleScriptSync(script: string, options?: Options): string;
|
||||
37
node_modules/run-applescript/index.js
generated
vendored
Normal file
37
node_modules/run-applescript/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import process from 'node:process';
|
||||
import {promisify} from 'node:util';
|
||||
import {execFile, execFileSync} from 'node:child_process';
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export async function runAppleScript(script, {humanReadableOutput = true, signal} = {}) {
|
||||
if (process.platform !== 'darwin') {
|
||||
throw new Error('macOS only');
|
||||
}
|
||||
|
||||
const outputArguments = humanReadableOutput ? [] : ['-ss'];
|
||||
|
||||
const execOptions = {};
|
||||
if (signal) {
|
||||
execOptions.signal = signal;
|
||||
}
|
||||
|
||||
const {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments], execOptions);
|
||||
return stdout.trim();
|
||||
}
|
||||
|
||||
export function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {
|
||||
if (process.platform !== 'darwin') {
|
||||
throw new Error('macOS only');
|
||||
}
|
||||
|
||||
const outputArguments = humanReadableOutput ? [] : ['-ss'];
|
||||
|
||||
const stdout = execFileSync('osascript', ['-e', script, ...outputArguments], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
timeout: 500,
|
||||
});
|
||||
|
||||
return stdout.trim();
|
||||
}
|
||||
9
node_modules/run-applescript/license
generated
vendored
Normal file
9
node_modules/run-applescript/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
42
node_modules/run-applescript/package.json
generated
vendored
Normal file
42
node_modules/run-applescript/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "run-applescript",
|
||||
"version": "7.1.0",
|
||||
"description": "Run AppleScript and get the result",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/run-applescript",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"macos",
|
||||
"mac",
|
||||
"applescript",
|
||||
"osascript",
|
||||
"run",
|
||||
"execute"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^6.0.1",
|
||||
"tsd": "^0.30.0",
|
||||
"xo": "^0.56.0"
|
||||
}
|
||||
}
|
||||
78
node_modules/run-applescript/readme.md
generated
vendored
Normal file
78
node_modules/run-applescript/readme.md
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# run-applescript
|
||||
|
||||
> Run AppleScript and get the result
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install run-applescript
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {runAppleScript} from 'run-applescript';
|
||||
|
||||
const result = await runAppleScript('return "unicorn"');
|
||||
|
||||
console.log(result);
|
||||
//=> 'unicorn'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### runAppleScript(script, options?)
|
||||
|
||||
Returns a `Promise<string>` with the script result.
|
||||
|
||||
#### script
|
||||
|
||||
Type: `string`
|
||||
|
||||
The script to run.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### humanReadableOutput
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Change the output style.
|
||||
|
||||
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
|
||||
|
||||
##### signal
|
||||
|
||||
Type: `AbortSignal`
|
||||
|
||||
An AbortSignal that can be used to cancel the AppleScript execution.
|
||||
|
||||
### runAppleScriptSync(script, options?)
|
||||
|
||||
Returns a `string` with the script result.
|
||||
|
||||
#### script
|
||||
|
||||
Type: `string`
|
||||
|
||||
The script to run.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### humanReadableOutput
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Change the output style.
|
||||
|
||||
When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
|
||||
|
||||
## Related
|
||||
|
||||
- [run-jxa](https://github.com/sindresorhus/run-jxa) - Run JXA code and get the result
|
||||
Reference in New Issue
Block a user