Compare commits

..

24 Commits

Author SHA1 Message Date
Ádám Kovács
b76426ba83 faet(frontend): Add tour manager store 2023-03-10 20:11:25 +01:00
Ádám Kovács
1cb2a177c6 Merge branch 'main' into tutorials 2023-03-10 19:13:04 +01:00
Ádám Kovács
db87577a1b feat(frontend): Add app editor tour 2023-03-10 19:11:34 +01:00
Ruben Fiszel
bc440f8d41 feat(frontend-apps): add variable picker for static string input on apps 2023-03-10 18:41:27 +01:00
Ádám Kovács
c219eb0ee9 feat(frontend): Add flow editor tour 2023-03-10 18:36:53 +01:00
Ruben Fiszel
1d5c194f09 feat(bash): add default argument handling for bash 2023-03-10 15:04:34 +01:00
Ruben Fiszel
7a9d230459 disable playwright for now 2023-03-10 12:54:00 +01:00
Ruben Fiszel
4d5e2499cf cleanup .workflows 2023-03-10 12:48:02 +01:00
Ruben Fiszel
686275fd46 trim tailwindcss 2023-03-10 12:44:08 +01:00
Ruben Fiszel
99399f4f77 fix serde test 2023-03-10 12:19:56 +01:00
Ruben Fiszel
6e09194313 fix compile 2023-03-10 12:12:10 +01:00
Ruben Fiszel
7c825c212d fix(backend): add killpill for lines reading 2023-03-10 12:04:05 +01:00
Ádám Kovács
bfe5b56c99 feat(frontend): Add script editor tour 2023-03-10 09:38:34 +01:00
Ruben Fiszel
480fd781b6 worker ping at least every 5s even when running long jobs 2023-03-10 01:38:12 +01:00
Ruben Fiszel
4f2079f624 trim tailwind safelist 2023-03-10 01:06:55 +01:00
Ruben Fiszel
43c45d930c chore(main): release 1.74.2 (#1277)
* chore(main): release 1.74.2

* Apply automatic changes

---------

Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com>
2023-03-10 00:55:13 +01:00
Faton Ramadani
8d5c5b88a3 fix(frontend): fix splitpanes navigation (#1276) 2023-03-10 00:32:33 +01:00
Ruben Fiszel
cc8bedd0c7 make frontend configurable through consts.ts 2023-03-09 22:54:25 +01:00
Ruben Fiszel
74c3d6443c chore(main): release 1.74.1 (#1275)
* chore(main): release 1.74.1

* Apply automatic changes

---------

Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com>
2023-03-09 22:45:53 +01:00
Ruben Fiszel
c7be313210 fix importjson 2023-03-09 22:42:47 +01:00
Ruben Fiszel
ae53bafaf6 fix(apps): proper reactivity for non rendered static components 2023-03-09 22:29:19 +01:00
Ruben Fiszel
2ea15d5035 fix(ci): make windmill compile again by pinning swc deps 2023-03-09 22:20:31 +01:00
Ruben Fiszel
0f187d66dd show backtrace for cook 2023-03-09 21:22:36 +01:00
Ádám Kovács
4453690521 feat(frontend): Add onboarding tour to home page 2023-03-09 20:11:27 +01:00
127 changed files with 1424 additions and 479 deletions

View File

@@ -1,20 +0,0 @@
name: Deploy to windmill.dev
on:
push:
branches: [main]
paths:
- "community/**"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to windmill.dev
uses: windmill-labs/windmill-gh-action-deploy@v2.0.0
with:
dry_run: false
input_dir: community
windmill_workspace: starter
windmill_token: ${{ secrets.WINDMILL_API_TOKEN }}

View File

@@ -109,38 +109,38 @@ jobs:
${{ steps.meta-ee-public.outputs.labels }}
org.opencontainers.image.licenses=Windmill-Enterprise-License
playwright:
runs-on: [self-hosted, new]
needs: [build]
services:
postgres:
image: postgres
env:
POSTGRES_DB: windmill
POSTGRES_USER: admin
POSTGRES_PASSWORD: changeme
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: "Docker"
run: echo "::set-output name=id::$(docker run --network=host --rm -d -p 8000:8000 --privileged -it -e DATABASE_URL=postgres://admin:changeme@localhost:5432/windmill -e BASE_INTERNAL_URL=http://localhost:8000 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest)"
id: docker-container
- uses: actions/setup-node@v3
with:
node-version: 16
- name: "Playwright run"
timeout-minutes: 2
run: cd frontend && npm ci @playwright/test && npx playwright install && export BASE_URL=http://localhost:8000 && npm run test
- name: "Clean up"
run: docker kill ${{ steps.docker-container.outputs.id }}
if: always()
# disabled until we make it 100% reliable and add more meaningful tests
# playwright:
# runs-on: [self-hosted, new]
# needs: [build]
# services:
# postgres:
# image: postgres
# env:
# POSTGRES_DB: windmill
# POSTGRES_USER: admin
# POSTGRES_PASSWORD: changeme
# ports:
# - 5432:5432
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# steps:
# - uses: actions/checkout@v3
# - name: "Docker"
# run: echo "::set-output name=id::$(docker run --network=host --rm -d -p 8000:8000 --privileged -it -e DATABASE_URL=postgres://admin:changeme@localhost:5432/windmill -e BASE_INTERNAL_URL=http://localhost:8000 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest)"
# id: docker-container
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# - name: "Playwright run"
# timeout-minutes: 2
# run: cd frontend && npm ci @playwright/test && npx playwright install && export BASE_URL=http://localhost:8000 && npm run test
# - name: "Clean up"
# run: docker kill ${{ steps.docker-container.outputs.id }}
# if: always()
publish_privately_heavy:

View File

@@ -1,6 +1,21 @@
# Changelog
## [1.74.2](https://github.com/windmill-labs/windmill/compare/v1.74.1...v1.74.2) (2023-03-09)
### Bug Fixes
* **frontend:** fix splitpanes navigation ([#1276](https://github.com/windmill-labs/windmill/issues/1276)) ([8d5c5b8](https://github.com/windmill-labs/windmill/commit/8d5c5b88a35d7a3bad1d8ddf2d940026825241eb))
## [1.74.1](https://github.com/windmill-labs/windmill/compare/v1.74.0...v1.74.1) (2023-03-09)
### Bug Fixes
* **apps:** proper reactivity for non rendered static components ([ae53baf](https://github.com/windmill-labs/windmill/commit/ae53bafaf6777f928113f84b2c6ed6a2ed341844))
* **ci:** make windmill compile again by pinning swc deps ([2ea15d5](https://github.com/windmill-labs/windmill/commit/2ea15d5035e5e15473968db3c0501a4dddff5cd0))
## [1.74.0](https://github.com/windmill-labs/windmill/compare/v1.73.1...v1.74.0) (2023-03-09)

View File

@@ -73,7 +73,7 @@ ARG features=""
COPY --from=planner /windmill/recipe.json recipe.json
RUN CARGO_NET_GIT_FETCH_WITH_CLI=true cargo chef cook --release --features "$features" --recipe-path recipe.json
RUN CARGO_NET_GIT_FETCH_WITH_CLI=true RUST_BACKTRACE=1 cargo chef cook --release --features "$features" --recipe-path recipe.json
COPY ./openflow.openapi.yaml /openflow.openapi.yaml
COPY ./backend ./

39
backend/Cargo.lock generated
View File

@@ -2953,7 +2953,7 @@ dependencies = [
[[package]]
name = "rustpython-ast"
version = "0.2.0"
source = "git+https://github.com/RustPython/RustPython#1fceeab0fcc77c11dfe94092b27b2164b94d62e4"
source = "git+https://github.com/RustPython/RustPython#87728c44527272ece739cddbb4942ad7e176dd79"
dependencies = [
"num-bigint",
"rustpython-compiler-core",
@@ -2962,7 +2962,7 @@ dependencies = [
[[package]]
name = "rustpython-compiler-core"
version = "0.2.0"
source = "git+https://github.com/RustPython/RustPython#1fceeab0fcc77c11dfe94092b27b2164b94d62e4"
source = "git+https://github.com/RustPython/RustPython#87728c44527272ece739cddbb4942ad7e176dd79"
dependencies = [
"bitflags",
"bstr",
@@ -2975,7 +2975,7 @@ dependencies = [
[[package]]
name = "rustpython-parser"
version = "0.2.0"
source = "git+https://github.com/RustPython/RustPython#1fceeab0fcc77c11dfe94092b27b2164b94d62e4"
source = "git+https://github.com/RustPython/RustPython#87728c44527272ece739cddbb4942ad7e176dd79"
dependencies = [
"ahash",
"anyhow",
@@ -3694,9 +3694,9 @@ dependencies = [
[[package]]
name = "swc_ecma_ast"
version = "0.99.0"
version = "0.98.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06fb0d52a72db367f9bc9194ada9dceab809fe65d2974b5832e1d1264702fd3a"
checksum = "305d2aa5e36a775e0d376552b35b325fccf0d7d8c633da1e4aec8e16460251cf"
dependencies = [
"bitflags",
"is-macro",
@@ -3711,9 +3711,9 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
version = "0.129.0"
version = "0.128.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e9d50f3ed033037b795be7f371e0b1246dc9e910a8aa3adfd6654cda6b21e1b"
checksum = "35e349e3f4c5561645b9042caae162dbaf55502be7b583ac99f3ccf3e65bccb7"
dependencies = [
"either",
"enum_kind",
@@ -4742,7 +4742,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windmill"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"axum",
@@ -4769,7 +4769,7 @@ dependencies = [
[[package]]
name = "windmill-api"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"argon2",
@@ -4824,7 +4824,7 @@ dependencies = [
[[package]]
name = "windmill-api-client"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"base64 0.21.0",
"chrono",
@@ -4839,7 +4839,7 @@ dependencies = [
[[package]]
name = "windmill-audit"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"chrono",
"serde",
@@ -4852,7 +4852,7 @@ dependencies = [
[[package]]
name = "windmill-common"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"axum",
@@ -4877,7 +4877,7 @@ dependencies = [
[[package]]
name = "windmill-parser"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"serde",
"serde_json",
@@ -4885,13 +4885,14 @@ dependencies = [
[[package]]
name = "windmill-parser-bash"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"itertools",
"lazy_static",
"phf",
"regex",
"serde_json",
"unicode-general-category",
"windmill-common",
"windmill-parser",
@@ -4899,7 +4900,7 @@ dependencies = [
[[package]]
name = "windmill-parser-go"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"itertools",
@@ -4911,7 +4912,7 @@ dependencies = [
[[package]]
name = "windmill-parser-py"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"itertools",
@@ -4926,7 +4927,7 @@ dependencies = [
[[package]]
name = "windmill-parser-ts"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"deno_core",
@@ -4940,7 +4941,7 @@ dependencies = [
[[package]]
name = "windmill-queue"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"chrono",
@@ -4963,7 +4964,7 @@ dependencies = [
[[package]]
name = "windmill-worker"
version = "1.74.0"
version = "1.74.2"
dependencies = [
"anyhow",
"async-recursion",

View File

@@ -1,6 +1,6 @@
[package]
name = "windmill"
version = "1.74.0"
version = "1.74.2"
authors.workspace = true
edition.workspace = true
@@ -19,7 +19,7 @@ members = [
]
[workspace.package]
version = "1.74.0"
version = "1.74.2"
authors = ["Ruben Fiszel <ruben@windmill.dev>"]
edition = "2021"
@@ -123,8 +123,8 @@ regex = "^1"
deno_core = "^0"
async-recursion = "^1"
swc_common = "^0"
swc_ecma_parser = "^0"
swc_ecma_ast = "^0"
swc_ecma_parser = "0.128.2"
swc_ecma_ast = "0.98.1"
base64 = "0.21.0"
unicode-general-category = "^0"
hmac = "0.12.1"

View File

@@ -16,4 +16,5 @@ unicode-general-category.workspace = true
itertools.workspace = true
anyhow.workspace = true
regex.workspace = true
lazy_static.workspace = true
lazy_static.workspace = true
serde_json.workspace = true

View File

@@ -1,6 +1,8 @@
#![allow(non_snake_case)] // TODO: switch to parse_* function naming
use anyhow::anyhow;
use regex::Regex;
use serde_json::json;
use std::collections::HashMap;
use windmill_parser::{Arg, MainArgSignature, Typ};
@@ -17,19 +19,32 @@ pub fn parse_bash_sig(code: &str) -> windmill_common::error::Result<MainArgSigna
}
}
lazy_static::lazy_static! {
static ref RE: Regex = Regex::new(r#"(?m)^(\w+)="\$(?:(\d+)|\{(\d+):-(.*)\})"$"#).unwrap();
}
fn parse_file(code: &str) -> anyhow::Result<Option<Vec<Arg>>> {
let mut hm = HashMap::new();
let re = Regex::new(r#"(?m)^(\w+)="\$(\d+)"$"#).unwrap();
for cap in re.captures_iter(code) {
hm.insert(cap[2].parse::<i32>()?, cap[1].to_string());
let mut hm: HashMap<i32, (String, Option<String>)> = HashMap::new();
for cap in RE.captures_iter(code) {
hm.insert(
cap.get(2)
.or(cap.get(3))
.and_then(|x| x.as_str().parse::<i32>().ok())
.ok_or_else(|| anyhow!("Impossible to parse arg digit"))?,
(
cap[1].to_string(),
cap.get(4).map(|x| x.as_str().to_string()),
),
);
}
let mut args = vec![];
for i in 1..20 {
if hm.contains_key(&i) {
let (name, default) = hm.get(&i).unwrap();
args.push(Arg {
name: hm[&i].clone(),
name: name.clone(),
typ: Typ::Str(None),
default: None,
default: default.clone().map(|x| json!(x)),
otyp: None,
has_default: false,
});
@@ -43,6 +58,8 @@ fn parse_file(code: &str) -> anyhow::Result<Option<Vec<Arg>>> {
#[cfg(test)]
mod tests {
use serde_json::json;
use super::*;
#[test]
@@ -50,8 +67,7 @@ mod tests {
let code = r#"
token="$1"
image="$2"
digest="${3:-latest}"
foo="$4"
digest="${3:-latest with spaces}"
"#;
//println!("{}", serde_json::to_string()?);
@@ -74,6 +90,13 @@ foo="$4"
typ: Typ::Str(None),
default: None,
has_default: false
},
Arg {
otyp: None,
name: "digest".to_string(),
typ: Typ::Str(None),
default: Some(json!("latest with spaces")),
has_default: false
}
]
}

View File

@@ -5040,6 +5040,18 @@
},
"query": "\n SELECT id, flow_status, suspend, script_path\n FROM queue\n WHERE id = ( SELECT parent_job FROM queue WHERE id = $1 UNION ALL SELECT parent_job FROM completed_job WHERE id = $1)\n FOR UPDATE\n "
},
"c9d97800eb0ec87df8e8959b283dacb2c6cce422365ed394375641488ceb6b65": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Text"
]
}
},
"query": "UPDATE worker_ping SET ping_at = now() WHERE worker = $1"
},
"cac594031a21b4806de9c4616317d3541522ef9712a83ecff7bd8b5f6e870748": {
"describe": {
"columns": [],

View File

@@ -1,7 +1,7 @@
openapi: "3.0.3"
info:
version: 1.74.0
version: 1.74.2
title: Windmill API
contact:

View File

@@ -733,6 +733,9 @@ fn build_args(
path: String,
args: &Map<String, Value>,
) -> Result<Map<String, Value>> {
// disallow var and res access in args coming from the user for security reasons
args.into_iter()
.try_for_each(|x| disallow_var_res_access(x.1))?;
let static_args = policy
.triggerables
.get(&path)
@@ -753,3 +756,20 @@ fn build_args(
}
Ok(args)
}
fn disallow_var_res_access(args: &serde_json::Value) -> Result<()> {
match args {
Value::Object(v) => v.into_iter().try_for_each(|x| disallow_var_res_access(x.1)),
Value::Array(arr) => arr.into_iter().try_for_each(|v| disallow_var_res_access(v)),
Value::String(s) => {
if s.starts_with("$var:") || s.starts_with("$res:") {
Err(Error::BadRequest(format!(
"For security reasons, variable or resource access is not allowed as dynamic argument"
)))
} else {
Ok(())
}
}
_ => Ok(()),
}
}

View File

@@ -640,8 +640,6 @@ mod tests {
"type": "script",
"path": "test"
},
"stop_after_if": null,
"summary": null
},
{
"id": "b",
@@ -650,15 +648,12 @@ mod tests {
"input_transforms": {},
"type": "rawscript",
"content": "test",
"lock": null,
"path": null,
"language": "deno"
},
"stop_after_if": {
"expr": "foo = 'bar'",
"skip_if_stopped": false
},
"summary": null
}
},
{
"id": "c",
@@ -680,8 +675,7 @@ mod tests {
"stop_after_if": {
"expr": "previous.isEmpty()",
"skip_if_stopped": false,
},
"summary": null
}
}
],
"failure_module": {
@@ -695,8 +689,7 @@ mod tests {
"stop_after_if": {
"expr": "previous.isEmpty()",
"skip_if_stopped": false
},
"summary": null
}
}
});
assert_eq!(dbg!(serde_json::json!(fv)), dbg!(expect));

View File

@@ -34,7 +34,7 @@ use tokio::{
io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader},
process::{Child, Command},
sync::{
mpsc::{self, Sender}, watch,
mpsc::{self, Sender}, watch, broadcast,
},
time::{interval, sleep, Instant, MissedTickBehavior},
};
@@ -840,7 +840,7 @@ async fn handle_queued_job(
job_dir: &str,
metrics: Metrics,
same_worker_tx: Sender<Uuid>,
base_internal_url: &str
base_internal_url: &str,
) -> windmill_common::error::Result<()> {
if job.canceled {
return Err(Error::JsonErr(canceled_job_to_result(&job)))?;
@@ -888,10 +888,10 @@ async fn handle_queued_job(
logs.push_str(&format!("job {} on worker {}\n", &job.id, &worker_name));
let result = match job.job_kind {
JobKind::Dependencies => {
handle_dependency_job(&job, &mut logs, job_dir, db).await
handle_dependency_job(&job, &mut logs, job_dir, db, worker_name).await
}
JobKind::FlowDependencies => {
handle_flow_dependency_job(&job, &mut logs, job_dir, db)
handle_flow_dependency_job(&job, &mut logs, job_dir, db, worker_name)
.await
.map(|()| Value::Null)
}
@@ -912,7 +912,8 @@ async fn handle_queued_job(
job_dir,
worker_dir,
&mut logs,
base_internal_url
base_internal_url,
worker_name
)
.await
}
@@ -1064,7 +1065,9 @@ async fn handle_code_execution_job(
job_dir: &str,
worker_dir: &str,
logs: &mut String,
base_internal_url: &str
base_internal_url: &str,
worker_name: &str
) -> error::Result<serde_json::Value> {
let (inner_content, requirements_o, language) = match job.job_kind {
JobKind::Preview | JobKind::Script_Hub => (
@@ -1086,7 +1089,6 @@ async fn handle_code_execution_job(
"handle_code_execution_job should never be reachable with a non-code execution job"
),
};
let worker_name = worker_dir.split("/").last().unwrap_or("unknown");
let lang_str = job
.language
.as_ref()
@@ -1136,7 +1138,7 @@ mount {{
token,
&inner_content,
&shared_mount,
base_internal_url
base_internal_url,
)
.await
}
@@ -1151,7 +1153,8 @@ mount {{
&inner_content,
&shared_mount,
requirements_o,
base_internal_url
base_internal_url,
worker_name
)
.await
}
@@ -1166,7 +1169,8 @@ mount {{
job_dir,
requirements_o,
&shared_mount,
base_internal_url
base_internal_url,
worker_name
)
.await
}
@@ -1179,7 +1183,8 @@ mount {{
&inner_content,
job_dir,
&shared_mount,
base_internal_url
base_internal_url,
worker_name
)
.await
}
@@ -1208,6 +1213,7 @@ async fn handle_go_job(
requirements_o: Option<String>,
shared_mount: &str,
base_internal_url: &str,
worker_name: &str,
) -> Result<serde_json::Value, Error> {
//go does not like executing modules at temp root
let job_dir = &format!("{job_dir}/go");
@@ -1236,6 +1242,7 @@ async fn handle_go_job(
db,
true,
skip_go_mod,
worker_name
)
.await?;
@@ -1353,7 +1360,7 @@ func Run(req Req) (interface{{}}, error){{
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
handle_child(&job.id, db, logs, build_go, false).await?;
handle_child(&job.id, db, logs, build_go, false, worker_name).await?;
Command::new(NSJAIL_PATH.as_str())
.current_dir(job_dir)
@@ -1379,7 +1386,7 @@ func Run(req Req) (interface{{}}, error){{
.stderr(Stdio::piped())
.spawn()?
};
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL).await?;
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL, worker_name).await?;
read_result(job_dir).await
}
@@ -1393,6 +1400,7 @@ async fn handle_bash_job(
job_dir: &str,
shared_mount: &str,
base_internal_url: &str,
worker_name: &str,
) -> Result<serde_json::Value, Error> {
logs.push_str("\n\n--- BASH CODE EXECUTION ---\n");
set_logs(logs, &job.id, db).await;
@@ -1456,7 +1464,7 @@ async fn handle_bash_job(
.stderr(Stdio::piped())
.spawn()?
};
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL).await?;
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL, worker_name).await?;
//for now bash jobs have an empty result object
Ok(serde_json::json!(logs
.lines()
@@ -1484,7 +1492,8 @@ async fn handle_deno_job(
inner_content: &String,
shared_mount: &str,
lockfile: Option<String>,
base_internal_url: &str
base_internal_url: &str,
worker_name: &str
) -> error::Result<serde_json::Value> {
logs.push_str("\n\n--- DENO CODE EXECUTION ---\n");
set_logs(logs, &job.id, db).await;
@@ -1619,7 +1628,7 @@ run().catch(async (e) => {{
}
.instrument(trace_span!("create_deno_jail"))
.await?;
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL).await?;
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL, worker_name).await?;
read_result(job_dir).await
}
@@ -1657,7 +1666,7 @@ async fn handle_python_job(
token: String,
inner_content: &String,
shared_mount: &str,
base_internal_url: &str
base_internal_url: &str,
) -> error::Result<serde_json::Value> {
create_dependencies_dir(job_dir).await;
@@ -1671,7 +1680,7 @@ async fn handle_python_job(
if requirements.is_empty() {
"".to_string()
} else {
pip_compile(&job.id, &requirements, logs, job_dir, db)
pip_compile(&job.id, &requirements, logs, job_dir, db, worker_name)
.await
.map_err(|e| {
Error::ExecutionErr(format!("pip compile failed: {}", e.to_string()))
@@ -1888,7 +1897,7 @@ mount {{
.spawn()?
};
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL).await?;
handle_child(&job.id, db, logs, child, !*DISABLE_NSJAIL, worker_name).await?;
read_result(job_dir).await
}
@@ -1918,6 +1927,7 @@ async fn handle_dependency_job(
logs: &mut String,
job_dir: &str,
db: &sqlx::Pool<sqlx::Postgres>,
worker_name: &str,
) -> error::Result<serde_json::Value> {
let content = capture_dependency_job(
&job.id,
@@ -1932,7 +1942,8 @@ async fn handle_dependency_job(
.unwrap_or_else(|| "no raw code"),
logs,
job_dir,
db
db,
worker_name
)
.await;
match content {
@@ -1967,6 +1978,7 @@ async fn handle_flow_dependency_job(
logs: &mut String,
job_dir: &str,
db: &sqlx::Pool<sqlx::Postgres>,
worker_name: &str,
) -> error::Result<()> {
let path = job.script_path.clone().ok_or_else(|| {
error::Error::InternalErr(
@@ -1997,6 +2009,7 @@ async fn handle_flow_dependency_job(
logs,
job_dir,
db,
worker_name
)
.await;
match new_lock {
@@ -2111,12 +2124,13 @@ async fn capture_dependency_job(
job_raw_code: &str,
logs: &mut String,
job_dir: &str,
db: &sqlx::Pool<sqlx::Postgres>
db: &sqlx::Pool<sqlx::Postgres>,
worker_name: &str
) -> error::Result<String> {
match job_language {
ScriptLang::Python3 => {
create_dependencies_dir(job_dir).await;
pip_compile(job_id, job_raw_code, logs, job_dir, db ).await
pip_compile(job_id, job_raw_code, logs, job_dir, db, worker_name).await
}
ScriptLang::Go => {
install_go_dependencies(
@@ -2127,6 +2141,7 @@ async fn capture_dependency_job(
db,
false,
false,
worker_name
)
.await
}
@@ -2144,6 +2159,7 @@ async fn pip_compile(
logs: &mut String,
job_dir: &str,
db: &Pool<Postgres>,
worker_name: &str
) -> error::Result<String> {
logs.push_str(&format!("\nresolving dependencies..."));
set_logs(logs, job_id, db).await;
@@ -2176,7 +2192,7 @@ async fn pip_compile(
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
handle_child(job_id, db, logs, child, false)
handle_child(job_id, db, logs, child, false, worker_name)
.await
.map_err(|e| Error::ExecutionErr(format!("Lock file generation failed: {e:?}")))?;
let path_lock = format!("{job_dir}/requirements.txt");
@@ -2199,6 +2215,7 @@ async fn install_go_dependencies(
db: &sqlx::Pool<sqlx::Postgres>,
preview: bool,
skip_go_mod: bool,
worker_name: &str
) -> error::Result<String> {
if !skip_go_mod {
gen_go_mymod(code, job_dir).await?;
@@ -2209,7 +2226,7 @@ async fn install_go_dependencies(
.stderr(Stdio::piped())
.spawn()?;
handle_child(job_id, db, logs, child, false).await?;
handle_child(job_id, db, logs, child, false, worker_name).await?;
}
let child = Command::new(GO_PATH.as_str())
.current_dir(job_dir)
@@ -2217,7 +2234,7 @@ async fn install_go_dependencies(
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
handle_child(job_id, db, logs, child, false)
handle_child(job_id, db, logs, child, false, worker_name)
.await
.map_err(|e| Error::ExecutionErr(format!("Lock file generation failed: {e:?}")))?;
@@ -2323,6 +2340,7 @@ async fn handle_child(
logs: &mut String,
mut child: Child,
nsjail: bool,
worker_name: &str,
) -> error::Result<()> {
let update_job_interval = Duration::from_millis(500);
let write_logs_delay = Duration::from_millis(500);
@@ -2336,11 +2354,14 @@ async fn handle_child(
tracing::info!("could not get child pid");
}
let (set_too_many_logs, mut too_many_logs) = watch::channel::<bool>(false);
let (tx, mut rx) = broadcast::channel::<()>(3);
let mut rx2 = tx.subscribe();
let output = child_joined_output_stream(&mut child);
let job_id = job_id.clone();
let (tx, mut rx) = mpsc::channel::<()>(1);
/* the cancellation future is polled on by `wait_on_child` while
* waiting for the child to exit normally */
@@ -2350,10 +2371,22 @@ async fn handle_child(
let mut interval = interval(update_job_interval);
interval.set_missed_tick_behavior(MissedTickBehavior::Skip);
let mut i = 1;
loop {
tokio::select!(
_ = rx.recv() => break,
_ = interval.tick() => {
// update the last_ping column every 5 seconds
i+=1;
if i % 10 == 0 {
sqlx::query!(
"UPDATE worker_ping SET ping_at = now() WHERE worker = $1",
&worker_name
)
.execute(&db)
.await
.expect("update worker ping");
}
let mem_peak = get_mem_peak(pid, nsjail).await;
tracing::info!("{job_id} still running. mem peak: {}kB", mem_peak);
let mem_peak = if mem_peak > 0 { Some(mem_peak) } else { None };
@@ -2387,10 +2420,10 @@ async fn handle_child(
biased;
result = child.wait() => return result.map(Ok),
Ok(()) = too_many_logs.changed() => KillReason::TooManyLogs,
_ = update_job => KillReason::Cancelled,
_ = sleep(*TIMEOUT_DURATION) => KillReason::Timeout,
_ = update_job => KillReason::Cancelled,
};
tx.send(()).await.expect("rx should never be dropped");
tx.send(()).expect("rx should never be dropped");
drop(tx);
let set_reason = async {
@@ -2413,7 +2446,7 @@ async fn handle_child(
}
}
};
/* send SIGKILL and reap child process */
let (_, kill) = future::join(set_reason, child.kill()).await;
kill.map(|()| Err(kill_reason))
@@ -2429,12 +2462,13 @@ async fn handle_child(
/* log_remaining is zero when output limit was reached */
let mut log_remaining = max_log_size.saturating_sub(logs.chars().count());
let mut result = io::Result::Ok(());
let mut output = output;
let mut output = output.take_until(rx2.recv()).boxed();
/* `do_write` resolves the task, but does not contain the Result.
* It's useful to know if the task completed. */
let (mut do_write, mut write_result) = tokio::spawn(ready(())).remote_handle();
while let Some(line) = output.by_ref().next().await {
while let Some(line) = output.by_ref().next().await {
let do_write_ = do_write.shared();
let mut read_lines = stream::once(async { line })
@@ -2449,11 +2483,14 @@ async fn handle_child(
let mut joined = String::new();
while let Some(line) = read_lines.next().await {
match line {
Ok(_) if log_remaining == 0 => (),
Ok(line) => {
if line.is_empty() {
continue;
}
append_with_limit(&mut joined, &line, &mut log_remaining);
if log_remaining == 0 {
tracing::info!(%job_id, "Too many logs lines for job {job_id}");
let _ = set_too_many_logs.send(true);
@@ -2473,6 +2510,7 @@ async fn handle_child(
logs.push_str(&joined);
/* Ensure the last flush completed before starting a new one.
*
* This shouldn't pause since `take_until()` reads lines until `do_write`
@@ -2489,8 +2527,7 @@ async fn handle_child(
panic::resume_unwind(p);
}
(do_write, write_result) =
tokio::spawn(append_logs(job_id, joined, db.clone())).remote_handle();
(do_write, write_result) = tokio::spawn(append_logs(job_id, joined, db.clone())).remote_handle();
if let Err(err) = result {
tracing::error!(%job_id, %err, "error reading output for job {job_id}: {err}");
@@ -2500,6 +2537,7 @@ async fn handle_child(
if *set_too_many_logs.borrow() {
break;
}
}
/* drop our end of the pipe */
@@ -2813,7 +2851,7 @@ async fn handle_python_reqs(
.spawn()?
};
let child = handle_child(&job.id, db, logs, child, false).await;
let child = handle_child(&job.id, db, logs, child, false, worker_name).await;
tracing::info!(
worker_name = %worker_name,
job_id = %job.id,

View File

@@ -13,7 +13,7 @@ import sync from "./sync.ts";
import { tryResolveVersion } from "./context.ts";
import { GlobalOptions } from "./types.ts";
const VERSION = "v1.74.0";
const VERSION = "v1.74.2";
let command: any = new Command()
.name("wmill")

View File

@@ -1,12 +1,12 @@
{
"name": "windmill",
"version": "1.74.0",
"version": "1.74.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "windmill",
"version": "1.74.0",
"version": "1.74.2",
"dependencies": {
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
@@ -64,6 +64,7 @@
"postcss-load-config": "^4.0.1",
"prettier": "^2.8.3",
"prettier-plugin-svelte": "^2.9.0",
"shepherd.js": "^10.0.1",
"simple-svelte-autocomplete": "^2.5.1",
"stylelint-config-recommended": "^9.0.0",
"svelte": "^3.55.1",
@@ -6653,6 +6654,24 @@
"node": ">=8"
}
},
"node_modules/shepherd.js": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/shepherd.js/-/shepherd.js-10.0.1.tgz",
"integrity": "sha512-R32v4b4b0N1gK/vxvRtdhty+SBZlBPcPTSYCwcaAQvFd0n6Xki7cRH6Sx0oD9WB/HCkqCNM1msyIyylXmq635w==",
"dev": true,
"dependencies": {
"@popperjs/core": "^2.11.5",
"deepmerge": "^4.2.2",
"smoothscroll-polyfill": "^0.4.4"
},
"engines": {
"node": "12.* || 14.* || >= 16"
},
"funding": {
"type": "individual",
"url": "https://github.com/sponsors/rwwagner90"
}
},
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
@@ -6739,6 +6758,12 @@
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
}
},
"node_modules/smoothscroll-polyfill": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/smoothscroll-polyfill/-/smoothscroll-polyfill-0.4.4.tgz",
"integrity": "sha512-TK5ZA9U5RqCwMpfoMq/l1mrH0JAR7y7KRvOBx0n2869aLxch+gT9GhN3yUfjiw+d/DiF1mKo14+hd62JyMmoBg==",
"dev": true
},
"node_modules/sorcery": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.11.0.tgz",
@@ -12989,6 +13014,17 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"shepherd.js": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/shepherd.js/-/shepherd.js-10.0.1.tgz",
"integrity": "sha512-R32v4b4b0N1gK/vxvRtdhty+SBZlBPcPTSYCwcaAQvFd0n6Xki7cRH6Sx0oD9WB/HCkqCNM1msyIyylXmq635w==",
"dev": true,
"requires": {
"@popperjs/core": "^2.11.5",
"deepmerge": "^4.2.2",
"smoothscroll-polyfill": "^0.4.4"
}
},
"signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
@@ -13049,6 +13085,12 @@
"is-fullwidth-code-point": "^3.0.0"
}
},
"smoothscroll-polyfill": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/smoothscroll-polyfill/-/smoothscroll-polyfill-0.4.4.tgz",
"integrity": "sha512-TK5ZA9U5RqCwMpfoMq/l1mrH0JAR7y7KRvOBx0n2869aLxch+gT9GhN3yUfjiw+d/DiF1mKo14+hd62JyMmoBg==",
"dev": true
},
"sorcery": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.11.0.tgz",

View File

@@ -1,6 +1,6 @@
{
"name": "windmill",
"version": "1.74.0",
"version": "1.74.2",
"scripts": {
"dev": "vite dev",
"build": "vite build",
@@ -43,6 +43,7 @@
"postcss-load-config": "^4.0.1",
"prettier": "^2.8.3",
"prettier-plugin-svelte": "^2.9.0",
"shepherd.js": "^10.0.1",
"simple-svelte-autocomplete": "^2.5.1",
"stylelint-config-recommended": "^9.0.0",
"svelte": "^3.55.1",

View File

@@ -232,8 +232,14 @@
<Badge color={validCode ? 'green' : 'red'} class="min-w-[60px] mr-3">
{validCode ? 'Valid' : 'Invalid'}
</Badge>
<div class="flex items-center divide-x">
<Popover notClickable placement="bottom" disapperTimoout={0} class="pr-1" disablePopup={!iconOnly}>
<div id="script-tutorial-3" class="flex items-center divide-x">
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="pr-1"
disablePopup={!iconOnly}
>
<Button
color="light"
btnClasses="!font-medium !h-full"
@@ -245,11 +251,15 @@
>
+Context Var
</Button>
<svelte:fragment slot="text">
Add context variable
</svelte:fragment>
<svelte:fragment slot="text">Add context variable</svelte:fragment>
</Popover>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
color="light"
btnClasses="!font-medium !h-full"
@@ -261,11 +271,15 @@
>
+Variable
</Button>
<svelte:fragment slot="text">
Add variable
</svelte:fragment>
<svelte:fragment slot="text">Add variable</svelte:fragment>
</Popover>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
btnClasses="!font-medium !h-full"
size="xs"
@@ -277,11 +291,15 @@
>
+Resource
</Button>
<svelte:fragment slot="text">
Add resource
</svelte:fragment>
<svelte:fragment slot="text">Add resource</svelte:fragment>
</Popover>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
btnClasses="!font-medium !h-full"
size="xs"
@@ -293,11 +311,15 @@
>
Reset
</Button>
<svelte:fragment slot="text">
Reset
</svelte:fragment>
<svelte:fragment slot="text">Reset</svelte:fragment>
</Popover>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
btnClasses="!font-medium !h-full"
size="xs"
@@ -320,11 +342,15 @@
{/if}
</span>
</Button>
<svelte:fragment slot="text">
Reload assistant
</svelte:fragment>
<svelte:fragment slot="text">Reload assistant</svelte:fragment>
</Popover>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
btnClasses="!font-medium"
size="xs"
@@ -342,7 +368,13 @@
</Popover>
</div>
</div>
<Popover notClickable placement="bottom" disapperTimoout={0} class="px-1" disablePopup={!iconOnly}>
<Popover
notClickable
placement="bottom"
disapperTimoout={0}
class="px-1"
disablePopup={!iconOnly}
>
<Button
btnClasses="!font-medium"
size="xs"
@@ -354,9 +386,7 @@
>
Script
</Button>
<svelte:fragment slot="text">
Script
</svelte:fragment>
<svelte:fragment slot="text">Script</svelte:fragment>
</Popover>
</div>

View File

@@ -20,6 +20,7 @@
import { loadFlowSchedule, type Schedule } from './flows/scheduleUtils'
import type { FlowEditorContext } from './flows/types'
import { cleanInputs } from './flows/utils'
import { Tour } from './tutorial'
export let initialPath: string = ''
export let selectedId: string | undefined
@@ -27,6 +28,7 @@
export let loading = false
export let flowStore: Writable<Flow>
export let flowStateStore: Writable<FlowState>
export let tour = false
async function createSchedule(path: string) {
const { cron, args, enabled } = $scheduleStore
@@ -246,6 +248,10 @@
<svelte:window on:keydown={onKeyDown} />
{#if tour}
<Tour tutorial="flow" />
{/if}
{#if !$userStore?.operator}
<ScriptEditorDrawer bind:this={$scriptEditorDrawer} />

View File

@@ -58,6 +58,7 @@
on:refresh={async (e) => {
await loadResources(resourceType)
value = e.detail
valueSelect = { value: e.detail, label: e.detail }
}}
newPageOAuth
bind:this={appConnect}

View File

@@ -346,6 +346,7 @@
lang={script.language}
{initialArgs}
{kind}
tour
/>
{:else if step === 3}
<CenteredPage>

View File

@@ -17,6 +17,7 @@
import { Button, Kbd } from './common'
import SplitPanesWrapper from './splitPanes/SplitPanesWrapper.svelte'
import WindmillIcon from './icons/WindmillIcon.svelte'
import { Tour } from './tutorial'
// Exported
export let schema: Schema = emptySchema()
@@ -27,6 +28,7 @@
export let initialArgs: Record<string, any> = {}
export let fixedOverflowWidgets = true
export let noSyncFromGithub = false
export let tour = false
let websocketAlive = { pyright: false, black: false, deno: false, go: false }
@@ -114,6 +116,10 @@
<svelte:window on:keydown={onKeyDown} />
{#if tour}
<Tour tutorial="script" />
{/if}
<div class="border-b-2 shadow-sm px-1 pr-4" bind:clientWidth={width}>
<div class="flex justify-between space-x-2">
<EditorBar
@@ -146,6 +152,7 @@
<Splitpanes class="!overflow-visible">
<Pane size={60} minSize={10} class="!overflow-visible">
<div
id="script-tutorial-1"
class="pl-2 h-full !overflow-visible"
on:mouseleave={() => {
inferSchema(code)
@@ -180,7 +187,7 @@
</Pane>
<Pane size={40} minSize={10}>
<div class="flex flex-col h-full">
<div class="px-2 w-full border-b py-1">
<div id="script-tutorial-4" class="px-2 w-full border-b py-1">
{#if testIsLoading}
<Button on:click={testJobLoader?.cancelJob} btnClasses="w-full" color="red" size="xs">
<WindmillIcon
@@ -211,7 +218,7 @@
</div>
<Splitpanes horizontal class="!max-h-[calc(100%-43px)]">
<Pane size={33}>
<div class="px-2">
<div id="script-tutorial-2" class="px-2">
<div class="break-words relative font-sans">
<SchemaForm compact {schema} bind:args bind:isValid />
</div>

View File

@@ -186,9 +186,9 @@
syncIteration++
await loadTestJob(id)
let nextIteration = 50
if (syncIteration == ITERATIONS_BEFORE_SLOW_REFRESH) {
if (syncIteration > ITERATIONS_BEFORE_SLOW_REFRESH) {
nextIteration = 500
} else if (syncIteration == ITERATIONS_BEFORE_SUPER_SLOW_REFRESH) {
} else if (syncIteration > ITERATIONS_BEFORE_SUPER_SLOW_REFRESH) {
nextIteration = 2000
}
setTimeout(() => syncer(id), nextIteration)

View File

@@ -16,7 +16,7 @@
const dispatch = createEventDispatcher()
</script>
<span class="{$$props.class} z-auto">
<span class="{$$props.class ?? ''} z-auto">
<label
for={id}
class="inline-flex items-center mt-2 duration-200 {disabled

View File

@@ -3,7 +3,7 @@
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
import type RunnableComponent from '../helpers/RunnableComponent.svelte'
@@ -26,7 +26,7 @@
export const staticOutputs: string[] = ['loading', 'result']
const { runnableComponents, worldStore, app } = getContext<AppEditorContext>('AppEditorContext')
const { runnableComponents, worldStore, app } = getContext<AppViewerContext>('AppViewerContext')
let labelValue: string
let color: ButtonType.Color

View File

@@ -5,7 +5,7 @@
import { Icon } from 'svelte-awesome'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -24,7 +24,7 @@
export const staticOutputs: string[] = ['loading', 'result']
const { app, runnableComponents, worldStore, stateId } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
let labelValue: string = 'Default label'
let color: ButtonType.Color

View File

@@ -5,7 +5,7 @@
import { Icon } from 'svelte-awesome'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
import type RunnableComponent from '../helpers/RunnableComponent.svelte'
@@ -26,7 +26,7 @@
export const staticOutputs: string[] = ['loading', 'result']
const { app, runnableComponents, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { app, runnableComponents, worldStore } = getContext<AppViewerContext>('AppViewerContext')
let labelValue: string = 'Default label'
let color: ButtonType.Color

View File

@@ -17,7 +17,7 @@
import InputValue from '../helpers/InputValue.svelte'
import { concatCustomCss } from '../../utils'
import { getContext } from 'svelte'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
export let id: string
export let componentInput: AppInput | undefined
@@ -27,7 +27,7 @@
export let render: boolean
export const staticOutputs: string[] = ['loading', 'result']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
ChartJS.register(
Title,

View File

@@ -5,7 +5,7 @@
import type { AppInput } from '../../inputType'
import {
IS_APP_PUBLIC_CONTEXT_KEY,
type AppEditorContext,
type AppViewerContext,
type ComponentCustomCSS
} from '../../types'
import RunnableWrapper from '../helpers/RunnableWrapper.svelte'
@@ -17,7 +17,7 @@
export let render: boolean
const requireHtmlApproval = getContext<boolean | undefined>(IS_APP_PUBLIC_CONTEXT_KEY)
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let result: any = undefined
export const staticOutputs: string[] = ['result', 'loading']

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import RunnableWrapper from '../helpers/RunnableWrapper.svelte'
@@ -12,7 +12,7 @@
export let render: boolean
export const staticOutputs: string[] = ['result', 'loading']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let result: string | undefined = undefined
let h: number | undefined = undefined

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import { AlignWrapper, InputValue } from '../helpers'
import { loadIcon } from '../icon'
@@ -14,7 +14,7 @@
export let customCss: ComponentCustomCSS<'container' | 'icon'> | undefined = undefined
export let render: boolean
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let icon: string | undefined = undefined
let size: number

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { staticValues } from '../../editor/componentsPanel/componentStaticValues'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
@@ -15,7 +15,7 @@
export let customCss: ComponentCustomCSS<'image'> | undefined = undefined
export let render: boolean
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
const fit: Record<FitOption, string> = {
cover: 'object-cover',
contain: 'object-contain',

View File

@@ -2,7 +2,7 @@
import { getContext, onMount } from 'svelte'
import { concatCustomCss } from '../../utils'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { InputValue } from '../helpers'
import { twMerge } from 'tailwind-merge'
import { Map, View, Feature } from 'ol'
@@ -35,7 +35,7 @@
export let render: boolean
const { app, worldStore, selectedComponent, connectingInput, focusedGrid, mode } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
$: outputs = $worldStore?.outputsById[id] as {
mapRegion: Output<{

View File

@@ -4,7 +4,7 @@
import { getDocument, type PDFDocumentProxy, type PDFPageProxy } from 'pdfjs-dist'
import 'pdfjs-dist/build/pdf.worker.entry'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
import { throttle } from '../../../../utils'
@@ -19,7 +19,7 @@
export let customCss: ComponentCustomCSS<'container'> | undefined = undefined
export let render: boolean
const { app, mode, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, mode, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let source: string | ArrayBuffer | undefined = undefined
let wrapper: HTMLDivElement | undefined = undefined

View File

@@ -14,7 +14,7 @@
import RunnableWrapper from '../helpers/RunnableWrapper.svelte'
import type { AppInput } from '../../inputType'
import InputValue from '../helpers/InputValue.svelte'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import { getContext } from 'svelte'
@@ -26,7 +26,7 @@
export let render: boolean
export const staticOutputs: string[] = ['loading', 'result']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
ChartJS.register(
Title,

View File

@@ -19,7 +19,7 @@
import type { ChartOptions, ChartData } from 'chart.js'
import { concatCustomCss } from '../../utils'
import { getContext } from 'svelte'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
export let id: string
export let componentInput: AppInput | undefined
@@ -32,7 +32,7 @@
let pannable = false
export const staticOutputs: string[] = ['loading', 'result']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
ChartJS.register(
Title,

View File

@@ -8,7 +8,7 @@
import InputValue from '../helpers/InputValue.svelte'
import RunnableWrapper from '../helpers/RunnableWrapper.svelte'
import { twMerge } from 'tailwind-merge'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { getContext } from 'svelte'
import ResizeWrapper from '../helpers/ResizeWrapper.svelte'
@@ -23,7 +23,7 @@
export const staticOutputs: string[] = ['result', 'loading']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let result: string | undefined = undefined
let style: 'Title' | 'Subtitle' | 'Body' | 'Caption' | 'Label' | undefined = undefined

View File

@@ -20,7 +20,7 @@
import { Scatter } from 'svelte-chartjs'
import InputValue from '../helpers/InputValue.svelte'
import type { ChartOptions, ChartData } from 'chart.js'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { getContext } from 'svelte'
import { concatCustomCss } from '../../utils'
@@ -32,7 +32,7 @@
export let render: boolean
export const staticOutputs: string[] = ['loading', 'result']
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let logarithmicScale = false
let zoomable = false

View File

@@ -5,7 +5,7 @@
import { getContext, onMount } from 'svelte'
import type { Output } from '../../../rx'
import type { AppEditorContext } from '../../../types'
import type { AppViewerContext } from '../../../types'
import InputValue from '../../helpers/InputValue.svelte'
import type { AppInput } from '../../../inputType'
import RunnableWrapper from '../../helpers/RunnableWrapper.svelte'
@@ -23,7 +23,7 @@
let result: Record<string, any>[] | undefined = undefined
const { worldStore, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { worldStore, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let selectedRowIndex = -1

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext, onMount } from 'svelte'
import type { Output } from '../../../rx'
import type { AppEditorContext, BaseAppComponent, ComponentCustomCSS } from '../../../types'
import type { AppViewerContext, BaseAppComponent, ComponentCustomCSS } from '../../../types'
import InputValue from '../../helpers/InputValue.svelte'
import type { AppInput } from '../../../inputType'
import RunnableWrapper from '../../helpers/RunnableWrapper.svelte'
@@ -61,7 +61,7 @@
app,
worldStore,
staticOutputs: staticOutputsStore
} = getContext<AppEditorContext>('AppEditorContext')
} = getContext<AppViewerContext>('AppViewerContext')
let selectedRowIndex = -1

View File

@@ -3,7 +3,7 @@
import { deepEqual } from 'fast-equals'
import { getContext } from 'svelte'
import type { AppInput, EvalAppInput, UploadAppInput } from '../../inputType'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { accessPropertyByPath } from '../../utils'
type T = string | number | boolean | Record<string | number, any> | undefined
@@ -23,7 +23,7 @@
}
}
const { worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { worldStore } = getContext<AppViewerContext>('AppViewerContext')
$: state = $worldStore?.state

View File

@@ -1,16 +1,19 @@
<script lang="ts">
import { Loader2 } from 'lucide-svelte'
import { getContext } from 'svelte'
import { fade } from 'svelte/transition'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import InputValue from './InputValue.svelte'
export let componentInput: AppInput
export let id: string
export let result: any
export let render: boolean
// Sync the result to the output
const { worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { worldStore } = getContext<AppViewerContext>('AppViewerContext')
$: outputs = $worldStore?.outputsById[id] as {
loading: Output<boolean>
@@ -32,4 +35,16 @@
<InputValue {id} input={componentInput} bind:value={result} />
{/if}
<slot />
{#if render}
<slot />
{:else}
<div class="w-full h-full">
<div
out:fade|local={{ duration: 50 }}
class="absolute inset-0 center-center flex-col bg-white text-gray-600 border"
>
<Loader2 class="animate-spin" size={16} />
<span class="text-xs mt-1">Loading</span>
</div>
</div>
{/if}

View File

@@ -3,11 +3,11 @@
import { faRefresh } from '@fortawesome/free-solid-svg-icons'
import { RefreshCcw, RefreshCw } from 'lucide-svelte'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
export let componentId: string
const { runnableComponents, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { runnableComponents, worldStore } = getContext<AppViewerContext>('AppViewerContext')
async function refresh() {
window.dispatchEvent(new Event('pointerup'))

View File

@@ -1,11 +1,11 @@
<script lang="ts">
import { getContext } from 'svelte'
import { findGridItem } from '../../editor/appUtils'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
export let id: string
export let shouldWrap: boolean = false
const { app, breakpoint } = getContext<AppEditorContext>('AppEditorContext')
const { app, breakpoint } = getContext<AppViewerContext>('AppViewerContext')
$: gridItem = findGridItem($app, id)

View File

@@ -12,7 +12,7 @@
import { fade } from 'svelte/transition'
import type { AppInputs, Runnable } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import InputValue from './InputValue.svelte'
import RefreshButton from './RefreshButton.svelte'
@@ -43,7 +43,7 @@
errorByComponent,
mode,
stateId
} = getContext<AppEditorContext>('AppEditorContext')
} = getContext<AppViewerContext>('AppViewerContext')
onMount(() => {
if (autoRefresh) {

View File

@@ -1,9 +1,7 @@
<script lang="ts">
import { Loader2 } from 'lucide-svelte'
import { getContext, onMount } from 'svelte'
import { fade } from 'svelte/transition'
import type { AppInput } from '../../inputType'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { isScriptByNameDefined, isScriptByPathDefined } from '../../utils'
import NonRunnableComponent from './NonRunnableComponent.svelte'
import RunnableComponent from './RunnableComponent.svelte'
@@ -24,7 +22,7 @@
export let gotoNewTab: boolean | undefined = undefined
export let render: boolean
const { staticExporter, noBackend } = getContext<AppEditorContext>('AppEditorContext')
const { staticExporter, noBackend } = getContext<AppViewerContext>('AppViewerContext')
$: if (initializing && result) {
initializing = false
@@ -64,18 +62,8 @@
>
<slot />
</RunnableComponent>
{:else if render}
<NonRunnableComponent bind:result {id} {componentInput}>
{:else}
<NonRunnableComponent {render} bind:result {id} {componentInput}>
<slot />
</NonRunnableComponent>
{:else if !render}
<div class="w-full h-full">
<div
out:fade|local={{ duration: 50 }}
class="absolute inset-0 center-center flex-col bg-white text-gray-600 border"
>
<Loader2 class="animate-spin" size={16} />
<span class="text-xs mt-1">Loading</span>
</div>
</div>
{/if}

View File

@@ -3,7 +3,7 @@
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -15,7 +15,7 @@
export let customCss: ComponentCustomCSS<'text'> | undefined = undefined
export let render: boolean
const { app, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore } = getContext<AppViewerContext>('AppViewerContext')
export const staticOutputs: string[] = ['result']

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -16,7 +16,7 @@
export let customCss: ComponentCustomCSS<'input'> | undefined = undefined
export let render: boolean
const { app, worldStore, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let labelValue: string = 'Title'
let minValue: string = ''
let maxValue: string = ''

View File

@@ -4,7 +4,7 @@
import { FileInput } from '../../../common'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
@@ -14,7 +14,7 @@
export let customCss: ComponentCustomCSS<'container'> | undefined = undefined
export let render: boolean
const { app, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore } = getContext<AppViewerContext>('AppViewerContext')
let acceptedFileTypes: string[] | undefined = undefined
let allowMultiple: boolean | undefined = undefined

View File

@@ -3,7 +3,7 @@
import Select from 'svelte-select'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -18,7 +18,7 @@
export let render: boolean
const { app, worldStore, connectingInput, selectedComponent } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
let items: { label: string; value: string }[]
let placeholder: string = 'Select an item'

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -15,7 +15,7 @@
export let customCss: ComponentCustomCSS<'input'> | undefined = undefined
export let render: boolean
const { app, worldStore, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let defaultValue: number | undefined = undefined
let placeholder: string | undefined = undefined

View File

@@ -3,7 +3,7 @@
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
import { concatCustomCss } from '../../utils'
@@ -17,7 +17,7 @@
undefined
export let render: boolean
const { app, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore } = getContext<AppViewerContext>('AppViewerContext')
let min = 0
let max = 42
let step = 1

View File

@@ -3,7 +3,7 @@
import Select from 'svelte-select'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -18,7 +18,7 @@
export let render: boolean
const { app, worldStore, connectingInput, selectedComponent } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
let items: { label: string; value: any; created?: boolean }[]
let placeholder: string = 'Select an item'

View File

@@ -3,7 +3,7 @@
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
import { twMerge } from 'tailwind-merge'
@@ -17,7 +17,7 @@
undefined
export let render: boolean
const { app, worldStore, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let min = 0
let max = 42
let step = 1

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import AlignWrapper from '../helpers/AlignWrapper.svelte'
import InputValue from '../helpers/InputValue.svelte'
@@ -18,7 +18,7 @@
'textinputcomponent'
export let render: boolean
const { app, worldStore, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let placeholder: string | undefined = undefined
let defaultValue: string | undefined = undefined

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { AppInput } from '../../../inputType'
import type { Output } from '../../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../../types'
import { concatCustomCss } from '../../../utils'
import AlignWrapper from '../../helpers/AlignWrapper.svelte'
import InputValue from '../../helpers/InputValue.svelte'
@@ -16,7 +16,7 @@
export let customCss: ComponentCustomCSS<'input'> | undefined = undefined
export let render: boolean
const { app, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore } = getContext<AppViewerContext>('AppViewerContext')
let defaultValue: number | undefined = undefined

View File

@@ -2,7 +2,7 @@
import { getContext } from 'svelte'
import SubGridEditor from '../../editor/SubGridEditor.svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS, GridItem } from '../../types'
import type { AppViewerContext, ComponentCustomCSS, GridItem } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
@@ -15,7 +15,7 @@
let noPadding: boolean | undefined = undefined
export const staticOutputs: string[] = []
const { app, focusedGrid, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, focusedGrid, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
function onFocus() {
$focusedGrid = {

View File

@@ -3,7 +3,7 @@
import { twMerge } from 'tailwind-merge'
import type { AppInput } from '../../inputType'
import type {
AppEditorContext,
AppViewerContext,
ComponentCustomCSS,
HorizontalAlignment,
VerticalAlignment
@@ -20,7 +20,7 @@
export let position: 'horizontal' | 'vertical'
export let render: boolean
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let size = 2
let color = '#00000060'

View File

@@ -2,7 +2,7 @@
import { getContext } from 'svelte'
import SubGridEditor from '../../editor/SubGridEditor.svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppViewerContext, ComponentCustomCSS } from '../../types'
import InputValue from '../helpers/InputValue.svelte'
import Portal from 'svelte-portal'
import { concatCustomCss } from '../../utils'
@@ -18,7 +18,7 @@
export let noWFull = false
export let render: boolean
const { app, focusedGrid, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, focusedGrid, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
let gridContent: string[] | undefined = undefined
let noPadding: boolean | undefined = undefined

View File

@@ -2,7 +2,7 @@
import { getContext } from 'svelte'
import SubGridEditor from '../../editor/SubGridEditor.svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppEditorContext, AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
import { Pane, Splitpanes } from 'svelte-splitpanes'
@@ -16,8 +16,9 @@
export let panes: number[]
export let render: boolean
const { app, focusedGrid, selectedComponent, componentControl } =
getContext<AppEditorContext>('AppEditorContext')
const { app, focusedGrid, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
const { componentControl } = getContext<AppEditorContext>('AppEditorContext')
let noPadding: boolean | undefined = undefined
@@ -43,10 +44,12 @@
return false
},
right: () => {
if ($focusedGrid?.subGridIndex) {
// subGridIndex can be 0
if ($focusedGrid?.subGridIndex !== undefined) {
const index = $focusedGrid?.subGridIndex ?? 0
if (index < panes.length - 1) {
$focusedGrid.subGridIndex = index - 1
$focusedGrid.subGridIndex = index + 1
return true
}
}

View File

@@ -4,7 +4,7 @@
import SubGridEditor from '../../editor/SubGridEditor.svelte'
import type { AppInput } from '../../inputType'
import type { Output } from '../../rx'
import type { AppEditorContext, ComponentCustomCSS } from '../../types'
import type { AppEditorContext, AppViewerContext, ComponentCustomCSS } from '../../types'
import { concatCustomCss } from '../../utils'
import InputValue from '../helpers/InputValue.svelte'
@@ -18,8 +18,10 @@
export let render: boolean
export const staticOutputs: string[] = ['selectedTabIndex']
const { app, worldStore, focusedGrid, selectedComponent, componentControl } =
getContext<AppEditorContext>('AppEditorContext')
const { app, worldStore, focusedGrid, selectedComponent } =
getContext<AppViewerContext>('AppViewerContext')
const { componentControl } = getContext<AppEditorContext>('AppEditorContext')
let selected: string = tabs[0]
let noPadding: boolean | undefined = undefined

View File

@@ -4,11 +4,12 @@
import { twMerge } from 'tailwind-merge'
import { Pane, Splitpanes } from 'svelte-splitpanes'
import { writable } from 'svelte/store'
import { writable, type Writable } from 'svelte/store'
import { buildWorld, type World } from '../rx'
import type {
App,
AppEditorContext,
AppViewerContext,
ConnectingInput,
EditorBreakpoint,
EditorMode,
@@ -32,11 +33,14 @@
import SettingsPanel from './SettingsPanel.svelte'
import { fly } from 'svelte/transition'
import type { Policy } from '$lib/gen'
import { VariableService, type Policy } from '$lib/gen'
import { page } from '$app/stores'
import CssSettings from './componentsPanel/CssSettings.svelte'
import { initHistory } from '$lib/history'
import { Tour } from '../../tutorial'
import ComponentNavigation from './component/ComponentNavigation.svelte'
import ItemPicker from '$lib/components/ItemPicker.svelte'
import VariableEditor from '$lib/components/VariableEditor.svelte'
export let app: App
export let path: string
@@ -44,6 +48,7 @@
export let policy: Policy
export let summary: string
export let fromHub: boolean = false
export let tour: boolean = false
const appStore = writable<App>(app)
const worldStore = writable<World | undefined>(undefined)
@@ -62,8 +67,9 @@
const runnableComponents = writable<Record<string, () => Promise<void>>>({})
const errorByComponent = writable<Record<string, { error: string; componentId: string }>>({})
const focusedGrid = writable<FocusedGrid | undefined>(undefined)
const pickVariableCallback: Writable<((path: string) => void) | undefined> = writable(undefined)
setContext<AppEditorContext>('AppEditorContext', {
setContext<AppViewerContext>('AppViewerContext', {
worldStore,
staticOutputs,
app: appStore,
@@ -84,9 +90,13 @@
openDebugRun: writable(undefined),
focusedGrid,
stateId: writable(0),
parentWidth: writable(0),
parentWidth: writable(0)
})
setContext<AppEditorContext>('AppEditorContext', {
history,
componentControl: writable({})
componentControl: writable({}),
pickVariableCallback
})
let timeout: NodeJS.Timeout | undefined = undefined
@@ -132,10 +142,22 @@
} else {
selectedTab = 'insert'
}
let itemPicker: ItemPicker | undefined = undefined
$: if ($pickVariableCallback) {
itemPicker?.openDrawer()
}
let variableEditor: VariableEditor | undefined = undefined
</script>
<svelte:window on:hashchange={hashchange} />
{#if tour}
<Tour tutorial="app" />
{/if}
{#if $connectingInput.opened}
<div
class="absolute w-full h-screen bg-black border-2 bg-opacity-25 z-20 flex justify-center items-center"
@@ -180,6 +202,7 @@
$selectedComponent = undefined
$focusedGrid = undefined
}}
id="app-tutorial-3"
class={twMerge(
'bg-gray-100 h-full w-full',
$appStore.css?.['app']?.['viewer']?.class
@@ -205,7 +228,7 @@
</div>
</Pane>
<Pane size={$connectingInput?.opened ? 0 : 30}>
<div class="relative h-full w-full">
<div id="app-tutorial-4" class="relative h-full w-full">
<InlineScriptsPanel />
</div>
</Pane>
@@ -284,3 +307,36 @@
{:else}
App editor not available to operators
{/if}
<ItemPicker
bind:this={itemPicker}
pickCallback={(path, _) => {
$pickVariableCallback?.(path)
}}
itemName="Variable"
extraField="path"
loadItems={async () =>
(await VariableService.listVariable({ workspace: $workspaceStore ?? '' })).map((x) => ({
name: x.path,
...x
}))}
>
<div
slot="submission"
class="flex flex-row-reverse w-full bg-white border-t border-gray-200 rounded-bl-lg rounded-br-lg"
>
<Button
variant="border"
color="blue"
size="sm"
startIcon={{ icon: faPlus }}
on:click={() => {
variableEditor?.initNew?.()
}}
>
New variable
</Button>
</div>
</ItemPicker>
<VariableEditor bind:this={variableEditor} />

View File

@@ -27,7 +27,7 @@
import Tooltip from '$lib/components/Tooltip.svelte'
import { AppService, Job, Policy } from '$lib/gen'
import { redo, undo } from '$lib/history'
import { userStore, workspaceStore } from '$lib/stores'
import { workspaceStore } from '$lib/stores'
import {
faBug,
faClipboard,
@@ -61,7 +61,7 @@
StaticAppInput,
UserAppInput
} from '../inputType'
import type { AppEditorContext } from '../types'
import type { AppEditorContext, AppViewerContext } from '../types'
import { allItems, toStatic } from '../utils'
import AppExportButton from './AppExportButton.svelte'
import AppInputs from './AppInputs.svelte'
@@ -90,9 +90,10 @@
errorByComponent,
openDebugRun,
focusedGrid,
selectedComponent,
history
} = getContext<AppEditorContext>('AppEditorContext')
selectedComponent
} = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
const loading = {
publish: false,

View File

@@ -2,11 +2,11 @@
import { Alert } from '$lib/components/common'
import Toggle from '$lib/components/Toggle.svelte'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../types'
import type { AppViewerContext } from '../types'
import AppComponentInput from './AppComponentInput.svelte'
import InputsSpecsEditor from './settingsPanel/InputsSpecsEditor.svelte'
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let resourceOnly: boolean = true
</script>

View File

@@ -4,7 +4,7 @@
import { buildWorld, type World } from '../rx'
import type {
App,
AppEditorContext,
AppViewerContext,
ConnectingInput,
EditorBreakpoint,
EditorMode
@@ -40,7 +40,7 @@
const runnableComponents = writable<Record<string, () => Promise<void>>>({})
setContext<AppEditorContext>('AppEditorContext', {
setContext<AppViewerContext>('AppViewerContext', {
worldStore,
staticOutputs,
app: appStore,
@@ -61,9 +61,7 @@
openDebugRun: writable(undefined),
focusedGrid: writable(undefined),
stateId: writable(0),
parentWidth: writable(0),
history: writable<any>(undefined),
componentControl: writable({})
parentWidth: writable(0)
})
let mounted = false

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { classNames } from '$lib/utils'
import type { AppEditorContext } from '../types'
import type { AppViewerContext } from '../types'
import { Anchor, Bug, Expand, Move } from 'lucide-svelte'
import { createEventDispatcher, getContext } from 'svelte'
import Popover from '$lib/components/Popover.svelte'
@@ -15,7 +15,7 @@
const dispatch = createEventDispatcher()
const { errorByComponent, openDebugRun } = getContext<AppEditorContext>('AppEditorContext')
const { errorByComponent, openDebugRun } = getContext<AppViewerContext>('AppViewerContext')
$: error = Object.values($errorByComponent).find((e) => e.componentId === component.id)

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { getContext, afterUpdate } from 'svelte'
import type { App, AppEditorContext, GridItem } from '../types'
import type { App, AppEditorContext, AppViewerContext, GridItem } from '../types'
import Grid from '@windmill-labs/svelte-grid'
import { classNames } from '$lib/utils'
import { columnConfiguration, disableDrag, enableDrag, isFixed, toggleFixed } from '../gridUtils'
@@ -26,9 +26,10 @@
summary,
focusedGrid,
parentWidth,
history,
breakpoint
} = getContext<AppEditorContext>('AppEditorContext')
} = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
// The drag is disabled when the user is connecting an input
// or when the user is previewing the app

View File

@@ -1,9 +1,9 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppEditorContext, GridItem } from '../types'
import type { AppViewerContext, GridItem } from '../types'
import ComponentPanel from './settingsPanel/ComponentPanel.svelte'
const { selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
export let gridItems: GridItem[]
export let parent: string | undefined
</script>

View File

@@ -3,9 +3,9 @@
import { ChevronDown, RefreshCw } from 'lucide-svelte'
import { getContext, onMount } from 'svelte'
import Button from '../../common/button/Button.svelte'
import type { AppEditorContext } from '../types'
import type { AppViewerContext } from '../types'
const { runnableComponents } = getContext<AppEditorContext>('AppEditorContext')
const { runnableComponents } = getContext<AppViewerContext>('AppViewerContext')
let loading: boolean = false
let timeout: NodeJS.Timer | undefined = undefined
let interval: number | undefined = undefined
@@ -14,14 +14,14 @@
$: componentNumber = Object.keys($runnableComponents).length
function onClick(stopAfterClear = true) {
if(timeout) {
if (timeout) {
clearInterval(timeout)
timeout = undefined
shouldRefresh = false
if(stopAfterClear) return;
if (stopAfterClear) return
}
refresh()
if(interval) {
if (interval) {
shouldRefresh = true
timeout = setInterval(refresh, interval)
}
@@ -44,12 +44,12 @@
}
function visChange() {
if(document.visibilityState === 'hidden') {
if(timeout) {
if (document.visibilityState === 'hidden') {
if (timeout) {
clearInterval(timeout)
timeout = undefined
}
} else if(shouldRefresh) {
} else if (shouldRefresh) {
timeout = setInterval(refresh, interval)
}
}
@@ -58,7 +58,7 @@
document.addEventListener('visibilitychange', visChange)
return () => {
document.removeEventListener('visibilitychange', visChange)
if(timeout) clearInterval(timeout)
if (timeout) clearInterval(timeout)
}
})
</script>
@@ -66,17 +66,19 @@
<div class="flex items-center">
<Button
on:click={() => onClick()}
color="{timeout ? 'blue' : 'light'}"
variant="{timeout ? 'contained' : 'border'}"
color={timeout ? 'blue' : 'light'}
variant={timeout ? 'contained' : 'border'}
size="xs"
btnClasses="!rounded-r-none {timeout ? '!border !border-blue-500' : ''}"
title="Refresh {componentNumber} component{componentNumber > 1 ? 's' : ''} {interval ? `every ${interval / 1000} seconds` : 'once'}"
title="Refresh {componentNumber} component{componentNumber > 1 ? 's' : ''} {interval
? `every ${interval / 1000} seconds`
: 'once'}"
>
<RefreshCw class={loading ? 'animate-spin' : ''} size={16} />
</Button>
<Dropdown
btnClasses="!rounded-l-none !border-l-0 min-w-[4rem] !px-2"
color="{timeout ? 'blue' : 'light'}"
color={timeout ? 'blue' : 'light'}
variant="border"
dropdownItems={[
{
@@ -86,7 +88,7 @@
...[1, 2, 3, 4, 5, 6].map((i) => ({
displayName: `Every ${i * 5} seconds`,
action: () => setInter(i * 5000)
})),
}))
]}
>
<span class="grow text center">{interval ? `${interval / 1000}s` : 'once'}</span>

View File

@@ -1,11 +1,11 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppEditorContext } from '../types'
import type { AppViewerContext } from '../types'
import GridPanel from './GridPanel.svelte'
import PanelSection from './settingsPanel/common/PanelSection.svelte'
import InputsSpecsEditor from './settingsPanel/InputsSpecsEditor.svelte'
const { selectedComponent, app, stateId } = getContext<AppEditorContext>('AppEditorContext')
const { selectedComponent, app, stateId } = getContext<AppViewerContext>('AppViewerContext')
</script>
{#if $app.grid}

View File

@@ -4,7 +4,7 @@
import Grid from '@windmill-labs/svelte-grid'
import { twMerge } from 'tailwind-merge'
import { columnConfiguration, isFixed, toggleFixed } from '../gridUtils'
import type { AppEditorContext, GridItem } from '../types'
import type { AppEditorContext, AppViewerContext, GridItem } from '../types'
import Component from './component/Component.svelte'
import { expandGriditem, findGridItem } from './appUtils'
import { push } from '$lib/history'
@@ -22,16 +22,10 @@
const dispatch = createEventDispatcher()
const {
app,
connectingInput,
selectedComponent,
focusedGrid,
mode,
parentWidth,
breakpoint,
history
} = getContext<AppEditorContext>('AppEditorContext')
const { app, connectingInput, selectedComponent, focusedGrid, mode, parentWidth, breakpoint } =
getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
$: highlight = id === $focusedGrid?.parentComponentId && shouldHighlight

View File

@@ -3,7 +3,7 @@
import { fade } from 'svelte/transition'
import { Loader2 } from 'lucide-svelte'
import { twMerge } from 'tailwind-merge'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import ComponentHeader from '../ComponentHeader.svelte'
import type { AppComponent } from './components'
import {
@@ -49,7 +49,7 @@
export let render: boolean
const { staticOutputs, mode, connectingInput, app, errorByComponent } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
let hover = false
let initializing: boolean | undefined = undefined
let componentContainerHeight: number = 0
@@ -397,7 +397,6 @@
id={component.id}
customCss={component.customCss}
panes={component.panes}
bind:staticOutputs={$staticOutputs[component.id]}
{componentContainerHeight}
{render}
/>
@@ -407,7 +406,6 @@
id={component.id}
customCss={component.customCss}
panes={component.panes}
bind:staticOutputs={$staticOutputs[component.id]}
{componentContainerHeight}
horizontal={true}
{render}

View File

@@ -1,10 +1,12 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppEditorContext, EditorBreakpoint, GridItem } from '../../types'
import type { AppEditorContext, AppViewerContext, EditorBreakpoint, GridItem } from '../../types'
import { findGridItemParentId } from '../appUtils'
const { app, selectedComponent, breakpoint, componentControl, focusedGrid } =
getContext<AppEditorContext>('AppEditorContext')
const { app, selectedComponent, breakpoint, focusedGrid } =
getContext<AppViewerContext>('AppViewerContext')
const { componentControl } = getContext<AppEditorContext>('AppEditorContext')
function getSortedGridItemsOfChildren(): GridItem[] {
if (!$focusedGrid) {
@@ -38,7 +40,7 @@
)
}
function left(event) {
function left(event: KeyboardEvent) {
if (!$componentControl[$selectedComponent!]?.left?.()) {
const sortedGridItems = getSortedGridItemsOfGrid()
const currentIndex = sortedGridItems.findIndex((item) => item.id === $selectedComponent)
@@ -46,13 +48,12 @@
if (currentIndex !== -1 && currentIndex > 0) {
$selectedComponent = sortedGridItems[currentIndex - 1].id
}
event.preventDefault()
} else {
event.preventDefault()
}
event.preventDefault()
}
function right(event) {
function right(event: KeyboardEvent) {
let r = $componentControl[$selectedComponent!]?.right?.()
if (!r) {
const sortedGridItems = getSortedGridItemsOfGrid()
@@ -61,15 +62,15 @@
if (currentIndex !== -1 && currentIndex < sortedGridItems.length - 1) {
$selectedComponent = sortedGridItems[currentIndex + 1].id
}
event.preventDefault()
} else {
event.preventDefault()
}
event.preventDefault()
}
function down(event) {
function down(event: KeyboardEvent) {
if (!$focusedGrid) {
$selectedComponent = getSortedGridItemsOfChildren()[0]?.id
event.preventDefault()
} else if ($app.subgrids) {
const index = $focusedGrid?.subGridIndex ?? 0
const subgrid = $app.subgrids[`${$selectedComponent}-${index}`]

View File

@@ -72,14 +72,14 @@ return {
},
displaycomponent: {
deno: `export async function main() {
return {
"foo": 42
}
return {
"foo": 42
}
}`,
python3: `def main():
return {
"foo": 42
}`
return {
"foo": 42
}`
},
htmlcomponent: {
deno: `export async function main() {

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import type { AppEditorContext } from '../../types'
import type { AppEditorContext, AppViewerContext } from '../../types'
import { getContext } from 'svelte'
import { fade, slide } from 'svelte/transition'
import { dirtyStore } from '$lib/components/common/confirmationModal/dirtyStore'
@@ -10,8 +10,9 @@
import { push } from '$lib/history'
import { flip } from 'svelte/animate'
const { app, selectedComponent, focusedGrid, history } =
getContext<AppEditorContext>('AppEditorContext')
const { app, selectedComponent, focusedGrid } = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
function addComponent(appComponentType: AppComponent['type']): void {
push(history, $app)
@@ -64,7 +65,11 @@
No components found
</div>
{:else}
<div in:fade|local={{ duration: 50, delay: 50 }} out:fade|local={{ duration: 50 }}>
<div
id="app-tutorial-1"
in:fade|local={{ duration: 50, delay: 50 }}
out:fade|local={{ duration: 50 }}
>
{#each componentsFiltered as { title, components }, index (index)}
{#if components.length}
<div transition:slide|local={{ duration: 300 }}>

View File

@@ -4,7 +4,7 @@
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
import { emptyString } from '$lib/utils'
import { Tab, TabContent, Tabs } from '../../../common'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import ListItem from './ListItem.svelte'
import { isOpenStore } from './store'
import CssProperty from './CssProperty.svelte'
@@ -24,7 +24,7 @@
ids: string[]
}
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
let rawCode = ''
let viewJsonSchema = false

View File

@@ -2,12 +2,12 @@
import ObjectViewer from '$lib/components/propertyPicker/ObjectViewer.svelte'
import { getContext } from 'svelte'
import type { Output } from '../../rx'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
export let outputs: string[] = []
export let componentId: string
const { worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { worldStore } = getContext<AppViewerContext>('AppViewerContext')
let object = {}

View File

@@ -4,14 +4,14 @@
import { getContext } from 'svelte'
import { flip } from 'svelte/animate'
import { fade } from 'svelte/transition'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { findGridItem } from '../appUtils'
import { components } from '../component'
import PanelSection from '../settingsPanel/common/PanelSection.svelte'
import ComponentOutputViewer from './ComponentOutputViewer.svelte'
const { connectingInput, staticOutputs, worldStore, selectedComponent, app } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
function connectInput(componentId: string, path: string) {
if ($connectingInput) {
@@ -78,7 +78,7 @@
{/if}
</div>
</div>
<div class="relative p-2">
<div id="app-tutorial-2" class="relative p-2">
{#each filteredPanels as [componentId, outputs] (componentId)}
<div
animate:flip={{ duration: 300 }}

View File

@@ -11,7 +11,7 @@
import { Building, Globe2 } from 'lucide-svelte'
import { createEventDispatcher, getContext } from 'svelte'
import { fly } from 'svelte/transition'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { defaultCode } from '../component'
import InlineScriptList from '../settingsPanel/mainInput/InlineScriptList.svelte'
import WorkspaceScriptList from '../settingsPanel/mainInput/WorkspaceScriptList.svelte'
@@ -23,7 +23,7 @@
let filter: string = ''
let picker: Drawer
const { appPath, app } = getContext<AppEditorContext>('AppEditorContext')
const { appPath, app } = getContext<AppViewerContext>('AppViewerContext')
const dispatch = createEventDispatcher()
async function inferInlineScriptSchema(

View File

@@ -2,7 +2,7 @@
import Button from '$lib/components/common/button/Button.svelte'
import type { Preview } from '$lib/gen'
import { createEventDispatcher, getContext, onMount } from 'svelte'
import type { AppEditorContext, InlineScript } from '../../types'
import type { AppViewerContext, InlineScript } from '../../types'
import { CornerDownLeft, Maximize2, Plus, Trash2, X } from 'lucide-svelte'
import InlineScriptEditorDrawer from './InlineScriptEditorDrawer.svelte'
import { inferArgs } from '$lib/infer'
@@ -26,7 +26,7 @@
export let fields: Record<string, AppInput> = {}
export let syncFields: boolean = false
const { runnableComponents, stateId } = getContext<AppEditorContext>('AppEditorContext')
const { runnableComponents, stateId } = getContext<AppViewerContext>('AppViewerContext')
let editor: Editor
let validCode = true

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import SplitPanesWrapper from '$lib/components/splitPanes/SplitPanesWrapper.svelte'
import { Pane, Splitpanes } from 'svelte-splitpanes'
import InlineScriptsPanelList from './InlineScriptsPanelList.svelte'
@@ -9,7 +9,7 @@
import InlineScriptEditorPanel from './InlineScriptEditorPanel.svelte'
const { app, staticOutputs, runnableComponents } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
let selectedScriptComponentId: string | undefined = undefined

View File

@@ -3,7 +3,7 @@
import { Plus } from 'lucide-svelte'
import { getContext } from 'svelte'
import Tooltip from '../../../Tooltip.svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { getAllScriptNames } from '../../utils'
import PanelSection from '../settingsPanel/common/PanelSection.svelte'
import { getAppScripts } from './utils'
@@ -11,7 +11,7 @@
const PREFIX = 'script-selector-' as const
export let selectedScriptComponentId: string | undefined = undefined
const { app, selectedComponent } = getContext<AppEditorContext>('AppEditorContext')
const { app, selectedComponent } = getContext<AppViewerContext>('AppViewerContext')
function selectScript(id: string) {
selectedScriptComponentId = id

View File

@@ -3,12 +3,12 @@
import { faArrowRight, faCode, faPen } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { AppInput } from '../../inputType'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
export let componentInput: AppInput
export let disableStatic: boolean = false
const { onchange } = getContext<AppEditorContext>('AppEditorContext')
const { onchange } = getContext<AppViewerContext>('AppViewerContext')
$: if (componentInput.fieldType == 'template' && componentInput.type == 'static') {
//@ts-ignore

View File

@@ -2,7 +2,7 @@
import Button from '$lib/components/common/button/Button.svelte'
import { faChevronDown, faChevronUp, faCopy, faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppEditorContext, AppViewerContext } from '../../types'
import PanelSection from './common/PanelSection.svelte'
import InputsSpecsEditor from './InputsSpecsEditor.svelte'
import TableActions from './TableActions.svelte'
@@ -42,9 +42,10 @@
selectedComponent,
worldStore,
focusedGrid,
stateId,
history
} = getContext<AppEditorContext>('AppEditorContext')
stateId
} = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
function duplicateElement(id: string) {
push(history, $app)

View File

@@ -2,7 +2,7 @@
import Button from '$lib/components/common/button/Button.svelte'
import { faPlus, faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { deleteGridItem } from '../appUtils'
import type { AppComponent } from '../component'
import PanelSection from './common/PanelSection.svelte'
@@ -11,7 +11,7 @@
export let component: AppComponent
const { app, staticOutputs, runnableComponents } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
function addTab() {
const numberOfPanes = panes.length

View File

@@ -2,7 +2,7 @@
import Button from '$lib/components/common/button/Button.svelte'
import { faPlus, faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { deleteGridItem } from '../appUtils'
import type { AppComponent } from '../component'
import PanelSection from './common/PanelSection.svelte'
@@ -11,7 +11,7 @@
export let component: AppComponent
const { app, staticOutputs, runnableComponents, focusedGrid } =
getContext<AppEditorContext>('AppEditorContext')
getContext<AppViewerContext>('AppViewerContext')
function addTab() {
const numberOfTabs = tabs.length

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import VariableEditor from '$lib/components/VariableEditor.svelte'
import type {
ConnectedAppInput,
EvalAppInput,

View File

@@ -5,7 +5,7 @@
import { fieldTypeToTsType } from '../../utils'
import InputsSpecEditor from './InputsSpecEditor.svelte'
import { getContext } from 'svelte'
import type { AppEditorContext, BaseAppComponent } from '../../types'
import type { AppViewerContext, BaseAppComponent } from '../../types'
import Tooltip from '$lib/components/Tooltip.svelte'
import Popover from '$lib/components/Popover.svelte'
@@ -16,7 +16,7 @@
export let rowColumns = false
export let resourceOnly = false
const { connectingInput } = getContext<AppEditorContext>('AppEditorContext')
const { connectingInput } = getContext<AppViewerContext>('AppViewerContext')
</script>
{#if inputSpecs}

View File

@@ -4,7 +4,7 @@
import { push } from '$lib/history'
import { faCopy } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { App, AppEditorContext } from '../../types'
import type { App, AppEditorContext, AppViewerContext } from '../../types'
import {
createNewGridItem,
deleteGridItem,
@@ -19,7 +19,8 @@
let selectedOption: string
const { app, history } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
function listAllSubGrids(app: App) {
return app.subgrids ? Object.keys(app.subgrids) : []

View File

@@ -1,13 +1,13 @@
<script lang="ts">
import Badge from '$lib/components/common/badge/Badge.svelte'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import PanelSection from './common/PanelSection.svelte'
export let recomputeIds: string[] | undefined = undefined
export let ownId: string
const { runnableComponents } = getContext<AppEditorContext>('AppEditorContext')
const { runnableComponents } = getContext<AppViewerContext>('AppViewerContext')
function onChange(
event: Event & {

View File

@@ -4,11 +4,11 @@
import { faClose, faEdit } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import type { ResultAppInput } from '../../inputType'
import type { AppEditorContext } from '../../types'
import type { AppViewerContext } from '../../types'
import { clearResultAppInput } from '../../utils'
import InlineScriptEditorDrawer from '../inlineScriptsPanel/InlineScriptEditorDrawer.svelte'
const { app } = getContext<AppEditorContext>('AppEditorContext')
const { app } = getContext<AppViewerContext>('AppViewerContext')
export let appInput: ResultAppInput
let inlineScriptEditorDrawer: InlineScriptEditorDrawer

View File

@@ -6,7 +6,7 @@
import { faPlus, faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import { Icon } from 'svelte-awesome'
import type { AppEditorContext, BaseAppComponent } from '../../types'
import type { AppViewerContext, BaseAppComponent } from '../../types'
import type { ButtonComponent } from '../component'
import PanelSection from './common/PanelSection.svelte'
import TableActionLabel from './TableActionLabel.svelte'
@@ -14,7 +14,7 @@
export let components: (BaseAppComponent & ButtonComponent)[]
export let id: string
const { selectedComponent, staticOutputs } = getContext<AppEditorContext>('AppEditorContext')
const { selectedComponent, staticOutputs } = getContext<AppViewerContext>('AppViewerContext')
function addComponent() {
const actionId = getNextId(components.map((x) => x.id.split('_')[1]))

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import type { AppEditorContext } from '../../../types'
import type { AppViewerContext } from '../../../types'
import { Badge, Button } from '$lib/components/common'
import { faArrowRight, faClose } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
@@ -7,7 +7,7 @@
export let componentInput: ConnectedAppInput
const { connectingInput } = getContext<AppEditorContext>('AppEditorContext')
const { connectingInput } = getContext<AppViewerContext>('AppViewerContext')
function applyConnection() {
if (

View File

@@ -2,7 +2,7 @@
import type { EvalAppInput } from '../../../inputType'
import { getContext } from 'svelte'
import type { AppEditorContext } from '$lib/components/apps/types'
import type { AppViewerContext } from '$lib/components/apps/types'
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
import { buildExtraLib } from '$lib/components/apps/utils'
@@ -10,7 +10,7 @@
export let id: string
export let hasRows: boolean = false
const { onchange, worldStore } = getContext<AppEditorContext>('AppEditorContext')
const { onchange, worldStore } = getContext<AppViewerContext>('AppViewerContext')
$: componentInput && onchange?.()

View File

@@ -6,28 +6,31 @@
import ResourcePicker from '$lib/components/ResourcePicker.svelte'
import JsonEditor from './JsonEditor.svelte'
import { getContext } from 'svelte'
import type { AppEditorContext } from '$lib/components/apps/types'
import type { AppEditorContext, AppViewerContext } from '$lib/components/apps/types'
import IconSelectInput from './IconSelectInput.svelte'
import ColorInput from './ColorInput.svelte'
import { Icon } from 'svelte-awesome'
import { faDollarSign } from '@fortawesome/free-solid-svg-icons'
export let componentInput: StaticAppInput | undefined
const { onchange } = getContext<AppEditorContext>('AppEditorContext')
const { onchange } = getContext<AppViewerContext>('AppViewerContext')
const { pickVariableCallback } = getContext<AppEditorContext>('AppEditorContext')
$: componentInput && onchange?.()
</script>
{#if componentInput?.type === 'static'}
{#if componentInput.fieldType === 'number'}
<input type="number" bind:value={componentInput.value} />
<input on:keydown|stopPropagation type="number" bind:value={componentInput.value} />
{:else if componentInput.fieldType === 'textarea'}
<textarea bind:value={componentInput.value} />
<textarea on:keydown|stopPropagation bind:value={componentInput.value} />
{:else if componentInput.fieldType === 'date'}
<input type="date" bind:value={componentInput.value} />
<input on:keydown|stopPropagation type="date" bind:value={componentInput.value} />
{:else if componentInput.fieldType === 'boolean'}
<Toggle bind:checked={componentInput.value} />
{:else if componentInput.fieldType === 'select'}
<select bind:value={componentInput.value}>
<select on:keydown|stopPropagation on:keydown|stopPropagation bind:value={componentInput.value}>
{#each staticValues[componentInput.optionValuesKey] || [] as option}
<option value={option}>
{option}
@@ -64,6 +67,25 @@
{:else if componentInput.fieldType === 'array'}
<ArrayStaticInputEditor bind:componentInput on:deleteArrayItem />
{:else}
<input type="text" placeholder="Static value" bind:value={componentInput.value} />
<div class="flex gap-1">
<input
on:keydown|stopPropagation
type="text"
placeholder="Static value"
bind:value={componentInput.value}
/>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="min-w-min min-h-[34px] items-center leading-4 px-3 text-gray-600 cursor-pointer border border-gray-700 rounded center-center"
on:click={() => {
$pickVariableCallback = (variable) => {
if (componentInput) {
componentInput.value = `$var:${variable}`
}
}
}}
><Icon data={faDollarSign} />
</div>
</div>
{/if}
{/if}

View File

@@ -7,7 +7,7 @@
import type { ResultAppInput } from '$lib/components/apps/inputType'
import WorkspaceScriptList from './WorkspaceScriptList.svelte'
import WorkspaceFlowList from './WorkspaceFlowList.svelte'
import type { AppEditorContext, GridItem, InlineScript } from '$lib/components/apps/types'
import type { AppViewerContext, GridItem, InlineScript } from '$lib/components/apps/types'
import { getContext } from 'svelte'
import type { Schema } from '$lib/common'
import { getAllScriptNames, loadSchema, schemaToInputsSpec } from '$lib/components/apps/utils'
@@ -22,7 +22,7 @@
let filter: string = ''
let picker: Drawer
const { app, workspace } = getContext<AppEditorContext>('AppEditorContext')
const { app, workspace } = getContext<AppViewerContext>('AppViewerContext')
async function loadSchemaFromTriggerable(
path: string,

View File

@@ -3,6 +3,7 @@ import type { Preview } from '$lib/gen'
import type { History } from '$lib/history'
import type { FilledItem } from '@windmill-labs/svelte-grid'
import type { Writable } from 'svelte/store'
import type VariableEditor from '../VariableEditor.svelte'
import type { AppComponent } from './editor/component/components'
import type {
AppInput,
@@ -111,7 +112,7 @@ export type ConnectingInput = {
hoveredComponent: string | undefined
}
export type AppEditorContext = {
export type AppViewerContext = {
worldStore: Writable<World | undefined>
staticOutputs: Writable<Record<string, string[]>>
app: Writable<App>
@@ -133,8 +134,12 @@ export type AppEditorContext = {
focusedGrid: Writable<FocusedGrid | undefined>
stateId: Writable<number>
parentWidth: Writable<number>
}
export type AppEditorContext = {
history: History<App>
componentControl: Writable<Record<string, { left?: () => boolean; right?: () => boolean }>>
pickVariableCallback: Writable<((path: string) => void) | undefined>
}
export type FocusedGrid = { parentComponentId: string; subGridIndex: number }

View File

@@ -21,7 +21,7 @@
}[kind]
</script>
<div
<li
class="hover:bg-gray-50 w-full inline-flex items-center p-4 gap-4 first-of-type:!border-t-0
first-of-type:rounded-t-md last-of-type:rounded-b-md {color}"
>
@@ -61,4 +61,4 @@ first-of-type:rounded-t-md last-of-type:rounded-b-md {color}"
/>
</div>
{/if}
</div>
</li>

Some files were not shown because too many files have changed in this diff Show More