Coder Social home page Coder Social logo

c3-framework-core's Introduction

Construct 3 Framework

This repo contains the Alfred Botler CLI and TypeScript utilities needed for the Construct 3 Framework.

Since the framework is customizable you can install this package by yourself and setup things manually but using the previously mentioned template is highly encourage.

Installation

You can install this package through NPM using this repo URL:

npm install https://github.com/MasterPose/c3-framework

Structure

A normal structure for a project would look something like this:

/dist
/examples
├── example.c3p
└── example.png
/export
/src
├── /lang
│   ├── de-DE.json
│   └── es-MX.json
├── /libs
│   ├── mylib.ts
│   └── style.css
├── addon.ts
├── editor.ts
├── icon.svg
├── instance.ts
└── runtime.ts
c3.config.js
tsconfig.json

All the paths are customizable creating a c3.config.js on the root of the project.

You can check the template for more information.

Usage

Commands

You can run the following to see all the available commands:

npx alfred

You can build your project using:

npm run build

You can run a development server using:

npx alfred build --dev

You can generate documentation using:

npx alfred doc

Defining ACEs

The C3 Framework offers a coupled workflow for defining ACEs. You define the configuration of your ACEs by marking your code using TypeScript decorators.

To start you must tell to Alfred on what classes your ACEs will be defined, by using the @AceClass decorator. After that, you can start coding your logic in a natural way, marking functions and parameters with their respective decorators, and using the C3 types (such as combo, cmp, eventvar, etc.) automatically loaded from the framework:

import { AceClass, Behavior, Condition, Param } from "c3-framework";
import Config from "./addon";

const opts = [
  'test',
  'something',
  'another',
];

@AceClass()
class Instance extends Behavior.Instance(Config) {
  constructor() {
    super();
  }

  @Condition('Is Enabled')
  isEnabled() {
    return true;
  }

  @Condition('Is "{0}" Something')
  isSomething(
    @Param({
      items: [
        { test: 'Test' },
        { something: 'Something' },
        { another: 'Another' },
      ],
    })
    tag: combo // Notice that the Construct types are available to use on TypeScript
    // tag: Cnd.combo // You can also access them through the `Cnd` or `Act` namespaces
  ) {
    return opts[tag] == 'something';
  }
}

export default Instance;

Default build config

This is the default c3.config.js configuration loaded:

/** @type {import("c3-framework").BuildConfig} */
export default {
    minify: true,
    host: 'http://localhost',
    port: 3000,
    sourcePath: 'src/',
    runtimeScript: 'runtime.ts',
    addonScript: 'addon.ts',
    exportPath: 'export/',
    distPath: 'dist/',
    libPath: 'src/libs',
    langPath: 'src/lang',
    defPath: 'src/',
    examplesPath: 'examples/',
    defaultLang: 'en-US',
}

Credits

Thanks to Skymen and the ConstructFund for the efforts on making the C3IDE2, project that originated this framework.

c3-framework-core's People

Contributors

luanhimmlisch avatar

Forkers

armandoalonso

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.