@flowscripter/example-host-application 1.0.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.
@@ -0,0 +1,12 @@
1
+ name: check-bun-dependencies
2
+ on:
3
+ workflow_dispatch:
4
+ schedule:
5
+ - cron: "0 0 * * *"
6
+ permissions:
7
+ contents: read
8
+ pull-requests: write
9
+ jobs:
10
+ call-check-bun-dependencies:
11
+ uses: flowscripter/.github/.github/workflows/check-bun-dependencies.yml@v1
12
+ secrets: inherit
@@ -0,0 +1,13 @@
1
+ name: lint-pr-message
2
+ on:
3
+ pull_request_target:
4
+ types:
5
+ - opened
6
+ - edited
7
+ - synchronize
8
+ permissions:
9
+ contents: read
10
+ jobs:
11
+ call-lint-pr-message:
12
+ uses: flowscripter/.github/.github/workflows/lint-pr-message.yml@v1
13
+ secrets: inherit
@@ -0,0 +1,16 @@
1
+ name: release-bun-executable
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ permissions:
6
+ contents: write
7
+ issues: write
8
+ pull-requests: write
9
+ id-token: write
10
+ pages: write
11
+ jobs:
12
+ call-release-bun-executable:
13
+ uses: flowscripter/.github/.github/workflows/release-bun-executable.yml@v1
14
+ secrets: inherit
15
+ with:
16
+ executable-name: "example-host-application"
@@ -0,0 +1,10 @@
1
+ name: validate-bun-executable-pr
2
+ on:
3
+ pull_request:
4
+ branches: [main]
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ call-validate-bun-executable-pr:
9
+ uses: flowscripter/.github/.github/workflows/validate-bun-executable-pr.yml@v1
10
+ secrets: inherit
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Flowscripter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # example-host-application
2
+
3
+ [![version](https://img.shields.io/github/v/release/flowscripter/example-host-application?sort=semver)](https://github.com/flowscripter/example-host-application/releases)
4
+ [![build](https://img.shields.io/github/actions/workflow/status/flowscripter/example-host-application/release-bun-executable.yml)](https://github.com/flowscripter/example-host-application/actions/workflows/release-bun-executable.yml)
5
+ [![coverage](https://codecov.io/gh/flowscripter/example-host-application/branch/main/graph/badge.svg?token=EMFT2938ZF)](https://codecov.io/gh/flowscripter/example-host-application)
6
+ [![docs](https://img.shields.io/badge/docs-API-blue)](https://flowscripter.github.io/example-host-application/index.html)
7
+ [![license: MIT](https://img.shields.io/github/license/flowscripter/example-host-application)](https://github.com/flowscripter/example-host-application/blob/main/LICENSE)
8
+
9
+ > Example host application executable for the
10
+ > [dynamic-plugin-framework](https://github.com/flowscripter/dynamic-plugin-framework)
11
+
12
+ ## Binary Executable Usage
13
+
14
+ **NOTE**: The binaries are 10's of megabytes in size as the entire Bun runtime
15
+ is included.
16
+
17
+ #### MacOS
18
+
19
+ Via [Homebrew](https://brew.sh/):
20
+
21
+ `brew install flowscripter/tap/example-host-application`
22
+
23
+ #### Linux
24
+
25
+ In a terminal:
26
+
27
+ `curl -fsSL https://raw.githubusercontent.com/flowscripter/example-host-application/main/script/install.sh | sh`
28
+
29
+ #### Windows
30
+
31
+ Via [Winget](https://github.com/microsoft/winget-cli):
32
+
33
+ `winget install Flowscripter.example-host-application`
34
+
35
+ #### Manual Install
36
+
37
+ You can download and extract the binary zip files from the
38
+ [releases](https://github.com/flowscripter/example-host-application/releases)
39
+ page.
40
+
41
+ ## Functional Tests
42
+
43
+ Refer to [functional_tests/README.md](functional_tests/README.md)
44
+
45
+ ## Development
46
+
47
+ Install dependencies:
48
+
49
+ `bun install`
50
+
51
+ Test:
52
+
53
+ `bun test`
54
+
55
+ Run:
56
+
57
+ `bun run index.ts`
58
+
59
+ Compile binary:
60
+
61
+ `bun build index.ts --compile --outfile /tmp/example-host-application`
62
+
63
+ **NOTE**: The following tasks use Deno as it excels at these and Bun does not
64
+ currently provide such functionality:
65
+
66
+ Format:
67
+
68
+ `deno fmt`
69
+
70
+ Lint:
71
+
72
+ `deno lint index.ts src/ tests/`
73
+
74
+ Generate HTML API Documentation:
75
+
76
+ `deno doc --html --name=example-host-application index.ts`
77
+
78
+ ## Documentation
79
+
80
+ ### Framework API
81
+
82
+ Refer to the
83
+ [dynamic-plugin-framework](https://github.com/flowscripter/dynamic-plugin-framework)
84
+ for an overview of what this example is demonstrating.
85
+
86
+ ### API
87
+
88
+ Link to auto-generated API docs:
89
+
90
+ [API Documentation](https://flowscripter.github.io/example-host-application/index.html)
91
+
92
+ ## License
93
+
94
+ MIT © Flowscripter
package/bun.lock ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "name": "@flowscripter/example-host-application",
6
+ "dependencies": {
7
+ "@flowscripter/dynamic-plugin-framework": "^1.3.18",
8
+ "@flowscripter/example-plugin-api": "^1.0.8",
9
+ },
10
+ "devDependencies": {
11
+ "@types/bun": "^1.2.10",
12
+ },
13
+ "peerDependencies": {
14
+ "typescript": "^5.8.3",
15
+ },
16
+ },
17
+ },
18
+ "packages": {
19
+ "@flowscripter/dynamic-plugin-framework": ["@flowscripter/dynamic-plugin-framework@1.3.18", "", { "peerDependencies": { "typescript": "^5.8.3" } }, "sha512-OjH8O4MWXU/Wt1so49ef6OnnHlJkHuKKya8zVLR3nkxXhHbR3jHf2VmWl+mOR6liRyN9YN5IyeCvKonnAG6jTQ=="],
20
+
21
+ "@flowscripter/example-plugin-api": ["@flowscripter/example-plugin-api@1.0.8", "", { "peerDependencies": { "typescript": "^5.8.2" } }, "sha512-hRF0DRg+8aKmnAwLDQyA7phjRbET0yD9bBYdny2csL2N5JiV/KLFdfwtJSSSL/LlMdkwtl0VKAVroVc78eWAsw=="],
22
+
23
+ "@types/bun": ["@types/bun@1.2.10", "", { "dependencies": { "bun-types": "1.2.10" } }, "sha512-eilv6WFM3M0c9ztJt7/g80BDusK98z/FrFwseZgT4bXCq2vPhXD4z8R3oddmAn+R/Nmz9vBn4kweJKmGTZj+lg=="],
24
+
25
+ "@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="],
26
+
27
+ "bun-types": ["bun-types@1.2.10", "", { "dependencies": { "@types/node": "*" } }, "sha512-b5ITZMnVdf3m1gMvJHG+gIfeJHiQPJak0f7925Hxu6ZN5VKA8AGy4GZ4lM+Xkn6jtWxg5S3ldWvfmXdvnkp3GQ=="],
28
+
29
+ "typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],
30
+
31
+ "undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
32
+ }
33
+ }
@@ -0,0 +1,23 @@
1
+ ## Executable Functional Tests
2
+
3
+ #### Setup
4
+
5
+ Ensure the executable is built:
6
+
7
+ bun build ../index.ts --compile --outfile /tmp/example-host-application
8
+
9
+ Install requirements:
10
+
11
+ pip3 install -r pip-requirements.txt
12
+
13
+ #### Testing
14
+
15
+ Run the functional tests:
16
+
17
+ export EXECUTABLE=/tmp/example-host-application
18
+ behave
19
+
20
+ To run with logging output from the test steps (this is the best set of
21
+ arguments I can find):
22
+
23
+ behave --no-logcapture --no-color --logging-level=DEBUG
@@ -0,0 +1,9 @@
1
+ import os
2
+
3
+ from support.pexpect_wrapper import PExpectWrapper
4
+
5
+
6
+ def before_scenario(context, scenario):
7
+
8
+ context.config.setup_logging()
9
+ context.pexpect_wrapper = PExpectWrapper(os.environ.get('EXECUTABLE'))
@@ -0,0 +1,7 @@
1
+ Feature: Executable
2
+
3
+ Scenario: Executable success
4
+ When the executable is launched
5
+ Then the executable should complete successfully
6
+ And the executable should have output "Invoking extension"
7
+ And the executable should have output "hello world"
@@ -0,0 +1,18 @@
1
+ from behave import when, then
2
+
3
+
4
+ @when('the executable is launched')
5
+ def step_impl(context):
6
+ context.pexpect_wrapper.start()
7
+
8
+
9
+ @then('the executable should complete successfully')
10
+ def step_impl(context):
11
+ context.pexpect_wrapper.expect_eof()
12
+ status = context.pexpect_wrapper.complete()
13
+ assert status == 0, 'unexpected exit status: {}'.format(status)
14
+
15
+
16
+ @then('the executable should have output "{message}"')
17
+ def step_impl(context, message):
18
+ context.pexpect_wrapper.expect(message)
@@ -0,0 +1,45 @@
1
+ from pexpect.popen_spawn import PopenSpawn
2
+ from pexpect import EOF
3
+ import logging
4
+ log = logging.getLogger("pexpect_wrapper")
5
+
6
+
7
+ class PExpectWrapper:
8
+
9
+ def __init__(self, executable):
10
+ self.executable = executable
11
+ self.child = None
12
+ self.output = None
13
+
14
+ def start(self):
15
+ assert self.child is None
16
+
17
+ self.child = PopenSpawn(self.executable, encoding='utf-8')
18
+
19
+ def expect(self, message):
20
+ assert self.child is not None
21
+
22
+ found = ''
23
+ while len(self.output) > 0:
24
+ next_line = self.output.pop(0)
25
+ log.debug('looking for "{}" in "{}"'.format(message, next_line))
26
+ if message in next_line:
27
+ found = next_line
28
+ break
29
+
30
+ assert found != '', 'expected {} in output'.format(message)
31
+
32
+
33
+ def expect_eof(self):
34
+ assert self.child is not None
35
+
36
+ self.child.expect(EOF)
37
+
38
+ def complete(self):
39
+ assert self.child is not None
40
+
41
+ exit_status = self.child.wait()
42
+
43
+ self.output = self.child.before.split('\n')
44
+
45
+ return exit_status
@@ -0,0 +1,2 @@
1
+ pexpect
2
+ behave
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { exampleHostApplication } from "./src/ExampleHostApplication.ts";
2
+
3
+ await exampleHostApplication();
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@flowscripter/example-host-application",
3
+ "homepage": "https://github.com/flowscripter/example-host-application#readme",
4
+ "description": "Example host application for the https://github.com/flowscripter/dynamic-plugin-framework",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/flowscripter/example-host-application.git"
8
+ },
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "bun",
12
+ "example",
13
+ "plugin",
14
+ "framework",
15
+ "dynamic",
16
+ "import",
17
+ "executable",
18
+ "cli"
19
+ ],
20
+ "module": "index.ts",
21
+ "type": "module",
22
+ "version": "1.0.0",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "devDependencies": {
27
+ "@types/bun": "^1.2.10"
28
+ },
29
+ "peerDependencies": {
30
+ "typescript": "^5.8.3"
31
+ },
32
+ "dependencies": {
33
+ "@flowscripter/dynamic-plugin-framework": "^1.3.18",
34
+ "@flowscripter/example-plugin-api": "^1.0.8"
35
+ }
36
+ }
@@ -0,0 +1,25 @@
1
+ #!/bin/sh
2
+
3
+ set -e # Exit on error
4
+
5
+ # Define the download URL
6
+ URL="https://github.com/flowscripter/example-host-application/releases/latest/download/example-host-application_Linux_x86_64.zip"
7
+
8
+ # Create a temporary directory
9
+ TMP_DIR=$(mktemp -d)
10
+ cd "$TMP_DIR"
11
+
12
+ # Download and extract
13
+ echo "Downloading example-host-application..."
14
+ curl -fsSL "$URL" -o executable.zip
15
+ unzip executable.zip
16
+
17
+ # Install
18
+ chmod +x example-host-application
19
+ sudo mv example-host-application /usr/local/bin/
20
+
21
+ # Clean up
22
+ cd -
23
+ rm -rf "$TMP_DIR"
24
+
25
+ echo "✅ Installation complete! Run 'example-host-application' to get started."
@@ -0,0 +1,75 @@
1
+ import {
2
+ EXTENSION_POINT_1,
3
+ type ExtensionPoint1,
4
+ } from "@flowscripter/example-plugin-api";
5
+ import {
6
+ DefaultPluginManager,
7
+ type ExtensionInfo,
8
+ UrlListPluginRepository,
9
+ } from "@flowscripter/dynamic-plugin-framework";
10
+
11
+ /**
12
+ * Searches for an extension, instantiates it and invokes it.
13
+ */
14
+ export async function exampleHostApplication(): Promise<void> {
15
+ const pluginRepository = new UrlListPluginRepository(
16
+ new Set([
17
+ {
18
+ url: "https://unpkg.com/@flowscripter/example-plugin/dist/bundle.js",
19
+ extensionPoints: [EXTENSION_POINT_1],
20
+ },
21
+ ]),
22
+ );
23
+
24
+ const pluginManager = new DefaultPluginManager([pluginRepository]);
25
+
26
+ console.info(
27
+ `Registering extensions for ${EXTENSION_POINT_1} extension point`,
28
+ );
29
+
30
+ await pluginManager.registerExtensions(EXTENSION_POINT_1);
31
+
32
+ console.info("Registered extensions:");
33
+
34
+ const extensionInfos = await pluginManager.getRegisteredExtensions(
35
+ EXTENSION_POINT_1,
36
+ );
37
+
38
+ extensionInfos.forEach((extensionInfo: ExtensionInfo) => {
39
+ let extensionInfoString =
40
+ `extensionHandle: ${extensionInfo.extensionHandle}\n`;
41
+
42
+ if (extensionInfo.extensionData) {
43
+ extensionInfoString += `extensionData:\n`;
44
+ for (const entry of extensionInfo.extensionData.entries()) {
45
+ extensionInfoString += `\t${entry[0]} => ${entry[1]}\n`;
46
+ }
47
+ }
48
+ if (extensionInfo.pluginData) {
49
+ extensionInfoString += `pluginData:\n`;
50
+ for (const entry of extensionInfo.pluginData.entries()) {
51
+ extensionInfoString += `\t${entry[0]} => ${entry[1]}\n`;
52
+ }
53
+ }
54
+
55
+ console.info(extensionInfoString);
56
+ });
57
+
58
+ if (extensionInfos.length > 0) {
59
+ console.info("Instantiating first extension");
60
+
61
+ const extension = await pluginManager.instantiate(
62
+ extensionInfos[0].extensionHandle,
63
+ new Map([[
64
+ "host_foo",
65
+ "host_bar",
66
+ ]]),
67
+ ) as ExtensionPoint1;
68
+
69
+ console.info("Invoking extension");
70
+
71
+ extension.sayHello();
72
+ } else {
73
+ throw new Error("No extensions found");
74
+ }
75
+ }
@@ -0,0 +1,8 @@
1
+ import { describe, test } from "bun:test";
2
+ import { exampleHostApplication } from "../src/ExampleHostApplication.ts";
3
+
4
+ describe("ExampleHostApplication Tests", () => {
5
+ test("Invoke example host application", async () => {
6
+ await exampleHostApplication();
7
+ });
8
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }