1.10.5 • Published 12 days ago

@ray-js/panel-sdk v1.10.5

Weekly downloads
-
License
MIT
Repository
-
Last release
12 days ago

English | 简体中文

@ray-js/panel-sdk

latest download

Ray Panel Mini App Base JS SDK

Installation

$ npm install @ray-js/panel-sdk
# or
$ yarn add @ray-js/panel-sdk
# or
$ pnpm add @ray-js/panel-sdk

Basic Usage

Fully use

import { kit, hooks, utils, service } from '@ray-js/panel-sdk';

const { I18N } = kit;

// Never use hooks.useDpState, which will cause the eslint rule to fail to detect
const { useDpState } = hooks;

const data = utils.parseJSON('{}');

service.getAssetHostname().then(data => {
  console.lo('data: ', data);
});

Smart Device Model

Usage

import { SmartDeviceModel } from '@ray-js/panel-sdk';

// SmartDevices comes from typings/sdm.d.ts,negligible for non Typescript developers
export const devices = {} as SmartDevices;

SmartDeviceModel.init<SmartDeviceSchema>().then(device => {
  /**
   * It is recommended that the name of the smart device be used as the key name for assignment
   */
  devices.robot = device;
});

devices.robot.model.actions.power.toggle();

Ray / React Project

// src/app.tsx
import React from 'react';
import 'ray';
import '@/i18n';
import { kit, SdmProvider } from '@ray-js/panel-sdk';
import { devices } from '@/devices';

const { initPanelEnvironment } = kit;

interface Props {
  children: React.ReactNode;
}

initPanelEnvironment({ useDefaultOffline: true });

export default class App extends React.Component<Props> {
  onLaunch() {
    console.info('=== App onLaunch');
  }

  render() {
    return <SdmProvider value={devices.robot}>{this.props.children}</SdmProvider>;
  }
}
// src/pages/home/index.tsx
import React from 'react';
import { Button, View } from '@ray-js/ray';
import { devices } from '@/devices';

export default function Home() {
  const device = devices.robot;
  return (
    <View>
      <Button onClick={() => device.model.actions.power.toggle()}>Click me toggle power</Button>
    </View>
  );
}
1.10.5

12 days ago

1.10.4

1 month ago

1.10.3

1 month ago

1.10.2

1 month ago

1.10.1-beta.2

1 month ago

1.10.1-beta.1

2 months ago

1.10.1

2 months ago

1.10.1-beta.0

2 months ago

1.10.0

3 months ago

1.10.0-beta.8

3 months ago

1.10.0-beta.7

3 months ago

1.10.0-beta.6

4 months ago

1.10.0-linkage.2

4 months ago

1.9.1

4 months ago

1.10.0-beta.5

4 months ago

1.10.0-linkage.1

5 months ago

1.10.0-linkage.0

5 months ago

1.10.0-beta.4

5 months ago

1.10.0-beta.3

5 months ago

1.10.0-beta.2

5 months ago

1.10.0-beta.1

5 months ago

1.10.0-beta.0

5 months ago

1.7.0-beta.0

9 months ago

1.7.0-beta.1

9 months ago

1.7.0-beta.2

9 months ago

1.8.0

7 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.8.0-beta.0

7 months ago

1.9.0

7 months ago

1.7.1

7 months ago

1.7.0

9 months ago

1.6.0-beta.4

10 months ago

1.6.1-beta.0

9 months ago

1.6.0-beta.0

11 months ago

1.6.0-beta.1

10 months ago

1.6.0-beta.2

10 months ago

1.6.0-beta.3

10 months ago

1.9.0-beta.0

7 months ago

1.4.2

1 year ago

1.5.0

11 months ago

1.5.0-beta.0

1 year ago

1.5.0-sgm.0

12 months ago

1.5.0-sgm.1

12 months ago

1.3.4

1 year ago

1.3.3

1 year ago

1.4.1

1 year ago

1.3.2

1 year ago

1.4.0

1 year ago

1.4.0-beta.3

1 year ago

1.4.0-beta.2

1 year ago

1.4.0-beta.1

1 year ago

1.4.0-beta.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.3.0-beta.0

1 year ago

1.2.0

2 years ago

1.1.4

2 years ago

1.2.2

1 year ago

1.2.1

2 years ago

1.2.0-beta.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1-beta.1

2 years ago

1.0.1-beta.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.0

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.2

2 years ago

1.0.0-beta.1

2 years ago