open-index/open-npm huggingface dataset:
npm package: @foc-engine/core
Description: Core FOC Engine functionality for Starknet dApps - no React dependencies
Latest version: 1.0.0

# @foc-engine/core

Core FOC Engine functionality for Starknet dApps - no React dependencies required.

## Installation

```bash
npm install @foc-engine/core
```

## Features

- **FOC Engine & Paymaster**: Gasless transaction support
- **State Management**: Zustand-based stores for events, notifications, sound, and onchain actions
- **Observer Pattern**: Event-driven architecture
- **TypeScript Support**: Full type definitions included

## Usage

### Basic Usage (Non-React)

```javascript
import { FocEngine, Paymaster } from '@foc-engine/core';

// Initialize FOC Engine
const engine = new FocEngine('sepolia');
const paymaster = new Paymaster(engine);

// Build gasless transaction
const gaslessTx = await paymaster.buildGaslessTx(calls);
```

### State Management

```javascript
import { useEventManager, useInAppNotificationsStore } from '@foc-engine/core';

// Event management
const eventManager = useEventManager.getState();
eventManager.publish('user-action', { type: 'click' });

// Notifications
const notificationStore = useInAppNotificationsStore.getState();
notificationStore.sendInAppNotification(1, 'Transaction completed');
```

## API Reference

### Core Classes
- `FocEngine`: Main engine for FOC functionality
- `Paymaster`: Handles gasless transactions

### Stores
- `useEventManager`: Generic event management
- `useInAppNotificationsStore`: In-app notifications
- `useSoundStore`: Sound management
- `useOnchainActions`: Blockchain transaction management

### Observers
- `InAppNotificationsObserver`: Handle notification events
- `SoundObserver`: Handle sound events

## Requirements

- Node.js >= 14
- No React dependency required
npm package: @foc-engine/react
Description: React components and hooks for FOC Engine Starknet dApps
Latest version: 1.0.0

# @foc-engine/react

React components and hooks for FOC Engine Starknet dApps.

## Installation

```bash
npm install @foc-engine/react
```

**Note**: This package requires React >= 16.8.0 as a peer dependency.

## Features

- **React Context Providers**: FOC Engine and Starknet wallet integration
- **React Hooks**: Image preloading and management
- **Re-exports**: All `@foc-engine/core` functionality included

## Usage

### FOC Engine Provider

```jsx
import { FocEngineProvider, useFocEngine } from '@foc-engine/react';

// Wrap your app
function App() {
  return (
    <FocEngineProvider defaultNetwork="sepolia">
      <YourComponents />
    </FocEngineProvider>
  );
}

// Use in components
function MyComponent() {
  const { buildGaslessTx, sendGaslessTx } = useFocEngine();
  
  const handleTransaction = async () => {
    const tx = await buildGaslessTx({ calls });
    await sendGaslessTx(tx);
  };
}
```

### Starknet Connector

```jsx
import { StarknetProvider, useStarknet } from '@foc-engine/react';

// Configure provider
function App() {
  return (
    <StarknetProvider 
      defaultNetwork="sepolia"
      balanceTokens={['ETH', 'STRK', 'USDC']}
    >
      <YourComponents />
    </StarknetProvider>
  );
}

// Use in components
function WalletInfo() {
  const { account, balance, connect, disconnect } = useStarknet();
  
  return (
    <div>
      {account ? (
        <>
          <p>Balance: {balance}</p>
          <button onClick={disconnect}>Disconnect</button>
        </>
      ) : (
        <button onClick={connect}>Connect Wallet</button>
      )}
    </div>
  );
}
```

### Image Hooks

```jsx
import { useImagePreloader } from '@foc-engine/react';

function Gallery() {
  const { images, isLoading, progress } = useImagePreloader([
    { id: 'hero', source: '/images/hero.jpg' },
    { id: 'banner', source: '/images/banner.png' }
  ]);
  
  if (isLoading) return <div>Loading {progress}%</div>;
  
  return <img src={images.hero} alt="Hero" />;
}
```

## API Reference

### Context Providers
- `FocEngineProvider`: FOC Engine integration
- `StarknetProvider`: Enhanced Starknet wallet connection

### Hooks
- `useFocEngine`: Access FOC Engine functionality
- `useStarknet`: Access wallet and blockchain state
- `useImagePreloader`: Preload and manage images
- `useImages`: Image utilities

### Re-exported from @foc-engine/core
All core functionality is also available through this package.

## Requirements

- React >= 16.8.0
- React DOM >= 16.8.0 (optional)
npm package: @focme/argv
Description: node command arguments formater
Author: focme
Latest version: 4.0.1

# @focme/argv

a useless node arguments formater  

## usage  

```javascript
const createArgv = require("@focme/argv")

const argv = createArgv() // a map
const argvObject = argv.object() // an object
```

`createArgv()` will return a map object for the options  
`createArgv().object()` will return an object for the options  
`createArgv().opt()` will return an object for the options that every key removed the leading `-` or `--`  
`createArgv().array()` will return an entries of the options map  


```javascript
// --config ./webpack/webpack.dev.config

console.log(createArgv())
// Map(1) { "--config" => "./webpack/webpack.dev.config" }

console.log(createArgv().object())
// { "--config": "./webpack/webpack.dev.config" }

console.log(createArgv().opt())
// { "config": "./webpack/webpack.dev.config" }

console.log(createArgv().array())
// [["--config", "./webpack/webpack.dev.config"]]
```

## pipe and commit  

**pipe**  

```javascript
pipe(command, callback, type)
```

use `pipe()` function to put a callback into a map for one key in the options  
the callback could be an async function  

```javascript
// call this pipe callback while there is a command --key
createArgv().pipe("key", value => { ... }).commit(() => { ... })

// always call this pipe callback whether there is a command --key
// the value will be undefined
createArgv().pipe("key", value => { ... }, "always").commit(() => { ... })

// will not call the pipe callbacks after this pipe if there is a command --key
createArgv().pipe("key", value => { ... }, "break").commit(() => { ... })
```

**commit**  

use `commit()` function to run the callbacks in the pipe  
after `commit()` complete the pipe will be cleard

```javascript
await createArgv().pipe(key, value => {
    ...
}).commit()
```

as `commit` is an async function  
always should use async before it or use then after it  

in the callback of `commit` will send the keys in `createArgv` but not in the pipe  
return `false` the commit will stop run pipe callbacks  

```javascript
// -V
await createArgv().pipe("v", value => {
    console.log("version 10.01")
}).commit((keys) => {
    // keys = ["-V"]
    if (keys.length > 0) {
        console.log(`bad option ${key}`) // bad option -V
    }
    // commit will not run the pipe callbacks if keys.length > 0
    return keys.length < 1 
})
```

dont use the commit callback if dont care about the not matched keys
npm package: @focme/rollup-plugin-pick
Description: a rollup plugin for picking up values from a .json file
Author: focme
Latest version: 1.0.2

# @focme/rollup-plugin-pick

pick up values from the .json file and write it into a new file  

in default without a config will pick up `package.json` file in project main directory  
to the `./dist` directory  

## usage  

```javascript
// rollup.config.js
import pick from "@focme/rollup-plugin-pick"

export default {
    ...
    plugins: [
        ...
        pick({ ... })
    ]
}
```

## option  

default value  
```javascript
// the same option
pick()

pick({
    src: "./package.json",
    dest: "./dist"
})
```

pass `pick` array to the function  
```javascript
// the same option
pick(["name", "version"])

pick({
    src: "./package.json",
    dest: "./dist",
    pick: ["name", "version"]
})
```

**src**  
type `string`  
set the input file  
default value `./package.json` if not set

relative paths are matched based on `process.cwd()`

**dest**  
type `string`  
set the output file path  
default value `./dist` if not set  

relative paths are matched based on `process.cwd()`

**filename**  
type `string`  
set the output file name  
use `src` file's name if not set   

**pick**  
type `string[]` or `entries`  
like `[key_1, key_2]` or `[[key_1, value_1?], [key2, value_2?]]`
set the values from the `src` file to the `dest` file  
use all the `src` file values if not set  

`value` could be undefined or a value  

```json
// pick({ pick: ["name", "auther"] })
// pick up src file values
{
    "name": "@focme/rollup-plugin-pick",
    "auther": "focme"
}

// pick({ pick: ["name", ["auther", "others"]] })
// use the pick-up value instead of src file values
{
    "name": "@focme/rollup-plugin-pick",
    "auther": "others"
}
```

**transform**  
type `(current: Record<string, any>, origin: Record<string, any>) => Record<string, any>`  
format the final value before write into output file  

```javascript
// rollup.config.js
import pick from "@focme/rollup-plugin-pick"

export default {
    ...
    plugins: [
        ...
        pick({
            pick: ["name", "auth"],
            transform: (current, origin) => {
                return { ...current, auther: origin.auther + "-auther" }
            }
        })
    ]
}
```

```json
// current value
{
    "name": "@focme/rollup-plugin-pick",
    "auther": "focme"
}

// origin value
// the value of ./package.json

// final value
{
    "name": "@focme/rollup-plugin-pick",
    "auther": "focme-auther"
}
```
npm package: @focme/stringify-json
Description: a json write file formatter
Author: focme
Latest version: 2.0.0

# stringify-json

format the json string before write into file  
with indent and linebreak

## usage  

```javascript
const fs = require("node:fs")
const stringify = require("@focme/stringify-json")
const filePath = "/.../test.json"
const json = { ... }
const config = { ... }

fs.writeFileSync(filePath, stringify(json, config))
```

## config  

**config.keySpace**  

every key name has a `:` after it  
and every `:` has a key-space after it  
default to `" "`

```javascript
// with keySpace is " " the file will looks like
{
  "name": "@focme/stringify-json"
}

// with keySpace is ""
{
  "name":"@focme/stringify-json"
}

// with keySpace is " ~ "
{
  "name": ~ "@focme/stringify-json"
}
```

**config.indent**  

the indent at start of the line  
the indent will double after line break  
default is `"  "`

```javascript
// with indent is "   " the file will looks like
{
   "name": "@focme/stringify-json",
   "script": {
      "test": "node ./script/test/index.test.js"
   }
}

// with indent is " "
{
 "name": "@focme/stringify-json",
 "script": {
  "test": "node ./script/test/index.test.js"
 }
}
```

**config.lineBreak**  

every line will have a line break in the end  
except the last line  
default is `"\n"`

```javascript
// with lineBreak is "\n" the file will looks like
{
   "name": "@focme/stringify-json",
   "script": {
       "test": "node ./script/test/index.test.js"
   }
}

// with indent is " "
{ "name": "@focme/stringify-json", "script": { "test": "node ./script/test/index.test.js" } }
```

## have fun  

when set config to `{ indent: "", keySpace: "", lineBreak: "" }`  
the file will be exactly the same with `fs.writeFileSync(JSON.stringify(json))`