npm package: @scom/core
Description: Secure Compute core library
Latest version: 0.1.3

# @scom/core

Core library for Secure Compute components, providing essential runtime dependencies and utilities for building secure, modular web applications.

## Overview

The `@scom/core` package serves as the foundation for the Secure Compute ecosystem, bundling essential JavaScript libraries and providing an AMD loader for dynamic module loading. This package ensures consistent runtime environments across all Secure Compute components.

## Features

- **AMD Module Loader**: Dynamic module loading system for secure component isolation
- **React Runtime**: Bundled React and ReactDOM production builds
- **Development Server**: Local development environment with live reloading
- **Automated Building**: Scripts for bundling and distribution

## Installation

```bash
npm install @scom/core
```

## Scripts

### Development

```bash
# Start development server with examples
npm test
```

Starts a development server on port 8080 with live examples and AMD loader mapping.

### Building

```bash
# Create production bundle
npm run build
```

Creates multiple output files:
- `dist/index.js` - Combined AMD loader, core functionality, and React wrapper
- `dist/es6-wrapper.js` - ES6 module wrapper for modern environments
- `dist/lib/` - React production builds (`react.production.js`, `react-dom.production.js`, `react-dom-client.production.js`)

### Building

The build process compiles TypeScript sources and creates production bundles through a multi-step process:

1. **TypeScript Compilation**: Compiles `.ts` files to JavaScript
2. **Bundle Creation**: Combines AMD loader, core functionality, and React wrapper into `dist/index.js`
3. **ES6 Wrapper**: Creates modern ES6 module wrapper at `dist/es6-wrapper.js`

React production files are pre-bundled in `src/lib/` and included in the distribution.

## Project Structure

```
@scom/core/
├── dist/                 # Production bundles
│   ├── index.js         # Combined AMD + React bundle
│   ├── es6-wrapper.js   # ES6 module wrapper
│   └── lib/             # React production builds
├── src/                 # TypeScript source files
│   ├── lib/             # Pre-bundled React files
│   │   ├── react.production.js
│   │   ├── react-dom.production.js
│   │   └── react-dom-client.production.js
│   ├── amd-loader.ts    # AMD loader implementation
│   ├── index.ts         # Core functionality
│   ├── react-wrapper.ts # React wrapper
│   └── es6-wrapper.ts   # ES6 module wrapper
├── examples/            # Development examples
│   ├── index.html
│   ├── test-amd-loader.html
│   ├── api.js
│   ├── ui.js
│   └── utils.js
└── tsconfig.json        # TypeScript configuration
```

## Usage

### In HTML Applications

Include the core bundle in your HTML:

```html
<script src="node_modules/@scom/core/dist/index.js"></script>
```

Or use the ES6 module:

```javascript
import '@scom/core';
// or
import '@scom/core/amd'; // for AMD-only functionality
```

### With AMD Loader

The core library provides an AMD loader for dynamic module loading:

```javascript
// Load modules dynamically
require(['your-module'], function(module) {
    // Use your module
});
```

### Development Examples

The `examples/` directory contains sample implementations demonstrating:
- AMD loader functionality
- API integration patterns
- UI component examples
- Utility functions

## Dependencies

- **React**: ^19.1.0 (DevDependency)
- **ReactDOM**: ^19.1.0 (DevDependency)
- **@scom/cli**: Development and build tooling

## Development

1. Clone the repository
2. Install dependencies: `npm install`
3. Start development server: `npm test`
4. Open http://localhost:8080 to view examples

## Building for Production

1. Run the build script: `npm run build`
2. The output will be in `dist/index.js` and `dist/es6-wrapper.js`
3. Include this file in your production applications

## Integration with Secure Compute

This core library is designed to work seamlessly with the broader Secure Compute ecosystem:

- Provides consistent runtime environment for all components
- Enables secure module loading and isolation
- Supports dynamic component composition
- Maintains compatibility across different deployment environments