All Projects β†’ LinkedSoftwareDependencies β†’ Components.js

LinkedSoftwareDependencies / Components.js

Licence: other
🧩 A semantic dependency injection framework

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Components.js

Deli
Deli is an easy-to-use Dependency Injection(DI).
Stars: ✭ 125 (+267.65%)
Mutual labels:  dependency-injection, inversion-of-control
Typedi
Simple yet powerful dependency injection tool for JavaScript and TypeScript.
Stars: ✭ 2,832 (+8229.41%)
Mutual labels:  dependency-injection, inversion-of-control
React Ioc
Hierarchical Dependency Injection with new React 16 Context API
Stars: ✭ 133 (+291.18%)
Mutual labels:  dependency-injection, inversion-of-control
Factory
Factory for object creation and dependency injection. Works with normal C# apps or under Unity3d
Stars: ✭ 50 (+47.06%)
Mutual labels:  dependency-injection, inversion-of-control
stashbox
A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
Stars: ✭ 120 (+252.94%)
Mutual labels:  dependency-injection, inversion-of-control
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (+85.29%)
Mutual labels:  dependency-injection, inversion-of-control
Ioc
πŸ¦„ lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (+402.94%)
Mutual labels:  dependency-injection, inversion-of-control
Swinject
Dependency injection framework for Swift with iOS/macOS/Linux
Stars: ✭ 4,958 (+14482.35%)
Mutual labels:  dependency-injection, inversion-of-control
awilix-express
Awilix helpers/middleware for Express
Stars: ✭ 100 (+194.12%)
Mutual labels:  dependency-injection, inversion-of-control
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+7873.53%)
Mutual labels:  dependency-injection, inversion-of-control
Picobox
Dependency injection framework designed with Python in mind.
Stars: ✭ 35 (+2.94%)
Mutual labels:  dependency-injection, inversion-of-control
vesselize
β›΅ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-35.29%)
Mutual labels:  dependency-injection, inversion-of-control
Go Spring
基于 IoC ηš„ Go εŽη«―δΈ€η«™εΌεΌ€ε‘ζ‘†ζžΆ πŸš€
Stars: ✭ 744 (+2088.24%)
Mutual labels:  dependency-injection, inversion-of-control
Container Ioc
Inversion of Control container & Dependency Injection for Javascript and Node.js apps powered by Typescript.
Stars: ✭ 89 (+161.76%)
Mutual labels:  dependency-injection, inversion-of-control
Dryioc
DryIoc is fast, small, full-featured IoC Container for .NET
Stars: ✭ 555 (+1532.35%)
Mutual labels:  dependency-injection, inversion-of-control
Qframework
Unity3D System Design Architecture
Stars: ✭ 2,326 (+6741.18%)
Mutual labels:  dependency-injection, inversion-of-control
Ditranquillity
Dependency injection for iOS (Swift)
Stars: ✭ 317 (+832.35%)
Mutual labels:  dependency-injection, inversion-of-control
Inversify Express Utils
Some utilities for the development of Express application with InversifyJS
Stars: ✭ 454 (+1235.29%)
Mutual labels:  dependency-injection, inversion-of-control
Inversify Express Example
The official express + inversify+ inversify-express-utils examples
Stars: ✭ 210 (+517.65%)
Mutual labels:  dependency-injection, inversion-of-control
waiter
Dependency injection, Inversion of control container for rust with compile time binding.
Stars: ✭ 71 (+108.82%)
Mutual labels:  dependency-injection, inversion-of-control

Components.js

A semantic dependency injection framework

Build status Coverage Status npm version DOI

This repository contains the source code of Components.js. Full documentation on its usage can be found at http://componentsjs.readthedocs.io/.

Interested in contributing to this project? Have a look at this contribution guide.

Introduction

Components.js is a dependency injection framework for TypeScript and JavaScript projects using JSON(-LD) files.

Instead of hard-wiring software components together, Components.js allows these components to be instantiated and wired together declaratively using semantic configuration files. The advantage of these semantic configuration files is that software components can be uniquely and globally identified using URIs.

Configurations can be written in any RDF serialization, such as JSON-LD.

This software is aimed for developers who want to build modular and easily configurable and rewireable JavaScript applications.

Get started with the TypeScript or JavaScript quick start guide below!

Quick Start (TypeScript)

1. Install dependencies

Components.js can be installed using npm:

$ npm install componentsjs

Component and module files can be automatically generated using Components-Generator.js:

$ npm install -D componentsjs-generator

2. Mark your package as a Components.js module

package.json:

{
  "name": "my-package",
  "version": "2.3.4",
  "lsd:module": true,
  ...
  "scripts": {
    ...
    "build": "npm run build:ts && npm run build:components",
    "build:ts": "tsc",
    "build:components": "componentsjs-generator",
    "prepare": "npm run build",
    ...
  }
}

"lsd:module" will allow Components.js to find your module(s) when they are included from other packages.

The "scripts" entry will make sure that all required component files will be generated when building your package.

3. Create a configuration file to instantiate our class

Assuming a TypeScript class that is exported from the package:

export class MyClass {
  public readonly name: string;
  constructor(name: string) {
    this.name = name;  
  }
}

config.jsonld:

{
  "@context": [
    "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
    "https://linkedsoftwaredependencies.org/bundles/npm/my-package/^2.0.0/components/context.jsonld"
  ],
  "@id": "urn:my-package:myInstance",
  "@type": "MyClass",
  "name": "John"
}

This configuration is a semantic representation of the instantiation of MyClass with name set to "John".

4. Instantiate from config file

...
import { ComponentsManager } from 'componentsjs';

const manager = await ComponentsManager.build({
  mainModulePath: __dirname, // Path to your npm package's root
});
await manager.configRegistry.register('config.jsonld');
const myInstance = await manager.instantiate('urn:my-package:myInstance');
...

myInstance is an instance of type MyClass, as defined in the config file.

Quick Start (JavaScript)

1. Install dependencies

Components.js can be installed using npm:

$ npm install componentsjs

2. Define your module and its components

Assuming a JavaScript class that is exported from the package:

export class MyClass {
  public readonly name;
  constructor(name) {
    this.name = name;  
  }
}

module.jsonld:

{
  "@context": [
    "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
    { "ex": "http://example.org/" }
  ],
  "@id": "ex:MyPackage",
  "@type": "Module",
  "requireName": "my-package",
  "components": [
    {
      "@id": "ex:MyPackage/MyClass",
      "@type": "Class",
      "requireElement": "MyClass",
      "parameters": [
        { "@id": "ex:MyPackage/MyClass#name", "unique": true }
      ],
      "constructorArguments": [
        { "@id": "ex:MyPackage/MyClass#name" }
      ]
    }
  ]
}

The npm module my-package exports a class with the name MyClass.

The constructor of MyClass takes a single name argument.

3. Create a configuration file to instantiate our class

config.jsonld:

{
  "@context": [
    "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
    {
      "ex": "http://example.org/",
      "name": "ex:MyPackage/MyClass#name"
    }
  ],
  "@id": "http://example.org/myInstance",
  "@type": "ex:MyPackage/MyClass",
  "name": "John"
}

This configuration is a semantic representation of the instantiation of MyClass with name set to "John".

4. Instantiate from config file

...
import { ComponentsManager } from 'componentsjs';

const manager = await ComponentsManager.build({
  mainModulePath: __dirname, // Path to your npm package's root
});
await manager.configRegistry.register('config.jsonld');
const myInstance = await manager.instantiate('http://example.org/myInstance');
...

myInstance is an instance of type MyClass, as defined in the config file.

Advanced usage

The ComponentsManager can be customized with the following options:

const manager = await ComponentsManager.build({
    // Absolute path to the package root from which module resolution should start.
    mainModulePath: __dirname,
    // Callback for registering components and modules
    // Defaults to an invocation of {@link ComponentRegistry.registerAvailableModules}.
    moduleLoader: (registry) => {},
    // Callback for registering configurations.
    // Defaults to no config registrations.
    configLoader: (registry) => {},
    // A strategy for constructing instances.
    // Defaults to {@link ConstructionStrategyCommonJs}.
    constructionStrategy: new ConstructionStrategyCommonJs(),
    // If the error state should be dumped into `componentsjs-error-state.json` after failed instantiations.
    // Defaults to `true`.
    dumpErrorState: true,
    // The logging level.
    // Defaults to `'warn'`.
    logLevel: 'warn',
    // The module state.
    // Defaults to a newly created instance on the {@link mainModulePath}.
    moduleState: {},
    // If JSON-LD context validation should be skipped.
    // Defaults to `true`.
    skipContextValidation: true,
    // If values for parameters should be type-checked.
    // Defaults to `true`.
    typeChecking: true,
});

Cite

If you are using or extending Components.js as part of a scientific publication, we would appreciate a citation of our article.

@article{taelman_swj_componentsjs_2022,
  author = {Taelman, Ruben and Van Herwegen, Joachim and Vander Sande, Miel and Verborgh, Ruben},
  title = {Components.js: Semantic Dependency Injection},
  journal = {Semantic Web Journal},
  year = {2022},
  month = jan,
  url = {https://linkedsoftwaredependencies.github.io/Article-System-Components/}
}

License

Components.js is written by Ruben Taelman.

This code is copyrighted by Ghent University – imec and released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].