Skip to content

Commit

Permalink
Merge branch '1.x' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-jerry committed Apr 30, 2024
2 parents c690f12 + 80db9df commit 8c12d1d
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changes/plugin-init-script-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:enhance
---

Run each plugin initialization script on its own context so they do not interfere with each other or the Tauri init script.
6 changes: 3 additions & 3 deletions .github/workflows/covector-version-or-publish-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
}
- {
target: x86_64-apple-darwin,
os: macos-latest,
os: macos-13,
toolchain: '1.60.0'
}
steps:
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest, macos-13, windows-latest]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: yarn
cache-dependency-path: tooling/*/yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/covector-version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: yarn
cache-dependency-path: tooling/*/yarn.lock
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: 16
cache: yarn
cache-dependency-path: tooling/cli/node/yarn.lock
- name: install deps via yarn
Expand All @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: 16
cache: yarn
cache-dependency-path: tooling/api/yarn.lock

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-cli-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
target: x86_64-apple-darwin
architecture: x64
build: |
yarn build:release
yarn build:release --target=x86_64-apple-darwin
strip -x *.node
- host: windows-latest
build: yarn build:release
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
# usesh: true
# mem: 3000
# prepare: |
# pkg install -y curl node14 python2
# pkg install -y curl node16 python2
# curl -qL https://www.npmjs.com/install.sh | sh
# npm install -g yarn
# curl https://sh.rustup.rs -sSf --output rustup.sh
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
matrix:
settings:
- host: macos-latest
target: 'x86_64-apple-darwin'
target: 'aarch64-apple-darwin'
- host: windows-latest
target: x86_64-pc-windows-msvc
node:
Expand Down Expand Up @@ -375,7 +375,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
check-latest: true
cache: yarn
cache-dependency-path: 'tooling/cli/node/yarn.lock'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-cli-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: setup node
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
cache: yarn
cache-dependency-path: tooling/cli/node/yarn.lock

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
}
- {
target: x86_64-apple-darwin,
os: macos-latest,
os: macos-13,
toolchain: '1.60.0'
}
features:
Expand Down
2 changes: 0 additions & 2 deletions core/tauri/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
window.__TAURI_INVOKE__('__initialized', { url: window.location.href })
})
}

__RAW_plugin_initialization_script__
})()
13 changes: 6 additions & 7 deletions core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl<R: Runtime> WindowManager<R> {
app_handle: AppHandle<R>,
) -> crate::Result<PendingWindow<EventLoopMessage, R>> {
let is_init_global = self.inner.config.build.with_global_tauri;
let plugin_init = self
let plugin_init_scripts = self
.inner
.plugins
.lock()
Expand Down Expand Up @@ -471,8 +471,11 @@ impl<R: Runtime> WindowManager<R> {
window_labels_array = serde_json::to_string(&window_labels)?,
current_window_label = serde_json::to_string(&label)?,
))
.initialization_script(&self.initialization_script(&ipc_init.into_string(),&pattern_init.into_string(),&plugin_init, is_init_global)?)
;
.initialization_script(&self.initialization_script(&ipc_init.into_string(),&pattern_init.into_string(),is_init_global)?);

for plugin_init_script in plugin_init_scripts {
webview_attributes = webview_attributes.initialization_script(&plugin_init_script);
}

#[cfg(feature = "isolation")]
if let Pattern::Isolation { schema, .. } = self.pattern() {
Expand Down Expand Up @@ -781,7 +784,6 @@ impl<R: Runtime> WindowManager<R> {
&self,
ipc_script: &str,
pattern_script: &str,
plugin_initialization_script: &str,
with_global_tauri: bool,
) -> crate::Result<String> {
#[derive(Template)]
Expand All @@ -801,8 +803,6 @@ impl<R: Runtime> WindowManager<R> {
#[raw]
event_initialization_script: &'a str,
#[raw]
plugin_initialization_script: &'a str,
#[raw]
freeze_prototype: &'a str,
#[raw]
hotkeys: &'a str,
Expand Down Expand Up @@ -867,7 +867,6 @@ impl<R: Runtime> WindowManager<R> {
.render_default(&Default::default())?
.into_string(),
event_initialization_script: &self.event_initialization_script(),
plugin_initialization_script,
freeze_prototype,
hotkeys: &hotkeys,
}
Expand Down
7 changes: 3 additions & 4 deletions core/tauri/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,13 @@ impl<R: Runtime> PluginStore<R> {
}

/// Generates an initialization script from all plugins in the store.
pub(crate) fn initialization_script(&self) -> String {
pub(crate) fn initialization_script(&self) -> Vec<String> {
self
.store
.values()
.filter_map(|p| p.initialization_script())
.fold(String::new(), |acc, script| {
format!("{acc}\n(function () {{ {script} }})();")
})
.map(|script| format!("(function () {{ {script} }})();"))
.collect()
}

/// Runs the created hook for all plugins in the store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 12
node-version: 16
registry-url: 'https://registry.npmjs.org'

- name: cargo login
Expand Down

0 comments on commit 8c12d1d

Please sign in to comment.