-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(JS lib): add a client JS lib for the Communicator
similar to trame-client js-api, trame-iframe js-api provides an agnostic library that can be installed in a regular JS project. trame-iframe js-api could be installed in a host application (could be react/streamlit/vue/... based) to proxy the trame API calls through the iframe to the Communicator and the trame application. The goal is to replicate the trame-client js-api features to make it transparent to the consumer code. API: - trame.state.set - trame.state.update - trame.state.watch - trame.trigger This is still possible to directly interact with the Communicator from an host application by manually sending/listening to events.
- Loading branch information
Showing
9 changed files
with
5,743 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-env node */ | ||
require("@rushstack/eslint-patch/modern-module-resolution"); | ||
|
||
module.exports = { | ||
root: true, | ||
extends: [ | ||
"eslint:recommended", | ||
"@vue/eslint-config-prettier", | ||
], | ||
env : { | ||
browser : true, | ||
es6 : true, | ||
}, | ||
rules : { | ||
"no-unused-vars" : 2, | ||
"no-undef" : 2 | ||
}, | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: "latest", | ||
}, | ||
}; |
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 @@ | ||
dist |
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,15 @@ | ||
Apache Software License 2.0 | ||
|
||
Copyright (c) 2024, Kitware Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,18 @@ | ||
// const trame = new Trame({ iframe }); | ||
// await trame.connect({ application: 'trame' }); | ||
|
||
// State handing | ||
trame.state.set("a", 5); | ||
console.log(trame.state.get("b")); | ||
trame.state.update({ | ||
a: 1, | ||
b: 2, | ||
}); | ||
|
||
// Method call on Python | ||
const result = await trame.trigger("name", [arg_0, arg_1], { kwarg_0: 1, kwarg_1: 2 }); | ||
|
||
// TODO - state watching | ||
trame.state.watch(["a"], (a) => { | ||
console.log(`a changed to ${a}`); | ||
}) |
Oops, something went wrong.