jac-client 0.2.6__py3-none-any.whl → 0.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jac_client/examples/all-in-one/src/app.jac +473 -741
- jac_client/examples/all-in-one/src/components/CategoryFilter.jac +35 -0
- jac_client/examples/all-in-one/src/components/Header.jac +13 -0
- jac_client/examples/all-in-one/src/components/ProfitOverview.jac +50 -0
- jac_client/examples/all-in-one/src/components/Summary.jac +53 -0
- jac_client/examples/all-in-one/src/components/TransactionForm.jac +158 -0
- jac_client/examples/all-in-one/src/components/TransactionItem.jac +55 -0
- jac_client/examples/all-in-one/src/components/TransactionList.jac +37 -0
- jac_client/examples/all-in-one/src/components/navigation.jac +132 -0
- jac_client/examples/all-in-one/src/constants/categories.jac +37 -0
- jac_client/examples/all-in-one/src/constants/clients.jac +13 -0
- jac_client/examples/all-in-one/src/context/BudgetContext.jac +28 -0
- jac_client/examples/all-in-one/src/hooks/useBudget.jac +116 -0
- jac_client/examples/all-in-one/src/hooks/useLocalStorage.jac +36 -0
- jac_client/examples/all-in-one/src/pages/BudgetPlanner.cl.jac +70 -0
- jac_client/examples/all-in-one/src/pages/BudgetPlanner.jac +126 -0
- jac_client/examples/all-in-one/src/pages/FeaturesTest.cl.jac +552 -0
- jac_client/examples/all-in-one/src/pages/FeaturesTest.jac +126 -0
- jac_client/examples/all-in-one/src/pages/LandingPage.jac +101 -0
- jac_client/examples/all-in-one/src/pages/loginPage.jac +132 -0
- jac_client/examples/all-in-one/src/pages/nestedDemo.jac +61 -0
- jac_client/examples/all-in-one/src/pages/notFound.jac +24 -0
- jac_client/examples/all-in-one/src/pages/signupPage.jac +133 -0
- jac_client/examples/all-in-one/src/utils/formatters.jac +52 -0
- jac_client/examples/asset-serving/css-with-image/src/app.jac +3 -3
- jac_client/examples/asset-serving/image-asset/src/app.jac +3 -3
- jac_client/examples/asset-serving/import-alias/src/app.jac +3 -3
- jac_client/examples/basic/src/app.jac +3 -3
- jac_client/examples/basic-auth/src/app.jac +31 -37
- jac_client/examples/basic-auth-with-router/src/app.jac +16 -16
- jac_client/examples/basic-full-stack/src/app.jac +24 -30
- jac_client/examples/css-styling/js-styling/src/app.jac +5 -5
- jac_client/examples/css-styling/material-ui/src/app.jac +5 -5
- jac_client/examples/css-styling/pure-css/src/app.jac +5 -5
- jac_client/examples/css-styling/sass-example/src/app.jac +5 -5
- jac_client/examples/css-styling/styled-components/src/app.jac +5 -5
- jac_client/examples/css-styling/tailwind-example/src/app.jac +5 -5
- jac_client/examples/full-stack-with-auth/src/app.jac +16 -16
- jac_client/examples/ts-support/src/app.jac +4 -4
- jac_client/examples/with-router/src/app.jac +4 -4
- jac_client/plugin/cli.jac +155 -203
- jac_client/plugin/client_runtime.cl.jac +5 -1
- jac_client/plugin/impl/client.impl.jac +74 -12
- jac_client/plugin/plugin_config.jac +11 -11
- jac_client/plugin/src/compiler.jac +2 -1
- jac_client/plugin/src/impl/babel_processor.impl.jac +22 -17
- jac_client/plugin/src/impl/compiler.impl.jac +57 -18
- jac_client/plugin/src/impl/vite_bundler.impl.jac +66 -102
- jac_client/plugin/src/package_installer.jac +1 -1
- jac_client/plugin/src/vite_bundler.jac +1 -0
- jac_client/tests/conftest.py +10 -8
- jac_client/tests/fixtures/spawn_test/app.jac +15 -18
- jac_client/tests/fixtures/with-ts/app.jac +4 -4
- jac_client/tests/test_cli.py +99 -45
- jac_client/tests/test_it.py +290 -79
- {jac_client-0.2.6.dist-info → jac_client-0.2.7.dist-info}/METADATA +16 -7
- jac_client-0.2.7.dist-info/RECORD +97 -0
- jac_client-0.2.6.dist-info/RECORD +0 -74
- {jac_client-0.2.6.dist-info → jac_client-0.2.7.dist-info}/WHEEL +0 -0
- {jac_client-0.2.6.dist-info → jac_client-0.2.7.dist-info}/entry_points.txt +0 -0
- {jac_client-0.2.6.dist-info → jac_client-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Custom hook for budget operations
|
|
2
|
+
# Demonstrates: custom hooks, useState, array methods
|
|
3
|
+
|
|
4
|
+
cl import from react { useCallback, useMemo }
|
|
5
|
+
|
|
6
|
+
cl {
|
|
7
|
+
# Main budget management hook
|
|
8
|
+
def:pub useBudget() -> dict {
|
|
9
|
+
# Simple useState - no complex localStorage hook
|
|
10
|
+
[transactions, setTransactions] = useState([]);
|
|
11
|
+
|
|
12
|
+
# Add a new transaction
|
|
13
|
+
def addTransaction(description: str, amount: float, category: str, txType: str, isBusiness: bool, clientName: str) -> None {
|
|
14
|
+
newTx = {
|
|
15
|
+
"id": Date.now().toString(),
|
|
16
|
+
"description": description,
|
|
17
|
+
"amount": amount,
|
|
18
|
+
"category": category,
|
|
19
|
+
"type": txType,
|
|
20
|
+
"date": Reflect.construct(Date, []).toISOString(),
|
|
21
|
+
"isBusinessTransaction": isBusiness,
|
|
22
|
+
"clientName": clientName if clientName != "" else None
|
|
23
|
+
};
|
|
24
|
+
setTransactions(transactions.concat([newTx]));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Delete a transaction by ID
|
|
28
|
+
def deleteTransaction(id: str) -> None {
|
|
29
|
+
filtered = transactions.filter(lambda tx: dict -> bool {
|
|
30
|
+
return tx["id"] != id;
|
|
31
|
+
});
|
|
32
|
+
setTransactions(filtered);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Calculate totals
|
|
36
|
+
totalIncome = 0.0;
|
|
37
|
+
totalExpenses = 0.0;
|
|
38
|
+
for tx in transactions {
|
|
39
|
+
if tx["type"] == "income" {
|
|
40
|
+
totalIncome = totalIncome + tx["amount"];
|
|
41
|
+
} else {
|
|
42
|
+
totalExpenses = totalExpenses + tx["amount"];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
balance = totalIncome - totalExpenses;
|
|
46
|
+
|
|
47
|
+
# Calculate business/personal breakdown
|
|
48
|
+
businessIncome = 0.0;
|
|
49
|
+
businessExpenses = 0.0;
|
|
50
|
+
personalIncome = 0.0;
|
|
51
|
+
personalExpenses = 0.0;
|
|
52
|
+
|
|
53
|
+
for tx in transactions {
|
|
54
|
+
isBusiness = tx["isBusinessTransaction"] || false;
|
|
55
|
+
amount = tx["amount"];
|
|
56
|
+
|
|
57
|
+
if tx["type"] == "income" {
|
|
58
|
+
if isBusiness {
|
|
59
|
+
businessIncome = businessIncome + amount;
|
|
60
|
+
} else {
|
|
61
|
+
personalIncome = personalIncome + amount;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if isBusiness {
|
|
65
|
+
businessExpenses = businessExpenses + amount;
|
|
66
|
+
} else {
|
|
67
|
+
personalExpenses = personalExpenses + amount;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Tax calculations
|
|
73
|
+
TAX_RATE = 0.20;
|
|
74
|
+
taxReserve = businessIncome * TAX_RATE;
|
|
75
|
+
netProfit = businessIncome - businessExpenses - taxReserve;
|
|
76
|
+
|
|
77
|
+
# Get expense breakdown by category (for chart)
|
|
78
|
+
def getExpensesByCategory() -> list {
|
|
79
|
+
categoryTotals = {};
|
|
80
|
+
for tx in transactions {
|
|
81
|
+
if tx["type"] == "expense" {
|
|
82
|
+
cat = tx["category"];
|
|
83
|
+
if categoryTotals[cat] {
|
|
84
|
+
categoryTotals[cat] = categoryTotals[cat] + tx["amount"];
|
|
85
|
+
} else {
|
|
86
|
+
categoryTotals[cat] = tx["amount"];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
result = [];
|
|
91
|
+
for key in Object.keys(categoryTotals) {
|
|
92
|
+
result = result.concat([{
|
|
93
|
+
"name": key,
|
|
94
|
+
"value": categoryTotals[key]
|
|
95
|
+
}]);
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
"transactions": transactions,
|
|
102
|
+
"addTransaction": addTransaction,
|
|
103
|
+
"deleteTransaction": deleteTransaction,
|
|
104
|
+
"totalIncome": totalIncome,
|
|
105
|
+
"totalExpenses": totalExpenses,
|
|
106
|
+
"balance": balance,
|
|
107
|
+
"expensesByCategory": getExpensesByCategory(),
|
|
108
|
+
"businessIncome": businessIncome,
|
|
109
|
+
"businessExpenses": businessExpenses,
|
|
110
|
+
"personalIncome": personalIncome,
|
|
111
|
+
"personalExpenses": personalExpenses,
|
|
112
|
+
"taxReserve": taxReserve,
|
|
113
|
+
"netProfit": netProfit
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Custom hook for localStorage persistence
|
|
2
|
+
# Demonstrates: custom hooks, try/except error handling, useEffect
|
|
3
|
+
|
|
4
|
+
cl import from react { useEffect }
|
|
5
|
+
|
|
6
|
+
cl {
|
|
7
|
+
# Custom hook for syncing state with localStorage
|
|
8
|
+
def useLocalStorage(key: str, initialValue: list) -> list {
|
|
9
|
+
# Initialize state with value from localStorage or default
|
|
10
|
+
[storedValue, setStoredValue] = useState(lambda -> any {
|
|
11
|
+
try {
|
|
12
|
+
item = window.localStorage.getItem(key);
|
|
13
|
+
if item {
|
|
14
|
+
return JSON.parse(item);
|
|
15
|
+
}else{
|
|
16
|
+
return initialValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
} except Exception as e {
|
|
20
|
+
console.log("Error reading from localStorage");
|
|
21
|
+
return initialValue;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
# Update localStorage when state changes
|
|
26
|
+
useEffect(lambda -> None {
|
|
27
|
+
try {
|
|
28
|
+
window.localStorage.setItem(key, JSON.stringify(storedValue));
|
|
29
|
+
} except Exception as e {
|
|
30
|
+
console.log("Error saving to localStorage");
|
|
31
|
+
}
|
|
32
|
+
}, [key, storedValue]);
|
|
33
|
+
|
|
34
|
+
return [storedValue, setStoredValue];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Budget Planner Page
|
|
2
|
+
# Main application page with budget tracking features
|
|
3
|
+
|
|
4
|
+
# Local JAC file imports
|
|
5
|
+
cl import from ..context.BudgetContext { useBudgetContext }
|
|
6
|
+
cl import from ..components.Header { Header }
|
|
7
|
+
cl import from ..components.Summary { Summary }
|
|
8
|
+
cl import from ..components.ProfitOverview { ProfitOverview }
|
|
9
|
+
cl import from ..components.TransactionForm { TransactionForm }
|
|
10
|
+
cl import from ..components.TransactionList { TransactionList }
|
|
11
|
+
cl import from ..components.CategoryFilter { CategoryFilter }
|
|
12
|
+
cl import from ..constants.categories { CATEGORY_COLORS }
|
|
13
|
+
|
|
14
|
+
# cl import from "..components.PieChart.tsx" { PieChart }
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
cl def:pub BudgetPlanner() -> any {
|
|
18
|
+
[filter, setFilter] = useState("ALL");
|
|
19
|
+
budget = useBudgetContext();
|
|
20
|
+
|
|
21
|
+
# Filter transactions based on selected category
|
|
22
|
+
filtered = budget["transactions"];
|
|
23
|
+
if filter != "ALL" {
|
|
24
|
+
filtered = filtered.filter(lambda tx: dict -> bool {
|
|
25
|
+
return tx["category"] == filter;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Sort by date (newest first)
|
|
30
|
+
sorted = filtered.slice().sort(lambda a: dict, b: dict -> int {
|
|
31
|
+
return Reflect.construct(Date, [b["date"]]).getTime() - Reflect.construct(Date, [a["date"]]).getTime();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
# Prepare chart data with colors
|
|
35
|
+
chartData = budget["expensesByCategory"].map(lambda item: dict -> dict {
|
|
36
|
+
return {
|
|
37
|
+
"name": item["name"],
|
|
38
|
+
"value": item["value"],
|
|
39
|
+
"color": CATEGORY_COLORS[item["name"]]
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return <div className="app-container">
|
|
44
|
+
<Header />
|
|
45
|
+
|
|
46
|
+
<main className="main-content">
|
|
47
|
+
<div className="left-panel">
|
|
48
|
+
<Summary />
|
|
49
|
+
<ProfitOverview />
|
|
50
|
+
<TransactionForm />
|
|
51
|
+
<CategoryFilter
|
|
52
|
+
selectedCategory={filter}
|
|
53
|
+
onSelect={setFilter}
|
|
54
|
+
/>
|
|
55
|
+
<TransactionList
|
|
56
|
+
transactions={sorted}
|
|
57
|
+
onDelete={budget["deleteTransaction"]}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<div className="right-panel">
|
|
62
|
+
# <PieChart
|
|
63
|
+
# data={chartData}
|
|
64
|
+
# title="Expense Breakdown"
|
|
65
|
+
# colors={CATEGORY_COLORS}
|
|
66
|
+
# />
|
|
67
|
+
</div>
|
|
68
|
+
</main>
|
|
69
|
+
</div>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Features Test Page - Backend Logic
|
|
2
|
+
# This file is intentionally kept empty to demonstrate the separation of concerns
|
|
3
|
+
# where UI logic resides in .cl.jac files and backend walker logic in app.jac
|
|
4
|
+
|
|
5
|
+
# All walker implementations for this feature are in src/app.jac
|
|
6
|
+
# This demonstrates that you can have separate .jac files for different purposes
|
|
7
|
+
# Features Test - Backend Walkers
|
|
8
|
+
# This file demonstrates walker functionality for testing various JAC features
|
|
9
|
+
|
|
10
|
+
import from datetime { datetime, timedelta }
|
|
11
|
+
|
|
12
|
+
# Node definition for storing test data
|
|
13
|
+
node TestData {
|
|
14
|
+
has message: str;
|
|
15
|
+
has count: int = 0;
|
|
16
|
+
has created_at: str = "";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Walker: Create test data
|
|
20
|
+
walker create_test_data {
|
|
21
|
+
has message: str;
|
|
22
|
+
|
|
23
|
+
can create with `root entry {
|
|
24
|
+
new_data = here ++> TestData(
|
|
25
|
+
message=self.message,
|
|
26
|
+
count=1,
|
|
27
|
+
created_at=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
28
|
+
);
|
|
29
|
+
report new_data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Walker: Read all test data
|
|
34
|
+
walker read_test_data {
|
|
35
|
+
can read with `root entry {
|
|
36
|
+
visit [-->(`?TestData)];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
can report_data with exit {
|
|
40
|
+
report here;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Walker: Update test data
|
|
45
|
+
walker update_test_data {
|
|
46
|
+
has new_message: str;
|
|
47
|
+
|
|
48
|
+
can update with TestData entry {
|
|
49
|
+
here.message = self.new_message;
|
|
50
|
+
here.count = here.count + 1;
|
|
51
|
+
report here;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Walker: Delete test data
|
|
56
|
+
walker delete_test_data {
|
|
57
|
+
can delete with TestData entry {
|
|
58
|
+
del here;
|
|
59
|
+
report {"status": "deleted"};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# Walker: String manipulation test
|
|
64
|
+
walker test_string_methods {
|
|
65
|
+
has input_text: str;
|
|
66
|
+
|
|
67
|
+
can process with `root entry {
|
|
68
|
+
result = {
|
|
69
|
+
"original": self.input_text,
|
|
70
|
+
"uppercase": self.input_text.upper(),
|
|
71
|
+
"lowercase": self.input_text.lower(),
|
|
72
|
+
"capitalized": self.input_text.capitalize(),
|
|
73
|
+
"reversed": self.input_text[::-1],
|
|
74
|
+
"length": len(self.input_text),
|
|
75
|
+
"words": self.input_text.split(),
|
|
76
|
+
"trimmed": self.input_text.strip(),
|
|
77
|
+
"replaced": self.input_text.replace("test", "demo")
|
|
78
|
+
};
|
|
79
|
+
report result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Walker: Array/List operations test
|
|
84
|
+
walker test_list_operations {
|
|
85
|
+
has numbers: list;
|
|
86
|
+
|
|
87
|
+
can process with `root entry {
|
|
88
|
+
result = {
|
|
89
|
+
"original": self.numbers,
|
|
90
|
+
"sorted": sorted(self.numbers),
|
|
91
|
+
"reversed": list(reversed(self.numbers)),
|
|
92
|
+
"sum": sum(self.numbers),
|
|
93
|
+
"max": max(self.numbers) if len(self.numbers) > 0 else 0,
|
|
94
|
+
"min": min(self.numbers) if len(self.numbers) > 0 else 0,
|
|
95
|
+
"length": len(self.numbers),
|
|
96
|
+
"doubled": [x * 2 for x in self.numbers]
|
|
97
|
+
};
|
|
98
|
+
report result;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Walker: Complex data processing
|
|
103
|
+
walker process_complex_data {
|
|
104
|
+
has items: list;
|
|
105
|
+
|
|
106
|
+
can process with `root entry {
|
|
107
|
+
processed = [];
|
|
108
|
+
for item in self.items {
|
|
109
|
+
processed.append({
|
|
110
|
+
"id": item.get("id", 0),
|
|
111
|
+
"name": item.get("name", "").upper(),
|
|
112
|
+
"value": item.get("value", 0) * 2,
|
|
113
|
+
"processed_at": datetime.now().strftime("%H:%M:%S")
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
result = {
|
|
118
|
+
"original_count": len(self.items),
|
|
119
|
+
"processed_count": len(processed),
|
|
120
|
+
"items": processed,
|
|
121
|
+
"total_value": sum([p["value"] for p in processed])
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
report result;
|
|
125
|
+
}
|
|
126
|
+
}
|