Skip to content
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

Support embedding nodejs into any TEN app #543

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8b590d5
refactor: refine tman install (#513)
halajohn Jan 6, 2025
b8cb884
refactor: refine tman install (#514)
halajohn Jan 6, 2025
857e92d
chore: add more test cases for local dependency (#515)
halajohn Jan 6, 2025
eee1896
feat: add support for local dependency in extension (#516)
halajohn Jan 7, 2025
de6c849
chore: add more code comments
halajohn Jan 7, 2025
575e6f5
chore: refine some codes
halajohn Jan 7, 2025
47bd3cc
fix: fix designer UI embedding
halajohn Jan 7, 2025
03d91e7
feat: support C/D/A/V connections and nodes info (#519)
shczhen Jan 7, 2025
1b77a51
chore: update dependency of tman designer UI
halajohn Jan 7, 2025
13e18b3
fix: avoid native addon loader files to trigger other addon loadres t…
halajohn Jan 7, 2025
bc721ae
chore: add cancel workflow on PR merge yml
halajohn Jan 7, 2025
17367f0
chore: update version number
halajohn Jan 7, 2025
cec5aea
feat: i18n update (#521)
shczhen Jan 7, 2025
aacb019
chore: update github action yml
halajohn Jan 7, 2025
db3eee5
chore: remove ubuntu 18.04 support
halajohn Jan 7, 2025
204a11e
feat: allow the start graph action to return a failure error (#522)
halajohn Jan 8, 2025
79c5c55
feat: allow the start graph action to return a failure error (#523)
halajohn Jan 8, 2025
b981216
doc: fix create extension command (#526)
plutoless Jan 8, 2025
0e3e232
fix: make sure on_deinit of addon_loader be called before destroyed (…
sunxilin Jan 8, 2025
1f81cde
feat: allow the start graph action to return a failure error (#527)
halajohn Jan 8, 2025
52d3258
feat: add websocket server nodejs extension which depends on third-pa…
sunxilin Jan 8, 2025
d8c4ffa
chore: remove unused C header files in C source file
halajohn Jan 9, 2025
e43cd9f
feat: add more test cases of failing to start graph (#529)
halajohn Jan 9, 2025
d1c1445
feat: add doc support for story teller (#528)
plutoless Jan 9, 2025
5216bec
chore: refine test case name
halajohn Jan 9, 2025
b7eb3ab
feat: gracefully exit the app if auto start predefined_graph fail to …
halajohn Jan 9, 2025
37429a7
feat: create build_node_shared.yml (#531)
sunxilin Jan 9, 2025
0349047
fix: modify workflow yml (#533)
sunxilin Jan 9, 2025
fce8599
feat: enable extensions in different threads can receive msgs when on…
halajohn Jan 9, 2025
542cff4
fix: fix tman designer terminal function
halajohn Jan 9, 2025
016a82a
fix: support calling ten_env_tester api on outer thread in python (#536)
sunxilin Jan 9, 2025
c5654c3
Update overview.md (#539)
nitte93 Jan 10, 2025
e73dcfb
feat: add get base_dir support in tman designer (#540)
halajohn Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .github/tools/setup_pytest_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ def setup():
"python-dotenv",
]
)
utils.run_cmd_with_retry(
[
sys.executable,
"-m",
"pip",
"install",
"websocket-client",
]
)


if __name__ == "__main__":
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
- image_name: "ubuntu2204"
workdir: "tools/docker_for_building/ubuntu/22.04"
platforms: linux/amd64,linux/arm64
- image_name: "ubuntu1804"
workdir: "tools/docker_for_building/ubuntu/18.04"
platforms: linux/amd64
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
122 changes: 0 additions & 122 deletions .github/workflows/build_linux_ubuntu1804.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/build_node_shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Node.js Shared Library

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/build_node_shared.yml'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
container:
image: ghcr.io/ten-framework/ten_building_ubuntu2204
steps:
- name: Checkout Node.js
uses: actions/checkout@v4
with:
repository: nodejs/node
ref: v22.12.0

- name: Configure and Build
run: |
if [ "$compiler" == "gcc" ]; then
export CC=gcc
export CXX=g++
else
export CC=clang
export CXX=clang++
fi

./configure --shared
make -j$(nproc)
46 changes: 46 additions & 0 deletions .github/workflows/cancel_on_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Cancel Workflows on PR Merge

on:
pull_request:
types: [closed]

jobs:
cancel_workflows:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Cancel Related Workflow Runs
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
const headSha = context.payload.pull_request.head.sha;

console.log(`Cancelling workflows related to PR #${prNumber} (SHA: ${headSha})`);

// Retrieve all workflow runs associated with the head SHA of the PR.
const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner,
repo,
head_sha: headSha,
status: 'in_progress',
});

if (runs.data.workflow_runs.length === 0) {
console.log('No workflow runs found to cancel.');
return;
}

// Cancel all related workflow runs.
for (const run of runs.data.workflow_runs) {
console.log(`Cancel workflow run: ${run.id} (${run.name})`);
await github.rest.actions.cancelWorkflowRun({
owner,
repo,
run_id: run.id,
});
}

console.log('All related workflow runs have been canceled.');
20 changes: 14 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/standalone/ten_runtime_smoke_test",
"args": [
"--gtest_filter=AudioFrameTest.FromJson"
"--gtest_filter=ExtensionTest.ExtensionSendMsgToIncorrectEngine"
],
"cwd": "${workspaceFolder}/out/linux/x64/tests/standalone/",
"env": {
Expand Down Expand Up @@ -392,6 +392,10 @@
"args": [
"--config-file=${workspaceFolder}/out/linux/x64/tests/local_registry/config.json",
"install",
"extension",
"ext_a",
"--os=linux",
"--arch=x64"
],
"preRunCommands": [
"script import pathlib;import subprocess;import lldb;rustc_sysroot = subprocess.getoutput(\"rustc --print sysroot\");rustlib_etc = pathlib.Path(rustc_sysroot) / \"lib\" / \"rustlib\" / \"etc\";lldb.debugger.HandleCommand(f'command script import \"{rustlib_etc / \"lldb_lookup.py\"}\"');lldb.debugger.HandleCommand(f'command source -s 0 \"{rustlib_etc / \"lldb_commands\"}\"')"
Expand All @@ -416,7 +420,7 @@
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/core/src/ten_manager/target/x86_64-unknown-linux-gnu/debug/tman",
"cwd": "${workspaceFolder}/core/src/ten_manager/target/x86_64-unknown-linux-gnu/debug/",
"cwd": "/home/wei/MyData/MyProject/ten_framework_internal_base/ten_framework/out/linux/x64/tests/ten_runtime/integration/cpp/ffmpeg_basic/ffmpeg_basic_app",
"args": [
"designer",
],
Expand Down Expand Up @@ -669,9 +673,9 @@
"request": "launch",
"program": "node",
"args": [
"${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/http_server_nodejs/http_server_nodejs_app/build/start.js"
"${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/mix_python_ext_nodejs/mix_python_ext_nodejs_app/build/start.js"
],
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/http_server_nodejs/http_server_nodejs_app/",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/mix_python_ext_nodejs/mix_python_ext_nodejs_app/",
"env": {
"LD_PRELOAD": "ten_packages/system/ten_runtime/lib/libasan.so",
"NODE_PATH": "ten_packages/system/ten_runtime_nodejs/lib:$NODE_PATH",
Expand All @@ -685,9 +689,9 @@
"program": "/usr/bin/node",
"args": [
"--expose-gc",
"${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/http_server_nodejs/http_server_nodejs_app/build/start.js"
"${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/mix_python_ext_nodejs/mix_python_ext_nodejs_app/build/start.js"
],
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/http_server_nodejs/http_server_nodejs_app/",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/nodejs/mix_python_ext_nodejs/mix_python_ext_nodejs_app/",
"environment": [
{
"name": "LD_PRELOAD",
Expand All @@ -704,6 +708,10 @@
{
"name": "LSAN_OPTIONS",
"value": "verbosity=1:log_threads=1"
},
{
"name": "TEN_ENABLE_MEMORY_TRACKING",
"value": "true"
}
],
"sourceFileMap": {
Expand Down
5 changes: 5 additions & 0 deletions build/ten_runtime/feature/build_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ def build_nodejs_extensions(app_root_path: str) -> int:
# Change to extension directory.
os.chdir(extension_path)

status = npm_install()
if status != 0:
print(f"Failed to npm install in {extension_path}")
return 1

now = datetime.now()
cmd = ["npm", "run", "build"]
returncode, output = cmd_exec.run_cmd(cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class cmd_stop_graph_t : public cmd_t {
cmd_stop_graph_t &operator=(const cmd_stop_graph_t &cmd) = delete;
cmd_stop_graph_t &operator=(cmd_stop_graph_t &&cmd) = delete;
// @}

std::string get_graph_id(error_t *err = nullptr) const {
return ten_cmd_stop_graph_get_graph_id(c_msg);
}
bool set_graph_id(const char *graph_id, error_t *err = nullptr) {
return ten_cmd_stop_graph_set_graph_id(c_msg, graph_id);
}
};

} // namespace ten
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class extension_tester_t {
: c_extension_tester(::ten_extension_tester_create(
reinterpret_cast<ten_extension_tester_on_start_func_t>(
&proxy_on_start),
nullptr,
reinterpret_cast<ten_extension_tester_on_cmd_func_t>(&proxy_on_cmd),
reinterpret_cast<ten_extension_tester_on_data_func_t>(
&proxy_on_data),
Expand Down
6 changes: 6 additions & 0 deletions core/include/ten_runtime/msg/cmd/stop_graph/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
typedef struct ten_msg_t ten_msg_t;

TEN_RUNTIME_API ten_shared_ptr_t *ten_cmd_stop_graph_create(void);

TEN_RUNTIME_API const char *ten_cmd_stop_graph_get_graph_id(
ten_shared_ptr_t *self);

TEN_RUNTIME_API bool ten_cmd_stop_graph_set_graph_id(ten_shared_ptr_t *self,
const char *graph_id);
3 changes: 3 additions & 0 deletions core/include/ten_runtime/test/env_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ typedef struct ten_env_tester_t ten_env_tester_t;
TEN_RUNTIME_API bool ten_env_tester_on_start_done(ten_env_tester_t *self,
ten_error_t *err);

TEN_RUNTIME_API bool ten_env_tester_on_stop_done(ten_env_tester_t *self,
ten_error_t *err);

typedef void (*ten_env_tester_cmd_result_handler_func_t)(
ten_env_tester_t *self, ten_shared_ptr_t *cmd_result, void *user_data,
ten_error_t *error);
Expand Down
10 changes: 10 additions & 0 deletions core/include/ten_runtime/test/extension_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ typedef enum TEN_EXTENSION_TESTER_TEST_MODE {
typedef void (*ten_extension_tester_on_start_func_t)(
ten_extension_tester_t *self, ten_env_tester_t *ten_env);

typedef void (*ten_extension_tester_on_stop_func_t)(
ten_extension_tester_t *self, ten_env_tester_t *ten_env);

typedef void (*ten_extension_tester_on_cmd_func_t)(ten_extension_tester_t *self,
ten_env_tester_t *ten_env,
ten_shared_ptr_t *cmd);
Expand All @@ -41,6 +44,7 @@ typedef void (*ten_extension_tester_on_video_frame_func_t)(

TEN_RUNTIME_API ten_extension_tester_t *ten_extension_tester_create(
ten_extension_tester_on_start_func_t on_start,
ten_extension_tester_on_stop_func_t on_stop,
ten_extension_tester_on_cmd_func_t on_cmd,
ten_extension_tester_on_data_func_t on_data,
ten_extension_tester_on_audio_frame_func_t on_audio_frame,
Expand Down Expand Up @@ -75,8 +79,14 @@ TEN_RUNTIME_API ten_env_tester_t *ten_extension_tester_get_ten_env_tester(
TEN_RUNTIME_PRIVATE_API void ten_extension_tester_on_test_extension_start(
ten_extension_tester_t *self);

TEN_RUNTIME_PRIVATE_API void ten_extension_tester_on_test_extension_stop(
ten_extension_tester_t *self);

TEN_RUNTIME_PRIVATE_API void ten_extension_tester_on_test_extension_deinit(
ten_extension_tester_t *self);

TEN_RUNTIME_PRIVATE_API void ten_extension_tester_on_start_done(
ten_extension_tester_t *self);

TEN_RUNTIME_PRIVATE_API void ten_extension_tester_on_stop_done(
ten_extension_tester_t *self);
Loading
Loading