From e2f266fe894944c4d285f5457ab5eee7a41d0faa Mon Sep 17 00:00:00 2001 From: himself65 Date: Thu, 11 Aug 2022 13:09:59 -0500 Subject: [PATCH] feat: add basic example --- .gitignore | 15 +- examples/basic/next-env.d.ts | 5 + examples/basic/next.config.js | 15 ++ examples/basic/package.json | 21 ++ examples/basic/pages/index.tsx | 27 +++ examples/basic/tsconfig.json | 20 ++ examples/basic/yarn.lock | 417 +++++++++++++++++++++++++++++++++ package.json | 4 +- 8 files changed, 516 insertions(+), 8 deletions(-) create mode 100644 examples/basic/next-env.d.ts create mode 100644 examples/basic/next.config.js create mode 100644 examples/basic/package.json create mode 100644 examples/basic/pages/index.tsx create mode 100644 examples/basic/tsconfig.json create mode 100644 examples/basic/yarn.lock diff --git a/.gitignore b/.gitignore index d8a1f67c..69ec7c8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions +**/.yarn/* +**/!.yarn/patches +**/!.yarn/plugins +**/!.yarn/releases +**/!.yarn/sdks +**/!.yarn/versions # Swap the comments on the following lines if you don't wish to use zero-installs # Documentation here: https://yarnpkg.com/features/zero-installs @@ -14,3 +14,6 @@ dist tsconfig.tsbuildinfo .eslintcache node_modules + +.next +.vercel diff --git a/examples/basic/next-env.d.ts b/examples/basic/next-env.d.ts new file mode 100644 index 00000000..4f11a03d --- /dev/null +++ b/examples/basic/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/basic/next.config.js b/examples/basic/next.config.js new file mode 100644 index 00000000..987cc510 --- /dev/null +++ b/examples/basic/next.config.js @@ -0,0 +1,15 @@ +/** @type {import('next').NextConfig} */ +const nextConfig = { + reactStrictMode: true, + optimizeFonts: true, + experimental: { + externalDir: true + } +} + +const withTM = require('next-transpile-modules')([], { + resolveSymlinks: true, + debug: false +}) + +module.exports = withTM(nextConfig) diff --git a/examples/basic/package.json b/examples/basic/package.json new file mode 100644 index 00000000..364de147 --- /dev/null +++ b/examples/basic/package.json @@ -0,0 +1,21 @@ +{ + "name": "@textea/json-viewer-example-basic", + "private": true, + "scripts": { + "dev": "next dev -p 3020", + "build": "next build", + "start": "next start", + "lint": "next lint" + }, + "dependencies": { + "next": "^12.2.4", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.0.17", + "@types/react-dom": "^18.0.6", + "next-transpile-modules": "^9.0.0", + "typescript": "^4.7.4" + } +} diff --git a/examples/basic/pages/index.tsx b/examples/basic/pages/index.tsx new file mode 100644 index 00000000..aa772480 --- /dev/null +++ b/examples/basic/pages/index.tsx @@ -0,0 +1,27 @@ +import type React from 'react' +import JsonViewer from '@textea/json-viewer' + +const example = { + string: 'this is a test string', + integer: 42, + array: [1, 2, 3, 'test', NaN], + float: 3.14159, + undefined: undefined, + object: { + 'first-child': true, + 'second-child': false, + 'last-child': null + }, + string_number: '1234', + date: new Date() +} + +const IndexPage: React.FC = () => { + return ( +
+ +
+ ) +} + +export default IndexPage diff --git a/examples/basic/tsconfig.json b/examples/basic/tsconfig.json new file mode 100644 index 00000000..3c8e48c4 --- /dev/null +++ b/examples/basic/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "@textea/dev-kit/config/tsconfig.root.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@textea/json-viewer": ["../../src/index"] + }, + "jsx": "preserve", + "jsxImportSource": "react", + "noEmit": true + }, + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/examples/basic/yarn.lock b/examples/basic/yarn.lock new file mode 100644 index 00000000..e802a419 --- /dev/null +++ b/examples/basic/yarn.lock @@ -0,0 +1,417 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 6 + cacheKey: 8 + +"@next/env@npm:12.2.4": + version: 12.2.4 + resolution: "@next/env@npm:12.2.4" + checksum: f09ae1ddebaa2b081e13b55d3d533b281f335e8ec7d70743d935b3a1295f2f8f0510a39d5991afaeb728949d5c518dd34a0cf3003016d62042b6d0f2e6489cb8 + languageName: node + linkType: hard + +"@next/swc-android-arm-eabi@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-android-arm-eabi@npm:12.2.4" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@next/swc-android-arm64@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-android-arm64@npm:12.2.4" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@next/swc-darwin-arm64@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-darwin-arm64@npm:12.2.4" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@next/swc-darwin-x64@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-darwin-x64@npm:12.2.4" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@next/swc-freebsd-x64@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-freebsd-x64@npm:12.2.4" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@next/swc-linux-arm-gnueabihf@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-linux-arm-gnueabihf@npm:12.2.4" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@next/swc-linux-arm64-gnu@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-linux-arm64-gnu@npm:12.2.4" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@next/swc-linux-arm64-musl@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-linux-arm64-musl@npm:12.2.4" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@next/swc-linux-x64-gnu@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-linux-x64-gnu@npm:12.2.4" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@next/swc-linux-x64-musl@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-linux-x64-musl@npm:12.2.4" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@next/swc-win32-arm64-msvc@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-win32-arm64-msvc@npm:12.2.4" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@next/swc-win32-ia32-msvc@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-win32-ia32-msvc@npm:12.2.4" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@next/swc-win32-x64-msvc@npm:12.2.4": + version: 12.2.4 + resolution: "@next/swc-win32-x64-msvc@npm:12.2.4" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"@swc/helpers@npm:0.4.3": + version: 0.4.3 + resolution: "@swc/helpers@npm:0.4.3" + dependencies: + tslib: ^2.4.0 + checksum: 5c2f173e950dd3929d84ae48b3586a274d5a874e7cf2013b3d8081e4f8c723fa3a4d4e63b263e84bb7f06431f87b640e91a12655410463c81a3dc2bbc15eceda + languageName: node + linkType: hard + +"@textea/json-viewer-example-basic@workspace:.": + version: 0.0.0-use.local + resolution: "@textea/json-viewer-example-basic@workspace:." + dependencies: + "@types/react": ^18.0.17 + "@types/react-dom": ^18.0.6 + next: ^12.2.4 + next-transpile-modules: ^9.0.0 + react: ^18.2.0 + react-dom: ^18.2.0 + typescript: ^4.7.4 + languageName: unknown + linkType: soft + +"@types/prop-types@npm:*": + version: 15.7.5 + resolution: "@types/prop-types@npm:15.7.5" + checksum: 5b43b8b15415e1f298243165f1d44390403bb2bd42e662bca3b5b5633fdd39c938e91b7fce3a9483699db0f7a715d08cef220c121f723a634972fdf596aec980 + languageName: node + linkType: hard + +"@types/react-dom@npm:^18.0.6": + version: 18.0.6 + resolution: "@types/react-dom@npm:18.0.6" + dependencies: + "@types/react": "*" + checksum: db571047af1a567631758700b9f7d143e566df939cfe5fbf7535347cc0c726a1cdbb5e3f8566d076e54cf708b6c1166689de194a9ba09ee35efc9e1d45911685 + languageName: node + linkType: hard + +"@types/react@npm:*, @types/react@npm:^18.0.17": + version: 18.0.17 + resolution: "@types/react@npm:18.0.17" + dependencies: + "@types/prop-types": "*" + "@types/scheduler": "*" + csstype: ^3.0.2 + checksum: 18cae64f5bfd6bb58fbd8ee2ba52ec82de844f114254e26de7b513e4b86621f643f9b71d7066958cd571b0d78cb86cbceda449c5289f9349ca573df29ab69252 + languageName: node + linkType: hard + +"@types/scheduler@npm:*": + version: 0.16.2 + resolution: "@types/scheduler@npm:0.16.2" + checksum: b6b4dcfeae6deba2e06a70941860fb1435730576d3689225a421280b7742318d1548b3d22c1f66ab68e414f346a9542f29240bc955b6332c5b11e561077583bc + languageName: node + linkType: hard + +"caniuse-lite@npm:^1.0.30001332": + version: 1.0.30001375 + resolution: "caniuse-lite@npm:1.0.30001375" + checksum: 6ed9cf7a3f80f5880cb021105864b869dddfdda8490559aa623e77feeca5ce8958a3b7c1cf37322e519176dcb488c99e6358b8c2de2aa4a0e08846ac122c4e75 + languageName: node + linkType: hard + +"csstype@npm:^3.0.2": + version: 3.1.0 + resolution: "csstype@npm:3.1.0" + checksum: 644e986cefab86525f0b674a06889cfdbb1f117e5b7d1ce0fc55b0423ecc58807a1ea42ecc75c4f18999d14fc42d1d255f84662a45003a52bb5840e977eb2ffd + languageName: node + linkType: hard + +"enhanced-resolve@npm:^5.7.0": + version: 5.10.0 + resolution: "enhanced-resolve@npm:5.10.0" + dependencies: + graceful-fs: ^4.2.4 + tapable: ^2.2.0 + checksum: 0bb9830704db271610f900e8d79d70a740ea16f251263362b0c91af545576d09fe50103496606c1300a05e588372d6f9780a9bc2e30ce8ef9b827ec8f44687ff + languageName: node + linkType: hard + +"escalade@npm:^3.1.1": + version: 3.1.1 + resolution: "escalade@npm:3.1.1" + checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 + languageName: node + linkType: hard + +"graceful-fs@npm:^4.2.4": + version: 4.2.10 + resolution: "graceful-fs@npm:4.2.10" + checksum: 3f109d70ae123951905d85032ebeae3c2a5a7a997430df00ea30df0e3a6c60cf6689b109654d6fdacd28810a053348c4d14642da1d075049e6be1ba5216218da + languageName: node + linkType: hard + +"js-tokens@npm:^3.0.0 || ^4.0.0": + version: 4.0.0 + resolution: "js-tokens@npm:4.0.0" + checksum: 8a95213a5a77deb6cbe94d86340e8d9ace2b93bc367790b260101d2f36a2eaf4e4e22d9fa9cf459b38af3a32fb4190e638024cf82ec95ef708680e405ea7cc78 + languageName: node + linkType: hard + +"loose-envify@npm:^1.1.0": + version: 1.4.0 + resolution: "loose-envify@npm:1.4.0" + dependencies: + js-tokens: ^3.0.0 || ^4.0.0 + bin: + loose-envify: cli.js + checksum: 6517e24e0cad87ec9888f500c5b5947032cdfe6ef65e1c1936a0c48a524b81e65542c9c3edc91c97d5bddc806ee2a985dbc79be89215d613b1de5db6d1cfe6f4 + languageName: node + linkType: hard + +"nanoid@npm:^3.3.4": + version: 3.3.4 + resolution: "nanoid@npm:3.3.4" + bin: + nanoid: bin/nanoid.cjs + checksum: 2fddd6dee994b7676f008d3ffa4ab16035a754f4bb586c61df5a22cf8c8c94017aadd360368f47d653829e0569a92b129979152ff97af23a558331e47e37cd9c + languageName: node + linkType: hard + +"next-transpile-modules@npm:^9.0.0": + version: 9.0.0 + resolution: "next-transpile-modules@npm:9.0.0" + dependencies: + enhanced-resolve: ^5.7.0 + escalade: ^3.1.1 + checksum: 9a5d86d80cedc2404b2b1d5bd4994f2f7bf60e5e20f24e8cc5cfec34da1418b4a439916f37a95ca336bcf6d81094c3647354ac6a0c6737b3df59e62b6380507d + languageName: node + linkType: hard + +"next@npm:^12.2.4": + version: 12.2.4 + resolution: "next@npm:12.2.4" + dependencies: + "@next/env": 12.2.4 + "@next/swc-android-arm-eabi": 12.2.4 + "@next/swc-android-arm64": 12.2.4 + "@next/swc-darwin-arm64": 12.2.4 + "@next/swc-darwin-x64": 12.2.4 + "@next/swc-freebsd-x64": 12.2.4 + "@next/swc-linux-arm-gnueabihf": 12.2.4 + "@next/swc-linux-arm64-gnu": 12.2.4 + "@next/swc-linux-arm64-musl": 12.2.4 + "@next/swc-linux-x64-gnu": 12.2.4 + "@next/swc-linux-x64-musl": 12.2.4 + "@next/swc-win32-arm64-msvc": 12.2.4 + "@next/swc-win32-ia32-msvc": 12.2.4 + "@next/swc-win32-x64-msvc": 12.2.4 + "@swc/helpers": 0.4.3 + caniuse-lite: ^1.0.30001332 + postcss: 8.4.14 + styled-jsx: 5.0.2 + use-sync-external-store: 1.2.0 + peerDependencies: + fibers: ">= 3.1.0" + node-sass: ^6.0.0 || ^7.0.0 + react: ^17.0.2 || ^18.0.0-0 + react-dom: ^17.0.2 || ^18.0.0-0 + sass: ^1.3.0 + dependenciesMeta: + "@next/swc-android-arm-eabi": + optional: true + "@next/swc-android-arm64": + optional: true + "@next/swc-darwin-arm64": + optional: true + "@next/swc-darwin-x64": + optional: true + "@next/swc-freebsd-x64": + optional: true + "@next/swc-linux-arm-gnueabihf": + optional: true + "@next/swc-linux-arm64-gnu": + optional: true + "@next/swc-linux-arm64-musl": + optional: true + "@next/swc-linux-x64-gnu": + optional: true + "@next/swc-linux-x64-musl": + optional: true + "@next/swc-win32-arm64-msvc": + optional: true + "@next/swc-win32-ia32-msvc": + optional: true + "@next/swc-win32-x64-msvc": + optional: true + peerDependenciesMeta: + fibers: + optional: true + node-sass: + optional: true + sass: + optional: true + bin: + next: dist/bin/next + checksum: 31da1485d3499b2d43b452378931cc04d3593dcdecb7629263d5f5dae375ae956d68963a7398b613a283d0c42c50a7ab9f5ef911d8df50f740e8438721e06457 + languageName: node + linkType: hard + +"picocolors@npm:^1.0.0": + version: 1.0.0 + resolution: "picocolors@npm:1.0.0" + checksum: a2e8092dd86c8396bdba9f2b5481032848525b3dc295ce9b57896f931e63fc16f79805144321f72976383fc249584672a75cc18d6777c6b757603f372f745981 + languageName: node + linkType: hard + +"postcss@npm:8.4.14": + version: 8.4.14 + resolution: "postcss@npm:8.4.14" + dependencies: + nanoid: ^3.3.4 + picocolors: ^1.0.0 + source-map-js: ^1.0.2 + checksum: fe58766ff32e4becf65a7d57678995cfd239df6deed2fe0557f038b47c94e4132e7e5f68b5aa820c13adfec32e523b693efaeb65798efb995ce49ccd83953816 + languageName: node + linkType: hard + +"react-dom@npm:^18.2.0": + version: 18.2.0 + resolution: "react-dom@npm:18.2.0" + dependencies: + loose-envify: ^1.1.0 + scheduler: ^0.23.0 + peerDependencies: + react: ^18.2.0 + checksum: 7d323310bea3a91be2965f9468d552f201b1c27891e45ddc2d6b8f717680c95a75ae0bc1e3f5cf41472446a2589a75aed4483aee8169287909fcd59ad149e8cc + languageName: node + linkType: hard + +"react@npm:^18.2.0": + version: 18.2.0 + resolution: "react@npm:18.2.0" + dependencies: + loose-envify: ^1.1.0 + checksum: 88e38092da8839b830cda6feef2e8505dec8ace60579e46aa5490fc3dc9bba0bd50336507dc166f43e3afc1c42939c09fe33b25fae889d6f402721dcd78fca1b + languageName: node + linkType: hard + +"scheduler@npm:^0.23.0": + version: 0.23.0 + resolution: "scheduler@npm:0.23.0" + dependencies: + loose-envify: ^1.1.0 + checksum: d79192eeaa12abef860c195ea45d37cbf2bbf5f66e3c4dcd16f54a7da53b17788a70d109ee3d3dde1a0fd50e6a8fc171f4300356c5aee4fc0171de526bf35f8a + languageName: node + linkType: hard + +"source-map-js@npm:^1.0.2": + version: 1.0.2 + resolution: "source-map-js@npm:1.0.2" + checksum: c049a7fc4deb9a7e9b481ae3d424cc793cb4845daa690bc5a05d428bf41bf231ced49b4cf0c9e77f9d42fdb3d20d6187619fc586605f5eabe995a316da8d377c + languageName: node + linkType: hard + +"styled-jsx@npm:5.0.2": + version: 5.0.2 + resolution: "styled-jsx@npm:5.0.2" + peerDependencies: + react: ">= 16.8.0 || 17.x.x || ^18.0.0-0" + peerDependenciesMeta: + "@babel/core": + optional: true + babel-plugin-macros: + optional: true + checksum: 86d55819ebeabd283a574d2f44f7d3f8fa6b8c28fa41687ece161bf1e910e04965611618921d8f5cd33dc6dae1033b926a70421ae5ea045440a9861edc3e0d87 + languageName: node + linkType: hard + +"tapable@npm:^2.2.0": + version: 2.2.1 + resolution: "tapable@npm:2.2.1" + checksum: 3b7a1b4d86fa940aad46d9e73d1e8739335efd4c48322cb37d073eb6f80f5281889bf0320c6d8ffcfa1a0dd5bfdbd0f9d037e252ef972aca595330538aac4d51 + languageName: node + linkType: hard + +"tslib@npm:^2.4.0": + version: 2.4.0 + resolution: "tslib@npm:2.4.0" + checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113 + languageName: node + linkType: hard + +"typescript@npm:^4.7.4": + version: 4.7.4 + resolution: "typescript@npm:4.7.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 5750181b1cd7e6482c4195825547e70f944114fb47e58e4aa7553e62f11b3f3173766aef9c281783edfd881f7b8299cf35e3ca8caebe73d8464528c907a164df + languageName: node + linkType: hard + +"typescript@patch:typescript@^4.7.4#~builtin": + version: 4.7.4 + resolution: "typescript@patch:typescript@npm%3A4.7.4#~builtin::version=4.7.4&hash=f456af" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 9096d8f6c16cb80ef3bf96fcbbd055bf1c4a43bd14f3b7be45a9fbe7ada46ec977f604d5feed3263b4f2aa7d4c7477ce5f9cd87de0d6feedec69a983f3a4f93e + languageName: node + linkType: hard + +"use-sync-external-store@npm:1.2.0": + version: 1.2.0 + resolution: "use-sync-external-store@npm:1.2.0" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: 5c639e0f8da3521d605f59ce5be9e094ca772bd44a4ce7322b055a6f58eeed8dda3c94cabd90c7a41fb6fa852210092008afe48f7038792fd47501f33299116a + languageName: node + linkType: hard diff --git a/package.json b/package.json index 828a629d..d513202b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "@textea/json-viewer", - "packageManager": "yarn@3.2.2", "description": "Interactive react component for displaying javascript arrays and JSON objects.", "version": "1.23.0-alpha.0", "types": "src/type.d.ts", @@ -66,5 +65,6 @@ "vite": "^3.0.5", "vite-plugin-dts": "^1.4.1", "vitest": "^0.21.1" - } + }, + "packageManager": "yarn@3.2.2" }