From 1f594c5c593a7bf76d131477802f8b2cedbd4f00 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 3 Aug 2024 19:34:09 +0900 Subject: [PATCH 1/2] feat(docs): add sandpack component --- docs/.vitepress/config.mts | 11 + docs/.vitepress/theme/index.js | 9 +- docs/components/Sandpack.vue | 35 ++ docs/package.json | 5 +- yarn.lock | 596 +++++++++++++++++++++++++++++++++ 5 files changed, 654 insertions(+), 2 deletions(-) create mode 100644 docs/components/Sandpack.vue diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 60a42bbbe..d8091d0e7 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,4 +1,6 @@ import { defineConfig } from 'vitepress'; +import container from 'markdown-it-container'; +import { renderSandbox } from 'vitepress-plugin-sandpack'; import { en } from './en.mts'; import { ko } from './ko.mts'; import { zh_hans } from './zh_hans.mts'; @@ -11,4 +13,13 @@ export default defineConfig({ ko: { label: '한국어', ...ko }, zh_hans: { label: '简体中文', ...zh_hans }, }, + markdown: { + config(md) { + md.use(container, 'sandpack', { + render(tokens: any[], idx: number) { + return renderSandbox(tokens, idx, 'sandpack'); + }, + }); + }, + }, }); diff --git a/docs/.vitepress/theme/index.js b/docs/.vitepress/theme/index.js index 2423da6bf..63f90f3a0 100644 --- a/docs/.vitepress/theme/index.js +++ b/docs/.vitepress/theme/index.js @@ -1,4 +1,11 @@ import DefaultTheme from 'vitepress/theme'; +import Sandpack from '../../components/Sandpack.vue'; import './index.css'; -export default DefaultTheme; +export default { + ...DefaultTheme, + enhanceApp(ctx) { + DefaultTheme.enhanceApp(ctx); + ctx.app.component('Sandpack', Sandpack); + }, +}; diff --git a/docs/components/Sandpack.vue b/docs/components/Sandpack.vue new file mode 100644 index 000000000..7c6344d0d --- /dev/null +++ b/docs/components/Sandpack.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/docs/package.json b/docs/package.json index 997e2cd88..27604d392 100644 --- a/docs/package.json +++ b/docs/package.json @@ -2,7 +2,10 @@ "name": "docs", "private": true, "devDependencies": { - "vitepress": "^1.2.2" + "markdown-it-container": "^4.0.0", + "vitepress": "^1.2.2", + "vitepress-plugin-sandpack": "^1.1.4", + "vue": "^3.4.34" }, "scripts": { "docs:dev": "vitepress dev", diff --git a/yarn.lock b/yarn.lock index 66c19e886..e2141c7e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -519,6 +519,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-string-parser@npm:^7.24.8": + version: 7.24.8 + resolution: "@babel/helper-string-parser@npm:7.24.8" + checksum: 10c0/6361f72076c17fabf305e252bf6d580106429014b3ab3c1f5c4eb3e6d465536ea6b670cc0e9a637a77a9ad40454d3e41361a2909e70e305116a23d68ce094c08 + languageName: node + linkType: hard + "@babel/helper-validator-identifier@npm:^7.22.20, @babel/helper-validator-identifier@npm:^7.24.5, @babel/helper-validator-identifier@npm:^7.24.6": version: 7.24.6 resolution: "@babel/helper-validator-identifier@npm:7.24.6" @@ -526,6 +533,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-identifier@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/helper-validator-identifier@npm:7.24.7" + checksum: 10c0/87ad608694c9477814093ed5b5c080c2e06d44cb1924ae8320474a74415241223cc2a725eea2640dd783ff1e3390e5f95eede978bc540e870053152e58f1d651 + languageName: node + linkType: hard + "@babel/helper-validator-option@npm:^7.23.5": version: 7.23.5 resolution: "@babel/helper-validator-option@npm:7.23.5" @@ -576,6 +590,17 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.24.7": + version: 7.25.3 + resolution: "@babel/parser@npm:7.25.3" + dependencies: + "@babel/types": "npm:^7.25.2" + bin: + parser: ./bin/babel-parser.js + checksum: 10c0/874b01349aedb805d6694f867a752fdc7469778fad76aca4548d2cc6ce96087c3ba5fb917a6f8d05d2d1a74aae309b5f50f1a4dba035f5a2c9fcfe6e106d2c4e + languageName: node + linkType: hard + "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:7.24.5" @@ -1622,6 +1647,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.25.2": + version: 7.25.2 + resolution: "@babel/types@npm:7.25.2" + dependencies: + "@babel/helper-string-parser": "npm:^7.24.8" + "@babel/helper-validator-identifier": "npm:^7.24.7" + to-fast-properties: "npm:^2.0.0" + checksum: 10c0/e489435856be239f8cc1120c90a197e4c2865385121908e5edb7223cfdff3768cba18f489adfe0c26955d9e7bbb1fb10625bc2517505908ceb0af848989bd864 + languageName: node + linkType: hard + "@changesets/apply-release-plan@npm:^7.0.3": version: 7.0.3 resolution: "@changesets/apply-release-plan@npm:7.0.3" @@ -1892,6 +1928,154 @@ __metadata: languageName: node linkType: hard +"@codemirror/autocomplete@npm:^6.0.0, @codemirror/autocomplete@npm:^6.12.0": + version: 6.17.0 + resolution: "@codemirror/autocomplete@npm:6.17.0" + dependencies: + "@codemirror/language": "npm:^6.0.0" + "@codemirror/state": "npm:^6.0.0" + "@codemirror/view": "npm:^6.17.0" + "@lezer/common": "npm:^1.0.0" + peerDependencies: + "@codemirror/language": ^6.0.0 + "@codemirror/state": ^6.0.0 + "@codemirror/view": ^6.0.0 + "@lezer/common": ^1.0.0 + checksum: 10c0/b3c10985ac9593139f1d044c6d5de4e3369ef133d76680568d8cd9b22777299af0ab376c59fdb505fbd59b0cc4b8f77e6b7b743046be0788297af3a765dcb044 + languageName: node + linkType: hard + +"@codemirror/commands@npm:^6.3.3": + version: 6.6.0 + resolution: "@codemirror/commands@npm:6.6.0" + dependencies: + "@codemirror/language": "npm:^6.0.0" + "@codemirror/state": "npm:^6.4.0" + "@codemirror/view": "npm:^6.27.0" + "@lezer/common": "npm:^1.1.0" + checksum: 10c0/72be283779dafb1dc7ec4a7c80a7911b9edc251944f0a2c8112230154e7e84a0b3dedc3f09277935614b92eb3d3194b32fdbc3e167496c2501e8ee2ed4e42909 + languageName: node + linkType: hard + +"@codemirror/lang-css@npm:^6.0.0, @codemirror/lang-css@npm:^6.2.1": + version: 6.2.1 + resolution: "@codemirror/lang-css@npm:6.2.1" + dependencies: + "@codemirror/autocomplete": "npm:^6.0.0" + "@codemirror/language": "npm:^6.0.0" + "@codemirror/state": "npm:^6.0.0" + "@lezer/common": "npm:^1.0.2" + "@lezer/css": "npm:^1.0.0" + checksum: 10c0/1196926c0145156bf96f3c9ae71549fbf0a24aa27cdcdc5a7b11107e7c0dbbb3dfd2e84c552978b6378605e03921b0ddc0bfe0617800f7d15cbd245be2f57e40 + languageName: node + linkType: hard + +"@codemirror/lang-html@npm:^6.4.8": + version: 6.4.9 + resolution: "@codemirror/lang-html@npm:6.4.9" + dependencies: + "@codemirror/autocomplete": "npm:^6.0.0" + "@codemirror/lang-css": "npm:^6.0.0" + "@codemirror/lang-javascript": "npm:^6.0.0" + "@codemirror/language": "npm:^6.4.0" + "@codemirror/state": "npm:^6.0.0" + "@codemirror/view": "npm:^6.17.0" + "@lezer/common": "npm:^1.0.0" + "@lezer/css": "npm:^1.1.0" + "@lezer/html": "npm:^1.3.0" + checksum: 10c0/0d6197aa645cc0a9da33789ea30423d4b8320b8e636c8587c7fcf58bdf90ea6934451d84ccbd9dd60dbc7046428204d7c986bd742c2cc459bee7c9653258db70 + languageName: node + linkType: hard + +"@codemirror/lang-javascript@npm:^6.0.0, @codemirror/lang-javascript@npm:^6.2.1": + version: 6.2.2 + resolution: "@codemirror/lang-javascript@npm:6.2.2" + dependencies: + "@codemirror/autocomplete": "npm:^6.0.0" + "@codemirror/language": "npm:^6.6.0" + "@codemirror/lint": "npm:^6.0.0" + "@codemirror/state": "npm:^6.0.0" + "@codemirror/view": "npm:^6.17.0" + "@lezer/common": "npm:^1.0.0" + "@lezer/javascript": "npm:^1.0.0" + checksum: 10c0/348969167fa5f18e8ec7e3614d408a95a54514f5625afcc680377d58a53d0f4ea412dcaeee65f0965e7d96f358d513b5c2744641b21ee5d0d976905b33715e48 + languageName: node + linkType: hard + +"@codemirror/language@npm:^6.0.0, @codemirror/language@npm:^6.10.0, @codemirror/language@npm:^6.4.0, @codemirror/language@npm:^6.6.0": + version: 6.10.2 + resolution: "@codemirror/language@npm:6.10.2" + dependencies: + "@codemirror/state": "npm:^6.0.0" + "@codemirror/view": "npm:^6.23.0" + "@lezer/common": "npm:^1.1.0" + "@lezer/highlight": "npm:^1.0.0" + "@lezer/lr": "npm:^1.0.0" + style-mod: "npm:^4.0.0" + checksum: 10c0/ac9b24dffb3aa6f502283dfe2bc4b4038f9fecbed9450fc4a72d408b9a09dc254f9af735b98091531829da163eb116e4cfa95aeacacff4fd36ef95cd9a54c4a6 + languageName: node + linkType: hard + +"@codemirror/lint@npm:^6.0.0": + version: 6.8.1 + resolution: "@codemirror/lint@npm:6.8.1" + dependencies: + "@codemirror/state": "npm:^6.0.0" + "@codemirror/view": "npm:^6.0.0" + crelt: "npm:^1.0.5" + checksum: 10c0/3e7ca352fe08dd11cea4f3b5cdccff2fd08afb5393fdaf98ac659ef368d9169b4d42618c4f856168910a5d1bae7aa1ab6c72020be85b56ccdeb7f678ceb65b6d + languageName: node + linkType: hard + +"@codemirror/state@npm:^6.0.0, @codemirror/state@npm:^6.4.0": + version: 6.4.1 + resolution: "@codemirror/state@npm:6.4.1" + checksum: 10c0/cdab74d0ca4e262531a257ac419c9c44124f3ace8b0ca1262598a9218fbb6fd8f0afeb4b5ed2f64552a9573a0fc5d55481d4b9b05e9505ef729f9bd0f9469423 + languageName: node + linkType: hard + +"@codemirror/view@npm:^6.0.0, @codemirror/view@npm:^6.17.0, @codemirror/view@npm:^6.23.0, @codemirror/view@npm:^6.23.1, @codemirror/view@npm:^6.27.0": + version: 6.29.1 + resolution: "@codemirror/view@npm:6.29.1" + dependencies: + "@codemirror/state": "npm:^6.4.0" + style-mod: "npm:^4.1.0" + w3c-keyname: "npm:^2.2.4" + checksum: 10c0/f5cc5aed853ab5c0ca2fcb3337b7332650bcbc403faddd436fd7d57bc811901b28fd505bd9301e067b2fefd7f36382f0f67977c2866b2b5b905c01e4ef666476 + languageName: node + linkType: hard + +"@codesandbox/nodebox@npm:0.1.8": + version: 0.1.8 + resolution: "@codesandbox/nodebox@npm:0.1.8" + dependencies: + outvariant: "npm:^1.4.0" + strict-event-emitter: "npm:^0.4.3" + checksum: 10c0/f7c3da0d371ea8801aa362259eb8fc5c1a102d9fc49167236fef6a18452fd1dfd60d302b34b5f166aeee336fd9f066d643609beddedcb86451c3a2c290444225 + languageName: node + linkType: hard + +"@codesandbox/sandpack-client@npm:^2.11.2": + version: 2.18.2 + resolution: "@codesandbox/sandpack-client@npm:2.18.2" + dependencies: + "@codesandbox/nodebox": "npm:0.1.8" + buffer: "npm:^6.0.3" + dequal: "npm:^2.0.2" + mime-db: "npm:^1.52.0" + outvariant: "npm:1.4.0" + static-browser-server: "npm:1.0.3" + checksum: 10c0/e25397fc452a6ca0e92638a5420219a2c895c5c33a1390f7fcde25f275d881ab4cdf196ceac168755f5a2d58f160f9e4fdeb0d28d1b22fc761ed2287571fd7ae + languageName: node + linkType: hard + +"@codesandbox/sandpack-themes@npm:^2.0.21": + version: 2.0.21 + resolution: "@codesandbox/sandpack-themes@npm:2.0.21" + checksum: 10c0/929d4488724e38d18a713892f30b6811bc40adbcd49dbc7dc544b3dc4842c1fdb6e280bd61620662a6ce7def88bd664598c2e37791a518b045067774df2a5ced + languageName: node + linkType: hard + "@colors/colors@npm:1.5.0": version: 1.5.0 resolution: "@colors/colors@npm:1.5.0" @@ -2434,6 +2618,64 @@ __metadata: languageName: node linkType: hard +"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0": + version: 1.2.1 + resolution: "@lezer/common@npm:1.2.1" + checksum: 10c0/af61436dc026f8deebaded13d8e1beea2ae307cbbfb270116cdedadb8208f0674da9c3b5963128a2b1cd4072b4e90bc8128133f4feaf31b6e801e4568f1a15a6 + languageName: node + linkType: hard + +"@lezer/css@npm:^1.0.0, @lezer/css@npm:^1.1.0": + version: 1.1.8 + resolution: "@lezer/css@npm:1.1.8" + dependencies: + "@lezer/common": "npm:^1.2.0" + "@lezer/highlight": "npm:^1.0.0" + "@lezer/lr": "npm:^1.0.0" + checksum: 10c0/d28a84c912eedd675b437a7d0b95c72a6c00987da7dc208049889f64ce57250e9ae640856d007a32df6b8f4b0c8986e7751b40e2536b4df26382a78ead362281 + languageName: node + linkType: hard + +"@lezer/highlight@npm:^1.0.0, @lezer/highlight@npm:^1.1.3, @lezer/highlight@npm:^1.2.0": + version: 1.2.0 + resolution: "@lezer/highlight@npm:1.2.0" + dependencies: + "@lezer/common": "npm:^1.0.0" + checksum: 10c0/d4312f95b78e4b6f10833b1cf99601c6381c22b755bbf60fd61d6fe9b4cf7780650e2e2dadf75beb8d94824dcb5ec81da5cfc9ca54122688a482e488103105aa + languageName: node + linkType: hard + +"@lezer/html@npm:^1.3.0": + version: 1.3.10 + resolution: "@lezer/html@npm:1.3.10" + dependencies: + "@lezer/common": "npm:^1.2.0" + "@lezer/highlight": "npm:^1.0.0" + "@lezer/lr": "npm:^1.0.0" + checksum: 10c0/a7e782f9e9c5c5ffaa4a6fcf4ea5284e62c8fd3f0d378c86738b57077c002cbb013aeeb8aaae292b9517fea8b959216ce7af053269329962f6df2c7f9c2c8d99 + languageName: node + linkType: hard + +"@lezer/javascript@npm:^1.0.0": + version: 1.4.17 + resolution: "@lezer/javascript@npm:1.4.17" + dependencies: + "@lezer/common": "npm:^1.2.0" + "@lezer/highlight": "npm:^1.1.3" + "@lezer/lr": "npm:^1.3.0" + checksum: 10c0/5e69eabd7b6ea58ff828073324282a38567488bd6da1541023f1a66268a0ac9d01cde924f4fad183fcbf630ac33680e6b859a18f6fbec14ffb76073cdccf7b2b + languageName: node + linkType: hard + +"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.3.0": + version: 1.4.2 + resolution: "@lezer/lr@npm:1.4.2" + dependencies: + "@lezer/common": "npm:^1.0.0" + checksum: 10c0/22bb5d0d4b33d0de5eb0706b7e5b5f2d20f570e112d9110009bd35b62ff10f2eb4eff8da4cf373dd4ddf5e06a304120b8f039add7ed9997c981c13945d5329cd + languageName: node + linkType: hard + "@manypkg/find-root@npm:^1.1.0": version: 1.1.0 resolution: "@manypkg/find-root@npm:1.1.0" @@ -2509,6 +2751,13 @@ __metadata: languageName: node linkType: hard +"@open-draft/deferred-promise@npm:^2.1.0": + version: 2.2.0 + resolution: "@open-draft/deferred-promise@npm:2.2.0" + checksum: 10c0/eafc1b1d0fc8edb5e1c753c5e0f3293410b40dde2f92688211a54806d4136887051f39b98c1950370be258483deac9dfd17cf8b96557553765198ef2547e4549 + languageName: node + linkType: hard + "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -2730,6 +2979,13 @@ __metadata: languageName: node linkType: hard +"@stitches/core@npm:^1.2.8": + version: 1.2.8 + resolution: "@stitches/core@npm:1.2.8" + checksum: 10c0/f2ddf5aba3f3794529ceda10e573d61d649899c1d6e4f72f0fb77915577bb4e5a1ffc6e0cebd2bc19a1e6f93d5e1e91ff0790c7a8dfb452e90b090b1a5f1c531 + languageName: node + linkType: hard + "@types/babel__core@npm:^7": version: 7.20.5 resolution: "@types/babel__core@npm:7.20.5" @@ -3215,6 +3471,19 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-core@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/compiler-core@npm:3.4.35" + dependencies: + "@babel/parser": "npm:^7.24.7" + "@vue/shared": "npm:3.4.35" + entities: "npm:^4.5.0" + estree-walker: "npm:^2.0.2" + source-map-js: "npm:^1.2.0" + checksum: 10c0/34fe4aaee292cda4e6fadeca6b85e0ca635c6b57aad47054e9764bc56a5dd7621c9ac9df1021b612f336d215add8e8f8674606074471ddac5ea36a759cf59e86 + languageName: node + linkType: hard + "@vue/compiler-dom@npm:3.4.27": version: 3.4.27 resolution: "@vue/compiler-dom@npm:3.4.27" @@ -3225,6 +3494,16 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-dom@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/compiler-dom@npm:3.4.35" + dependencies: + "@vue/compiler-core": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + checksum: 10c0/e1470ae29a87d4be187a9030f0048df134d6c4672fa24522ce9c3476b9495e7818764512f1ae57b2dac1dee1a87374f68da65ce9e3a70a02f4c9f44f029d19ef + languageName: node + linkType: hard + "@vue/compiler-sfc@npm:3.4.27": version: 3.4.27 resolution: "@vue/compiler-sfc@npm:3.4.27" @@ -3242,6 +3521,23 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-sfc@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/compiler-sfc@npm:3.4.35" + dependencies: + "@babel/parser": "npm:^7.24.7" + "@vue/compiler-core": "npm:3.4.35" + "@vue/compiler-dom": "npm:3.4.35" + "@vue/compiler-ssr": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + estree-walker: "npm:^2.0.2" + magic-string: "npm:^0.30.10" + postcss: "npm:^8.4.40" + source-map-js: "npm:^1.2.0" + checksum: 10c0/479363ad7e6ce3f8be864752e7dd006af820450267c4a12f6437d2da27596d59d0b9afc9c4a4272c2e0f34f66ad044c1479539feeceaee1231cc384e824922d6 + languageName: node + linkType: hard + "@vue/compiler-ssr@npm:3.4.27": version: 3.4.27 resolution: "@vue/compiler-ssr@npm:3.4.27" @@ -3252,6 +3548,16 @@ __metadata: languageName: node linkType: hard +"@vue/compiler-ssr@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/compiler-ssr@npm:3.4.35" + dependencies: + "@vue/compiler-dom": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + checksum: 10c0/3493e17998a6a60f75f63882dcdb15547c586960450fb0ff1576dccc0e2bc35a98a9b70f9b66bdcd05d1fb909d9554e3ac95c1206a8c9b0003ded92a96d3c3c5 + languageName: node + linkType: hard + "@vue/devtools-api@npm:^7.2.0": version: 7.2.1 resolution: "@vue/devtools-api@npm:7.2.1" @@ -3294,6 +3600,15 @@ __metadata: languageName: node linkType: hard +"@vue/reactivity@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/reactivity@npm:3.4.35" + dependencies: + "@vue/shared": "npm:3.4.35" + checksum: 10c0/b19a8b21b3991b0569ab650338f9344c74f1f0fbe6ec488e5db96623b0397f808635fd055cacb7ff61410760cbc8e0ffc320b5c99aca18c456ddbc37f8ce4180 + languageName: node + linkType: hard + "@vue/runtime-core@npm:3.4.27": version: 3.4.27 resolution: "@vue/runtime-core@npm:3.4.27" @@ -3304,6 +3619,16 @@ __metadata: languageName: node linkType: hard +"@vue/runtime-core@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/runtime-core@npm:3.4.35" + dependencies: + "@vue/reactivity": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + checksum: 10c0/64c1bf1e9e7af2c4bff7879842b6c43e575b054cd8b13a65142568a668e33636ca26a05253e5aaff8ba4c579476be99b9ef01e6fe672883f848e6cf36a39bf5c + languageName: node + linkType: hard + "@vue/runtime-dom@npm:3.4.27": version: 3.4.27 resolution: "@vue/runtime-dom@npm:3.4.27" @@ -3315,6 +3640,18 @@ __metadata: languageName: node linkType: hard +"@vue/runtime-dom@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/runtime-dom@npm:3.4.35" + dependencies: + "@vue/reactivity": "npm:3.4.35" + "@vue/runtime-core": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + csstype: "npm:^3.1.3" + checksum: 10c0/80fefde3b30110125f36af59cd4d875fc5c550a1033e4a91287574a51efea486713759739f16ea5283ac1b23bd8ff08194abd87073a9074c6fb484a6c63e0754 + languageName: node + linkType: hard + "@vue/server-renderer@npm:3.4.27": version: 3.4.27 resolution: "@vue/server-renderer@npm:3.4.27" @@ -3327,6 +3664,18 @@ __metadata: languageName: node linkType: hard +"@vue/server-renderer@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/server-renderer@npm:3.4.35" + dependencies: + "@vue/compiler-ssr": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + peerDependencies: + vue: 3.4.35 + checksum: 10c0/6ff8c36ee572c243ae394368d0d22288e708cdc7a316ab6e3ea32756d3cd3b08dd4d49a5f4faf511a894122a3d43cb3a2c400ac37c761d351779dd00e5470fbb + languageName: node + linkType: hard + "@vue/shared@npm:3.4.27, @vue/shared@npm:^3.4.27": version: 3.4.27 resolution: "@vue/shared@npm:3.4.27" @@ -3334,6 +3683,13 @@ __metadata: languageName: node linkType: hard +"@vue/shared@npm:3.4.35": + version: 3.4.35 + resolution: "@vue/shared@npm:3.4.35" + checksum: 10c0/a3711abaf4e5be996112387f2304bf5d51d246c680d93eb8894430b37fe3f0edc9f72428ccbb3ed91656e947d3ac9bdcad41f5c6e51bd1121e222901dab8cb10 + languageName: node + linkType: hard + "@vueuse/core@npm:10.9.0, @vueuse/core@npm:^10.9.0": version: 10.9.0 resolution: "@vueuse/core@npm:10.9.0" @@ -3513,6 +3869,13 @@ __metadata: languageName: node linkType: hard +"anser@npm:^2.1.1": + version: 2.1.1 + resolution: "anser@npm:2.1.1" + checksum: 10c0/47a844fea847ffd580c37587c97c49e505390cb034e397b02c38aafc23d52c64d40fbeefe04a86b83867cfb7093d8884826a0551211b69dda473b1f76ce38e98 + languageName: node + linkType: hard + "ansi-colors@npm:^4.1.1, ansi-colors@npm:^4.1.3": version: 4.1.3 resolution: "ansi-colors@npm:4.1.3" @@ -3601,6 +3964,21 @@ __metadata: languageName: node linkType: hard +"ansi-to-vue3@npm:^0.1.2": + version: 0.1.2 + resolution: "ansi-to-vue3@npm:0.1.2" + dependencies: + anser: "npm:^2.1.1" + escape-carriage: "npm:^1.3.1" + peerDependencies: + vue: ^3.2.0 + peerDependenciesMeta: + vue: + optional: true + checksum: 10c0/ae157e564322d4210e66afac5d6fe50e5f99aa4116aec441d156a95c826a8b95091c1097a8c9c6cceedd4ec3a2e6c93ff4437b1f1407147b063e337215759975 + languageName: node + linkType: hard + "ansicolors@npm:~0.3.2": version: 0.3.2 resolution: "ansicolors@npm:0.3.2" @@ -3803,6 +4181,13 @@ __metadata: languageName: node linkType: hard +"base64-js@npm:^1.3.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 10c0/f23823513b63173a001030fae4f2dabe283b99a9d324ade3ad3d148e218134676f1ee8568c877cd79ec1c53158dcf2d2ba527a97c606618928ba99dd930102bf + languageName: node + linkType: hard + "bcrypt-pbkdf@npm:^1.0.0": version: 1.0.2 resolution: "bcrypt-pbkdf@npm:1.0.2" @@ -3962,6 +4347,16 @@ __metadata: languageName: node linkType: hard +"buffer@npm:^6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" + dependencies: + base64-js: "npm:^1.3.1" + ieee754: "npm:^1.2.1" + checksum: 10c0/2a905fbbcde73cc5d8bd18d1caa23715d5f83a5935867c2329f0ac06104204ba7947be098fe1317fbd8830e26090ff8e764f08cd14fefc977bb248c3487bcbd0 + languageName: node + linkType: hard + "bundle-require@npm:^5.0.0": version: 5.0.0 resolution: "bundle-require@npm:5.0.0" @@ -4246,6 +4641,13 @@ __metadata: languageName: node linkType: hard +"clean-set@npm:^1.1.2": + version: 1.1.2 + resolution: "clean-set@npm:1.1.2" + checksum: 10c0/f77a1204ea1f90d85a21fe434a08f3ec09753eb416544db1f37612653caf40ac52d5941c61f76d367aea5b46a2c29c0b0e7e05029e88c02abb136de5d17283d5 + languageName: node + linkType: hard + "clean-stack@npm:^2.0.0": version: 2.2.0 resolution: "clean-stack@npm:2.2.0" @@ -4461,6 +4863,13 @@ __metadata: languageName: node linkType: hard +"crelt@npm:^1.0.5": + version: 1.0.6 + resolution: "crelt@npm:1.0.6" + checksum: 10c0/e0fb76dff50c5eb47f2ea9b786c17f9425c66276025adee80876bdbf4a84ab72e899e56d3928431ab0cb057a105ef704df80fe5726ef0f7b1658f815521bdf09 + languageName: node + linkType: hard + "cross-spawn@npm:^5.1.0": version: 5.1.0 resolution: "cross-spawn@npm:5.1.0" @@ -4692,6 +5101,13 @@ __metadata: languageName: node linkType: hard +"dequal@npm:^2.0.2, dequal@npm:^2.0.3": + version: 2.0.3 + resolution: "dequal@npm:2.0.3" + checksum: 10c0/f98860cdf58b64991ae10205137c0e97d384c3a4edc7f807603887b7c4b850af1224a33d88012009f150861cbee4fa2d322c4cc04b9313bee312e47f6ecaa888 + languageName: node + linkType: hard + "detect-indent@npm:^6.0.0": version: 6.1.0 resolution: "detect-indent@npm:6.1.0" @@ -4726,7 +5142,10 @@ __metadata: version: 0.0.0-use.local resolution: "docs@workspace:docs" dependencies: + markdown-it-container: "npm:^4.0.0" vitepress: "npm:^1.2.2" + vitepress-plugin-sandpack: "npm:^1.1.4" + vue: "npm:^3.4.34" languageName: unknown linkType: soft @@ -4739,6 +5158,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:^16.0.3": + version: 16.4.5 + resolution: "dotenv@npm:16.4.5" + checksum: 10c0/48d92870076832af0418b13acd6e5a5a3e83bb00df690d9812e94b24aff62b88ade955ac99a05501305b8dc8f1b0ee7638b18493deb6fe93d680e5220936292f + languageName: node + linkType: hard + "dotenv@npm:^8.1.0": version: 8.6.0 resolution: "dotenv@npm:8.6.0" @@ -5195,6 +5621,13 @@ __metadata: languageName: node linkType: hard +"escape-carriage@npm:^1.3.1": + version: 1.3.1 + resolution: "escape-carriage@npm:1.3.1" + checksum: 10c0/ef82888d664d93a0b7246eecf33859235da4a1059c14ce4102894145bc31f82d095579ffd405c01eb8b77a7ee751d1e29e25df85a4b0769ad1c79afa8e983de5 + languageName: node + linkType: hard + "escape-string-regexp@npm:^1.0.0, escape-string-regexp@npm:^1.0.2, escape-string-regexp@npm:^1.0.5": version: 1.0.5 resolution: "escape-string-regexp@npm:1.0.5" @@ -6184,6 +6617,13 @@ __metadata: languageName: node linkType: hard +"ieee754@npm:^1.2.1": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 10c0/b0782ef5e0935b9f12883a2e2aa37baa75da6e66ce6515c168697b42160807d9330de9a32ec1ed73149aea02e0d822e572bca6f1e22bdcbd2149e13b050b17bb + languageName: node + linkType: hard + "ignore@npm:^5.2.0, ignore@npm:^5.3.1": version: 5.3.1 resolution: "ignore@npm:5.3.1" @@ -7018,6 +7458,15 @@ __metadata: languageName: node linkType: hard +"lz-string@npm:^1.5.0": + version: 1.5.0 + resolution: "lz-string@npm:1.5.0" + bin: + lz-string: bin/bin.js + checksum: 10c0/36128e4de34791838abe979b19927c26e67201ca5acf00880377af7d765b38d1c60847e01c5ec61b1a260c48029084ab3893a3925fd6e48a04011364b089991b + languageName: node + linkType: hard + "magic-string@npm:^0.30.10, magic-string@npm:^0.30.5": version: 0.30.10 resolution: "magic-string@npm:0.30.10" @@ -7087,6 +7536,20 @@ __metadata: languageName: node linkType: hard +"markdown-it-container@npm:^3.0.0": + version: 3.0.0 + resolution: "markdown-it-container@npm:3.0.0" + checksum: 10c0/478dc04ec0348ad26a8bd5ee842e897d7aa47f4305023f1a6ac39b056e10b6ba66aed13b42223ee6abd15f5547570857bd0db63064af10386a612d0ac2e69ac1 + languageName: node + linkType: hard + +"markdown-it-container@npm:^4.0.0": + version: 4.0.0 + resolution: "markdown-it-container@npm:4.0.0" + checksum: 10c0/768390a6e2c182996b4d0be8dd1a7279d266ca2f29936dd8265ef0954a97606bc3514802cc3576db59e119e241e61924a4a1e601a91480be1c12bef5e28797ae + languageName: node + linkType: hard + "marked-terminal@npm:^6.0.0": version: 6.2.0 resolution: "marked-terminal@npm:6.2.0" @@ -7169,6 +7632,13 @@ __metadata: languageName: node linkType: hard +"mime-db@npm:^1.52.0": + version: 1.53.0 + resolution: "mime-db@npm:1.53.0" + checksum: 10c0/1dcc37ba8ed5d1c179f5c6f0837e8db19371d5f2ea3690c3c2f3fa8c3858f976851d3460b172b4dee78ebd606762cbb407aa398545fbacd539e519f858cd7bf4 + languageName: node + linkType: hard + "mime-types@npm:^2.1.12, mime-types@npm:~2.1.19": version: 2.1.35 resolution: "mime-types@npm:2.1.35" @@ -7678,6 +8148,20 @@ __metadata: languageName: node linkType: hard +"outvariant@npm:1.4.0": + version: 1.4.0 + resolution: "outvariant@npm:1.4.0" + checksum: 10c0/502d075509fe9709a376cdf9a3eccbd9599fe0c42ed8c723e8c95d4856fa80154e1e957ea0d0d6bb9e0c33352086a6a623803fb5f16775322ede4b9354635bb5 + languageName: node + linkType: hard + +"outvariant@npm:^1.3.0, outvariant@npm:^1.4.0": + version: 1.4.3 + resolution: "outvariant@npm:1.4.3" + checksum: 10c0/5976ca7740349cb8c71bd3382e2a762b1aeca6f33dc984d9d896acdf3c61f78c3afcf1bfe9cc633a7b3c4b295ec94d292048f83ea2b2594fae4496656eba992c + languageName: node + linkType: hard + "p-filter@npm:^2.1.0": version: 2.1.0 resolution: "p-filter@npm:2.1.0" @@ -7992,6 +8476,17 @@ __metadata: languageName: node linkType: hard +"postcss@npm:^8.4.40": + version: 8.4.40 + resolution: "postcss@npm:8.4.40" + dependencies: + nanoid: "npm:^3.3.7" + picocolors: "npm:^1.0.1" + source-map-js: "npm:^1.2.0" + checksum: 10c0/65ed67573e5443beaeb582282ff27a6be7c7fe3b4d9fa15761157616f2b97510cb1c335023c26220b005909f007337026d6e3ff092f25010b484ad484e80ea7f + languageName: node + linkType: hard + "preact@npm:^10.0.0": version: 10.22.0 resolution: "preact@npm:10.22.0" @@ -8579,6 +9074,34 @@ __metadata: languageName: node linkType: hard +"sandpack-vue3@npm:^3.1.9": + version: 3.1.11 + resolution: "sandpack-vue3@npm:3.1.11" + dependencies: + "@codemirror/autocomplete": "npm:^6.12.0" + "@codemirror/commands": "npm:^6.3.3" + "@codemirror/lang-css": "npm:^6.2.1" + "@codemirror/lang-html": "npm:^6.4.8" + "@codemirror/lang-javascript": "npm:^6.2.1" + "@codemirror/language": "npm:^6.10.0" + "@codemirror/state": "npm:^6.4.0" + "@codemirror/view": "npm:^6.23.1" + "@codesandbox/sandpack-client": "npm:^2.11.2" + "@lezer/highlight": "npm:^1.2.0" + "@stitches/core": "npm:^1.2.8" + ansi-to-vue3: "npm:^0.1.2" + clean-set: "npm:^1.1.2" + dequal: "npm:^2.0.3" + lz-string: "npm:^1.5.0" + peerDependencies: + vue: ">=3.2.0" + peerDependenciesMeta: + vue: + optional: true + checksum: 10c0/d0597a8ca47576521cfd4c3d8cf838486866127084e18827e417547b7d02d592f893354cbfaa04aa0112cfb47a87252b779dab49e6aeb037232919c6630024e8 + languageName: node + linkType: hard + "semver@npm:2 || 3 || 4 || 5, semver@npm:^5.0.1": version: 5.7.2 resolution: "semver@npm:5.7.2" @@ -8977,6 +9500,18 @@ __metadata: languageName: node linkType: hard +"static-browser-server@npm:1.0.3": + version: 1.0.3 + resolution: "static-browser-server@npm:1.0.3" + dependencies: + "@open-draft/deferred-promise": "npm:^2.1.0" + dotenv: "npm:^16.0.3" + mime-db: "npm:^1.52.0" + outvariant: "npm:^1.3.0" + checksum: 10c0/fc82cecdc388c54547ef91ad1a51af8aa71459f905b9496a6588bdfe933ede66c11bb4af3b7f42b9f3f08c28e9f4f07838f94ad384698453a113fc90164f5849 + languageName: node + linkType: hard + "std-env@npm:^3.5.0, std-env@npm:^3.7.0": version: 3.7.0 resolution: "std-env@npm:3.7.0" @@ -9012,6 +9547,13 @@ __metadata: languageName: node linkType: hard +"strict-event-emitter@npm:^0.4.3": + version: 0.4.6 + resolution: "strict-event-emitter@npm:0.4.6" + checksum: 10c0/d0231ef081cb1937b1445da59a1ec202d1c097d825c504f398600532490a4104e200b0dce4137467a8eaac5f8f9718d01c99869687afad78cad3b14c4b2e6a39 + languageName: node + linkType: hard + "string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -9175,6 +9717,13 @@ __metadata: languageName: node linkType: hard +"style-mod@npm:^4.0.0, style-mod@npm:^4.1.0": + version: 4.1.2 + resolution: "style-mod@npm:4.1.2" + checksum: 10c0/ad4d870b3642b0e42ecc7be0e106dd14b7af11985e34fee8de34e5e38c3214bfc96fa7055acea86d75a3a59ddea3f6a8c6641001a66494d7df72d09685e3fadb + languageName: node + linkType: hard + "sucrase@npm:^3.35.0": version: 3.35.0 resolution: "sucrase@npm:3.35.0" @@ -10028,6 +10577,28 @@ __metadata: languageName: node linkType: hard +"vitepress-plugin-sandpack@npm:^1.1.4": + version: 1.1.4 + resolution: "vitepress-plugin-sandpack@npm:1.1.4" + dependencies: + "@codesandbox/sandpack-themes": "npm:^2.0.21" + markdown-it-container: "npm:^3.0.0" + sandpack-vue3: "npm:^3.1.9" + peerDependencies: + vite: ">=4.0.0" + vitepress: ^1.0.0-beta.1 + vue: ">=3.2.0" + peerDependenciesMeta: + vite: + optional: true + vitepress: + optional: true + vue: + optional: true + checksum: 10c0/8c3a8b2bf880db3ca77fc676e9c2f479b43d0690ba72b5dd9e1fa02ac6a07d1da2f74d634de05b9d6beb98759ce809d2d18272ea82ae3f319af0e3b019f9b715 + languageName: node + linkType: hard + "vitepress@npm:^1.2.2": version: 1.2.2 resolution: "vitepress@npm:1.2.2" @@ -10195,6 +10766,31 @@ __metadata: languageName: node linkType: hard +"vue@npm:^3.4.34": + version: 3.4.35 + resolution: "vue@npm:3.4.35" + dependencies: + "@vue/compiler-dom": "npm:3.4.35" + "@vue/compiler-sfc": "npm:3.4.35" + "@vue/runtime-dom": "npm:3.4.35" + "@vue/server-renderer": "npm:3.4.35" + "@vue/shared": "npm:3.4.35" + peerDependencies: + typescript: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/072e5550cc15404ce463bde0455e9a5bafa8dd4e2dba1c784ea6a8a531e2eb3fac549bc8f1cb028f861646c96b4fc17071b624f9036199a581c283ada0d648b1 + languageName: node + linkType: hard + +"w3c-keyname@npm:^2.2.4": + version: 2.2.8 + resolution: "w3c-keyname@npm:2.2.8" + checksum: 10c0/37cf335c90efff31672ebb345577d681e2177f7ff9006a9ad47c68c5a9d265ba4a7b39d6c2599ceea639ca9315584ce4bd9c9fbf7a7217bfb7a599e71943c4c4 + languageName: node + linkType: hard + "wcwidth@npm:^1.0.1": version: 1.0.1 resolution: "wcwidth@npm:1.0.1" From 5476eaf01dc84e49ba7ddf7c798680c581b04a1d Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 3 Aug 2024 19:35:18 +0900 Subject: [PATCH 2/2] docs: add demo in chunk api doc --- docs/ko/reference/array/chunk.md | 12 ++++++++++++ docs/reference/array/chunk.md | 14 +++++++++++++- docs/zh_hans/reference/array/chunk.md | 20 ++++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/docs/ko/reference/array/chunk.md b/docs/ko/reference/array/chunk.md index 5b9e83883..b0767156c 100644 --- a/docs/ko/reference/array/chunk.md +++ b/docs/ko/reference/array/chunk.md @@ -38,6 +38,18 @@ chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3); // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']] ``` +## 사용해보기 + +::: sandpack + +```ts index.ts +import { chunk } from 'es-toolkit/array'; + +console.log(chunk([1, 2, 3, 4, 5], 2)); +``` + +::: + ## Lodash 호환성 `es-toolkit/compat`에서 `chunk`를 가져오면 lodash와 호환돼요. diff --git a/docs/reference/array/chunk.md b/docs/reference/array/chunk.md index 66cdf5ff1..f26a3b13d 100644 --- a/docs/reference/array/chunk.md +++ b/docs/reference/array/chunk.md @@ -39,6 +39,18 @@ chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3); // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']] ``` +## Demo + +::: sandpack + +```ts index.ts +import { chunk } from 'es-toolkit/array'; + +console.log(chunk([1, 2, 3, 4, 5], 2)); +``` + +::: + ## Lodash Compatibility Import `chunk` from `es-toolkit/compat` for full compatibility with lodash. @@ -58,4 +70,4 @@ chunk([1, 2, 3], 0); // Returns [] | ----------------- | ----------------------------------- | ----------------------------------- | | es-toolkit | 238 bytes (92.4% smaller) | 9,338,821 times (11% slower) | | es-toolkit/compat | 307 bytes (90.2% smaller) | 9,892,157 times (5% slower) | -| lodash-es | 3,153 bytes | 10,523,270 times | \ No newline at end of file +| lodash-es | 3,153 bytes | 10,523,270 times | diff --git a/docs/zh_hans/reference/array/chunk.md b/docs/zh_hans/reference/array/chunk.md index 17c9279ec..aee8f5742 100644 --- a/docs/zh_hans/reference/array/chunk.md +++ b/docs/zh_hans/reference/array/chunk.md @@ -39,6 +39,18 @@ chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3); // 返回: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']] ``` +## 試用 + +::: sandpack + +```ts index.ts +import { chunk } from 'es-toolkit/array'; + +console.log(chunk([1, 2, 3, 4, 5], 2)); +``` + +::: + ## Lodash兼容性 从`es-toolkit/compat`中导入`chunk`以实现与lodash的完全兼容。 @@ -55,7 +67,7 @@ chunk([1, 2, 3], 0); // Returns [] ## 性能对比 | | [包大小](../../bundle-size.md) | [性能](../../performance.md) | -| ----------------- | ------------------------------ | ----------------------------------- | -| es-toolkit | 238 字节 (小 92.4%) | 9,338,821 次 (慢 11%) | -| es-toolkit/compat | 307 字节 (小 90.2%) | 9,892,157 次 (慢 5%) | -| lodash-es | 3,153 字节 | 10,523,270 次 | +| ----------------- | ------------------------------ | ---------------------------- | +| es-toolkit | 238 字节 (小 92.4%) | 9,338,821 次 (慢 11%) | +| es-toolkit/compat | 307 字节 (小 90.2%) | 9,892,157 次 (慢 5%) | +| lodash-es | 3,153 字节 | 10,523,270 次 |