-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve developer documentation #34
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c7d9c72
add "embedding a fragment" sample
WanjaTschuorSICKAG e95b745
add some documentation for the internal collage library concepts
WanjaTschuorSICKAG 5b8e1fc
define type for randomUuid more narrow
WanjaTschuorSICKAG 09d516c
add some more developer documentation for the core concepts
WanjaTschuorSICKAG 0a7aadd
add developer documentation for core concepts
WanjaTschuorSICKAG fe427d2
rename README.md files intended for developer documentation to more s…
WanjaTschuorSICKAG 5705ffa
Revert "define type for randomUuid more narrow"
WanjaTschuorSICKAG 8c9c7ef
add developer documentation
WanjaTschuorSICKAG df37186
link documentation files of core concepts in CORE_CONCEPTS.md
WanjaTschuorSICKAG 6d1b5da
add tsdoc for direct functions plugin
WanjaTschuorSICKAG 81c3f65
add more documention about the handshake plugin
WanjaTschuorSICKAG 1a889f2
fix typos
WanjaTschuorSICKAG 764650f
fix typo in messages.sendMessage definition
WanjaTschuorSICKAG 55c28fe
small changes at the user documentation
WanjaTschuorSICKAG afa4379
Fix typos
kirchsuSICKAG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Developer Documentation | ||
|
||
Before starting to develop collage, please read the documentation about the collage [features](../docs/docs/features.md), [core concepts](../docs/docs/concepts.md) and [core api](../docs/docs/core-api.md). | ||
|
||
## Getting started | ||
|
||
```bash | ||
git clone https://github.com/SICKAG/collage.git | ||
cd collage | ||
npm install | ||
``` | ||
|
||
Now you are ready for developing | ||
|
||
### Start the dev server | ||
|
||
You can start the dev server by running | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
This will start a dev server. You then can view and debug the example and integration tests defined in the sample folders of the plugins (src/core/) | ||
|
||
### Running the tests | ||
|
||
You can (and should) keep the unit test running in watch mode while developing | ||
|
||
```bash | ||
npm run test:watch | ||
``` | ||
|
||
> Hint: you can keep the dev server and and the unit test running at the same time | ||
|
||
## What we are building upon: | ||
|
||
- typescript (see [typescript](https://www.typescriptlang.org/) and [tsconfig.json](../tsconfig.json)) | ||
- vite for serving our examples and integration tests and bundling the library (see [vite](https://vitejs.dev) and [vite.config.js](../vite.config.js)) | ||
- jest for unit tests (see [jest](https://jestjs.io) and [jest.config.js](../jest.config.js)) | ||
- vuepress for building our user documentation (see [vuepress](https://vuepress) and [vuepress-config.mjs](../docs/vuepress-config.mjs)) | ||
- github actions for ci/cd | ||
- penpal for the communication between fragments and arrangements (see [penpal](https://github.com/Aaronius/penpal#readme)) | ||
|
||
## Structure of the Repository | ||
|
||
The structure of the repository is as follows. | ||
In each folder, you will find a documenting markdown file explaining the details of the respective part. | ||
|
||
```md | ||
collage/ | ||
|-- .github/ // github actions configurations | ||
|-- docs/ // user documentation built with vuepress | ||
|-- e2e/ // our e2e tests | ||
|-- src/ // source code | ||
| |-- core/ // core concepts of collage implemented as collage plugins | ||
| |-- elements/ // custom elements for a convenient usage of collage | ||
| |-- lib/ // internal library structure of collage | ||
| | |-- api/ // collage api | ||
|
||
``` | ||
|
||
- [core](./core/CORE_CONCEPTS.md) | ||
- [elements](./elements/README.md) | ||
- [lib](./lib/README.md) | ||
|
||
## Architecture | ||
|
||
Collage is build as a plugin library. Each basic feature is defined as a plugin. All default plugins are configured and bootstrapped together. | ||
|
||
How this is done, you can read in the documentation about the [internal structure of the collage library](./lib/README.md). | ||
|
||
In short: | ||
|
||
- all types, and everything needed to put collage and the plugins together can be found in lib. | ||
- everything that implements functionality for the user is a plugin and can be found in core. | ||
|
||
## Contributing | ||
|
||
Every contribution is welcome, as we want to make collage a vivid community project. | ||
|
||
At the moment we lack a system to enable plug ins dynamically, so each plugin must be built and bundled with the library. We are evaluating to change that in the future, so everybody could add functionality to collage. | ||
|
||
### Creating a new plugin/feature | ||
|
||
#### Workflow | ||
|
||
1. create the plugin | ||
1. create a new folder in the src/core directory | ||
1. create a plugin file as ts (orient at the core plugins) | ||
1. create a samples folder for integration testing examples | ||
1. create tests | ||
1. create e2e test for the new feature | ||
1. create unit tests in the plugin folder | ||
1. create documentation | ||
1. create a documentation file as md if necessary | ||
1. add the plugin to collage | ||
1. import the plugin | ||
1. add to the plugins array | ||
|
||
#### How a plugin is made | ||
|
||
With a plugin, you are able to enhance collage by new features. | ||
For an example of a minimal plugin, please have a look at the [create-context](./core/create-context/create-context.ts). | ||
|
||
In short, a valid plugin needs to export the default function `plugin` where it can pass an object, that uses the PluginFunctions to enhance collage by the new features (see [src/types.ts>PluginFunctions](./types.ts) and [collage-plugin](./lib/collage-plugin.ts)). | ||
|
||
```ts | ||
import plugin from '../../lib/collage-plugin'; | ||
|
||
export default plugin({ | ||
enhanceExpose: async () => { | ||
console.log('I send a message everytime expose() is called'); | ||
}, | ||
}); | ||
``` | ||
|
||
## Core Concepts | ||
|
||
Read further in the [Core Concepts Documentation](./core/CORE_CONCEPTS.md) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Core Concepts | ||
|
||
The core concepts and their implementations as plugins build upon each other and each enhance collage by their specific features. | ||
|
||
1. The [collage-fragment](../elements/README.md) custom element. | ||
1. The [create-context](./create-context/CREATE_CONTEXT.md) plugin | ||
1. The [handshake](./handshake-plugin/HANDSHAKE.md) plugin | ||
1. The [direct functions](./direct-functions-plugin/DIRECT_FUNCTIONS.md) plugin | ||
1. The [services](./services-plugin/SERVICES.md) plugin | ||
1. The [topics](./topics-plugin/TOPICS.md) plugin | ||
|
||
### Notes | ||
|
||
How the connection between arrangement and fragment works: | ||
|
||
The connection is mediated by the custom element, since that is the point where we are in the parents code context but acually know about a specific child to connect. | ||
|
||
A successful connection then enhances the fragments context with methods from the arrangement. | ||
|
||
## Create Context | ||
The most basic concept in collage is that of a context. At it's base a context is simply the representation of a uniquly identified fragment and the connection to a potential parent. | ||
|
||
For a more detailled description of the handshake, see [Create Context plugin documentation](./create-context/CREATE_CONTEXT.md). | ||
|
||
|
||
## Handshake | ||
To set up the communication between a fragment and an arrangement, collage performs a handshake between them. | ||
|
||
For a more detailled description of the handshake, see [Handshake plugin documentation](./handshake-plugin/HANDSHAKE.md). | ||
|
||
## Service Functions | ||
Services are functions, an arrangement can provide to all the fragments (and their fragments). | ||
|
||
For a more detailled description of the service functions, see [Services plugin documentation](./services-plugin/SERVICES.md). | ||
|
||
## Direct Functions | ||
Direct Functions can be called on a fragment directly by its arrangement | ||
|
||
For a more detailled description of direct functions, see [Direct Functions plugin documentation](./direct-functions-plugin/DIRECT_FUNCTIONS.md). | ||
|
||
## Topics | ||
The Topics feature allows an easy way to subscribe to topics and publish new values to topics. | ||
|
||
For a more detailled description of the topics plugin, see [Topics plugin documentation](./topics-plugin/TOPICS.md). | ||
|
||
## Config | ||
With configurations an arrangement gets the possibility to configure an embedded fragment and overwrite the default configuration of it. | ||
|
||
For a more detailled description of the config plugin, see [Config plugin documentation](./config-plugin/CONFIG_PLUGIN.md). | ||
|
||
|
||
## Finalize Api | ||
|
||
The last module to be performed will trim the resulting context api to the fields that we intend a client to use. | ||
|
||
Any internal state that may have been needed to communicate between plugin modules should not be visible in client context. | ||
|
||
|
||
|
||
## Fragment <-> Arrangement | ||
|
||
**In the fragment** | ||
|
||
1. collect stuff for my children | ||
2. collect my exposed functions (child functions) | ||
3. simple beacon request --> get simple beacon answer? | ||
4. `connectToParent` with my functions -> gain parent services | ||
5. add parent stuff to context | ||
6. send `collage-initialized` event | ||
7. all my fragments will initialize iframes | ||
1. create iframe | ||
2. send _what is your id?_ as post message | ||
3. await answer | ||
4. if answer: `connectToChild` | ||
|
||
**In the arrangement** | ||
|
||
1. setup a beacon | ||
2. When a question arrives -> check if we have a matching fragment element (id) | ||
3. initiate `connectToChild` with the iframe in that element | ||
4. send response | ||
|
||
```javascript | ||
const definition = { | ||
services: {}, | ||
topics: {}, | ||
configuration: {}, | ||
functions: {}, | ||
} | ||
|
||
const context = await expose(description) | ||
|
||
const arrangementContext = connectToArrangement(description, context) | ||
|
||
const combined = combineContexts(context, arrangementContext) | ||
|
||
createBeacon(combined, (question) => { | ||
if (findFragmentInDOM(question)) { | ||
connectToChild() | ||
sendAnswer() | ||
} | ||
}) | ||
|
||
return combined | ||
``` | ||
|
||
```html | ||
<collage-fragment context-id="1234-12344-1234"> | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "acually"