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 Sep 1, 2023
1 parent af3268a commit bb90206
Show file tree
Hide file tree
Showing 23 changed files with 555 additions and 3,993 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.

71 changes: 36 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,48 @@
"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": {
"prepublishOnly": "node ./scripts/generate-dts.js",
"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": {
"dts-buddy": "^0.2.4",
"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/index.d.ts",
"import": "./src/event.js"
},
"./tauri": {
"types": "./types/index.d.ts",
"import": "./src/tauri.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.

12 changes: 12 additions & 0 deletions tooling/api/scripts/generate-dts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createBundle } from 'dts-buddy'

await createBundle({
project: 'tsconfig.json',
output: 'types/index.d.ts',
include: ['src'],
modules: {
'@tauri-apps/api': 'src/index.js',
'@tauri-apps/api/tauri': 'src/tauri.js',
'@tauri-apps/api/event': 'src/event.js'
}
})
77 changes: 77 additions & 0 deletions tooling/api/src/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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
* @param {(event: Event<T>) => void} callback
*/
function listen(callback) {}

export { listen, TauriEvent, BaseDirectory }
Loading

0 comments on commit bb90206

Please sign in to comment.