This project is dedicated to collecting high-quality macOS software and organizing them systematically by different categories for easy search and use.
Dockerfile appappleapplicationappsawesomeawesome-listawesome-macdesktop-appdesktop-applicationdesktop-appslistmacmac-osxmacosmacos-appmacos-appsmacosxsoftwareswiftswiftui
feat: add ES6 module import support for JSON files
小弟调调590a45aa51cb
diff --git a/ES6-IMPORT-GUIDE.md b/ES6-IMPORT-GUIDE.mdnew file mode 100644index 00000000..07080af6--- /dev/null+++ b/ES6-IMPORT-GUIDE.md@@ -0,0 +1,118 @@+ES6 Import Support Guide+===++The `awesome-mac` package now supports ES6 module imports for JSON data.++## Installation++```bash+npm install awesome-mac+```++## Usage++### ES6 Module Import (Node.js)++```javascript+// Import default English data+import data from 'awesome-mac' with { type: 'json' };++// Import Korean data+import koData from 'awesome-mac/ko' with { type: 'json' };++// Import Japanese data+import jaData from 'awesome-mac/ja' with { type: 'json' };++// Import Chinese data+import zhData from 'awesome-mac/zh' with { type: 'json' };++console.log('Mac app data:', data);+console.log('Total categories:', data.length);+```++### CommonJS Import (Traditional Node.js)++```javascript+// Import default English data+const data = require('awesome-mac');++// Import other language versions+const koData = require('awesome-mac/ko');+const jaData = require('awesome-mac/ja');+const zhData = require('awesome-mac/zh');+```++### TypeScript++To use with TypeScript, you can create type declarations:++```typescript+// types/awesome-mac.d.ts+declare module 'awesome-mac' {+ interface AppInfo {+ icons: Array<{type: string, url: string}>;+ title: string;+ url: string;+ }++ interface CategoryItem {+ type: string;+ value?: string;+ children?: any[];+ mark?: AppInfo;+ }++ const data: CategoryItem[];+ export default data;+}++declare module 'awesome-mac/ko' {+ import { CategoryItem } from 'awesome-mac';+ const data: CategoryItem[];+ export default data;+}++declare module 'awesome-mac/ja' {+ import { CategoryItem } from 'awesome-mac';+ const data: CategoryItem[];+ export default data;+}++declare module 'awesome-mac/zh' {+ import { CategoryItem } from 'awesome-mac';+ const data: CategoryItem[];+ export default data;+}+```++## Available Import Paths++- `awesome-mac` - Default English data+- `awesome-mac/ko` - Korean data+- `awesome-mac/ja` - Japanese data+- `awesome-mac/zh` - Chinese data++## Data Structure++Each JSON file contains an array representing different app categories and app information. Each app entry includes:++- `title`: Application name+- `url`: Application official website link+- `icons`: Contains app type icon information (open source, free, App Store, etc.)++## Compatibility++- ✅ Node.js ES6 modules (requires `with { type: 'json' }`)+- ✅ Node.js CommonJS+- ✅ Modern bundlers (Webpack, Vite, etc.)+- ✅ TypeScript (requires type declarations)++## Notes++When importing JSON files in newer versions of Node.js, you need to use import assertions:++```javascript+import data from 'awesome-mac' with { type: 'json' };+```++This is a security feature requirement of Node.js.\ No newline at end of filediff --git a/README-ja.md b/README-ja.mdindex 17bbb43f..052a80dc 100644--- a/README-ja.md+++ b/README-ja.md@@ -161,8 +161,8 @@ Awesome Mac- [コントリビューター](#コントリビューター)- [ライセンス](#ライセンス)-<!--start--><!--idoc:ignore:end-->+<!--start-->## 読み書きツールdiff --git a/README-ko.md b/README-ko.mdindex 30fc7023..ca7aade3 100644--- a/README-ko.md+++ b/README-ko.md@@ -135,9 +135,10 @@ Awesome Mac- [기여자](#기여자)- [라이선스](#라이선스)-<!--start--><!--idoc:ignore:end-->+<!--start-->+## 읽기 및 쓰기 도구### 텍스트 편집기@@ -793,6 +794,8 @@ Awesome Mac**[⬆ 상단으로 이동](#목차)**+<!--end-->+## 기여자이 프로젝트는 기여해 주신 모든 분들 덕분에 존재합니다.diff --git a/README-zh.md b/README-zh.mdindex c79e73d3..d7f505d5 100755--- a/README-zh.md+++ b/README-zh.md@@ -153,8 +153,8 @@ Awesome Mac- [Contributors](#contributors)- [License](#license)-<!--start--><!--idoc:ignore:end-->+<!--start-->## 开发者工具diff --git a/README.md b/README.mdindex 979b030f..32161d19 100755--- a/README.md+++ b/README.md@@ -161,9 +161,10 @@ Any comments, suggestions? [Let us know!](https://github.com/jaywcjlove/awesome-- [Contributors](#contributors)- [License](#license)-<!--start--><!--idoc:ignore:end-->+<!--start-->+## Reading and Writing Tools*Applications to edit text, I suggest the open-source editors*diff --git a/build/ast.mjs b/build/ast.mjsindex 6a655351..cf0cec74 100644--- a/build/ast.mjs+++ b/build/ast.mjs@@ -139,3 +139,29 @@ remark()console.log(' create file: \x1b[32;1m ./dist/awesome-mac.zh.json \x1b[0m');}).processSync(toVFile.readSync('README-zh.md'))+++remark()+ .use(gfm)+ .use(() => (tree) => {+ const startIndex = tree.children.findIndex(item => item.type === 'html' && /<!--start-->/.test(item.value))+ const endIndex = tree.children.findIndex(item => item.type === 'html' && /<!--end-->/.test(item.value))+ const data = tree.children.slice(startIndex + 1, endIndex)+ const dataAST = getMdToAST([...data])+ FS.outputJsonSync('./dist/awesome-mac.ja.json', dataAST)+ console.log(' create file: \x1b[32;1m ./dist/awesome-mac.ja.json \x1b[0m');+ })+ .processSync(toVFile.readSync('README-ja.md'))+++remark()+ .use(gfm)+ .use(() => (tree) => {+ const startIndex = tree.children.findIndex(item => item.type === 'html' && /<!--start-->/.test(item.value))+ const endIndex = tree.children.findIndex(item => item.type === 'html' && /<!--end-->/.test(item.value))+ const data = tree.children.slice(startIndex + 1, endIndex)+ const dataAST = getMdToAST([...data])+ FS.outputJsonSync('./dist/awesome-mac.ko.json', dataAST)+ console.log(' create file: \x1b[32;1m ./dist/awesome-mac.ko.json \x1b[0m');+ })+ .processSync(toVFile.readSync('README-ko.md'))\ No newline at end of filediff --git a/package.json b/package.jsonindex 5ace0eee..4ffc30ad 100644--- a/package.json+++ b/package.json@@ -5,6 +5,31 @@"homepage": "https://jaywcjlove.github.io/awesome-mac","funding": "https://jaywcjlove.github.io/#/sponsor","main": "dist/awesome-mac.json",+ "module": "dist/awesome-mac.json",+ "type": "module",+ "exports": {+ ".": {+ "import": "./dist/awesome-mac.json",+ "require": "./dist/awesome-mac.json",+ "default": "./dist/awesome-mac.json"+ },+ "./ko": {+ "import": "./dist/awesome-mac.ko.json",+ "require": "./dist/awesome-mac.ko.json",+ "default": "./dist/awesome-mac.ko.json"+ },+ "./ja": {+ "import": "./dist/awesome-mac.ja.json",+ "require": "./dist/awesome-mac.ja.json",+ "default": "./dist/awesome-mac.ja.json"+ },+ "./zh": {+ "import": "./dist/awesome-mac.zh.json",+ "require": "./dist/awesome-mac.zh.json",+ "default": "./dist/awesome-mac.zh.json"+ },+ "./package.json": "./package.json"+ },"scripts": {"start": "npm run build && npm run create:ast","doc": "idoc --watch",@@ -24,6 +49,8 @@],"files": ["dist/awesome-mac.json",+ "dist/awesome-mac.ko.json",+ "dist/awesome-mac.ja.json","dist/awesome-mac.zh.json"],"author": "kenny wang <[email protected]>",@@ -38,4 +65,4 @@"remark-gfm": "^3.0.1","to-vfile": "^7.2.3"}-}+}\ No newline at end of file