@weaverse/react 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +32 -27
  3. package/readme.md +83 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Paul Phan
3
+ Copyright (c) 2022 Weaverse
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,37 +1,42 @@
1
1
  {
2
- "version": "2.5.0",
3
- "license": "MIT",
4
- "main": "dist/index.js",
5
- "typings": "dist/index.d.ts",
6
- "module": "dist/index.mjs",
7
- "publishConfig": {
8
- "access": "public"
2
+ "name" : "@weaverse/react",
3
+ "author" : "Weaverse Team",
4
+ "description" : "React bindings for Weaverse",
5
+ "version" : "2.6.0",
6
+ "license" : "MIT",
7
+ "main" : "dist/index.js",
8
+ "typings" : "dist/index.d.ts",
9
+ "module" : "dist/index.mjs",
10
+ "repository" : {
11
+ "url" : "git+https://github.com/Weaverse/weaverse.git",
12
+ "directory" : "packages/react"
9
13
  },
10
- "files": [
14
+ "publishConfig" : {
15
+ "access" : "public"
16
+ },
17
+ "files" : [
11
18
  "dist/*"
12
19
  ],
13
- "engines": {
14
- "node": ">=16"
20
+ "engines" : {
21
+ "node" : ">=16"
15
22
  },
16
- "scripts": {
17
- "start": "npm run dev",
18
- "dev": "tsup src/index.ts --format esm,cjs --dts --outDir dist --watch --external react,clsx --sourcemap",
19
- "build": "tsup src/index.ts --format esm,cjs --dts --outDir dist --external react,clsx",
20
- "clean": "rimraf dist",
21
- "prepublish": "npm run build"
23
+ "scripts" : {
24
+ "start" : "npm run dev",
25
+ "dev" : "tsup src/index.ts --format esm,cjs --dts --outDir dist --watch --external react,clsx --sourcemap",
26
+ "build" : "tsup src/index.ts --format esm,cjs --dts --outDir dist --external react,clsx",
27
+ "clean" : "rimraf dist",
28
+ "prepublish" : "npm run build"
22
29
  },
23
- "peerDependencies": {
24
- "react": ">=16.8.0",
25
- "react-dom": ">=16.8.0"
30
+ "peerDependencies" : {
31
+ "react" : ">=16.8.0",
32
+ "react-dom" : ">=16.8.0"
26
33
  },
27
- "prettier": {
28
- "printWidth": 80,
29
- "semi": false,
30
- "singleQuote": true
34
+ "prettier" : {
35
+ "printWidth" : 80,
36
+ "semi" : false,
37
+ "singleQuote" : true
31
38
  },
32
- "name": "@weaverse/react",
33
- "author": "Weaverse Team",
34
- "dependencies": {
35
- "@weaverse/core": "2.5.0"
39
+ "dependencies" : {
40
+ "@weaverse/core" : "2.6.0"
36
41
  }
37
42
  }
package/readme.md ADDED
@@ -0,0 +1,83 @@
1
+ # @weaverse/react
2
+
3
+ ## Overview
4
+
5
+ `@weaverse/react` is a specialized package in the Weaverse ecosystem, designed specifically for React applications. It
6
+ provides React components and mechanisms to render content from Weaverse CMS data. This package builds upon the core
7
+ functionalities of `@weaverse/core`, enabling easy integration of Weaverse content into React projects.
8
+
9
+ ## Features
10
+
11
+ - React components compatible with Weaverse CMS data.
12
+ - Initialization of Weaverse Core instances tailored for React.
13
+ - `WeaverseRoot` component for rendering within the Weaverse context.
14
+ - Mechanism to register React components for use with Weaverse CMS.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @weaverse/react
20
+ ```
21
+
22
+ ## Initialization and Component Registration
23
+
24
+ First, initialize a Weaverse Core instance with the necessary parameters:
25
+
26
+ ```jsx
27
+ import { Weaverse } from '@weaverse/core';
28
+
29
+ let weaverse = new Weaverse({
30
+ projectId: 'your_project_id',
31
+ data: 'WeaverseProjectDataType' // fetched from Weaverse CMS
32
+ });
33
+ ```
34
+
35
+ Next, register your React components with the Weaverse instance:
36
+
37
+ ```jsx
38
+ weaverse.registerElement({
39
+ type: 'Button',
40
+ Component: ButtonComponent,
41
+ schema: {
42
+ title: 'Button',
43
+ type: 'Button',
44
+ inspector: {
45
+ // define settings inputs for customizing the Component here
46
+ }
47
+ }
48
+ });
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ After initializing and registering elements, use the `WeaverseRoot` component to render your React components within the
54
+ Weaverse context:
55
+
56
+ ```jsx
57
+ import React from 'react';
58
+ import { WeaverseRoot } from '@weaverse/react';
59
+
60
+ function App() {
61
+ // ... your other React component logic
62
+
63
+ return <WeaverseRoot context={weaverse} />;
64
+ }
65
+
66
+ export default App;
67
+ ```
68
+
69
+ ## Best Practices
70
+
71
+ - Initialize the Weaverse instance at your application's root level.
72
+ - Register all necessary React components with the Weaverse instance before rendering.
73
+ - Use the `WeaverseRoot` component to integrate the Weaverse CMS data into your React application effectively.
74
+
75
+ ## Contributing
76
+
77
+ We welcome contributions to the `@weaverse/react` package. For more information on contributing, please refer to our
78
+ guidelines.
79
+
80
+ ## License
81
+
82
+ This project is created by The Weaverse Team ([https://weaverse.io](https://weaverse.io)) and is licensed under the MIT
83
+ License.