Skip to content

Commit

Permalink
refactor(tooling/api): migrate from Typescript to JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Aug 31, 2023
1 parent af3268a commit d3d09d3
Show file tree
Hide file tree
Showing 20 changed files with 288 additions and 4,004 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"semi": false,
"trailingComma": "none"
}
9 changes: 0 additions & 9 deletions .prettierrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"url": "https://github.com/tauri-apps/tauri.git"
},
"scripts": {
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .prettierignore",
"format": "prettier --write . --config .prettierrc --ignore-path .prettierignore",
"format:check": "prettier --check . --config .prettierrc --ignore-path .prettierignore",
"postinstall": "husky install"
},
"devDependencies": {
Expand Down
56 changes: 0 additions & 56 deletions tooling/api/.eslintrc.cjs

This file was deleted.

4 changes: 0 additions & 4 deletions tooling/api/.npmignore

This file was deleted.

5 changes: 0 additions & 5 deletions tooling/api/.prettierrc.cjs

This file was deleted.

1 change: 0 additions & 1 deletion tooling/api/docs/js-api.json

This file was deleted.

77 changes: 42 additions & 35 deletions tooling/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,10 @@
"name": "@tauri-apps/api",
"version": "2.0.0-alpha.6",
"description": "Tauri API definitions",
"type": "module",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"exports": {
"./package.json": "./package.json"
},
"scripts": {
"build": "yarn tsup && node ./scripts/after-build.cjs && yarn generate-docs",
"npm-pack": "yarn build && cd ./dist && npm pack",
"npm-publish": "yarn build && cd ./dist && yarn publish --access public --loglevel silly --tag next",
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path ../../.prettierignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path ../../.prettierignore",
"generate-docs": "typedoc --plugin typedoc-plugin-markdown --plugin typedoc-plugin-mdn-links"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tauri-apps/tauri.git"
Expand All @@ -32,33 +18,54 @@
"url": "https://github.com/tauri-apps/tauri/issues"
},
"homepage": "https://github.com/tauri-apps/tauri#readme",
"type": "module",
"files": [
"src",
"types",
"LICENSE_*",
"CHANGELOG.md"
],
"scripts": {
"check": "tsc",
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint:fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore --ignore-path ../../.prettierignore",
"format:check": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore --ignore-path ../../.prettierignore"
},
"devDependencies": {
"prettier": "2.8.8",
"typescript": "^4.9.4"
},
"types": "types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./types/index.d.ts",
"import": "./src/index.js"
},
"./event": {
"types": "./types/event.d.ts",
"import": "./src/event.js"
},
"./tauri": {
"types": "./types/tauri.d.ts",
"import": "./src/tauri.js"
},
"./path": {
"types": "./types/path.d.ts",
"import": "./src/path.js"
},
"./mocks": {
"types": "./types/mocks.d.ts",
"import": "./src/mocks.js"
}
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">= 14.6.0",
"npm": ">= 6.6.0",
"yarn": ">= 1.19.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.46.0",
"eslint-config-prettier": "8.10.0",
"eslint-config-standard-with-typescript": "34.0.1",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-n": "15.7.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-security": "1.7.1",
"prettier": "2.8.8",
"tsup": "6.7.0",
"typedoc": "0.24.8",
"typedoc-plugin-markdown": "3.15.4",
"typedoc-plugin-mdn-links": "3.0.3",
"typescript": "5.1.6"
},
"resolutions": {
"semver": ">=7.5.2"
}
}
44 changes: 0 additions & 44 deletions tooling/api/scripts/after-build.cjs

This file was deleted.

84 changes: 84 additions & 0 deletions tooling/api/src/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

/**
* The event system allows you to emit events to the backend and listen to events from it.
*
* This package is also accessible with `window.__TAURI__.event` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
* @module
*/

/**
* @since 1.1.0
* @enum {string}
*/
const TauriEvent = {
WINDOW_RESIZED: 'tauri://resize',
WINDOW_MOVED: 'tauri://move',
WINDOW_CLOSE_REQUESTED: 'tauri://close-requested',
WINDOW_CREATED: 'tauri://window-created',
WINDOW_DESTROYED: 'tauri://destroyed',
WINDOW_FOCUS: 'tauri://focus',
WINDOW_BLUR: 'tauri://blur',
WINDOW_SCALE_FACTOR_CHANGED: 'tauri://scale-change',
WINDOW_THEME_CHANGED: 'tauri://theme-changed',
WINDOW_FILE_DROP: 'tauri://file-drop',
WINDOW_FILE_DROP_HOVER: 'tauri://file-drop-hover',
WINDOW_FILE_DROP_CANCELLED: 'tauri://file-drop-cancelled',
MENU: 'tauri://menu'
}

/**
* @since 2.0.0
*
* @enum {number}
*/
const BaseDirectory = {
Audio: 1,
Cache: 2,
Config: 3,
Data: 4,
LocalData: 5,
Document: 6,
Download: 7,
Picture: 8,
Public: 9,
Video: 10,
Resource: 11,
Temp: 12,
AppConfig: 13,
AppData: 14,
AppLocalData: 15,
AppCache: 16,
AppLog: 17,
Desktop: 18,
Executable: 19,
Font: 20,
Home: 21,
Runtime: 22,
Template: 23
}

/**
* @template T
* @typedef {Object} Event
* @property {number} id event id
* @property {string} name event name
* @property {T} payload The payload of the event
*/

/**
* @template T
* @callback EventCallback
* @param {Event<T>} event
* @returns {void}
*/

/**
* @template T
* @param {EventCallback<T>} callback
*/
function listen(callback) {}

export { listen, TauriEvent, BaseDirectory }
Loading

0 comments on commit d3d09d3

Please sign in to comment.