open-index/open-npm huggingface dataset:
npm package: @stabldev/pkgversion
Description: A tiny Node.js utility to retrieve the installed version of a package.
Author: stabldev
Latest version: 1.0.1

# pkgversion

![NPM Version](https://img.shields.io/npm/v/%40stabldev%2Fpkgversion?style=flat-square)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40stabldev%2Fpkgversion?style=flat-square)
![NPM Type Definitions](https://img.shields.io/npm/types/%40stabldev%2Fpkgversion?style=flat-square)
![NPM License](https://img.shields.io/npm/l/%40stabldev%2Fpkgversion?style=flat-square)

A tiny Node.js utility to retrieve the installed version of a package.

## Installation

```bash
npm i @stabldev/pkgversion
````

## Usage

```js
import pkgversion from "@stabldev/pkgversion"

const reactVersion = pkgversion("react")
console.log(reactVersion) // e.g., "19.1.1"
```

## API Reference

```ts
pkgversion(pkgName: string, baseDir?: string): string | null
```

* `pkgName`: The name of the installed package (e.g., `"react"`).
* `baseDir` (optional): Directory to start from (defaults to `process.cwd()`).

## License

[MIT](https://github.com/stabldev/pkgversion/blob/main/LICENSE) Copyright (c) [stabldev](https://github.com/stabldev)
npm package: @stable-canvas/civitai-rest-api-client
Description: civitai rest api client for js
Author: zhzluke96
Latest version: 1.0.2

# @stable-canvas/civitai-rest-api-client
civitai rest api client for js

This is a lightweight, type-safe JavaScript/TypeScript library for interacting with the Civitai REST API. It supports both web browsers and Node.js environments.

## Features

- **Small Footprint**: The library has a minimal dependency footprint, making it suitable for use in various project environments.
- **Type Safety**: Written in TypeScript, the library provides type safety and better tooling support, reducing runtime errors and improving developer experience.
- **Cross-Platform**: The library can be used in both web browsers (via bundlers like Webpack or Rollup) and Node.js environments.

## Installation

Using npm:

```bash
npm install @stable-canvas/civitai-rest-api-client
```

Using yarn:

```bash
yarn add @stable-canvas/civitai-rest-api-client
```

## Usage

```typescript
import "./ensure-fetch"; // Required for NodeJS
import { CivitaiRESTAPIClient } from "@stable-canvas/civitai-rest-api-client";

const client = new CivitaiRESTAPIClient();
const models = await client.default.getModels({
    nsfw: false,
    limit: 5,
});
console.log(models);
```

> full example in `/examples` folder

## Supported Endpoints

This library is implemented based on the [Civitai REST API Reference](https://github.com/civitai/civitai/wiki/REST-API-Reference). The following endpoints are supported:

### Creators

- `getCreators`

### Images

- `getImages`

### Models

- `getModels`
- `getModels1`

### Model Versions

- `getModelVersions`
- `getModelVersionsByHash`

### Tags

- `getTags`

For detailed information on the parameters and response types for each endpoint, please refer to the [Civitai REST API Reference](https://github.com/civitai/civitai/wiki/REST-API-Reference).

## Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

## License

This project is licensed under the [MIT License](LICENSE).
npm package: @stable-canvas/comfyui-client-cli
Description: cli tools for @stable-canvas/comfyui-client
Author: zhzluke96
Latest version: 1.6.0

# cli tools for @stable-canvas/comfyui-client

[readme](https://github.com/StableCanvas/comfyui-client)

## usage

```
npm install -g @stable-canvas/comfyui-client-cli
```

```
> cuc-w2c -h
```

```bash
Usage: nodejs-comfy-ui-client-code-gen [options]

Use this tool to generate the corresponding calling code using workflow

Options:
  -V, --version              output the version number
  -t, --template [template]  Specify the template for generating code, builtin tpl: [esm,cjs,web,none]
                             (default: "esm")
  -o, --out [output]         Specify the output file for the generated code. default to stdout
  -i, --in <input>           Specify the input file, support .json/.png file
  -h, --help                 display help for command
```

## Example

```
cuc-w2c -i ./tests/test-inputs/workflow_api.json
```

### Expected Output

```ts
import { Client, Workflow } from "@stable-canvas/comfyui-client";

const createWorkflow = () => {
  const workflow = new Workflow();
  const cls = workflow.classes;

  const [LATENT_2] = cls.EmptyLatentImage({
    width: 512,
    height: 512,
    batch_size: 1,
  });
  const [MODEL_1, CLIP_1, VAE_1] = cls.CheckpointLoaderSimple({
    ckpt_name: "EPIC-la-v1.ckpt",
  });
  const [CONDITIONING_2] = cls.CLIPTextEncode({
    text: "text, watermark",
    clip: CLIP_1,
  });
  const [CONDITIONING_1] = cls.CLIPTextEncode({
    text: "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
    clip: CLIP_1,
  });
  const [LATENT_1] = cls.KSampler({
    seed: 156680208700286,
    steps: 20,
    cfg: 8,
    sampler_name: "euler",
    scheduler: "normal",
    denoise: 1,
    model: MODEL_1,
    positive: CONDITIONING_1,
    negative: CONDITIONING_2,
    latent_image: LATENT_2,
  });
  const [IMAGE_1] = cls.VAEDecode({
    samples: LATENT_1,
    vae: VAE_1,
  });
  const [] = cls.SaveImage({
    filename_prefix: "ComfyUI",
    images: IMAGE_1,
  });

  return workflow;
};

async function main(envs = {}) {
  const env = (k) => envs[k];

  const client = new Client({
    api_host: env("COMFYUI_CLIENT_API_HOST"),
    api_base: env("COMFYUI_CLIENT_API_BASE"),
    clientId: env("COMFYUI_CLIENT_CLIENT_ID"),
  });

  await client.connect();

  const workflow = createWorkflow();

  console.time("enqueue workflow");
  try {
    return await workflow.invoke(client);
  } catch (error) {
    throw error;
  } finally {
    console.timeEnd("enqueue workflow");
    client.disconnect();
  }
}

main(
  typeof globalThis?.process?.env === "object"
    ? globalThis.process.env
    : globalThis,
)
  .then(() => {
    console.log("DONE");
  })
  .catch((err) => {
    console.error("ERR", err);
  });
```
npm package: @stable-canvas/cw-reader
Description: read workflow(comfyui) info from image/json
Author: lenml
Latest version: 1.0.4

# cw-reader

ComfyUI Workflow Reader

```
npm install @stable-canvas/cw-reader
```

references:

- [comfyui-client](https://github.com/StableCanvas/comfyui-client)

# Usage

- NodeJS

```ts
import { ImageReader } from "@stable-canvas/cw-reader";
const file1 = await fs.promises.readFile("./tests/img2img_workflow.png");
const reader = new ImageReader(file1.buffer);
const workflow = await reader.getWorkflowJson();
await fs.promises.writeFile(
  "./img2img_workflow.json",
  JSON.stringify(workflow, null, 2),
);
```

- ESM

```html
<input type="file" accept="image/*" />
<pre><code id="output">// Output will appear here</code></pre>

<script type="module">
  import { ImageReader } from "https://esm.run/@stable-canvas/cw-reader";

  const fileInput = dropZone.querySelector("input");
  const output = document.getElementById("output");

  async function handleFile(file) {
    try {
      const arrayBuffer = await file.arrayBuffer();
      const reader = new ImageReader(arrayBuffer);
      const workflow = await reader.getWorkflowJson();
      output.textContent = JSON.stringify(workflow, null, 2);
    } catch (err) {
      output.textContent = `Error: ${err.message}`;
    }
  }
</script>
```

# What is `./data/\*.json`

## `comfyui.node.types.json`

This file comes from the ComfyUI runtime and is used during code generation to annotate output types.

(The “types” here refer to internal types used by ComfyUI; in the generated code, they are only written as comments without any type checking.)

It is generated by a script. Since the script is extremely simple, it doesn’t make sense to open source it for now. Also, whether this file is correct or not does not affect the use of the library, so it won’t be updated in real-time.

## `comfyui.node.widgets.json`

This file comes from the ComfyUI WebUI runtime environment. It is required when parsing non-API format workflows.

This file affects the final execution result, because workflow definition files are missing some content needed for API requests. These values are estimated using this file. If the file content is incorrect, workflow parsing will fail.

Therefore, it is not recommended to use workflow documents for code generation.
npm package: @stable-canvas/sd-webui-a1111-pnginfo
Description: pnginfo reader/parser for a1111/webui
Author: zhzluke96
Latest version: 1.0.3

# sd-webui-a1111-pnginfo
pnginfo reader/parser for a1111/webui

# usage
```ts
import { PNGInfo } from '@stable-canvas/sd-webui-a1111-pnginfo';
const $image = /** <img /> ; base64_str ; Blob ; File ...  */ ; 
const pnginfo = new PNGInfo($image);
const params = await pnginfo.getParams();
console.log(params);
```

# todos
- [ ] more formats support
- [ ] support utf8 prompt (exifr problem)