Skip to content

Commit 0204451

Browse files
committed
fix typos & improve error messages
1 parent 0848919 commit 0204451

File tree

14 files changed

+67
-243
lines changed

14 files changed

+67
-243
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ Cargo.lock
1414
node_modules/
1515

1616
dist
17+
dist-js
18+
!dist-js/*.iife.js

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tauri-plugin-python"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
authors = [ "Marco Mengelkoch" ]
55
description = "A tauri 2 plugin to use python code in the backend."
66
keywords = ["rust", "python", "tauri", "gui"]

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ which can be complicated, especially for mobile targets.
1212

1313
The plugin reads by default the file `src-tauri/src-python/main.py` during
1414
startup and runs it immediately. Make sure to add all your python source as tauri resource,
15-
so it is shipped together with your productioon binaries. Python functions are all registered during plugin initialization
15+
so it is shipped together with your production binaries. Python functions are all registered during plugin initialization
1616
and can get called during application workflow.
1717

1818

@@ -58,11 +58,10 @@ Javascript in [examples/plain-javascript](https://github.com/marcomq/tauri-plugi
5858

5959
## Add the plugin to an existing tauri application
6060

61-
6261
These steps assume that you already have a basic tauri application available. Alternatively, you can immediately start with the application in "example" directory.
6362

6463
- run `npm run tauri add python`
65-
- add `src-tauri/src-python/main.py` and modify it acording to your needs, for example add
64+
- add `src-tauri/src-python/main.py` and modify it according to your needs, for example add
6665
```python
6766
# src-tauri/src-python/main.py
6867
_tauri_plugin_functions = ["greet_python"] # make "greet_python" callable from UI

dist-js/index.cjs

Lines changed: 0 additions & 83 deletions
This file was deleted.

dist-js/index.d.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

dist-js/index.iife.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if ('__TAURI__' in window) {
2-
var __TAURI_PYTHON_PLUGIN_API__ = (function (exports) {
2+
var __TAURI_PLUGIN_PYTHON_API__ = (function (exports) {
33
'use strict';
44

55
/******************************************************************************
@@ -46,7 +46,7 @@ var __TAURI_PYTHON_PLUGIN_API__ = (function (exports) {
4646
/** Tauri Python Plugin
4747
* © Copyright 2024, by Marco Mengelkoch
4848
* Licensed under MIT License, see License file for more details
49-
* git clonehttps://github.com/marcomq/tauri-plugin-python
49+
* git clone https://github.com/marcomq/tauri-plugin-python
5050
**/
5151
let call = {}; // array of functions
5252
async function runPython(code) {
@@ -59,10 +59,10 @@ var __TAURI_PYTHON_PLUGIN_API__ = (function (exports) {
5959
});
6060
}
6161
/**
62-
* Regeisters function on server and makes it available via `call.{jsFunctionName}`
62+
* Registers function on server and makes it available via `call.{jsFunctionName}`
6363
* @param {string} pythonFunctionCall - The python function call, can contain one dot
64-
* @param {number} [numberOfArgs] - Number of arguments, used for validation in pythons, use -1 to ignore this value
65-
* @param {string} [jsFunctionName] - Name that is used in javscript: "call.jsFunctionName". Must not contain dots.
64+
* @param {number} [numberOfArgs] - Number of arguments, used for validation in python, use -1 to ignore this value
65+
* @param {string} [jsFunctionName] - Name that is used in javascript: "call.jsFunctionName". Must not contain dots.
6666
*/
6767
async function registerFunction(pythonFunctionCall, numberOfArgs, jsFunctionName) {
6868
if (numberOfArgs !== undefined && numberOfArgs < 0) {
@@ -82,7 +82,7 @@ var __TAURI_PYTHON_PLUGIN_API__ = (function (exports) {
8282
* No server invokation - assumes that function has already been registered server-side
8383
* Makes function available as `call.{jsFunctionName}`
8484
* @param {string} pythonFunctionCall - The python function call, can contain one dot
85-
* @param {string} [jsFunctionName] - Name that is used in javscript: "call.jsFunctionName". Must not contain dots.
85+
* @param {string} [jsFunctionName] - Name that is used in javascript: "call.jsFunctionName". Must not contain dots.
8686
*/
8787
async function registerJs(pythonFunctionCall, jsFunctionName) {
8888
if (jsFunctionName === undefined) {
@@ -126,4 +126,4 @@ var __TAURI_PYTHON_PLUGIN_API__ = (function (exports) {
126126
return exports;
127127

128128
})({});
129-
Object.defineProperty(window.__TAURI__, 'python', { value: __TAURI_PYTHON_PLUGIN_API__ }) }
129+
Object.defineProperty(window.__TAURI__, 'python', { value: __TAURI_PLUGIN_PYTHON_API__ }) }

dist-js/index.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

guest-js/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** Tauri Python Plugin
22
* © Copyright 2024, by Marco Mengelkoch
33
* Licensed under MIT License, see License file for more details
4-
* git clonehttps://github.com/marcomq/tauri-plugin-python
4+
* git clone https://github.com/marcomq/tauri-plugin-python
55
**/
66

77
import { invoke } from '@tauri-apps/api/core'
@@ -19,10 +19,10 @@ export async function runPython(code: string): Promise<string> {
1919
}
2020

2121
/**
22-
* Regeisters function on server and makes it available via `call.{jsFunctionName}`
22+
* Registers function on server and makes it available via `call.{jsFunctionName}`
2323
* @param {string} pythonFunctionCall - The python function call, can contain one dot
24-
* @param {number} [numberOfArgs] - Number of arguments, used for validation in pythons, use -1 to ignore this value
25-
* @param {string} [jsFunctionName] - Name that is used in javscript: "call.jsFunctionName". Must not contain dots.
24+
* @param {number} [numberOfArgs] - Number of arguments, used for validation in python, use -1 to ignore this value
25+
* @param {string} [jsFunctionName] - Name that is used in javascript: "call.jsFunctionName". Must not contain dots.
2626
*/
2727
export async function registerFunction(
2828
pythonFunctionCall: string,
@@ -42,13 +42,11 @@ export async function registerFunction(
4242
});
4343
}
4444

45-
46-
4745
/**
4846
* No server invokation - assumes that function has already been registered server-side
4947
* Makes function available as `call.{jsFunctionName}`
5048
* @param {string} pythonFunctionCall - The python function call, can contain one dot
51-
* @param {string} [jsFunctionName] - Name that is used in javscript: "call.jsFunctionName". Must not contain dots.
49+
* @param {string} [jsFunctionName] - Name that is used in javascript: "call.jsFunctionName". Must not contain dots.
5250
*/
5351
export async function registerJs(pythonFunctionCall: string, jsFunctionName?: string) {
5452
if (jsFunctionName === undefined) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tauri-plugin-python-api",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"author": "Marco Mengelkoch",
55
"description": "Javascript package for tauri 2 python plugin.",
66
"type": "module",

rollup.config.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { readFileSync } from 'fs'
22
import { join } from 'path'
33
import { cwd } from 'process'
4-
54
import { nodeResolve } from '@rollup/plugin-node-resolve'
65
import typescript from '@rollup/plugin-typescript'
76

87
const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8'))
98

10-
119
const pluginJsName = 'python' // window.__TAURI__.python
12-
const iifeVarName = '__TAURI_PYTHON_PLUGIN_API__'
10+
const iifeVarName = '__TAURI_PLUGIN_PYTHON_API__'
1311

1412
export default [{
1513
input: 'guest-js/index.ts',
@@ -35,19 +33,19 @@ export default [{
3533
...Object.keys(pkg.peerDependencies || {})
3634
]
3735
},
38-
{
39-
input: 'guest-js/index.ts',
40-
output: [
41-
{
42-
name: iifeVarName,
43-
file: pkg.exports.html,
44-
format: 'iife',
45-
banner: "if ('__TAURI__' in window) {",
46-
// the last `}` closes the if in the banner
47-
footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`
36+
{
37+
input: 'guest-js/index.ts',
38+
output: [
39+
{
40+
name: iifeVarName,
41+
file: pkg.exports.html,
42+
format: 'iife',
43+
banner: "if ('__TAURI__' in window) {",
44+
// the last `}` closes the if in the banner
45+
footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`
4846

49-
}
50-
],
51-
plugins: [typescript(), nodeResolve()],
52-
}
47+
}
48+
],
49+
plugins: [typescript(), nodeResolve()],
50+
}
5351
]

0 commit comments

Comments
 (0)