New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@scriptables/manifest

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scriptables/manifest - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

dist/consts.d.ts

3

dist/index.d.ts

@@ -1,2 +0,3 @@

export * from './banner';
export * from './consts';
export * from './manifest';
export * from './types';
'use strict';
var banner = require('./banner.js');
var consts = require('./consts.js');
var manifest = require('./manifest.js');
var types = require('./types.js');
exports.generateBanner = banner.generateBanner;
exports.SCRIPTABLE_BANNER_STATIC_LINES = consts.SCRIPTABLE_BANNER_STATIC_LINES;
exports.REGEXP_BANNER_MANIFEST = manifest.REGEXP_BANNER_MANIFEST;
exports.buildBannerManifestRegex = manifest.buildBannerManifestRegex;
exports.extractScriptableManifest = manifest.extractScriptableManifest;
exports.generateManifestText = manifest.generateManifestText;
exports.generateScriptableBanner = manifest.generateScriptableBanner;
exports.hasBannerManifest = manifest.hasBannerManifest;
exports.isManifestBanner = manifest.isManifestBanner;
exports.isScriptableBanner = manifest.isScriptableBanner;
exports.isStaticBanner = manifest.isStaticBanner;
exports.matchAllBannerManifest = manifest.matchAllBannerManifest;
exports.updateScriptableManifest = manifest.updateScriptableManifest;
exports.ScriptableBannerManifestKeys = types.ScriptableBannerManifestKeys;

@@ -0,2 +1,7 @@

export type ScriptableShareSheetInputs = Array<'file-url' | 'url' | 'image' | 'plain-text'>;
/**
* The manifest for a Scriptable script.
*/
export interface ScriptableManifest {
name?: string;
always_run_in_app?: boolean;

@@ -7,3 +12,13 @@ icon?: {

};
share_sheet_inputs?: Array<'file-url' | 'url' | 'image' | 'plain-text'>;
share_sheet_inputs?: ScriptableShareSheetInputs;
script?: string;
[key: string]: unknown;
}
export declare const ScriptableBannerManifestKeys: readonly ["always-run-in-app", "share-sheet-inputs", "icon-color", "icon-glyph"];
export type ScriptableBannerManifestKeys = (typeof ScriptableBannerManifestKeys)[number];
export interface ScriptableBannerManifest {
'always-run-in-app'?: boolean | string;
'share-sheet-inputs'?: string;
'icon-color'?: string;
'icon-glyph'?: string;
}
'use strict';
const ScriptableBannerManifestKeys = [
'always-run-in-app',
'share-sheet-inputs',
'icon-color',
'icon-glyph',
];
exports.ScriptableBannerManifestKeys = ScriptableBannerManifestKeys;
{
"name": "@scriptables/manifest",
"description": "@scriptables/manifest is a toolkit designed to streamline Scriptable script development by automating metadata and comment generation for better documentation and maintainability.",
"version": "0.2.2",
"description": "An utilities to generate, parse, and update manifest headers in Scriptable scripts.",
"version": "0.2.3",
"keywords": [

@@ -52,3 +52,3 @@ "scriptable",

],
"gitHead": "e1e2fd9448ac3c218e6a046d47ac9dc19affe8d8"
"gitHead": "1e4ecf9d7d249001b78135920673aa9c73b6d4b6"
}
# @scriptables/manifest
@scriptables/manifest is a toolkit designed to streamline Scriptable script development by automating manifest and
comment generation for better documentation and maintainability.
An utilities to generate, parse, and update manifest headers in [Scriptable](https://scriptable.app) scripts.
## Overview
[Scriptable](https://scriptable.app) scripts can include special manifest comments at the top of the file that configure
various script behaviors and appearance settings. This library makes it easy to work with these manifests
programmatically.
Example manifest:
```
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: circle; always-run-in-app: true; share-sheet-inputs: file-url, url;
```
## Installation
To install the package, use the following command:
Choose your preferred package manager:
```sh
```bash
# npm
npm install @scriptables/manifest
# yarn
yarn add @scriptables/manifest
# pnpm
pnpm add @scriptables/manifest
# bun
bun add @scriptables/manifest
```
or with npm:
## API
```sh
npm install @scriptables/manifest
### Functions
#### `generateScriptableBanner(manifest?: ScriptableManifest, noDefaults = false): string`
Generates a complete Scriptable manifest banner with the specified settings.
```typescript
const manifest = {
icon: {
color: 'red',
glyph: 'square',
},
always_run_in_app: true,
share_sheet_inputs: ['file-url', 'url'],
};
const banner = generateScriptableBanner(manifest);
```
## Usage
#### `extractScriptableManifest(script: string, attrs?: ScriptableBannerManifestKeys[]): Partial<ScriptableManifest>`
To use the `generateBanner` function, import it and pass the manifest object:
Extracts manifest settings from a script's content.
```typescript
import generateBanner from '@scriptables/manifest';
const script = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: square;
const meta = {
name: 'Test Script',
always_run_in_app: true,
console.log('Hello world');`;
const manifest = extractScriptableManifest(script);
// Result: { icon: { color: 'red', glyph: 'square' } }
```
#### `updateScriptableManifest(script: string, manifest: Partial<ScriptableManifest>): [string, string]`
Updates an existing script's manifest with new settings. Returns a tuple of [banner, updatedScript].
```typescript
const [banner, updatedScript] = updateScriptableManifest(script, {
icon: {
color: 'blue',
glyph: 'circle',
},
});
```
### Helper Functions
- `hasBannerManifest(script: string): boolean` - Checks if a script has a manifest banner
- `isStaticBanner(line: string): boolean` - Checks if a line is part of the static banner
- `isManifestBanner(line: string): boolean` - Checks if a line contains manifest settings
- `isScriptableBanner(line: string): boolean` - Checks if a line is part of any banner type
## Types
```typescript
interface ScriptableManifest {
always_run_in_app?: boolean;
share_sheet_inputs?: ScriptableShareSheetInputs;
icon?: {
color?: string;
glyph?: string;
};
}
type ScriptableShareSheetInputs = Array<'file-url' | 'url' | 'plain-text' | 'images'>;
enum ScriptableBannerManifestKeys {
'always-run-in-app',
'share-sheet-inputs',
'icon-color',
'icon-glyph',
}
```
## Usage Examples
### Basic Usage
```typescript
import {generateScriptableBanner, updateScriptableManifest} from '@scriptables/manifest';
// Generate a new banner
const manifest = {
icon: {
color: 'red',
glyph: 'star',
glyph: 'square',
},
share_sheet_inputs: ['file-url', 'url'],
};
const banner = generateScriptableBanner(manifest);
const banner = generateBanner(meta);
console.log(banner);
// Update existing script
const script = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: circle;
console.log('Hello world');`;
const [newBanner, updatedScript] = updateScriptableManifest(script, manifest);
```
## Acknowledgements
### Extract and Modify Manifest
Portions of code and functionality are referenced from the
[rollup-plugin-scriptable](https://github.com/jag-k/rollup-plugin-scriptable) project. Many thanks!
```typescript
import {extractScriptableManifest, updateScriptableManifest} from '@scriptables/manifest';
// Extract existing manifest
const script = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: circle;
console.log('Hello world');`;
const manifest = extractScriptableManifest(script);
// Modify manifest
manifest.icon.color = 'red';
// Update script with modified manifest
const [newBanner, updatedScript] = updateScriptableManifest(script, manifest);
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Credits
This project draws inspiration and references code from:
- [rollup-plugin-scriptable](https://github.com/jag-k/rollup-plugin-scriptable)
Special thanks to jag-k for their contributions to the Scriptable community.
## License
This project is licensed under the Apache-2.0 License.
Apache-2.0

@@ -1,2 +0,3 @@

export * from './banner';
export * from './consts';
export * from './manifest';
export * from './types';

@@ -0,2 +1,8 @@

export type ScriptableShareSheetInputs = Array<'file-url' | 'url' | 'image' | 'plain-text'>;
/**
* The manifest for a Scriptable script.
*/
export interface ScriptableManifest {
name?: string;
always_run_in_app?: boolean;

@@ -7,3 +13,21 @@ icon?: {

};
share_sheet_inputs?: Array<'file-url' | 'url' | 'image' | 'plain-text'>;
share_sheet_inputs?: ScriptableShareSheetInputs;
script?: string;
[key: string]: unknown;
}
export const ScriptableBannerManifestKeys = [
'always-run-in-app',
'share-sheet-inputs',
'icon-color',
'icon-glyph',
] as const;
export type ScriptableBannerManifestKeys = (typeof ScriptableBannerManifestKeys)[number];
export interface ScriptableBannerManifest {
'always-run-in-app'?: boolean | string;
'share-sheet-inputs'?: string;
'icon-color'?: string;
'icon-glyph'?: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc