项目作者: croquet

项目描述 :
Application framework for real time collaboration using Croquet
高级语言: JavaScript
项目地址: git://github.com/croquet/virtual-dom.git
创建时间: 2020-11-21T01:01:06Z
项目社区:https://github.com/croquet/virtual-dom

开源协议:Other

下载


Croquet Virtual DOM

last modified on 2021-10-26, or Oct 26th, 2021

Introduction

Croquet Virtual DOM is an application framework that helps to develop an application based on the Document Object Model and real time collaboration over the Croquet library.

For basic concepts and examples, please refer to docs/en/vdom.md.html.

Installation

There is exactly one external dependency, which is the Croquet Client library. You can simply copy that library to your local directory:

  1. # mkdir -p croquet; curl -L -o croquet/croquet-latest.min.js https://unpkg.com/@croquet/croquet@1.0.5

The -L option specifies to follow redirection. You may copy the file from https://unpkg.com/@croquet/croquet@1.0.5/pub/croquet.min.js.

You can also change the script tag of your html file to refer to the latest code at https://unpkg.com/@croquet/croquet. The advantage of copying the file to a local directory is that you can develop your application off the internet.

For those example applications to run, you need to obtain the API key from croquet.io/keys. Once you create an API key, replace "<put your apiKey from croquet.io/keys>" line in apiKey.js with it.

An application can be developed without using npm or additional package manager. You can run the simple http server (written in JavaScript):

  1. # node server.js &

and point your browser to an example such as localhost:8000/apps/text-chat.html. There is an equivalent server written in Python (server.py), for those who don’t install Node.js but has Python.

Alternatively, you can specify @croquet/croquet as dependency in package.json and use a bundler. Howeever, the expander code requires the class and method names are retained. Refer to the Deployment section below for more information.

Deployment

When you prefer to create a minified and simplified deployment, you can roll up some files. Add devDependencies to your package.json:

  1. "devDependencies": {
  2. "@babel/core": "^7.9.0",
  3. "rollup": "^2.17.0",
  4. "rollup-plugin-babel": "^4.4.0",
  5. "rollup-plugin-terser": "^5.2.0"
  6. }

run npm install, and run something the following to make a distributable set of minified files in a directory called dist.

  1. mkdir -p dist/examples
  2. mkdir -p dist/src
  3. mkdir -p dist/widgets
  4. cp examples/<your example.js> dist/examples/
  5. npx rollup src/croquet-virtual-dom.js --config rollup.config.js --file dist/src/croquet-virtual-dom.js --format es
  6. npx rollup widgets/widgets.js --config rollup.config.js --file dist/widgets/widgets.js --format es
  7. cp croquet/croquet-latest.min.js dist/croquet/croquet-latest.min.js

Alternative Deployment Scheme

Lately, many apps that use the Croquet Virtual DOM Framework have its own directory. All they need is to load the croquet library and croquet-virtual-dom.js from unpkg.com. Please refer to the @croquet/virtual-dom">description on npmjs.com.