mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-24 03:04:36 +03:00
refactor(api)!: Rename primitives
mod to core
(#8273)
This commit is contained in:
parent
618b0d01cb
commit
c2ad4d28c4
5
.changes/api-primitives-core.md
Normal file
5
.changes/api-primitives-core.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'@tauri-apps/api': 'patch:breaking'
|
||||
---
|
||||
|
||||
Changed former `tauri` module from `primitives` to `core`.
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
import { writable } from 'svelte/store'
|
||||
import { invoke } from '@tauri-apps/api/primitives'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
import Welcome from './views/Welcome.svelte'
|
||||
import Communication from './views/Communication.svelte'
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { listen, emit } from '@tauri-apps/api/event'
|
||||
import { invoke } from '@tauri-apps/api/primitives'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { onMount, onDestroy } from 'svelte'
|
||||
|
||||
export let onMessage
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { invoke } from '@tauri-apps/api/primitives'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { getName, getVersion, getTauriVersion } from '@tauri-apps/api/app'
|
||||
|
||||
let version = '1.0.0'
|
||||
|
@ -15,7 +15,7 @@
|
||||
function runCommand(commandName, args, optional) {
|
||||
const id = optional ? '#response-optional' : '#response'
|
||||
const result = document.querySelector(id)
|
||||
window.__TAURI__.primitives
|
||||
window.__TAURI__.core
|
||||
.invoke(commandName, args)
|
||||
.then((response) => {
|
||||
const val =
|
||||
|
2
examples/isolation/dist/index.html
vendored
2
examples/isolation/dist/index.html
vendored
@ -71,7 +71,7 @@
|
||||
const ping = document.querySelector("#ping")
|
||||
const pong = document.querySelector('#pong')
|
||||
ping.addEventListener("click", () => {
|
||||
window.__TAURI__.primitives.invoke("ping")
|
||||
window.__TAURI__.core.invoke("ping")
|
||||
.then(() => {
|
||||
pong.innerText = `ok: ${Date.now()}`
|
||||
})
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
const responseContainer = document.getElementById('response')
|
||||
function runCommand(commandName, args, optional) {
|
||||
window.__TAURI__.primitives
|
||||
window.__TAURI__.core
|
||||
.invoke(commandName, args)
|
||||
.then((response) => {
|
||||
responseContainer.innerText += `Ok(${response})\n\n`
|
||||
|
2
examples/splashscreen/dist/index.html
vendored
2
examples/splashscreen/dist/index.html
vendored
@ -6,7 +6,7 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// we delay here just so we can see the splashscreen for a while
|
||||
setTimeout(() => {
|
||||
window.__TAURI__.primitives.invoke('close_splashscreen')
|
||||
window.__TAURI__.core.invoke('close_splashscreen')
|
||||
}, 2000)
|
||||
})
|
||||
</script>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<source type="video/mp4" />
|
||||
</video>
|
||||
<script>
|
||||
const { invoke, convertFileSrc } = window.__TAURI__.primitives
|
||||
const { invoke, convertFileSrc } = window.__TAURI__.core
|
||||
const video = document.getElementById('video_source')
|
||||
const source = document.createElement('source')
|
||||
invoke('video_uri').then(([scheme, path]) => {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { invoke } from '@tauri-apps/api/primitives'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
export const NAME = 'Tauri'
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { invoke } from './primitives'
|
||||
import { invoke } from './core'
|
||||
|
||||
/**
|
||||
* Application metadata and related APIs.
|
||||
|
@ -107,7 +107,7 @@ interface InvokeOptions {
|
||||
* Sends a message to the backend.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { invoke } from '@tauri-apps/api/primitives';
|
||||
* import { invoke } from '@tauri-apps/api/core';
|
||||
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
|
||||
* ```
|
||||
*
|
||||
@ -139,7 +139,7 @@ async function invoke<T>(
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appDataDir, join } from '@tauri-apps/api/path';
|
||||
* import { convertFileSrc } from '@tauri-apps/api/primitives';
|
||||
* import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
* const appDataDirPath = await appDataDir();
|
||||
* const filePath = await join(appDataDirPath, 'assets/video.mp4');
|
||||
* const assetUrl = convertFileSrc(filePath);
|
@ -9,7 +9,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { invoke, transformCallback } from './primitives'
|
||||
import { invoke, transformCallback } from './core'
|
||||
|
||||
interface Event<T> {
|
||||
/** Event name */
|
||||
|
2
tooling/api/src/global.d.ts
vendored
2
tooling/api/src/global.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
/** @ignore */
|
||||
|
||||
import type { invoke, transformCallback, convertFileSrc } from './primitives'
|
||||
import type { invoke, transformCallback, convertFileSrc } from './core'
|
||||
|
||||
/** @ignore */
|
||||
declare global {
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
import * as app from './app'
|
||||
import * as event from './event'
|
||||
import * as primitives from './primitives'
|
||||
import * as core from './core'
|
||||
import * as window from './window'
|
||||
import * as path from './path'
|
||||
import * as dpi from './dpi'
|
||||
import * as tray from './tray'
|
||||
import * as menu from './menu'
|
||||
|
||||
export { app, dpi, event, path, primitives, window, tray, menu }
|
||||
export { app, dpi, event, path, core, window, tray, menu }
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
|
||||
/**
|
||||
* A rust-backed resource.
|
||||
|
@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { Resource } from '../internal'
|
||||
import { Channel, invoke } from '../primitives'
|
||||
import { Channel, invoke } from '../core'
|
||||
import { CheckMenuItemOptions } from './checkMenuItem'
|
||||
import { IconMenuItemOptions } from './iconMenuItem'
|
||||
import { MenuItemOptions } from './menuItem'
|
||||
|
@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { MenuItemBase, newMenu } from './base'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
import { type MenuItemOptions } from '../menu'
|
||||
|
||||
/** Options for creating a new check menu item. */
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import { MenuItemBase, newMenu } from './base'
|
||||
import { type MenuItemOptions } from '../menu'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
|
@ -16,7 +16,7 @@ import { PredefinedMenuItem } from './predefinedMenuItem'
|
||||
import { Submenu } from './submenu'
|
||||
import { type LogicalPosition, PhysicalPosition } from '../dpi'
|
||||
import { type Window } from '../window'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
import { type ItemKind, MenuItemBase, newMenu } from './base'
|
||||
|
||||
function itemFromKind([rid, id, kind]: [number, string, ItemKind]):
|
||||
|
@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { MenuItemBase, newMenu } from './base'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
|
||||
/** Options for creating a new menu item. */
|
||||
export interface MenuItemOptions {
|
||||
|
@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { MenuItemBase, newMenu } from './base'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
|
||||
/** A metadata for the about predefined menu item. */
|
||||
export interface AboutMetadata {
|
||||
|
@ -11,7 +11,7 @@ import { MenuItem, type MenuItemOptions } from './menuItem'
|
||||
import { CheckMenuItem } from './checkMenuItem'
|
||||
import { IconMenuItem } from './iconMenuItem'
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem'
|
||||
import { invoke } from '../primitives'
|
||||
import { invoke } from '../core'
|
||||
import { type LogicalPosition, PhysicalPosition, type Window } from '../window'
|
||||
import { type ItemKind, MenuItemBase, newMenu } from './base'
|
||||
import { type MenuOptions } from './menu'
|
||||
|
@ -19,7 +19,7 @@ interface IPCMessage {
|
||||
* Testing setup using vitest:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/primitives"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
@ -42,7 +42,7 @@ interface IPCMessage {
|
||||
* The callback function can also return a Promise:
|
||||
* ```js
|
||||
* import { mockIPC, clearMocks } from "@tauri-apps/api/mocks"
|
||||
* import { invoke } from "@tauri-apps/api/primitives"
|
||||
* import { invoke } from "@tauri-apps/api/core"
|
||||
*
|
||||
* afterEach(() => {
|
||||
* clearMocks()
|
||||
@ -141,7 +141,7 @@ export function mockWindows(
|
||||
* @example
|
||||
* ```js
|
||||
* import { mockConvertFileSrc } from "@tauri-apps/api/mocks";
|
||||
* import { convertFileSrc } from "@tauri-apps/api/primitives";
|
||||
* import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
*
|
||||
* mockConvertFileSrc("windows")
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { invoke } from './primitives'
|
||||
import { invoke } from './core'
|
||||
|
||||
/**
|
||||
* @since 2.0.0
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import type { Menu, Submenu } from './menu'
|
||||
import { Resource } from './internal'
|
||||
import { Channel, invoke } from './primitives'
|
||||
import { Channel, invoke } from './core'
|
||||
|
||||
/**
|
||||
* Describes a tray event emitted when a tray icon is clicked
|
||||
|
@ -24,7 +24,7 @@ import {
|
||||
} from './dpi'
|
||||
import type { Event, EventName, EventCallback, UnlistenFn } from './event'
|
||||
import { TauriEvent, emit, listen, once } from './event'
|
||||
import { invoke } from './primitives'
|
||||
import { invoke } from './core'
|
||||
|
||||
/**
|
||||
* Allows you to retrieve information about a given monitor.
|
||||
|
@ -21,7 +21,7 @@ const onMessage = (message) => {
|
||||
|
||||
if (message.data.status === 'done') {
|
||||
// tell tauri that we are done
|
||||
window.__TAURI__.primitives.invoke('app_completed_successfully')
|
||||
window.__TAURI__.core.invoke('app_completed_successfully')
|
||||
}
|
||||
|
||||
status.innerHTML = `${prefix} Found <code>${message.data.count}</code> prime numbers in <code>${message.data.time}ms</code>`
|
||||
|
@ -10,17 +10,17 @@
|
||||
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
window.__TAURI__.primitives
|
||||
window.__TAURI__.core
|
||||
.invoke('read_file')
|
||||
.then((_data) => {
|
||||
// success
|
||||
window.__TAURI__.primitives.invoke('app_should_close', {
|
||||
window.__TAURI__.core.invoke('app_should_close', {
|
||||
exitCode: 0
|
||||
})
|
||||
})
|
||||
.catch((_error) => {
|
||||
// error
|
||||
window.__TAURI__.primitives.invoke('app_should_close', {
|
||||
window.__TAURI__.core.invoke('app_should_close', {
|
||||
exitCode: 1
|
||||
})
|
||||
})
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', (event) =>
|
||||
window.__TAURI__.primitives.invoke('app_loaded_successfully')
|
||||
window.__TAURI__.core.invoke('app_loaded_successfully')
|
||||
)
|
||||
</script>
|
||||
</body>
|
||||
|
@ -13,7 +13,7 @@ use std::{
|
||||
process::Command,
|
||||
};
|
||||
|
||||
const CORE_API_MODULES: &[&str] = &["dpi", "event", "path", "primitives", "window", "mocks"];
|
||||
const CORE_API_MODULES: &[&str] = &["dpi", "event", "path", "core", "window", "mocks"];
|
||||
const JS_EXTENSIONS: &[&str] = &["js", "jsx", "ts", "tsx", "mjs"];
|
||||
|
||||
pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
|
||||
@ -40,7 +40,7 @@ pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
|
||||
let original = cap.get(0).unwrap().as_str();
|
||||
|
||||
if module == "tauri" {
|
||||
let new = "@tauri-apps/api/primitives".to_string();
|
||||
let new = "@tauri-apps/api/core".to_string();
|
||||
log::info!("Replacing `{original}` with `{new}` on {}", path.display());
|
||||
new
|
||||
} else if CORE_API_MODULES.contains(&module) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { invoke } from "@tauri-apps/api/primitives"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
|
||||
let name = "";
|
||||
let greetMsg = ""
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{#if license_header}}
|
||||
{{ license_header }}
|
||||
{{/if}}
|
||||
import { invoke } from '@tauri-apps/api/primitives'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
export async function execute() {
|
||||
await invoke('plugin:{{ plugin_name }}|execute')
|
||||
|
Loading…
Reference in New Issue
Block a user