# @stack-scribe/icon-pack-aws

`@stack-scribe/icon-pack-aws` is the first-party AWS icon pack for Stack Scribe. It provides the AWS icon catalog, shorthand alias resolution, group icon mappings, browser-safe icon resolvers, and Node filesystem-backed icon loading.

Use it with `@stack-scribe/core` when you want canonical AWS node types, shorthand inputs such as `lambda` and `s3-bucket`, and bundled AWS SVG assets.

## Install

```bash
npm install @stack-scribe/core @stack-scribe/icon-pack-aws
```

## What It Provides

- The `awsIconPack` definition for Stack Scribe icon registries
- Alias normalization and canonical type resolution for AWS node types
- A browser-safe icon resolver via `@stack-scribe/icon-pack-aws/browser`
- A Node filesystem-backed icon resolver via `@stack-scribe/icon-pack-aws/node`
- Catalog exports for AWS node types and icon asset paths

## Registry Example

```ts
import { createIconRegistry } from "@stack-scribe/core";
import {
  awsIconPack,
  listAwsNodeTypeAliases,
  resolveAwsNodeType,
} from "@stack-scribe/icon-pack-aws";

const registry = createIconRegistry([awsIconPack]);

console.log(resolveAwsNodeType("lambda"));
console.log(listAwsNodeTypeAliases().slice(0, 5));
console.log(registry.resolveType("s3-bucket"));
```

## Browser Usage

Use the browser subpath when rendering inside a browser bundle.

```ts
import { renderDiagramFromInput } from "@stack-scribe/core";
import { awsBrowserRenderOptions } from "@stack-scribe/icon-pack-aws/browser";

const rendered = await renderDiagramFromInput(
  {
    nodes: [
      { id: "api", type: "aws.networking-content-delivery.api-gateway" },
      { id: "fn", type: "lambda" },
    ],
    edges: [{ from: "api", to: "fn" }],
  },
  awsBrowserRenderOptions,
);

console.log(rendered.svg);
```

`awsBrowserRenderOptions` supplies a trusted browser icon resolver for Stack Scribe rendering.

## Node Usage

Use the Node subpath when you need filesystem-backed icon loading or direct access to the packaged SVG assets.

```ts
import { createIconRegistry } from "@stack-scribe/core";
import { awsIconPack } from "@stack-scribe/icon-pack-aws";
import {
  createAwsIconResolver,
  getAwsIcon,
  getAwsIconPath,
  getAwsIconsDirectory,
} from "@stack-scribe/icon-pack-aws/node";

const iconRegistry = createIconRegistry([awsIconPack]);
const iconResolver = createAwsIconResolver();

console.log(Boolean(iconRegistry.resolveType("cloudfront")));
console.log(getAwsIconPath("aws.compute.lambda"));
console.log(getAwsIconsDirectory());
console.log(getAwsIcon("s3-bucket").includes("<svg"));
console.log(Boolean(iconResolver));
```

## Public Exports

From `@stack-scribe/icon-pack-aws`:

- `awsIconPack`
- `createAwsIconRegistry()`
- `AwsNodeTypeSchema`
- `awsNodeTypeToIcon`
- `awsGroupIconDefinitions`
- `listAwsNodeTypeAliases()`
- `normalizeAwsNodeTypeInput()`
- `resolveAwsNodeType()`

From `@stack-scribe/icon-pack-aws/browser`:

- `createAwsBrowserIconAssetLoader()`
- `createAwsBrowserIconResolver()`
- `awsBrowserIconResolver`
- `awsBrowserRenderOptions`

From `@stack-scribe/icon-pack-aws/node`:

- `createAwsIconAssetLoader()`
- `createAwsIconResolver()`
- `getAwsIconsDirectory()`
- `getAwsIconPath()` and `getAwsGroupIconPath()`
- `getAwsIcon()` and `getAwsGroupIcon()`
- `clearAwsIconCache()`
- `fallbackIconSvg`

From `@stack-scribe/icon-pack-aws/catalog`:

- `NodeTypeSchema`
- `nodeTypeToIcon`

## Notes

- The package ships the AWS SVG assets alongside the package files.
- Root exports stay browser-safe; Node filesystem access lives under the `./node` subpath.
- Alias resolution is explicit and supports common shorthand inputs used by Stack Scribe tooling.