open-index/open-npm huggingface dataset:
npm package: @photon-elements/photon-iron
Description: A set of visual and non-visual utility elements for dealing with Warp 10
Latest version: 1.4.0

# Photon Iron Elements


A set of visual and non-visual utility elements for dealing with Warp 10


Inspired by [Polymer Iron Elements](https://github.com/PolymerElements/iron-elements) and 
[Warp 10 Iron Elements](https://github.com/cityzendata/warp10-iron/).


## Included elements

* `photon-warpscript-caller`:  an element calling WarpScript endpoints, sending the script and dealing
with the GTS stack in the response.
npm package: @photon-elements/photon-tools
Description: A set of utilities used by photon-elements
Author: Horacio Gonzalez
Latest version: 1.7.0

# photon-tools

A set of utilities used by photon-elements

## Install

[Node.js](http://nodejs.org) users can install from the [npm](https://www.npmjs.com/package/@photon-elements/photon-tools) registry using

    $ npm install --save @photon-elements/photon-tools


## Use    

All the tools are exposed as ES6 modules.

The tools currently available in this package are:

### photon-looseJSON

A JSON parser and serializer, based on standard JavaScript `JSON.parse()` and `JSON.stringify()`
but adding support for the much needed null, NaN and infinities, and big integers using 
[big.js](https://github.com/MikeMcl/big.js/).

It exports a `looseJSON` object with two methods, `looseJSON.parse()` and `looseJSON.stringify()`.


### photon-timeseries-tools

A set of tools to deal with time-series:

- `isArray()`
- `isTimeseries()`
- `jsonToStack()`
- `serializeTimeseriesMetadata()`
- `sameMetadata()`
- `isPlottable()`
- `isAnnotable()`
- `sort()`
- `timeRange()`
- `timeseriesToC3()`

### photon-timeseries-to-c3-worker

A [web worker] to parse Warp 10 JSON response and translate it to C3 data format


### photon-ts-plotting-tools

An utility class helping to deal with time-series plotting
npm package: @photon-sdk/react-native-tcp
Description: node's net API for react-native
Author: Hawking
Latest version: 6.3.0

# TCP in React Native

node's [net](https://nodejs.org/api/net.html) API in React Native

## Install

- Create a new react-native project. [Check react-native getting started](http://facebook.github.io/react-native/docs/getting-started.html#content)

- In your project dir:

```
npm install @photon-sdk/react-native-tcp --save
```

## if using Cocoapods

Update the following line with your path to `node_modules/` and add it to your
podfile:

```ruby
pod 'TcpSockets', :path => '../node_modules/react-native-tcp'
```

## Link in the native dependency

```
react-native link @photon-sdk/react-native-tcp
```

## Additional dependencies

### Due to limitations in the react-native packager, streams need to be hacked in with [rn-nodeify](https://www.npmjs.com/package/rn-nodeify)

1. install rn-nodeify as a dev-dependency
   `npm install --save-dev rn-nodeify`
2. run rn-nodeify manually
   `rn-nodeify --install stream,process,util --hack`
3. optionally you can add this as a postinstall script
   `"postinstall": "rn-nodeify --install stream,process,util --hack"`

## Usage

### package.json

_only if you want to write require('net') or require('tls') in your javascript_

```json
{
  "react-native": {
    "net": "@photon-sdk/react-native-tcp",
    "tls": "@photon-sdk/react-native-tcp/tls"
  }
}
```

### JS

_see/run [index.ios.js/index.android.js](examples/rctsockets) for a complete example, but basically it's just like net_

```js
var net = require("net");
var net = require("tls");
// OR, if not shimming via package.json "react-native" field:
// var net = require('@photon-sdk/react-native-tcp')
// var tls = require('@photon-sdk/react-native-tcp/tls')

var server = net
  .createServer(function(socket) {
    socket.write("excellent!");
  })
  .listen(12345);

var client = net.createConnection(12345);

client.on("error", function(error) {
  console.log(error);
});

client.on("data", function(data) {
  console.log("message was received", data);
});
```

### TLS support

TLS is only supported in the client interface. To use TLS, use the `tls.connect()`
syntax and not `socket = new tls.Socket()` syntax.

```
const socket = tls.connect({port: 50002, host:'electrum.villocq.com', rejectUnauthorized: false}, () => {
  socket.write('{ "id": 5, "method": "blockchain.estimatefee", "params": [2] }\n')
  console.log('Connected')
})

socket.on('data', (data) => {
  console.log('data:' + data.toString('ascii'))
})
```
npm package: @photon-sdk/rn-electrum-client
Description: Electrum protocol client for React Native & Node.js
Latest version: 4.0.0

# rn-electrum-client

Electrum Protocol Client for React Native

# based on

* https://github.com/you21979/node-electrum-client
* https://github.com/7kharov/node-electrum-client

# features

* persistence (ping strategy and reconnection)
* batch requests
* works in RN and nodejs

## protocol spec

* https://electrumx.readthedocs.io/en/latest/PROTOCOL.html

## usage

```
npm install --save @photon-sdk/rn-electrum-client
```

Relies on `@photon-sdk/react-native-tcp` so it should be already installed and linked in RN project.
npm package: @photon-terminal/lexer
Description: The lexical analysis tool for Photon Terminal
Author: Casper Tollefsen
Latest version: 0.1.0-alpha.1

# Photon Terminal Lexer

The lexical analysis tool made for Photon Terminal.

## Install

```bash
npm i @photon-terminal/lexer
```

## Usage

```typescript
import { Token, Tokenizer } from '@photon-terminal/lexer'

// Initialize the lexer with some code
const lexer = new Tokenizer().init('1 + 2;')

const tokens: Token[] = [lexer.getNextToken()]
let nextToken: Token | null = lexer.getNextToken()

while (nextToken) {
  tokens.push(nextToken)
  nextToken = lexer.getNextToken()
}

console.log(tokens)
// [
//   { type: 'NUMBER', value: '1' },
//   { type: 'ADDITIVE_OPERATOR', value: '+' },
//   { type: 'NUMBER', value: '2' },
//   { type: 'SEMICOLON', value: ';' },
// ]
```

The code above shows how you can perform your own lexical analysis on JavaScript code.
npm package: @photon-terminal/parser
Description: The syntax analysis tool for Photon Terminal
Author: Casper Tollefsen
Latest version: 0.1.0-alpha.1

# Photon Terminal Parser

The syntax analysis tool made for Photon Terminal.

## Install

```bash
npm i @photon-terminal/parser
```

## Usage

```typescript
import { parse } from '@photon-terminal/parser'

const ast = parse(`
  const age = 42;
  let isOld;

  if (age <= 69) {
    isOld = false;
  } else {
    isOld = true;
  }
`)

console.log(JSON.stringify(ast, null, 2))
```

Will print

```json
{
  "type": "Program",
  "body": [
    {
      "type": "VariableStatement",
      "kind": "const",
      "declarations": [
        {
          "type": "VaraiableDeclaration",
          "id": {
            "type": "Identifier",
            "name": "age"
          },
          "init": {
            "type": "NumericLiteral",
            "value": 42
          }
        }
      ]
    },
    {
      "type": "VariableStatement",
      "kind": "let",
      "declarations": [
        {
          "type": "VaraiableDeclaration",
          "id": {
            "type": "Identifier",
            "name": "isOld"
          },
          "init": null
        }
      ]
    },
    {
      "type": "IfStatement",
      "test": {
        "type": "ExpressionStatement",
        "expression": {
          "type": "BinaryExpression",
          "operator": "<=",
          "left": {
            "type": "Identifier",
            "name": "age"
          },
          "right": {
            "type": "NumericLiteral",
            "value": 69
          }
        }
      },
      "consequent": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "AssignmentExpression",
              "operator": "=",
              "left": {
                "type": "Identifier",
                "name": "isOld"
              },
              "right": {
                "type": "BooleanLiteral",
                "value": false
              }
            }
          }
        ]
      },
      "alternate": [
        {
          "type": "ExpressionStatement",
          "expression": {
            "type": "AssignmentExpression",
            "operator": "=",
            "left": {
              "type": "Identifier",
              "name": "isOld"
            },
            "right": {
              "type": "BooleanLiteral",
              "value": true
            }
          }
        }
      ]
    }
  ]
}
```
npm package: @photon-terminal/shared
Description: Shared resources for Photon Terminal
Author: Casper Tollefsen
Latest version: 0.1.0-alpha.1

# Photon Terminal Shared

Shared utilities and resources used by Photon Terminal.

## Install

```bash
npm i @photon-terminal/shared
```

## Usage

```typescript
import { isNumber, isString, toNumber, toString } from '@photon-terminal/shared'

const user = {
  age: '30',
  firstName: 'John',
  lastName: 'Doe',
}

console.log(isNumber(user.age)) // false
console.log(isString(user.age)) // true

user.age = toNumber(user.age)
console.log(user.age) // 30
console.log(isNumber(user.age)) // true
console.log(isString(user.age)) // false

user.age = toString(user.age)
console.log(isNumber(user.age)) // false
console.log(isString(user.age)) // true
```

## API

### isNumber(value)

> Replaces `typeof myVar === 'number'`

Checks if the provided value is of type number, and has the benefit of being more readable.

```typescript
import { isNumber } from '@photon-terminal/shared'

function validateAge(age: unknown): number {
  if (isNumber(age)) {
    return age
  }
  throw new Error(`Expected age to be a number, but got ${typeof age} instead`)
}
```

### isString(value)

> Replaces `typeof myVar === 'string'`

Checks if the provided value is of type string, and has the benefit of being more readable.

```typescript
import { isString } from '@photon-terminal/shared'

function validateAge(age: number | string): number {
  if (isString(age)) {
    throw new Error(`Expected age to be a number, but got a string instead`)
  }
  return age
}
```

### toNumber(value)

Converts the provided value to a number if possible. Otherwise throwing a syntax error. It also converts comma-separated decimals contained within strings.

```typescript
import { toNumber } from '@photon-terminal/shared'

console.log(toNumber(0)) //  0
console.log(toNumber('0')) //  0
console.log(toNumber('3.14')) //  3.14
console.log(toNumber('3,14')) //  3.14
console.log(toNumber('-0.45')) // -0.45

// These will throw SyntaxError
toNumber(null)
toNumber(unknown)
toNumber(true)
toNumber('3x')
```

### toString(value)

Converts the provided value to a string.

```typescript
import { toString } from '@photon-terminal/shared'

console.log(toString(0)) // '0'
console.log(toString(true)) // 'true'
console.log(toString(null)) // 'null'
console.log(toString(undefined)) // 'undefined'
```
npm package: @photon1/photon-sdk
Description: Photon Enterprise SDK
Author: Photon Team
Latest version: 2.0.1

# Photon SDK

`PhotonCore` 是嵌入式收银台的宿主层 SDK，职责是管理 iframe 生命周期、会话握手与事件回调。

## 核心职责（v2）

- 加载/销毁 cashier iframe
- 与 iframe 建立安全消息通道（origin + source + sessionId + nonce）
- 提供 `submit()` 和事件回调给商户页面
- 同步最小化的 checkout 状态（用于刷新恢复）
- 按环境解析收银台地址，默认只走生产环境

## 非职责

- 不代理 cashier 的业务 API 请求
- 不代理 crypto 轮询与退款业务编排
- 不接触 PAN/CVV 等敏感数据
- 不内置 `APP_ID / APP_SECRET`，这些由 `PhotonLens` 在 iframe 内部管理

## 安装

```bash
npm install @photon1/photon-sdk
```

## 快速开始

```js
import { Photon } from '@photon1/photon-sdk'

const photon = new Photon('pk_test_xxx', {
  baseURL: '/api',
  environment: 'production',
  platform: 'auto',
  authCode: 'ac_xxx',
  debug: true
})

const checkout = await photon.initEmbeddedCheckout({
  container: '#checkout',
  enabledMethods: ['cardInfo', 'billing', 'email', 'cryptoPay'],
  onReady: () => console.log('ready'),
  onComplete: (result) => console.log('complete', result),
  onError: (error) => console.error('error', error)
})
```

## 环境切换

SDK 内置以下 cashier 地址映射：

- `production` -> `https://cashier.photonpay.com`
- `pre` -> `https://cashier1.pre.photontech.cc`
- `uat` -> `https://cashier1.uat.photontech.cc`
- `sit` -> `https://cashier1.sit.photontech.cc`
- `dev` -> `https://cashier1.dev.photontech.cc`
- `local` -> `http://localhost:3001`

默认环境始终是 `production`。

只有以下场景允许切换到非生产环境：

- 页面运行在 `localhost / 127.0.0.1 / 0.0.0.0`
- 页面运行在 `*.photontech.cc`

这意味着外部商户即使传了 `environment: 'sit'`，SDK 也会自动回退到 `production`。

## 平台选择

- `platform: 'auto'`：默认值，按屏幕宽度和 `matchMedia('(max-width: 768px)')` 判断
- `platform: 'desktop'`：强制桌面策略
- `platform: 'mobile'`：强制移动策略

## 事件模型

`EmbeddedCheckout` 继承 `EventEmitter`，可监听：

- `ready`
- `resize`
- `change`
- `validation`
- `submit_start`
- `complete`
- `submit_error`
- `3ds_required`
- `3ds_complete`
- `back_to_merchant`
- `error`

## npm 发包说明

`PhotonCore` 是 npm 包，不是把 `dist/` 单独上传到 npm。

正确流程：

1. 在 `PhotonCore` 根目录执行 `npm run build`
2. 用 `npm pack --dry-run` 检查最终入包文件
3. 在 `PhotonCore` 根目录执行 `npm publish`

npm 真正上传的是整个包（tarball），而不是手工上传某个文件夹。

### 当前发包内容

包内只保留：

- `dist/`
- `index.d.ts`
- `README.md`
- `LICENSE`

不会再把 `src/` 或 `const/` 源码一起发布到 npm。

### 构建产物说明

- `dist/photon-sdk.esm.js`：给 Vite / Webpack / Rollup 等现代前端工程使用
- `dist/photon-sdk.cjs`：给 CommonJS / Node 工程使用
- `dist/photon-sdk.umd.js`：给 CDN / `<script>` 直插场景使用

npm 用户默认走 `ESM/CJS`；只有 CDN 场景才直接用 `UMD`。

## 本地开发

```bash
npm install
npm run build
npm run build:dev
npm pack --dry-run
```