Skip to content

Commit 991dc77

Browse files
committed
feat: add ll.onUnload #227
refactor: make version related api show LSE version
1 parent 768dbad commit 991dc77

File tree

7 files changed

+248
-129
lines changed

7 files changed

+248
-129
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
xmake repo -u
3737
3838
- run: |
39-
xmake f -a x64 -m release -p windows -v -y --backend=${{ matrix.backend }}
39+
xmake f -a x64 -m release -p windows -v -y --backend=${{ matrix.backend }} --publish=true
4040
4141
- run: |
4242
xmake -y

docs/apis/ScriptAPI/Ll.md

Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# 💡 Plugin loading related API
22

3-
Some interfaces related to loader operations are provided here.
3+
Some interfaces related to loader operations are provided here.
44

55
### Properties
66

77
| Property | Type | Description |
8-
| ------------------------ | --------- | ---------------------------------------------------------- |
8+
|--------------------------|-----------|------------------------------------------------------------|
99
| `ll.language` | `String` | The language LeviLamina used.(such as `zh`, `en`, `ru_RU`) |
1010
| `ll.major` | `Integer` | Major Version Number (ex: the **2** in **2**.7.1) |
1111
| `ll.minor` | `Integer` | Minor Version Number (ex: the **7** in 2.**7**.1) |
1212
| `ll.revision` | `Integer` | Revision Number: (ex: the **1** in 2.7.**1**) |
1313
| `ll.status` | `Integer` | Status (`0` is Dev, `1` is Beta, `2` is Release) |
14-
| `ll.scriptEngineVersion` | `String` | LeviLamina Script Engine Version |
14+
| `ll.scriptEngineVersion` | `String` | Script Engine Version |
1515
| `ll.isWine` | `Boolean` | Whether the LeviLamina started from Wine |
16-
| `ll.isDebugMode` | `Boolean` | Whether the LeviLamina in debug mode |
16+
| `ll.isDebugMode` | `Boolean` | Whether the LegacyScriptEngine in debug mode |
1717
| `ll.isBeta` | `Boolean` | Whether the current version is a beta version |
1818
| `ll.isDev` | `Boolean` | Whether the current version is a dev version |
1919
| `ll.isRelease` | `Boolean` | Whether the current version is a release version |
2020

21-
### Get LeviLamina loader version string
21+
### Get LegacyScriptEngine loader version string
22+
23+
!!! warning
24+
Before LSE 0.9.6, this function returns the version of LeviLamina.
2225

2326
`ll.versionString()`
2427

@@ -30,21 +33,21 @@ Some interfaces related to loader operations are provided here.
3033
`ll.getPluginInfo(name)`
3134

3235
- Parameter:
33-
- name: `String`
34-
Plugin name
36+
- name: `String`
37+
Plugin name
3538
- Return value: Plugin Object
3639
- Return value type: `Plugin`
37-
- For a returned plugin object, there are the following members:
38-
39-
| Property | Description | Type |
40-
| ----------------- | ----------------------- | -------------------------------- |
41-
| plugin.name | Plugin name | `String` |
42-
| plugin.desc | Plugin description | `String` |
43-
| plugin.type | Plugin type | `String` |
44-
| plugin.version | Plugin version (array) | `Array<Integer,Integer,Integer>` |
45-
| plugin.versionStr | Plugin version (string) | `String` |
46-
| plugin.filePath | Path to plugin | `String` |
47-
| plugin.others | Other information | `Object` |
40+
- For a returned plugin object, there are the following members:
41+
42+
| Property | Description | Type |
43+
|-------------------|-------------------------|----------------------------------|
44+
| plugin.name | Plugin name | `String` |
45+
| plugin.desc | Plugin description | `String` |
46+
| plugin.type | Plugin type | `String` |
47+
| plugin.version | Plugin version (array) | `Array<Integer,Integer,Integer>` |
48+
| plugin.versionStr | Plugin version (string) | `String` |
49+
| plugin.filePath | Path to plugin | `String` |
50+
| plugin.others | Other information | `Object` |
4851

4952
### List all loaded plugins
5053

@@ -60,74 +63,100 @@ Some interfaces related to loader operations are provided here.
6063
- Return value: A list containing the plugin objects of all loaded plugin
6164
- Return value type: `Array<Plugin,Plugin,...>`
6265

66+
### Set the function called while the plugin is unloading
67+
68+
!!! warning
69+
This function is only available in LSE 0.9.6 and later.
70+
71+
`ll.onUnload(func)`
72+
73+
- Parameter:
74+
- func : `Function`
75+
Function to be called while the plugin is unloading
76+
6377
### Remote Function Call
6478

65-
In order to allow the pre-plug-ins developed by developers to provide interfaces and services for other plug-ins, the remote function call function is provided here, so that one LLSE plug-in can call the existing functions in another plug-in.
79+
In order to allow the pre-plug-ins developed by developers to provide interfaces and services for other plug-ins, the
80+
remote function call function is provided here, so that one LLSE plug-in can call the existing functions in another
81+
plug-in.
6682

6783
#### Export Function
6884

69-
In order to allow the pre-plug-ins developed by developers to provide interfaces and services for other plug-ins, the remote function call function is provided here, so that an LL or LLSE plug-in can call the existing functions in another plug-in.
85+
In order to allow the pre-plug-ins developed by developers to provide interfaces and services for other plug-ins, the
86+
remote function call function is provided here, so that an LL or LLSE plug-in can call the existing functions in another
87+
plug-in.
7088

7189
`ll.exports(func,namespace,name)`
7290

73-
- Parameter:
74-
- func : `Function`
75-
Function to be exported
76-
- namespace : `String`
77-
The namespace name of the function, which is only convenient for distinguishing the API exported by different plugins.
78-
- name : `String`
79-
The export name of the function. Other plugins call this function based on the export name.
91+
- Parameter:
92+
- func : `Function`
93+
Function to be exported
94+
- namespace : `String`
95+
The namespace name of the function, which is only convenient for distinguishing the API exported by different
96+
plugins.
97+
- name : `String`
98+
The export name of the function. Other plugins call this function based on the export name.
8099
- Return value: Whether the export was successful.
81100
- Return value type: `Boolean`
82101

83-
Note: If the namespace and name of the exported function are exactly the same as another already exported function, the export will fail. Please select the namespace and export name appropriately when exporting.
102+
Note: If the namespace and name of the exported function are exactly the same as another already exported function, the
103+
export will fail. Please select the namespace and export name appropriately when exporting.
84104

85105
#### Import Function
86106

87-
After you have learned that there is a plug-in exporting function, in order to use the function exported by him, you first need to import this function into your own scripting system.
107+
After you have learned that there is a plug-in exporting function, in order to use the function exported by him, you
108+
first need to import this function into your own scripting system.
88109
LLSE provides the interface import to import functions already exported by other plugins.
89110

90111
`ll.imports(namespace,name)`
91112

92-
- Parameter:
93-
- namespace : `String`
94-
The namespace name used by the function that is being imported.
95-
- name : `String`
96-
The name of the function that is being imported.
113+
- Parameter:
114+
- namespace : `String`
115+
The namespace name used by the function that is being imported.
116+
- name : `String`
117+
The name of the function that is being imported.
97118
- Return value: The imported function
98119
- Return value type: `Function`
99120

100-
The return value of `ll.import` is a function. When you call this function, the cross-plugin call process will be done automatically in the background. The parameters of the calling function will be wrapped and passed to the remote function, and the return value of this function is the return value returned by the remote function after it has been executed.
121+
The return value of `ll.import` is a function. When you call this function, the cross-plugin call process will be done
122+
automatically in the background. The parameters of the calling function will be wrapped and passed to the remote
123+
function, and the return value of this function is the return value returned by the remote function after it has been
124+
executed.
101125

102-
#### Example of Remote Calling Function
126+
#### Example of Remote Calling Function
103127

104-
For example, there is a plug-in that exports a function using the namespace AAA, and the name of the exported function is Welcome
105-
You can execute `welcome = ll.import("AAA", "Welcome"); ` to import this function. After the import is complete, you can execute directly below:
128+
For example, there is a plug-in that exports a function using the namespace AAA, and the name of the exported function
129+
is Welcome
130+
You can execute `welcome = ll.import("AAA", "Welcome"); ` to import this function. After the import is complete, you can
131+
execute directly below:
106132

107-
`welcome("hello",2,true);`
133+
`welcome("hello",2,true);`
108134

109-
The parameters of the function will be automatically forwarded to the corresponding target function for execution, and the return value of the corresponding target function will be returned after execution. The whole process is automatically completed.
135+
The parameters of the function will be automatically forwarded to the corresponding target function for execution, and
136+
the return value of the corresponding target function will be returned after execution. The whole process is
137+
automatically completed.
110138

111-
Notice! When calling a function, you need to ensure that the number and types of parameters you pass in and the parameters accepted by the target function are correct and in one-to-one correspondence. Otherwise, an error will occur.
139+
Notice! When calling a function, you need to ensure that the number and types of parameters you pass in and the
140+
parameters accepted by the target function are correct and in one-to-one correspondence. Otherwise, an error will occur.
112141

113142
### Determine if a remote function has been exported
114143

115144
`ll.hasExported(namespace,name)`
116145

117146
- Parameter:
118-
- namespace : `String`
119-
Namespace name used by the function
120-
- name : `String`
121-
Export name used by the function
147+
- namespace : `String`
148+
Namespace name used by the function
149+
- name : `String`
150+
Export name used by the function
122151
- Return value:Whether the function has been exported
123152
- Return value type: `Boolean`
124153

125154
### Execute a String as a Script
126155

127156
`ll.eval(str)`
128157

129-
- Parameter:
130-
- str : `String`
131-
String to execute as a Script
158+
- Parameter:
159+
- str : `String`
160+
String to execute as a Script
132161
- Return value: Execution result
133162
- Return value type: `Any Type`

0 commit comments

Comments
 (0)