├── console ├── src │ ├── utils │ │ ├── index.ts │ │ ├── isBuffer.ts │ │ ├── isRegExp.ts │ │ ├── isList.ts │ │ ├── getObjectName.ts │ │ ├── isDataView.ts │ │ ├── isPromise.ts │ │ ├── isDom.ts │ │ ├── entries.ts │ │ ├── keys.ts │ │ ├── isArrayEmpty.ts │ │ ├── isCollection.ts │ │ └── isTypedArray.ts │ ├── components │ │ ├── console-item │ │ │ └── style.css │ │ ├── getter-field │ │ │ ├── style.css │ │ │ └── index.tsx │ │ ├── console-content │ │ │ └── style.scss │ │ ├── console-value-static │ │ │ └── style.scss │ │ ├── prop-name │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ ├── console-value │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ ├── console-group │ │ │ └── style.css │ │ ├── createAnchor.ts │ │ ├── console-badge │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ ├── index.ts │ │ ├── console-location │ │ │ └── index.tsx │ │ ├── console │ │ │ └── index.tsx │ │ ├── console-table │ │ │ └── style.scss │ │ ├── provider │ │ │ └── index.tsx │ │ ├── console-link │ │ │ └── index.tsx │ │ ├── dispatcher │ │ │ └── index.tsx │ │ └── parseLink.ts │ ├── core │ │ ├── store │ │ │ └── index.ts │ │ ├── api │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── utils.ts │ │ ├── index.ts │ │ ├── createRealItem.ts │ │ ├── encode │ │ │ ├── index.ts │ │ │ ├── common.ts │ │ │ └── basic.ts │ │ ├── getValue.ts │ │ ├── id-manager.ts │ │ ├── shouldInline.ts │ │ ├── getOwnDescriptorsIn.ts │ │ ├── getOwnDescriptorsBuffer.ts │ │ ├── getOwnDescriptorsDataView.ts │ │ ├── getOwnDescriptorsRegExp.ts │ │ ├── getStatePromise.ts │ │ ├── getOwnDescriptorsCollection.ts │ │ ├── getOwnDescriptorsTypedArray.ts │ │ └── getLocationCall.ts │ ├── index.ts │ ├── layouts │ │ ├── console-row │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ ├── console-wrapper │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ └── console-block │ │ │ └── index.tsx │ ├── definition │ │ ├── value.ts │ │ ├── index.ts │ │ └── data-preview.ts │ ├── type.ts │ ├── hooks │ │ ├── index.ts │ │ ├── useIndentLevel.ts │ │ ├── useCollapse.ts │ │ ├── useTheme.ts │ │ └── useValueRender.ts │ ├── icons │ │ ├── index.ts │ │ ├── debug │ │ │ ├── style.css │ │ │ └── index.tsx │ │ ├── warn │ │ │ ├── style.css │ │ │ └── index.tsx │ │ ├── error │ │ │ ├── style.css │ │ │ └── index.tsx │ │ └── collapse │ │ │ ├── style.css │ │ │ └── index.tsx │ ├── renders │ │ ├── common.ts │ │ ├── default.vue │ │ ├── array │ │ │ └── array-name.vue │ │ ├── index.ts │ │ ├── buffer.vue │ │ ├── basic.vue │ │ ├── regexp.vue │ │ ├── promise.vue │ │ ├── error.vue │ │ └── function.vue │ ├── assets │ │ ├── down.svg │ │ ├── right.svg │ │ ├── error.svg │ │ └── warn.svg │ └── style │ │ ├── wrap.css │ │ ├── vars.css │ │ └── styles.css ├── shims.d.ts ├── tsup.config.ts ├── windi.config.ts ├── tsconfig.json └── vite.config.ts ├── ui ├── src │ ├── widgets │ │ ├── actions │ │ │ ├── index.ts │ │ │ ├── edit │ │ │ │ └── style.css │ │ │ ├── fullscreen │ │ │ │ ├── style.css │ │ │ │ └── index.tsx │ │ │ ├── common.css │ │ │ └── collapse │ │ │ │ └── style.css │ │ ├── preview │ │ │ ├── block │ │ │ │ ├── style.css │ │ │ │ └── index.tsx │ │ │ ├── actions │ │ │ │ ├── ssr-switch │ │ │ │ │ ├── style.css │ │ │ │ │ └── index.tsx │ │ │ │ ├── terminal-switch │ │ │ │ │ ├── style.scss │ │ │ │ │ └── index.tsx │ │ │ │ ├── device-switch │ │ │ │ │ └── style.scss │ │ │ │ └── device-rotate │ │ │ │ │ └── style.scss │ │ │ ├── index.ts │ │ │ ├── loading │ │ │ │ ├── style.scss │ │ │ │ └── index.tsx │ │ │ ├── browser │ │ │ │ └── widgets │ │ │ │ │ ├── browser-url │ │ │ │ │ ├── style.scss │ │ │ │ │ └── index.tsx │ │ │ │ │ └── browser-decorate │ │ │ │ │ ├── style.scss │ │ │ │ │ └── index.tsx │ │ │ ├── error │ │ │ │ ├── style.scss │ │ │ │ └── index.tsx │ │ │ ├── device │ │ │ │ └── style.scss │ │ │ ├── context.ts │ │ │ ├── layout │ │ │ │ └── Content.tsx │ │ │ └── Preview.tsx │ │ ├── code │ │ │ ├── editor │ │ │ │ ├── index.tsx │ │ │ │ └── style.css │ │ │ ├── index.ts │ │ │ ├── panel │ │ │ │ └── context.ts │ │ │ └── preview │ │ │ │ └── index.tsx │ │ └── toolbar │ │ │ ├── index.tsx │ │ │ └── style.css │ ├── style │ │ └── vars.scss │ ├── index.ts │ ├── layout │ │ ├── block │ │ │ ├── style.scss │ │ │ └── index.tsx │ │ ├── index.tsx │ │ └── full │ │ │ ├── style.css │ │ │ └── index.tsx │ └── assets │ │ └── svg │ │ ├── arrow-down.svg │ │ ├── arrow-right.svg │ │ ├── arrow-left.svg │ │ ├── responsive.svg │ │ ├── terminal.svg │ │ ├── device-rotate.svg │ │ └── browser.svg ├── shims.d.ts ├── scripts │ ├── copy.js │ └── watchAndCopy.js ├── tsconfig.json └── vite.config.ts ├── style ├── src │ └── scss │ │ ├── index.scss │ │ └── use-bem │ │ ├── config.scss │ │ └── function.scss ├── script.js ├── tsconfig.json └── package.json ├── shared ├── src │ ├── config.ts │ ├── file │ │ ├── compile │ │ │ ├── config.ts │ │ │ ├── sfc │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── transform │ │ │ ├── ts │ │ │ │ ├── index.ts │ │ │ │ └── ts.ts │ │ │ ├── index.ts │ │ │ └── esm │ │ │ │ └── config.ts │ │ ├── format │ │ │ └── index.ts │ │ ├── types │ │ │ ├── index.ts │ │ │ └── sfc.ts │ │ ├── parse │ │ │ ├── matter.ts │ │ │ ├── default.ts │ │ │ ├── ts.ts │ │ │ └── comment.ts │ │ ├── index.ts │ │ └── utils.ts │ ├── core │ │ └── index.ts │ ├── index.ts │ ├── demo │ │ ├── transform.ts │ │ ├── format.ts │ │ ├── index.ts │ │ └── types.ts │ └── utils │ │ └── index.ts ├── prettier-standalone.d.ts ├── source-map-js.d.ts ├── tsconfig.json └── rollup.config.mjs ├── docs ├── guide │ ├── preview │ │ ├── view-ts-include.ts │ │ ├── view-ts-include2.ts │ │ ├── error.md │ │ ├── basic-block.vue │ │ ├── no-error-block.vue │ │ ├── terminal-ts.ts │ │ ├── style-background.vue │ │ ├── device.vue │ │ ├── no-error-browser.vue │ │ ├── view-ts.ts │ │ ├── device-scale.vue │ │ ├── error.vue │ │ ├── terminal-basic.vue │ │ ├── basic-browser.vue │ │ ├── ssr-csr-default.vue │ │ ├── ssr-csr.vue │ │ ├── repl.md │ │ ├── index.md │ │ ├── layout-demo │ │ │ └── menu-data.ts │ │ └── terminal-call.vue │ ├── demo.vue │ ├── writing │ │ ├── code.md │ │ ├── code-collapse.vue │ │ ├── highlight.vue │ │ ├── layout-demo │ │ │ └── menu-data.ts │ │ └── include.md │ ├── demo-with-docs.vue │ └── examples.md ├── .vitepress │ ├── cache │ │ └── deps │ │ │ ├── package.json │ │ │ ├── vue.js.map │ │ │ ├── c-UWFEVSM7.js.map │ │ │ ├── cpp-S2WHEMEY.js.map │ │ │ ├── css-QNQYM67B.js.map │ │ │ ├── diff-UN6D6R2L.js.map │ │ │ ├── glsl-WHANAUMW.js.map │ │ │ ├── hlsl-GG4V3PKA.js.map │ │ │ ├── html-GCRMQQEU.js.map │ │ │ ├── java-K7LB5NNM.js.map │ │ │ ├── json-QIYQ7XQJ.js.map │ │ │ ├── jsx-6AFOOOZY.js.map │ │ │ ├── less-JBM46DJ4.js.map │ │ │ ├── lodash-es.js.map │ │ │ ├── lua-FU65MOWE.js.map │ │ │ ├── php-TK6ZW4JE.js.map │ │ │ ├── pug-ICV5I3VQ.js.map │ │ │ ├── r-TMZQRDIU.js.map │ │ │ ├── ruby-R34QNAPN.js.map │ │ │ ├── rust-N23VMWP5.js.map │ │ │ ├── sass-E5YNGGVZ.js.map │ │ │ ├── scss-G7SZJXG7.js.map │ │ │ ├── sql-PDTWWLXF.js.map │ │ │ ├── tex-N2RYNPLG.js.map │ │ │ ├── toml-CVOL3YDE.js.map │ │ │ ├── tsx-UFMHX3OC.js.map │ │ │ ├── vue-5GL625E2.js.map │ │ │ ├── xml-35KRXHJK.js.map │ │ │ ├── yaml-EJH4NJTL.js.map │ │ │ ├── @vue_runtime-core.js.map │ │ │ ├── chunk-624QZG55.js.map │ │ │ ├── cmake-VOYXRBJN.js.map │ │ │ ├── coffee-C3OZ72QE.js.map │ │ │ ├── csharp-E4SSVNIS.js.map │ │ │ ├── gdscript-W27O2R37.js.map │ │ │ ├── gdshader-NFP6QAUP.js.map │ │ │ ├── gnuplot-NCWD27IZ.js.map │ │ │ ├── graphql-5BG7EG3P.js.map │ │ │ ├── haskell-G4JGVNYO.js.map │ │ │ ├── json5-KDJMOWV6.js.map │ │ │ ├── jsonc-CZDOFXJA.js.map │ │ │ ├── julia-DQTJYE73.js.map │ │ │ ├── markdown-2QMFZXFF.js.map │ │ │ ├── postcss-OPY2ATG3.js.map │ │ │ ├── python-3Y6U5HT3.js.map │ │ │ ├── scala-P2ZQ35JU.js.map │ │ │ ├── stylus-3Y4KE24R.js.map │ │ │ ├── turtle-PRUI3MWP.js.map │ │ │ ├── angular-html-R355AKIU.js.map │ │ │ ├── javascript-QVFX4NTP.js.map │ │ │ ├── shellscript-5X4ACGSA.js.map │ │ │ ├── typescript-XKOPEGTU.js.map │ │ │ ├── fortran-free-form-PDOJYNVE.js.map │ │ │ ├── html-derivative-L7GFRHVU.js.map │ │ │ ├── c-UWFEVSM7.js │ │ │ ├── r-TMZQRDIU.js │ │ │ ├── css-QNQYM67B.js │ │ │ ├── diff-UN6D6R2L.js │ │ │ ├── hlsl-GG4V3PKA.js │ │ │ ├── java-K7LB5NNM.js │ │ │ ├── json-QIYQ7XQJ.js │ │ │ ├── jsx-6AFOOOZY.js │ │ │ ├── less-JBM46DJ4.js │ │ │ ├── rust-N23VMWP5.js │ │ │ ├── sass-E5YNGGVZ.js │ │ │ ├── sql-PDTWWLXF.js │ │ │ ├── toml-CVOL3YDE.js │ │ │ ├── tsx-UFMHX3OC.js │ │ │ ├── yaml-EJH4NJTL.js │ │ │ ├── cmake-VOYXRBJN.js │ │ │ ├── json5-KDJMOWV6.js │ │ │ ├── jsonc-CZDOFXJA.js │ │ │ ├── scala-P2ZQ35JU.js │ │ │ ├── csharp-E4SSVNIS.js │ │ │ ├── python-3Y6U5HT3.js │ │ │ ├── stylus-3Y4KE24R.js │ │ │ ├── turtle-PRUI3MWP.js │ │ │ ├── gnuplot-NCWD27IZ.js │ │ │ ├── haskell-G4JGVNYO.js │ │ │ ├── postcss-OPY2ATG3.js │ │ │ ├── gdscript-W27O2R37.js │ │ │ ├── gdshader-NFP6QAUP.js │ │ │ ├── markdown-2QMFZXFF.js │ │ │ ├── javascript-QVFX4NTP.js │ │ │ ├── typescript-XKOPEGTU.js │ │ │ ├── shellscript-5X4ACGSA.js │ │ │ ├── lua-FU65MOWE.js │ │ │ ├── tex-N2RYNPLG.js │ │ │ ├── xml-35KRXHJK.js │ │ │ ├── glsl-WHANAUMW.js │ │ │ ├── scss-G7SZJXG7.js │ │ │ ├── coffee-C3OZ72QE.js │ │ │ ├── fortran-free-form-PDOJYNVE.js │ │ │ ├── html-GCRMQQEU.js │ │ │ ├── cpp-S2WHEMEY.js │ │ │ ├── angular-html-R355AKIU.js │ │ │ ├── html-derivative-L7GFRHVU.js │ │ │ ├── graphql-5BG7EG3P.js │ │ │ ├── php-TK6ZW4JE.js │ │ │ ├── pug-ICV5I3VQ.js │ │ │ ├── julia-DQTJYE73.js │ │ │ ├── ruby-R34QNAPN.js │ │ │ ├── vue-5GL625E2.js │ │ │ ├── tsv-DGBB7FGB.js │ │ │ ├── shellsession-UKFQWJ36.js │ │ │ ├── chunk-DX4IKWJU.js │ │ │ ├── git-rebase-ZFSD5SAA.js │ │ │ ├── csv-5Y4GJZEP.js │ │ │ ├── fortran-fixed-form-ZPSSVK44.js │ │ │ ├── shellsession-UKFQWJ36.js.map │ │ │ └── tsv-DGBB7FGB.js.map │ ├── config │ │ └── index.mts │ ├── theme │ │ └── index.ts │ └── components │ │ └── Layout.vue ├── public │ └── logo-with-shadow.png ├── layout │ ├── tabs.ts │ ├── logo │ │ └── logo.css │ └── links.ts ├── demo-block.vue ├── en │ └── index.md ├── demo-browser.vue ├── lunaria.config.json ├── demo-terminal.vue ├── uno.config.ts └── package.json ├── .npmrc ├── hooks ├── src │ ├── index.ts │ ├── types.ts │ └── hack.ts └── tsconfig.json ├── plugin ├── src │ ├── index.ts │ ├── vite │ │ ├── disableMinifyInternalExports.ts │ │ ├── parse │ │ │ ├── token.test.ts │ │ │ ├── path.test.ts │ │ │ └── file.ts │ │ ├── config.ts │ │ └── injectResolveAlias.ts │ └── markdown │ │ ├── index.ts │ │ └── attrs.ts └── tsconfig.json ├── pnpm-workspace.yaml ├── tsconfig.base.json ├── taze.config.ts ├── bump.config.ts ├── eslint.config.js ├── vitest.config.ts ├── .gitignore ├── LICENSE └── README.md /console/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/src/widgets/actions/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/block/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/src/components/console-item/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/src/scss/index.scss: -------------------------------------------------------------------------------- 1 | @forward 'use-bem/index' -------------------------------------------------------------------------------- /ui/src/style/vars.scss: -------------------------------------------------------------------------------- 1 | $preview-header-height: 2em; -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/ssr-switch/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shared/src/config.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export const CACHE_MAX_FILE = 32 -------------------------------------------------------------------------------- /ui/src/index.ts: -------------------------------------------------------------------------------- 1 | export {default as DemoBox} from './DemoBox' -------------------------------------------------------------------------------- /ui/src/widgets/actions/edit/style.css: -------------------------------------------------------------------------------- 1 | @import '../common.css'; -------------------------------------------------------------------------------- /docs/guide/preview/view-ts-include.ts: -------------------------------------------------------------------------------- 1 | export const message = 'Hello' -------------------------------------------------------------------------------- /shared/prettier-standalone.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'prettier-standalone'; -------------------------------------------------------------------------------- /docs/guide/preview/view-ts-include2.ts: -------------------------------------------------------------------------------- 1 | export const message = 'Sutras!' -------------------------------------------------------------------------------- /shared/src/file/compile/config.ts: -------------------------------------------------------------------------------- 1 | export const COMP_IDENTIFIER = `__sfc__` -------------------------------------------------------------------------------- /shared/src/file/transform/ts/index.ts: -------------------------------------------------------------------------------- 1 | export { transformTS } from './ts' -------------------------------------------------------------------------------- /console/src/core/store/index.ts: -------------------------------------------------------------------------------- 1 | export { LinkStore } from './store' 2 | 3 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /shared/src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './config' 2 | export * from './package' -------------------------------------------------------------------------------- /shared/src/file/compile/sfc/index.ts: -------------------------------------------------------------------------------- 1 | export { compileSFC } from './compile' -------------------------------------------------------------------------------- /shared/src/file/format/index.ts: -------------------------------------------------------------------------------- 1 | export { formatSFC, formatSFCJS } from './sfc' -------------------------------------------------------------------------------- /shared/src/file/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './sfc' 2 | export * from './file' -------------------------------------------------------------------------------- /ui/src/widgets/preview/index.ts: -------------------------------------------------------------------------------- 1 | export {default as Preview} from './Preview' -------------------------------------------------------------------------------- /console/src/components/getter-field/style.css: -------------------------------------------------------------------------------- 1 | .ml-0 { 2 | margin-left: 0; 3 | } -------------------------------------------------------------------------------- /console/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './components' 2 | export * from './core' 3 | -------------------------------------------------------------------------------- /shared/src/file/parse/matter.ts: -------------------------------------------------------------------------------- 1 | export { default as parseMatter } from 'gray-matter' -------------------------------------------------------------------------------- /ui/src/widgets/code/editor/index.tsx: -------------------------------------------------------------------------------- 1 | export {default as LightEditor} from './LightEditor' -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | ignore-workspace-root-check=true 2 | shamefully-hoist=true 3 | shell-emulator=true 4 | -------------------------------------------------------------------------------- /ui/src/widgets/code/index.ts: -------------------------------------------------------------------------------- 1 | import CodePanel from "./panel"; 2 | 3 | export { 4 | CodePanel 5 | } -------------------------------------------------------------------------------- /hooks/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './symbol' 2 | export * from './useDemoProvider' 3 | export * from './sandbox/useRepl' -------------------------------------------------------------------------------- /shared/src/file/transform/index.ts: -------------------------------------------------------------------------------- 1 | export { transformModules } from './esm' 2 | export { transformTS } from './ts/ts' -------------------------------------------------------------------------------- /console/src/layouts/console-row/style.scss: -------------------------------------------------------------------------------- 1 | @include b('console-row'){ 2 | width: 100%; 3 | overflow-x: hidden; 4 | } -------------------------------------------------------------------------------- /shared/src/file/compile/index.ts: -------------------------------------------------------------------------------- 1 | export { compileFile } from './compile' 2 | export type { CompileResult } from './compile' -------------------------------------------------------------------------------- /shared/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './file' 2 | export * from './demo' 3 | export * from './utils' 4 | export * from './core' -------------------------------------------------------------------------------- /docs/public/logo-with-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharpGoldWaveMaker/sutras/HEAD/docs/public/logo-with-shadow.png -------------------------------------------------------------------------------- /ui/src/widgets/preview/loading/style.scss: -------------------------------------------------------------------------------- 1 | @include b('preview-loading'){ 2 | top: 50%; 3 | left: 50%; 4 | position: absolute; 5 | } -------------------------------------------------------------------------------- /console/src/core/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types' 2 | 3 | export { isGroup } from './utils' 4 | export { ConsoleApi } from './basic' 5 | -------------------------------------------------------------------------------- /console/src/utils/isBuffer.ts: -------------------------------------------------------------------------------- 1 | export function isBuffer(buff: any): buff is ArrayBuffer { 2 | return buff instanceof ArrayBuffer 3 | } 4 | -------------------------------------------------------------------------------- /console/src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './encode' 2 | export * from './store' 3 | export * from './api' 4 | export { ConsoleApi } from './api' 5 | -------------------------------------------------------------------------------- /plugin/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './vite' 2 | export { defaultDeviceList, defaultDeviceTypes } from './vite/service' 3 | export * from './markdown' -------------------------------------------------------------------------------- /console/src/components/console-content/style.scss: -------------------------------------------------------------------------------- 1 | @include b(console-content){ 2 | @include m(error){ 3 | color: var(--c-text-error); 4 | } 5 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/vue.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /ui/src/widgets/actions/fullscreen/style.css: -------------------------------------------------------------------------------- 1 | @import '../common.css'; 2 | 3 | .su-fullscreen-action > svg{ 4 | height: 16px; 5 | width: 16px; 6 | } -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - plugin 3 | - ui 4 | - shared 5 | - hooks 6 | - docs 7 | - examples/* 8 | - console 9 | - style 10 | -------------------------------------------------------------------------------- /console/src/definition/value.ts: -------------------------------------------------------------------------------- 1 | export type Collection = 2 | | Map 3 | | WeakMap 4 | | Set 5 | | WeakSet 6 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/c-UWFEVSM7.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/cpp-S2WHEMEY.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/css-QNQYM67B.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/diff-UN6D6R2L.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/glsl-WHANAUMW.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/hlsl-GG4V3PKA.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/html-GCRMQQEU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/java-K7LB5NNM.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/json-QIYQ7XQJ.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/jsx-6AFOOOZY.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/less-JBM46DJ4.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/lodash-es.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/lua-FU65MOWE.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/php-TK6ZW4JE.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/pug-ICV5I3VQ.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/r-TMZQRDIU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/ruby-R34QNAPN.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/rust-N23VMWP5.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/sass-E5YNGGVZ.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/scss-G7SZJXG7.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/sql-PDTWWLXF.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tex-N2RYNPLG.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/toml-CVOL3YDE.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tsx-UFMHX3OC.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/vue-5GL625E2.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/xml-35KRXHJK.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/yaml-EJH4NJTL.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/@vue_runtime-core.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/chunk-624QZG55.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/cmake-VOYXRBJN.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/coffee-C3OZ72QE.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/csharp-E4SSVNIS.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gdscript-W27O2R37.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gdshader-NFP6QAUP.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gnuplot-NCWD27IZ.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/graphql-5BG7EG3P.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/haskell-G4JGVNYO.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/json5-KDJMOWV6.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/jsonc-CZDOFXJA.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/julia-DQTJYE73.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/markdown-2QMFZXFF.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/postcss-OPY2ATG3.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/python-3Y6U5HT3.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/scala-P2ZQ35JU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/stylus-3Y4KE24R.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/turtle-PRUI3MWP.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /ui/src/widgets/code/panel/context.ts: -------------------------------------------------------------------------------- 1 | import type { InjectionKey, Ref } from 'vue' 2 | export const EditorReadyInjectKey = Symbol('EditorReady') as InjectionKey> -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/angular-html-R355AKIU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/javascript-QVFX4NTP.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/shellscript-5X4ACGSA.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/typescript-XKOPEGTU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /console/src/core/createRealItem.ts: -------------------------------------------------------------------------------- 1 | export function createRealItem(value: T, hidden = false) { 2 | return { 3 | "@hidden": hidden, 4 | "@value": value 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /console/src/type.ts: -------------------------------------------------------------------------------- 1 | export type Promisy any> = ( 2 | ...args: T extends (...args: infer R) => any ? R : unknown 3 | ) => Promise> 4 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/fortran-free-form-PDOJYNVE.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/html-derivative-L7GFRHVU.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /console/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import type { DefineComponent } from 'vue' 3 | const component: DefineComponent<{}, {}, any> 4 | export default component 5 | } -------------------------------------------------------------------------------- /ui/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import type { DefineComponent } from 'vue' 3 | 4 | const component: DefineComponent<{}, {}, any> 5 | export default component 6 | } 7 | -------------------------------------------------------------------------------- /console/src/utils/isRegExp.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2 | export function isRegExp(obj: any): obj is RegExp { 3 | return obj instanceof RegExp 4 | } 5 | -------------------------------------------------------------------------------- /docs/layout/tabs.ts: -------------------------------------------------------------------------------- 1 | export const tabs = [ 2 | { 3 | tab: '基本信息', 4 | key: 'base', 5 | }, 6 | { 7 | tab: '详细信息', 8 | key: 'info', 9 | }, 10 | ] -------------------------------------------------------------------------------- /console/src/components/console-value-static/style.scss: -------------------------------------------------------------------------------- 1 | @import "../../style/styles.css"; 2 | 3 | @include b('console-value-static'){ 4 | @include e('number'){ 5 | color: #0643A0; 6 | } 7 | } -------------------------------------------------------------------------------- /console/src/utils/isList.ts: -------------------------------------------------------------------------------- 1 | export function isList(obj: any): obj is Array | NodeList { 2 | if (Array.isArray(obj)) 3 | return true 4 | 5 | return obj instanceof NodeList 6 | } 7 | -------------------------------------------------------------------------------- /console/src/core/encode/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | createEncoder, 3 | encode, 4 | } from './encode' 5 | export { 6 | LinkStore, 7 | } from '../store/store' 8 | 9 | export * from './types' 10 | -------------------------------------------------------------------------------- /console/src/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useLinkParser' 2 | export * from './useTheme' 3 | export * from './useValueRender' 4 | export * from './useIndentLevel' 5 | export * from './useCollapse' 6 | -------------------------------------------------------------------------------- /console/src/utils/getObjectName.ts: -------------------------------------------------------------------------------- 1 | const { toString } = Object.prototype 2 | 3 | export function getObjectName(obj: T): string { 4 | return toString.call(obj).slice(8, -1) 5 | } 6 | -------------------------------------------------------------------------------- /shared/source-map-js.d.ts: -------------------------------------------------------------------------------- 1 | import { SourceMapGenerator as SMG } from 'source-map-js'; 2 | 3 | declare module 'source-map-js/lib/source-map-generator' { 4 | export { SMG as SourceMapGenerator }; 5 | } -------------------------------------------------------------------------------- /console/src/utils/isDataView.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2 | export function isDataView(buff: any): buff is DataView { 3 | return buff instanceof DataView 4 | } 5 | -------------------------------------------------------------------------------- /console/src/components/prop-name/style.scss: -------------------------------------------------------------------------------- 1 | @import "../../style/styles.css"; 2 | 3 | @include b('console-prop-name'){ 4 | font-weight: bold; 5 | @include e('colon'){ 6 | margin-right: 6px; 7 | } 8 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/c-UWFEVSM7.js: -------------------------------------------------------------------------------- 1 | import { 2 | c 3 | } from "./chunk-FD6HLQV3.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | c as default 7 | }; 8 | //# sourceMappingURL=c-UWFEVSM7.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/r-TMZQRDIU.js: -------------------------------------------------------------------------------- 1 | import { 2 | r 3 | } from "./chunk-TRNN2VSC.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | r as default 7 | }; 8 | //# sourceMappingURL=r-TMZQRDIU.js.map 9 | -------------------------------------------------------------------------------- /console/src/utils/isPromise.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 2 | export function isPromise(obj: any): obj is Promise { 3 | return typeof obj?.then === "function" 4 | } 5 | -------------------------------------------------------------------------------- /style/src/scss/use-bem/config.scss: -------------------------------------------------------------------------------- 1 | $namespace: 'su' !default; 2 | $common-separator: '-' !default; 3 | $element-separator: '__' !default; 4 | $modifier-separator: '--' !default; 5 | $state-prefix: 'is-' !default; 6 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@sgwm-sutras/hooks":["./hooks/dist/index.d.mts"], 5 | "@sgwm-sutras/shared":["./shared/dist/index.d.mts"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/css-QNQYM67B.js: -------------------------------------------------------------------------------- 1 | import { 2 | css 3 | } from "./chunk-N3PN3MW6.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | css as default 7 | }; 8 | //# sourceMappingURL=css-QNQYM67B.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/diff-UN6D6R2L.js: -------------------------------------------------------------------------------- 1 | import { 2 | diff 3 | } from "./chunk-FHEPKERI.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | diff as default 7 | }; 8 | //# sourceMappingURL=diff-UN6D6R2L.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/hlsl-GG4V3PKA.js: -------------------------------------------------------------------------------- 1 | import { 2 | hlsl 3 | } from "./chunk-MTEWBWYP.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | hlsl as default 7 | }; 8 | //# sourceMappingURL=hlsl-GG4V3PKA.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/java-K7LB5NNM.js: -------------------------------------------------------------------------------- 1 | import { 2 | java 3 | } from "./chunk-6C2M7LIJ.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | java as default 7 | }; 8 | //# sourceMappingURL=java-K7LB5NNM.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/json-QIYQ7XQJ.js: -------------------------------------------------------------------------------- 1 | import { 2 | json 3 | } from "./chunk-MN6W72E5.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | json as default 7 | }; 8 | //# sourceMappingURL=json-QIYQ7XQJ.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/jsx-6AFOOOZY.js: -------------------------------------------------------------------------------- 1 | import { 2 | jsx 3 | } from "./chunk-QDAQRDRQ.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | jsx as default 7 | }; 8 | //# sourceMappingURL=jsx-6AFOOOZY.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/less-JBM46DJ4.js: -------------------------------------------------------------------------------- 1 | import { 2 | less 3 | } from "./chunk-VOJAU3C4.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | less as default 7 | }; 8 | //# sourceMappingURL=less-JBM46DJ4.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/rust-N23VMWP5.js: -------------------------------------------------------------------------------- 1 | import { 2 | rust 3 | } from "./chunk-IFTRH74U.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | rust as default 7 | }; 8 | //# sourceMappingURL=rust-N23VMWP5.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/sass-E5YNGGVZ.js: -------------------------------------------------------------------------------- 1 | import { 2 | sass 3 | } from "./chunk-5JVA6SGD.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | sass as default 7 | }; 8 | //# sourceMappingURL=sass-E5YNGGVZ.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/sql-PDTWWLXF.js: -------------------------------------------------------------------------------- 1 | import { 2 | sql 3 | } from "./chunk-TMEXIBF4.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | sql as default 7 | }; 8 | //# sourceMappingURL=sql-PDTWWLXF.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/toml-CVOL3YDE.js: -------------------------------------------------------------------------------- 1 | import { 2 | toml 3 | } from "./chunk-OYA7MWUT.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | toml as default 7 | }; 8 | //# sourceMappingURL=toml-CVOL3YDE.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tsx-UFMHX3OC.js: -------------------------------------------------------------------------------- 1 | import { 2 | tsx 3 | } from "./chunk-XBEED437.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | tsx as default 7 | }; 8 | //# sourceMappingURL=tsx-UFMHX3OC.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/yaml-EJH4NJTL.js: -------------------------------------------------------------------------------- 1 | import { 2 | yaml 3 | } from "./chunk-2L6RJMOL.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | yaml as default 7 | }; 8 | //# sourceMappingURL=yaml-EJH4NJTL.js.map 9 | -------------------------------------------------------------------------------- /shared/src/file/index.ts: -------------------------------------------------------------------------------- 1 | export * from './compile' 2 | export * from './transform' 3 | export * from './parse' 4 | export * from './types' 5 | export * from './utils' 6 | export * from './import' 7 | export * from './format' -------------------------------------------------------------------------------- /ui/src/layout/block/style.scss: -------------------------------------------------------------------------------- 1 | @include b('block-layout'){ 2 | @include e('toolbar'){ 3 | position: sticky; 4 | top: var(--vp-nav-height); 5 | z-index: 2; 6 | background-color: var(--vp-c-bg); 7 | } 8 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/cmake-VOYXRBJN.js: -------------------------------------------------------------------------------- 1 | import { 2 | cmake 3 | } from "./chunk-4O7KLP5W.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | cmake as default 7 | }; 8 | //# sourceMappingURL=cmake-VOYXRBJN.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/json5-KDJMOWV6.js: -------------------------------------------------------------------------------- 1 | import { 2 | json5 3 | } from "./chunk-5TD2JSII.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | json5 as default 7 | }; 8 | //# sourceMappingURL=json5-KDJMOWV6.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/jsonc-CZDOFXJA.js: -------------------------------------------------------------------------------- 1 | import { 2 | jsonc 3 | } from "./chunk-4C546BJY.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | jsonc as default 7 | }; 8 | //# sourceMappingURL=jsonc-CZDOFXJA.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/scala-P2ZQ35JU.js: -------------------------------------------------------------------------------- 1 | import { 2 | scala 3 | } from "./chunk-UFL7UBHL.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | scala as default 7 | }; 8 | //# sourceMappingURL=scala-P2ZQ35JU.js.map 9 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/browser/widgets/browser-url/style.scss: -------------------------------------------------------------------------------- 1 | @include b('browser-url'){ 2 | display: block; 3 | height: 1.2em; 4 | background-color: var(--vp-c-bg); 5 | border-radius: 2px; 6 | margin: 0 16px; 7 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/csharp-E4SSVNIS.js: -------------------------------------------------------------------------------- 1 | import { 2 | csharp 3 | } from "./chunk-YVTNK7OJ.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | csharp as default 7 | }; 8 | //# sourceMappingURL=csharp-E4SSVNIS.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/python-3Y6U5HT3.js: -------------------------------------------------------------------------------- 1 | import { 2 | python 3 | } from "./chunk-KWMUTFGQ.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | python as default 7 | }; 8 | //# sourceMappingURL=python-3Y6U5HT3.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/stylus-3Y4KE24R.js: -------------------------------------------------------------------------------- 1 | import { 2 | stylus 3 | } from "./chunk-K2AQWIQ7.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | stylus as default 7 | }; 8 | //# sourceMappingURL=stylus-3Y4KE24R.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/turtle-PRUI3MWP.js: -------------------------------------------------------------------------------- 1 | import { 2 | turtle 3 | } from "./chunk-3W7LADF5.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | turtle as default 7 | }; 8 | //# sourceMappingURL=turtle-PRUI3MWP.js.map 9 | -------------------------------------------------------------------------------- /shared/src/file/transform/esm/config.ts: -------------------------------------------------------------------------------- 1 | export const MODULES_KEY = `__modules__` 2 | export const EXPORT_KEY = `__export__` 3 | export const DYNAMIC_IMPORT_KEY = `__dynamic_import__` 4 | export const MODULE_KEY = `__module__` 5 | -------------------------------------------------------------------------------- /console/src/icons/index.ts: -------------------------------------------------------------------------------- 1 | export { default as CollapseIcon } from './collapse' 2 | export { default as DebugIcon } from './debug' 3 | export { default as ErrorIcon } from './error' 4 | export { default as WarnIcon } from './warn' 5 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gnuplot-NCWD27IZ.js: -------------------------------------------------------------------------------- 1 | import { 2 | gnuplot 3 | } from "./chunk-SP2ZTQOL.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | gnuplot as default 7 | }; 8 | //# sourceMappingURL=gnuplot-NCWD27IZ.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/haskell-G4JGVNYO.js: -------------------------------------------------------------------------------- 1 | import { 2 | haskell 3 | } from "./chunk-472HHJ6V.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | haskell as default 7 | }; 8 | //# sourceMappingURL=haskell-G4JGVNYO.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/postcss-OPY2ATG3.js: -------------------------------------------------------------------------------- 1 | import { 2 | postcss 3 | } from "./chunk-SEUWCAC5.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | postcss as default 7 | }; 8 | //# sourceMappingURL=postcss-OPY2ATG3.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gdscript-W27O2R37.js: -------------------------------------------------------------------------------- 1 | import { 2 | gdscript 3 | } from "./chunk-KEVDWAPB.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | gdscript as default 7 | }; 8 | //# sourceMappingURL=gdscript-W27O2R37.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/gdshader-NFP6QAUP.js: -------------------------------------------------------------------------------- 1 | import { 2 | gdshader 3 | } from "./chunk-TGNRD3UE.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | gdshader as default 7 | }; 8 | //# sourceMappingURL=gdshader-NFP6QAUP.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/markdown-2QMFZXFF.js: -------------------------------------------------------------------------------- 1 | import { 2 | markdown 3 | } from "./chunk-TEMCRTM6.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | markdown as default 7 | }; 8 | //# sourceMappingURL=markdown-2QMFZXFF.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/javascript-QVFX4NTP.js: -------------------------------------------------------------------------------- 1 | import { 2 | javascript 3 | } from "./chunk-NLFATCOM.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | javascript as default 7 | }; 8 | //# sourceMappingURL=javascript-QVFX4NTP.js.map 9 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/typescript-XKOPEGTU.js: -------------------------------------------------------------------------------- 1 | import { 2 | typescript 3 | } from "./chunk-LLA4QFJM.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | typescript as default 7 | }; 8 | //# sourceMappingURL=typescript-XKOPEGTU.js.map 9 | -------------------------------------------------------------------------------- /console/src/utils/isDom.ts: -------------------------------------------------------------------------------- 1 | export function isDom(el: any): el is Node { 2 | try { 3 | if (el instanceof Node) 4 | return el.nodeName !== undefined 5 | return false 6 | } 7 | catch { 8 | return false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/shellscript-5X4ACGSA.js: -------------------------------------------------------------------------------- 1 | import { 2 | shellscript 3 | } from "./chunk-4SM4DCKN.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | shellscript as default 7 | }; 8 | //# sourceMappingURL=shellscript-5X4ACGSA.js.map 9 | -------------------------------------------------------------------------------- /shared/src/demo/transform.ts: -------------------------------------------------------------------------------- 1 | import { DemoContext } from './types' 2 | 3 | export function stringifyDemoContext(context: DemoContext): string{ 4 | return JSON.stringify(context, null, 2).replace(/"\(\) => import\((.*?)\)"/g, '() => import($1)') 5 | } -------------------------------------------------------------------------------- /taze.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'taze' 2 | 3 | export default defineConfig({ 4 | ignorePaths: [ 5 | '**/node_modules/**', 6 | ], 7 | packageMode: { 8 | 'vitepress': 'latest', 9 | 'vue': 'latest' 10 | }, 11 | }) 12 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/lua-FU65MOWE.js: -------------------------------------------------------------------------------- 1 | import { 2 | lua 3 | } from "./chunk-LBVXTFW5.js"; 4 | import "./chunk-FD6HLQV3.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | lua as default 8 | }; 9 | //# sourceMappingURL=lua-FU65MOWE.js.map 10 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tex-N2RYNPLG.js: -------------------------------------------------------------------------------- 1 | import { 2 | tex 3 | } from "./chunk-SMZBJFAH.js"; 4 | import "./chunk-TRNN2VSC.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | tex as default 8 | }; 9 | //# sourceMappingURL=tex-N2RYNPLG.js.map 10 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/xml-35KRXHJK.js: -------------------------------------------------------------------------------- 1 | import { 2 | xml 3 | } from "./chunk-JERJOFXJ.js"; 4 | import "./chunk-6C2M7LIJ.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | xml as default 8 | }; 9 | //# sourceMappingURL=xml-35KRXHJK.js.map 10 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/glsl-WHANAUMW.js: -------------------------------------------------------------------------------- 1 | import { 2 | glsl 3 | } from "./chunk-HYK53CNE.js"; 4 | import "./chunk-FD6HLQV3.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | glsl as default 8 | }; 9 | //# sourceMappingURL=glsl-WHANAUMW.js.map 10 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/scss-G7SZJXG7.js: -------------------------------------------------------------------------------- 1 | import { 2 | scss 3 | } from "./chunk-7K4WEFBJ.js"; 4 | import "./chunk-N3PN3MW6.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | scss as default 8 | }; 9 | //# sourceMappingURL=scss-G7SZJXG7.js.map 10 | -------------------------------------------------------------------------------- /hooks/src/types.ts: -------------------------------------------------------------------------------- 1 | export type DemoPatternType = 'editable' | 'readPretty' 2 | 3 | export type DemoShowLangType = 'ts' | 'js' 4 | 5 | export type ThemeType = 'dark' | 'light' 6 | 7 | export interface DemoContext { 8 | /** 9 | * 10 | */ 11 | } 12 | -------------------------------------------------------------------------------- /style/script.js: -------------------------------------------------------------------------------- 1 | import { copy } from 'fs-extra' 2 | import fg from 'fast-glob' 3 | 4 | function toDest(file) { 5 | return file.replace(/^src\//, 'dist/') 6 | } 7 | 8 | fg.sync('src/scss/**').forEach((file) => { 9 | copy(file, toDest(file)) 10 | }) 11 | -------------------------------------------------------------------------------- /shared/src/demo/format.ts: -------------------------------------------------------------------------------- 1 | import { pascalCase } from "../utils"; 2 | 3 | export function getDemoInjectSymbol(name: string){ 4 | return `$${pascalCase(name)}DemoInjectKey` 5 | } 6 | 7 | export function getPageInjectSymbol(){ 8 | return `PageDataInjectKey` 9 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/coffee-C3OZ72QE.js: -------------------------------------------------------------------------------- 1 | import { 2 | coffee 3 | } from "./chunk-YQWML22X.js"; 4 | import "./chunk-NLFATCOM.js"; 5 | import "./chunk-624QZG55.js"; 6 | export { 7 | coffee as default 8 | }; 9 | //# sourceMappingURL=coffee-C3OZ72QE.js.map 10 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/fortran-free-form-PDOJYNVE.js: -------------------------------------------------------------------------------- 1 | import { 2 | fortran_free_form 3 | } from "./chunk-QXMAVGRV.js"; 4 | import "./chunk-624QZG55.js"; 5 | export { 6 | fortran_free_form as default 7 | }; 8 | //# sourceMappingURL=fortran-free-form-PDOJYNVE.js.map 9 | -------------------------------------------------------------------------------- /bump.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'bumpp' 2 | 3 | export default defineConfig({ 4 | files: [ 5 | 'package.json', 6 | 'plugins/*/package.json', 7 | 'docs/package.json', 8 | 'shared/package.json', 9 | 'ui/package.json', 10 | ], 11 | }) 12 | -------------------------------------------------------------------------------- /console/src/components/console-value/style.scss: -------------------------------------------------------------------------------- 1 | @import "../../style/styles.css"; 2 | 3 | @include b('console-value'){ 4 | margin-right: 4px; 5 | &:last-child { 6 | margin-right: 0; 7 | } 8 | // &:hover { 9 | // background-color: #F2F2F2; 10 | // } 11 | } -------------------------------------------------------------------------------- /console/src/core/getValue.ts: -------------------------------------------------------------------------------- 1 | export function getValue( 2 | data: object, 3 | name: string | symbol | number, 4 | receiver: object, 5 | ) { 6 | try { 7 | return Reflect.get(data, name, receiver) 8 | } 9 | catch (e) { 10 | return e 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /console/src/utils/entries.ts: -------------------------------------------------------------------------------- 1 | import { keys } from "./keys" 2 | 3 | export function entries(obj: T): [keyof T, T[keyof T]][] { 4 | return keys(obj).map((name) => [name, (obj as unknown as any)[name]]) as [ 5 | keyof T, 6 | T[keyof T] 7 | ][] 8 | } 9 | -------------------------------------------------------------------------------- /console/src/icons/debug/style.css: -------------------------------------------------------------------------------- 1 | .su-console-debug-icon{ 2 | display: inline-block; 3 | text-align: center; 4 | height: 12px; 5 | line-height: 12px; 6 | vertical-align: middle; 7 | } 8 | 9 | .su-console-debug-icon svg { 10 | height: 100%; 11 | width: 100%; 12 | } -------------------------------------------------------------------------------- /console/src/utils/keys.ts: -------------------------------------------------------------------------------- 1 | export function keys(obj: T): (string | number | symbol)[] { 2 | const keys: (string | number | symbol)[] = [ 3 | ...Object.getOwnPropertyNames(obj), 4 | ...Object.getOwnPropertySymbols(obj) 5 | ] 6 | 7 | return keys 8 | } 9 | -------------------------------------------------------------------------------- /ui/src/assets/svg/arrow-down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import antfu from '@antfu/eslint-config' 2 | 3 | export default antfu({ 4 | formatters: true, 5 | unocss: true, 6 | vue: true, 7 | typescript: { 8 | overrides: { 9 | 'n/prefer-global/process': ['error', 'always'], 10 | }, 11 | }, 12 | }) 13 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/html-GCRMQQEU.js: -------------------------------------------------------------------------------- 1 | import { 2 | html 3 | } from "./chunk-XERGCYM2.js"; 4 | import "./chunk-N3PN3MW6.js"; 5 | import "./chunk-NLFATCOM.js"; 6 | import "./chunk-624QZG55.js"; 7 | export { 8 | html as default 9 | }; 10 | //# sourceMappingURL=html-GCRMQQEU.js.map 11 | -------------------------------------------------------------------------------- /console/src/components/console-group/style.css: -------------------------------------------------------------------------------- 1 | .children\:ml-0:deep(> *) { 2 | margin-left: 0 !important; 3 | } 4 | .border-b-none { 5 | border-bottom: none; 6 | } 7 | .min-w-0 { 8 | min-width: 0; 9 | } 10 | 11 | .su-console-group{ 12 | border-bottom: 1px solid var(--c-border); 13 | } -------------------------------------------------------------------------------- /ui/src/widgets/preview/error/style.scss: -------------------------------------------------------------------------------- 1 | @include b('preview-error'){ 2 | border-width: 2px; 3 | position: absolute; 4 | top: 2em; 5 | width: 100%; 6 | & > div.ant-alert{ 7 | padding: 8px!important; 8 | border-radius: 0!important; 9 | border: 1px solid #ffccc7; 10 | } 11 | } -------------------------------------------------------------------------------- /console/src/utils/isArrayEmpty.ts: -------------------------------------------------------------------------------- 1 | export function isArrayEmpty({ arr }: { arr: Array }): boolean { 2 | // eslint-disable-next-line no-unreachable-loop 3 | for (const name in arr) { 4 | if (Number.isNaN(+name)) return true 5 | return false 6 | } 7 | 8 | return true 9 | } 10 | -------------------------------------------------------------------------------- /console/src/icons/warn/style.css: -------------------------------------------------------------------------------- 1 | .su-console-warn-icon{ 2 | display: inline-block; 3 | text-align: center; 4 | height: var(--su-console-line-height); 5 | line-height: var(--su-console-line-height); 6 | width: 12px; 7 | } 8 | 9 | .su-console-warn-icon svg { 10 | height: 100%; 11 | width: 100%; 12 | } -------------------------------------------------------------------------------- /ui/scripts/copy.js: -------------------------------------------------------------------------------- 1 | import { copy } from 'fs-extra' 2 | import fg from 'fast-glob' 3 | 4 | function toDest(file) { 5 | return file.replace(/^src\//, 'dist/') 6 | } 7 | 8 | fg.sync('src/**').forEach((file) => { 9 | if (/(\.ts|tsconfig\.json)$/.test(file)) return 10 | copy(file, toDest(file)) 11 | }) 12 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/browser/widgets/browser-decorate/style.scss: -------------------------------------------------------------------------------- 1 | @include b('browser-decorate'){ 2 | display: block; 3 | width: 0.5em; 4 | height: 0.5em; 5 | margin-right: 3em; 6 | background-color: #f44; 7 | border-radius: 50%; 8 | box-shadow: 0 0 0 2px #f44,1.25em 0 0 2px #9b3,2.5em 0 0 2px #fb5; 9 | } -------------------------------------------------------------------------------- /console/src/icons/error/style.css: -------------------------------------------------------------------------------- 1 | .su-console-error-icon{ 2 | display: inline-block; 3 | text-align: center; 4 | height: var(--su-console-line-height); 5 | line-height: var(--su-console-line-height); 6 | width: 12px; 7 | } 8 | 9 | .su-console-error-icon svg { 10 | height: 100%; 11 | width: 100%; 12 | } -------------------------------------------------------------------------------- /console/src/layouts/console-wrapper/style.scss: -------------------------------------------------------------------------------- 1 | @include b('console-wrapper') { 2 | margin: 4px; 3 | padding: 0 2px; 4 | background-color: var(--su-console-bg); 5 | font-size: 12px; 6 | height: 100%; 7 | font-family: 'Consolas', 'DejaVu Sans Mono', 'Fira Code', 'Roboto Mono', monospace; 8 | white-space: pre-wrap; 9 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/cpp-S2WHEMEY.js: -------------------------------------------------------------------------------- 1 | import { 2 | cpp 3 | } from "./chunk-HI2RMQ7U.js"; 4 | import "./chunk-HYK53CNE.js"; 5 | import "./chunk-TMEXIBF4.js"; 6 | import "./chunk-FD6HLQV3.js"; 7 | import "./chunk-624QZG55.js"; 8 | export { 9 | cpp as default 10 | }; 11 | //# sourceMappingURL=cpp-S2WHEMEY.js.map 12 | -------------------------------------------------------------------------------- /console/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: { 5 | runtime: './src/core/index.ts', 6 | }, 7 | splitting: true, 8 | format: ['esm'], 9 | target: 'esnext', 10 | dts: true, 11 | metafile: false, 12 | external: ['vue'], 13 | treeshake: true, 14 | }) 15 | -------------------------------------------------------------------------------- /console/src/icons/collapse/style.css: -------------------------------------------------------------------------------- 1 | .su-console-collapse-icon{ 2 | display: inline-block; 3 | text-align: center; 4 | height: var(--su-console-line-height); 5 | line-height: var(--su-console-line-height); 6 | width: 8px; 7 | cursor: pointer; 8 | } 9 | 10 | .su-console-collapse-icon svg { 11 | height: 100%; 12 | width: 100%; 13 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/angular-html-R355AKIU.js: -------------------------------------------------------------------------------- 1 | import { 2 | angular_html 3 | } from "./chunk-D5N6XTGZ.js"; 4 | import "./chunk-XERGCYM2.js"; 5 | import "./chunk-N3PN3MW6.js"; 6 | import "./chunk-NLFATCOM.js"; 7 | import "./chunk-624QZG55.js"; 8 | export { 9 | angular_html as default 10 | }; 11 | //# sourceMappingURL=angular-html-R355AKIU.js.map 12 | -------------------------------------------------------------------------------- /docs/.vitepress/config/index.mts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitepress' 2 | import { shared } from './shared' 3 | import { zh } from './zh' 4 | 5 | export default defineConfig({ 6 | ...shared, 7 | locales: { 8 | root: { label: '简体中文', ...zh }, 9 | // en: { label: 'English', ...en }, 10 | // pt: { label: 'Português', ...pt } 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/html-derivative-L7GFRHVU.js: -------------------------------------------------------------------------------- 1 | import { 2 | html_derivative 3 | } from "./chunk-DX4IKWJU.js"; 4 | import "./chunk-XERGCYM2.js"; 5 | import "./chunk-N3PN3MW6.js"; 6 | import "./chunk-NLFATCOM.js"; 7 | import "./chunk-624QZG55.js"; 8 | export { 9 | html_derivative as default 10 | }; 11 | //# sourceMappingURL=html-derivative-L7GFRHVU.js.map 12 | -------------------------------------------------------------------------------- /docs/guide/preview/error.md: -------------------------------------------------------------------------------- 1 | # 运行时错误 2 | 3 | 沙箱模式下,Sutra在展示区将对demo的运行时错误给予提示,这通常发生在用户编辑demo示例代码时。 4 | 5 | **抛出错误的demo** 6 | 7 | 8 | 9 | 你也可以将demo中的抛出错误相关代码移除,demo将重新执行,渲染正确的结果: 10 | 11 | ```js 12 | throw Error('demo 运行时发生了错误!') 13 | ``` 14 | 15 | **未抛出错误的demo** 16 | 17 | 18 | -------------------------------------------------------------------------------- /ui/src/assets/svg/arrow-right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/graphql-5BG7EG3P.js: -------------------------------------------------------------------------------- 1 | import { 2 | graphql 3 | } from "./chunk-KKV3GLWI.js"; 4 | import "./chunk-QDAQRDRQ.js"; 5 | import "./chunk-XBEED437.js"; 6 | import "./chunk-LLA4QFJM.js"; 7 | import "./chunk-NLFATCOM.js"; 8 | import "./chunk-624QZG55.js"; 9 | export { 10 | graphql as default 11 | }; 12 | //# sourceMappingURL=graphql-5BG7EG3P.js.map 13 | -------------------------------------------------------------------------------- /ui/src/assets/svg/arrow-left.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/src/definition/index.ts: -------------------------------------------------------------------------------- 1 | import type { PObjReal } from './data-preview' 2 | import type { DGetSetter } from './data' 3 | 4 | export * from './value' 5 | export * from './data' 6 | export * from './data-preview' 7 | 8 | export type ConsoleTypeBasic = 'warn' | 'info' | 'debug' | 'error' | 'output' | 'log' 9 | 10 | export type ConsoleItemData = PObjReal['']['@value'] | DGetSetter 11 | -------------------------------------------------------------------------------- /console/src/core/id-manager.ts: -------------------------------------------------------------------------------- 1 | const store = new Map() 2 | 3 | export function get(data: unknown): string { 4 | const inStore = store.get(data) 5 | 6 | if (inStore) 7 | return inStore 8 | 9 | const newKey = Math.random().toString(36) 10 | 11 | store.set(data, newKey) 12 | 13 | return newKey 14 | } 15 | export function clear(): void { 16 | store.clear() 17 | } 18 | -------------------------------------------------------------------------------- /console/src/core/shouldInline.ts: -------------------------------------------------------------------------------- 1 | const TEXT_NODE_MAX_INLINE_CHARS = 80 2 | 3 | export function shouldInline(data: Node): boolean { 4 | return ( 5 | data.childNodes.length === 0 6 | || (data.childNodes.length === 1 7 | && (!data.textContent 8 | || (data.childNodes[0].nodeType === Node.TEXT_NODE 9 | && data.textContent.length < TEXT_NODE_MAX_INLINE_CHARS))) 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /console/windi.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'windicss/helpers' 2 | import formsPlugin from 'windicss/plugin/forms' 3 | 4 | export default defineConfig({ 5 | darkMode: 'class', 6 | safelist: 'p-3 p-4 p-5', 7 | theme: { 8 | extend: { 9 | colors: { 10 | teal: { 11 | 100: '#096', 12 | }, 13 | }, 14 | }, 15 | }, 16 | plugins: [formsPlugin], 17 | }) -------------------------------------------------------------------------------- /ui/src/widgets/preview/browser/widgets/browser-url/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import { defineComponent } from 'vue' 3 | import './style.scss' 4 | 5 | const BrowserURL = defineComponent({ 6 | name: 'BrowserDecorate', 7 | setup(){ 8 | const ns = useNamespace('browser-url') 9 | return () =>
10 | } 11 | }) 12 | 13 | export default BrowserURL 14 | -------------------------------------------------------------------------------- /console/src/renders/common.ts: -------------------------------------------------------------------------------- 1 | import type { FunctionalComponent, SlotsType } from 'vue' 2 | import type { ConsoleItemData } from '../definition' 3 | 4 | export interface RenderProps { 5 | data: ConsoleItemData 6 | flat?: boolean 7 | isLog?: boolean 8 | } 9 | 10 | export type RenderSlots = SlotsType<{ 11 | default: any 12 | }> 13 | 14 | export type RenderFunction = FunctionalComponent 15 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | import Theme from 'vitepress/theme' 2 | import './style/main.css' 3 | import './style/var.css' 4 | import '@sgwm-sutras/ui/dist/style.css' 5 | import { DemoBox } from '@sgwm-sutras/ui' 6 | import Layout from '../components/Layout.vue' 7 | 8 | export default { 9 | extends: Theme, 10 | Layout: Layout, 11 | enhanceApp({ app }) { 12 | app.component('demo', DemoBox) 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /docs/guide/demo.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/browser/widgets/browser-decorate/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import { defineComponent } from 'vue' 3 | import './style.scss' 4 | 5 | const BrowserDecorate = defineComponent({ 6 | name: 'BrowserDecorate', 7 | setup(){ 8 | const ns = useNamespace('browser-decorate') 9 | return () =>
10 | } 11 | }) 12 | 13 | export default BrowserDecorate 14 | -------------------------------------------------------------------------------- /docs/guide/preview/basic-block.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /ui/src/widgets/toolbar/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from "vue"; 2 | import './style.css' 3 | 4 | const Toolbar = defineComponent({ 5 | name: 'Toolbar', 6 | setup(_, {slots}){ 7 | return () => { 8 | return ( 9 |
10 | {slots.default?.()} 11 |
12 | ) 13 | } 14 | } 15 | }) 16 | 17 | export default Toolbar -------------------------------------------------------------------------------- /docs/guide/preview/no-error-block.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /plugin/src/vite/disableMinifyInternalExports.ts: -------------------------------------------------------------------------------- 1 | import type { UserConfig } from "vite"; 2 | 3 | export function disableMinifyInternalExports(userConfig: UserConfig){ 4 | let outputs = userConfig?.build?.rollupOptions?.output 5 | if(outputs){ 6 | outputs = Array.isArray(outputs) ? outputs : [outputs] 7 | for (const output of outputs) { 8 | output.minifyInternalExports = false 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /ui/src/assets/svg/responsive.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/src/icons/warn/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from "vue"; 2 | import WarnSVG from '../../assets/warn.svg' 3 | import './style.css' 4 | 5 | const WarnIcon = defineComponent({ 6 | name: 'WarnIcon', 7 | props: { 8 | expand: Boolean 9 | }, 10 | setup(props){ 11 | return () => ( 12 | 13 | 14 | 15 | ) 16 | } 17 | }) 18 | 19 | export default WarnIcon -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/php-TK6ZW4JE.js: -------------------------------------------------------------------------------- 1 | import { 2 | php 3 | } from "./chunk-ZM6SOVWS.js"; 4 | import "./chunk-TMEXIBF4.js"; 5 | import "./chunk-JERJOFXJ.js"; 6 | import "./chunk-MN6W72E5.js"; 7 | import "./chunk-XERGCYM2.js"; 8 | import "./chunk-N3PN3MW6.js"; 9 | import "./chunk-6C2M7LIJ.js"; 10 | import "./chunk-NLFATCOM.js"; 11 | import "./chunk-624QZG55.js"; 12 | export { 13 | php as default 14 | }; 15 | //# sourceMappingURL=php-TK6ZW4JE.js.map 16 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/pug-ICV5I3VQ.js: -------------------------------------------------------------------------------- 1 | import { 2 | pug 3 | } from "./chunk-BGBLOFKN.js"; 4 | import "./chunk-YQWML22X.js"; 5 | import "./chunk-5JVA6SGD.js"; 6 | import "./chunk-K2AQWIQ7.js"; 7 | import "./chunk-XERGCYM2.js"; 8 | import "./chunk-7K4WEFBJ.js"; 9 | import "./chunk-N3PN3MW6.js"; 10 | import "./chunk-NLFATCOM.js"; 11 | import "./chunk-624QZG55.js"; 12 | export { 13 | pug as default 14 | }; 15 | //# sourceMappingURL=pug-ICV5I3VQ.js.map 16 | -------------------------------------------------------------------------------- /console/src/icons/debug/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from "vue"; 2 | import DebugSVG from '../../assets/debug.svg' 3 | import './style.css' 4 | 5 | const DebugIcon = defineComponent({ 6 | name: 'DebugIcon', 7 | props: { 8 | expand: Boolean 9 | }, 10 | setup(props){ 11 | return () => ( 12 | 13 | 14 | 15 | ) 16 | } 17 | }) 18 | 19 | export default DebugIcon -------------------------------------------------------------------------------- /console/src/icons/error/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from "vue"; 2 | import ErrorSVG from '../../assets/error.svg' 3 | import './style.css' 4 | 5 | const ErrorIcon = defineComponent({ 6 | name: 'ErrorIcon', 7 | props: { 8 | expand: Boolean 9 | }, 10 | setup(props){ 11 | return () => ( 12 | 13 | 14 | 15 | ) 16 | } 17 | }) 18 | 19 | export default ErrorIcon -------------------------------------------------------------------------------- /docs/.vitepress/components/Layout.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | -------------------------------------------------------------------------------- /ui/scripts/watchAndCopy.js: -------------------------------------------------------------------------------- 1 | import { copy, remove } from 'fs-extra' 2 | import { watch } from 'chokidar' 3 | import { normalizePath } from 'vite' 4 | 5 | function toDist(file) { 6 | return normalizePath(file).replace(/^src\//, 'dist/') 7 | } 8 | 9 | watch('src/client/**/!(*.ts|tsconfig.json)') 10 | .on('change', (file) => copy(file, toDist(file))) 11 | .on('add', (file) => copy(file, toDist(file))) 12 | .on('unlink', (file) => remove(toDist(file))) 13 | -------------------------------------------------------------------------------- /ui/src/widgets/toolbar/style.css: -------------------------------------------------------------------------------- 1 | .toolbar { 2 | width: 100%; 3 | padding: 12px 0; 4 | display: flex; 5 | flex-direction: row; 6 | align-items: center; 7 | justify-content: center; 8 | border-top: 1px dashed var(--vp-c-gray-2); 9 | border-bottom: 1px dashed var(--vp-c-gray-2); 10 | margin: 8px 0; 11 | } 12 | 13 | .toolbar >* { 14 | margin-right: 12px; 15 | } 16 | 17 | .toolbar >*:last-child { 18 | margin-right: 0; 19 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/julia-DQTJYE73.js: -------------------------------------------------------------------------------- 1 | import { 2 | julia 3 | } from "./chunk-7TEL7U62.js"; 4 | import "./chunk-KWMUTFGQ.js"; 5 | import "./chunk-TRNN2VSC.js"; 6 | import "./chunk-HI2RMQ7U.js"; 7 | import "./chunk-HYK53CNE.js"; 8 | import "./chunk-TMEXIBF4.js"; 9 | import "./chunk-FD6HLQV3.js"; 10 | import "./chunk-NLFATCOM.js"; 11 | import "./chunk-624QZG55.js"; 12 | export { 13 | julia as default 14 | }; 15 | //# sourceMappingURL=julia-DQTJYE73.js.map 16 | -------------------------------------------------------------------------------- /console/src/renders/default.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | -------------------------------------------------------------------------------- /docs/layout/logo/logo.css: -------------------------------------------------------------------------------- 1 | .cls-1{fill:none;} 2 | .cls-2{clip-path:url(#clip-path);} 3 | .cls-3{clip-path:url(#clip-path-2);} 4 | .cls-4{fill:url(#未命名的渐变);} 5 | .cls-5{clip-path:url(#clip-path-3);} 6 | .cls-6{fill:url(#未命名的渐变_2);} 7 | .cls-7{clip-path:url(#clip-path-4);} 8 | .cls-8{fill:url(#未命名的渐变_3);} 9 | .cls-9{fill:#e6e6e6;} 10 | .cls-10{fill:#ececec;} 11 | .cls-11{fill:#f2f2f2;} 12 | .cls-12{fill:#fff;} 13 | .cls-13{opacity:0.7;} 14 | .cls-14{clip-path:url(#clip-path-5);} -------------------------------------------------------------------------------- /console/src/layouts/console-row/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import { defineComponent } from 'vue' 3 | import './style.scss' 4 | 5 | const ConsoleRow = defineComponent({ 6 | name: 'ConsoleRow', 7 | setup(_, { slots }) { 8 | const ns = useNamespace('console-row') 9 | return () => ( 10 |
11 | {slots.default?.()} 12 |
13 | ) 14 | }, 15 | }) 16 | 17 | export default ConsoleRow 18 | -------------------------------------------------------------------------------- /docs/guide/writing/code.md: -------------------------------------------------------------------------------- 1 | # 代码块 2 | 3 | 代码块部分支持设置默认折叠状态与高亮样式 4 | 5 | ## 代码块折叠 6 | 7 | 界面模式下,代码块默认是折叠的; 8 | 终端模式下,为了让你的库学习者更直观了解demo,代码块默认是展开的。 9 | 10 | 你也可以手动配置代码块的默认折叠状态 11 | 12 | ``` 13 | --- 14 | defaultCodeCollapse: false // 默认展开 15 | --- 16 | ``` 17 | 18 | 19 | 20 | ## 代码块高亮 21 | 22 | Sutras在代码块中保留了Vitepress的代码块高亮功能 23 | 24 | ``` 25 | --- 26 | badge: warning-beta 27 | highlight: '{11}' 28 | --- 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/guide/preview/terminal-ts.ts: -------------------------------------------------------------------------------- 1 | import {chunk} from 'lodash-es' 2 | 3 | console.group('demo: chunk-2') 4 | console.log(chunk(['a', 'b', 'c', 'd'], 2)) 5 | console.groupEnd() 6 | 7 | console.group('demo: chunk-3') 8 | console.log(chunk(['a', 'b', 'c', 'd'], 3)) 9 | console.groupEnd() 10 | 11 | const result = chunk(['a', 'b', 'c', 'd'], 4) 12 | console.groupCollapsed('demo: chunk-4') 13 | console.log(result) 14 | console.groupEnd() 15 | 16 | console.assert(result.length === 2, `错误信息`) -------------------------------------------------------------------------------- /console/src/assets/down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/src/layouts/console-wrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from 'vue' 2 | import { useNamespace } from '@sgwm-sutras/style' 3 | import './style.scss' 4 | 5 | const ConsoleWrapper = defineComponent({ 6 | name: 'ConsoleWrapper', 7 | setup(_, { slots }) { 8 | const ns = useNamespace('console-wrapper') 9 | return () => ( 10 |
11 | {slots.default?.()} 12 |
13 | ) 14 | }, 15 | }) 16 | 17 | export default ConsoleWrapper 18 | -------------------------------------------------------------------------------- /docs/guide/preview/style-background.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 13 | 14 | 15 | --- 16 | background: 'rgb(190, 200, 200)' 17 | --- 18 | -------------------------------------------------------------------------------- /shared/src/file/parse/default.ts: -------------------------------------------------------------------------------- 1 | import { DemoMeta } from "../../demo"; 2 | import { parseCommentMeta } from "./comment"; 3 | 4 | export async function parseDefault(rawContent: string): Promise { 5 | return { 6 | code: rawContent, 7 | docMeta: parseCommentMeta(rawContent) 8 | } 9 | } 10 | 11 | export interface ParseBasicResult { 12 | code: string; 13 | docMeta: DemoMeta; 14 | /** 15 | * @name 文档内容 16 | */ 17 | docContent?: string 18 | } -------------------------------------------------------------------------------- /docs/layout/links.ts: -------------------------------------------------------------------------------- 1 | export const links = [ 2 | { 3 | key: 'Maya Design', 4 | title: 'Maya Design', 5 | href: 'https://pro.ant.design', 6 | blankTarget: true, 7 | }, 8 | { 9 | key: 'github', 10 | title: 'github', 11 | href: 'https://github.com/ant-design/ant-design-pro', 12 | blankTarget: true, 13 | }, 14 | { 15 | key: 'Dhyana', 16 | title: 'Dhyana', 17 | href: 'https://ant.design', 18 | blankTarget: true, 19 | }, 20 | ] -------------------------------------------------------------------------------- /docs/guide/preview/device.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | defaultDevice: 'iPhone X' 18 | --- 19 | -------------------------------------------------------------------------------- /console/src/style/wrap.css: -------------------------------------------------------------------------------- 1 | .console-wrap { 2 | font-family: Consolas, Lucida Console, Courier New, monospace, sans-serif; 3 | white-space: pre-wrap; 4 | 5 | --bg-color: var(--su-console-bg); 6 | background-color: var(--bg-color); 7 | color: var(--c-text); 8 | font-size: 13px; 9 | line-height: 1.2; 10 | 11 | position: relative; 12 | width: 100%; 13 | 14 | padding-right: (10px + 7 * 2); 15 | } 16 | 17 | .console-wrap:deep(a) { 18 | color: var(--c-anchor); 19 | text-decoration: underline; 20 | } 21 | -------------------------------------------------------------------------------- /console/src/core/encode/common.ts: -------------------------------------------------------------------------------- 1 | import type { DObjReal, DRecord } from '../../definition' 2 | 3 | export function createRealItem(value: T, hidden = false) { 4 | return { 5 | '@hidden': hidden, 6 | '@value': value, 7 | } 8 | } 9 | 10 | export function createFakeRecord( 11 | value: T, 12 | name: string | null = null, 13 | ): DRecord { 14 | return { 15 | '@t': 'object', 16 | '@name': name, 17 | '@first': false, 18 | '@real': value, 19 | '@des': null, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/ruby-R34QNAPN.js: -------------------------------------------------------------------------------- 1 | import { 2 | ruby 3 | } from "./chunk-RZTU227C.js"; 4 | import "./chunk-LBVXTFW5.js"; 5 | import "./chunk-4SM4DCKN.js"; 6 | import "./chunk-TMEXIBF4.js"; 7 | import "./chunk-FD6HLQV3.js"; 8 | import "./chunk-JERJOFXJ.js"; 9 | import "./chunk-XERGCYM2.js"; 10 | import "./chunk-N3PN3MW6.js"; 11 | import "./chunk-6C2M7LIJ.js"; 12 | import "./chunk-NLFATCOM.js"; 13 | import "./chunk-624QZG55.js"; 14 | export { 15 | ruby as default 16 | }; 17 | //# sourceMappingURL=ruby-R34QNAPN.js.map 18 | -------------------------------------------------------------------------------- /docs/guide/writing/code-collapse.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | defaultCodeCollapse: false 18 | --- 19 | -------------------------------------------------------------------------------- /plugin/src/vite/parse/token.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test} from 'vitest' 2 | import { parseToken } from './token' 3 | 4 | test("test basic", async () => { 5 | const testStr = ` 6 |
7 | 8 | 11 |
12 | ` 13 | const {tokens} = parseToken(testStr) 14 | expect(tokens[0].path).eq("a") 15 | expect(tokens[0].dir).eq(true) 16 | expect(tokens[1].path).eq("b") 17 | expect(tokens[1].dir).eq(false) 18 | }) 19 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/terminal-switch/style.scss: -------------------------------------------------------------------------------- 1 | @include b('terminal-switch'){ 2 | display: flex; 3 | flex-direction: row; 4 | align-items: center; 5 | cursor: pointer; 6 | font-size: 12px; 7 | padding: 0 4px; 8 | border-radius: 4px; 9 | height: 24px; 10 | &:hover { 11 | background-color: var(--vp-c-gray-1); 12 | } 13 | @include m('active'){ 14 | background-color: var(--vp-c-gray-1); 15 | } 16 | .icon { 17 | flex: 0 0 auto; 18 | height: 16px; 19 | width: 16px; 20 | } 21 | } -------------------------------------------------------------------------------- /console/src/assets/right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/guide/preview/no-error-browser.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | defaultPreviewMode: 'browser' 18 | --- 19 | -------------------------------------------------------------------------------- /docs/guide/writing/highlight.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | defaultCodeCollapse: false 18 | highlight: '{11}' 19 | --- 20 | -------------------------------------------------------------------------------- /docs/guide/preview/view-ts.ts: -------------------------------------------------------------------------------- 1 | import {defineComponent, h} from 'vue' 2 | import { message } from './view-ts-include' 3 | import { message as message2 } from './view-ts-include2' 4 | 5 | /** 6 | * docs 7 | * @param {string} defaultPreviewMode browser 8 | * @param {array} includes view-ts-include, ./view-ts-include2 9 | * @param {number} previewHeight 300 10 | * @param {boolean} defaultCodeCollapse true 11 | */ 12 | 13 | export default defineComponent({ 14 | setup(){ 15 | return () => h('div', `${message} ${message2}`) 16 | } 17 | }) -------------------------------------------------------------------------------- /docs/guide/preview/device-scale.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | defaultDevice: 'iPhone X' 18 | previewHeight: 500 19 | --- 20 | -------------------------------------------------------------------------------- /shared/src/file/parse/ts.ts: -------------------------------------------------------------------------------- 1 | import { transformTS } from "../transform" 2 | import { parseCommentMeta } from "./comment"; 3 | import { ParseBasicResult } from "./default"; 4 | 5 | export async function parseTS(rawContent: string): Promise { 6 | return { 7 | ts: rawContent, 8 | js: await transformTS(rawContent), 9 | docMeta: parseCommentMeta(rawContent), 10 | code: rawContent 11 | } 12 | } 13 | 14 | export interface TSParseResult extends ParseBasicResult { 15 | js: string; 16 | ts: string; 17 | } -------------------------------------------------------------------------------- /docs/guide/preview/error.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | --- 18 | defaultPreviewMode: 'browser' 19 | --- 20 | -------------------------------------------------------------------------------- /console/src/renders/array/array-name.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 24 | -------------------------------------------------------------------------------- /ui/src/widgets/actions/common.css: -------------------------------------------------------------------------------- 1 | .su-action { 2 | position: relative; 3 | width: 16px; 4 | height: 16px; 5 | font-size: 16px; 6 | line-height: 16px; 7 | color: var(--vp-c-text-2); 8 | cursor: pointer; 9 | transition: all 0.24s; 10 | text-align: center; 11 | } 12 | 13 | .su-action:hover { 14 | color: var(--vp-c-text-1); 15 | } 16 | 17 | .su-action.scale:hover { 18 | transform: scale(1.2); 19 | } 20 | 21 | .su-action.small { 22 | width: 12px; 23 | height: 12px; 24 | font-size: 12px; 25 | line-height: 12px; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/device/style.scss: -------------------------------------------------------------------------------- 1 | @include b('preview-device'){ 2 | height: 100%; 3 | width: 100%; 4 | background-color: var(--vp-code-block-bg); 5 | overflow: hidden; 6 | 7 | @include e('content'){ 8 | height: 100%; 9 | width: 100%; 10 | --tw-shadow-color: 0, 0, 0; 11 | --tw-shadow: 0 10px 15px -3px rgba(var(--tw-shadow-color), 0.1), 0 4px 6px -2px rgba(var(--tw-shadow-color), 0.05); 12 | box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); 13 | background-color: var(--vp-c-bg); 14 | } 15 | } -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsIn.ts: -------------------------------------------------------------------------------- 1 | import { isList } from '../utils/isList' 2 | import { getValue } from './getValue' 3 | 4 | export function getOwnDescriptorsIn(obj: T) { 5 | const des: Record = {} 6 | 7 | const list = isList(obj) 8 | 9 | for (const name in obj) { 10 | if (list && typeof name === 'string' && name !== 'length') 11 | continue // skip array exm: entries(), values() 12 | des[name] = { 13 | value: getValue(obj, name, obj), 14 | enumerable: true, 15 | } 16 | } 17 | return des 18 | } 19 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/device-switch/style.scss: -------------------------------------------------------------------------------- 1 | @include b(device-switch){ 2 | display: flex; 3 | flex-direction: row; 4 | align-items: center; 5 | cursor: pointer; 6 | font-size: 12px; 7 | padding: 0 4px; 8 | border-radius: 4px; 9 | &.ant-dropdown-open { 10 | background-color: var(--vp-c-gray-1); 11 | } 12 | @include e(label){ 13 | margin: 0 4px; 14 | } 15 | 16 | @include m(active) { 17 | background-color: var(--vp-c-gray-1) 18 | } 19 | 20 | @include e(icon){ 21 | flex: 0 0 auto; 22 | height: 16px; 23 | width: 16px; 24 | } 25 | } -------------------------------------------------------------------------------- /docs/demo-block.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | title: Button的类型 18 | badge: tip-block mode 19 | --- 20 | 按钮有五种类型:`主按钮`、`次按钮`、`虚线按钮`、`文本按钮`和`链接按钮`。 21 | 主按钮在**同一个操作区域最多出现一次**。 22 | -------------------------------------------------------------------------------- /docs/guide/demo-with-docs.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 15 | 16 | --- 17 | title: Button的类型 18 | badge: tip-我是徽章 19 | --- 20 | 按钮有五种类型:`主按钮`、`次按钮`、`虚线按钮`、`文本按钮`和`链接按钮`。 21 | 主按钮在**同一个操作区域最多出现一次**。 22 | -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsBuffer.ts: -------------------------------------------------------------------------------- 1 | import { getValue } from './getValue' 2 | 3 | const keys = ['byteLength'] 4 | export function getOwnDescriptorsBuffer(typed: ArrayBuffer) { 5 | const des: Record = {} 6 | 7 | keys.forEach((name) => { 8 | // ([name, meta]) 9 | const value = getValue(typed, name, typed) 10 | const enumerable = false 11 | 12 | if (typeof value !== 'function') { 13 | des[name.toString()] = { 14 | value: (typed as unknown as any)[name], 15 | enumerable, 16 | } 17 | } 18 | }) 19 | 20 | return des 21 | } 22 | -------------------------------------------------------------------------------- /console/src/components/createAnchor.ts: -------------------------------------------------------------------------------- 1 | import type { Component, Slot } from "vue" 2 | import { h } from "vue" 3 | 4 | export function createAnchor( 5 | component: Component | Slot | string, 6 | options: { 7 | target: string 8 | text: string 9 | href: string 10 | class?: string | string[] 11 | } 12 | ) { 13 | if (typeof component === "function") return h("span", [(component as Slot)(options)]) 14 | 15 | return h( 16 | component, 17 | { 18 | href: options.href, 19 | target: options.target, 20 | class: options.class 21 | }, 22 | [options.text] 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["esnext", "DOM"], 5 | "rootDir": ".", 6 | "module": "esnext", 7 | "moduleResolution": "Bundler", 8 | "types": ["node"], 9 | "allowJs": true, 10 | "strict": true, 11 | "strictNullChecks": true, 12 | "noEmit": true, 13 | "preserveValueImports": false, 14 | "esModuleInterop": true, 15 | "skipDefaultLibCheck": true, 16 | "skipLibCheck": true 17 | }, 18 | "include": [ 19 | "**/*.ts" 20 | ], 21 | "exclude": [ 22 | "node_modules/**", 23 | "dist/**" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /shared/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import { camelCase, upperFirst, kebabCase, repeat, head, tail, pick, flatten, pickBy, find, map, flatMap, uniqueId } from 'lodash-es' 2 | import {browserPath} from './path' 3 | 4 | const pascalCase = (str: string) => upperFirst(camelCase(str)) 5 | const tuple = (...args: T) => args; 6 | 7 | export { 8 | kebabCase, 9 | repeat, 10 | head, 11 | tail, 12 | pick, 13 | flatten, 14 | pickBy, 15 | find, 16 | map, 17 | flatMap, 18 | uniqueId , 19 | pascalCase, 20 | tuple, 21 | browserPath 22 | } 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /console/src/utils/isCollection.ts: -------------------------------------------------------------------------------- 1 | import { getObjectName } from "./getObjectName" 2 | 3 | export function isCollection( 4 | data: object 5 | ): data is 6 | | Map 7 | | WeakMap 8 | | Set 9 | | WeakSet { 10 | const type = getObjectName(data) 11 | 12 | return ( 13 | data !== null && 14 | typeof data === "object" && 15 | // なんで?わかない。ぼくわかない。 16 | Object.getPrototypeOf(data) === data.constructor?.prototype && 17 | (type === "Map" || 18 | type === "WeakMap" || 19 | type === "Set" || 20 | type === "WeakSet") 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /console/src/components/console-badge/style.scss: -------------------------------------------------------------------------------- 1 | @include b('console-badge'){ 2 | border-radius: 50%; 3 | font-weight: bold; 4 | background-color: var(--su-console-badge); 5 | color: var(--su-console-badge-text); 6 | padding: 0 4px; 7 | font-size: 10px; 8 | height: 14px; 9 | line-height: 14px; 10 | text-align: center; 11 | @include m('warn'){ 12 | background-color: var(--su-console-badge-warn); 13 | } 14 | @include m('error'){ 15 | background-color: var(--su-console-badge-error); 16 | } 17 | @include m('debug'){ 18 | background-color: var(--su-console-badge-debug); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /console/src/core/api/types.ts: -------------------------------------------------------------------------------- 1 | import type { EncodeResult } from '../encode' 2 | 3 | export interface LogData { 4 | readonly data: readonly EncodeResult[] 5 | count: number 6 | readonly type: 'warn' | 'info' | 'debug' | 'error' | 'output' | 'log' 7 | } 8 | export interface TableData { 9 | readonly data: EncodeResult 10 | readonly type: 'table' 11 | } 12 | 13 | export interface GroupData { 14 | readonly '@key': EncodeResult 15 | readonly '@items': (LogData | TableData | GroupData)[] 16 | '@end': boolean 17 | readonly '@collapse': boolean 18 | } 19 | 20 | export type ConsoleItemValue = LogData | TableData | GroupData 21 | -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsDataView.ts: -------------------------------------------------------------------------------- 1 | import { getValue } from './getValue' 2 | 3 | const keys = ['buffer', 'byteLength', 'byteOffset'] 4 | export function getOwnDescriptorsDataView(typed: DataView) { 5 | const des: Record = {} 6 | 7 | keys.forEach((name) => { 8 | // ([name, meta]) 9 | const value = getValue(typed, name, typed) 10 | const enumerable = false 11 | 12 | if (typeof value !== 'function') { 13 | des[name.toString()] = { 14 | value: (typed as unknown as any)[name], 15 | enumerable, 16 | } 17 | } 18 | }) 19 | 20 | return des 21 | } 22 | -------------------------------------------------------------------------------- /docs/guide/preview/terminal-basic.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | --- 24 | defaultPreviewMode: 'terminal' 25 | --- 26 | -------------------------------------------------------------------------------- /docs/guide/examples.md: -------------------------------------------------------------------------------- 1 | # 项目案例 2 | 3 | 本节中,Sutras根据常见项目场景列举使用案例。 4 | 5 | 为了排除干扰,让读者更直观了解Sutras,Sutras将这些案例分散在不同的仓库中,等价于你的实际项目。 6 | 7 | 每个案例也均项目结构做了说明,案例之间内容可能重复,为了方便读者可以从任一案例入手了解而不丢失信息。 8 | 9 | :::tip 点击案例名称将跳转至案例的文档页面,也就是案例的效果页。 10 | ::: 11 | 12 | | 案例 | 说明 | 13 | | ------------------------------------------- | :--- | 14 | | [SingleRepo](https://github.com/vitejs/vite) | single-repo结构,展示了Sutras的基础用法、高级用法以及大量沙箱下的性能表现 | 15 | | [Monorepo](https://github.com/vitejs/vite)| monorepo结构,采用相对知名的`ant-design-vue(组件库)`,`vueuse(hooks)`,`lodash(js)`作为不同的package,展示了Sutras的基础用法、高级用法以及大量沙箱下的性能表现| 16 | 17 | ## 下一步 18 | 19 | Sutras将向你更详细地介绍[路径解析方案](./path)。 -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsRegExp.ts: -------------------------------------------------------------------------------- 1 | import { entries } from '../utils/entries' 2 | 3 | const keys = entries(Object.getOwnPropertyDescriptors(RegExp.prototype)) 4 | export function getOwnDescriptorsRegExp(reg: RegExp) { 5 | const des: Record = {} 6 | 7 | keys.forEach(([name, meta]) => { 8 | const { value, enumerable } = meta 9 | if (name === 'lastIndex') 10 | return 11 | 12 | if (typeof value !== 'function') { 13 | des[name.toString()] = { 14 | value: (reg as unknown as any)[name], 15 | enumerable, 16 | } 17 | } 18 | }) 19 | 20 | return des 21 | } 22 | -------------------------------------------------------------------------------- /ui/src/widgets/actions/collapse/style.css: -------------------------------------------------------------------------------- 1 | @import '../common.css'; 2 | 3 | .su-collapse-action > img{ 4 | position: absolute; 5 | top: 0; 6 | left: 0; 7 | width: 100%; 8 | max-width: 100%; 9 | margin: 0; 10 | box-shadow: none; 11 | transition: all 0.4s; 12 | user-select: none; 13 | 14 | .ant-row-rtl & { 15 | right: 0; 16 | left: auto; 17 | } 18 | } 19 | 20 | .su-collapse-action > img.show { 21 | opacity: 0.55; 22 | pointer-events: auto; 23 | &:hover { 24 | opacity: 1; 25 | } 26 | } 27 | 28 | .su-collapse-action > img.hide { 29 | opacity: 0; 30 | pointer-events: none; 31 | } -------------------------------------------------------------------------------- /ui/src/widgets/preview/loading/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import { PreviewLoadingInjectKey } from "../context"; 3 | import Spin from 'ant-design-vue/es/spin' 4 | import { useNamespace } from "@sgwm-sutras/style"; 5 | import './style.scss' 6 | 7 | const PreviewLoading = defineComponent({ 8 | name: 'PreviewLoading', 9 | setup(){ 10 | const ns = useNamespace('preview-loading') 11 | const loading = inject(PreviewLoadingInjectKey) 12 | return () => { 13 | return ( 14 | 15 | ) 16 | } 17 | } 18 | }) 19 | 20 | export default PreviewLoading -------------------------------------------------------------------------------- /console/src/icons/collapse/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from "vue"; 2 | import type { PropType } from 'vue' 3 | import DownSVG from '../../assets/down.svg' 4 | import RightSVG from '../../assets/right.svg' 5 | import './style.css' 6 | 7 | const CollapseIcon = defineComponent({ 8 | name: 'CollapseIcon', 9 | props: { 10 | expand: Boolean, 11 | onClick: Function as PropType<() => void> 12 | }, 13 | setup(props){ 14 | return () => ( 15 | 16 | {props.expand ? : } 17 | 18 | ) 19 | } 20 | }) 21 | 22 | export default CollapseIcon -------------------------------------------------------------------------------- /ui/src/assets/svg/terminal.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/device-rotate/style.scss: -------------------------------------------------------------------------------- 1 | @include b(device-rotate){ 2 | display: flex; 3 | flex-direction: row; 4 | align-items: center; 5 | cursor: pointer; 6 | font-size: 12px; 7 | padding: 0 4px; 8 | border-radius: 4px; 9 | height: 24px; 10 | 11 | &:hover { 12 | background-color: var(--vp-c-gray-1); 13 | } 14 | 15 | @include e(icon){ 16 | flex: 0 0 auto; 17 | height: 16px; 18 | width: 16px; 19 | 20 | &.rotated { 21 | transform: rotate(90deg); 22 | } 23 | } 24 | 25 | @include m(active){ 26 | background-color: var(--vp-c-gray-1); 27 | @include e(icon){ 28 | transform: rotate(90deg); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /ui/src/widgets/preview/context.ts: -------------------------------------------------------------------------------- 1 | import type { InjectionKey, Ref } from "vue"; 2 | 3 | export const ShowTerminialInjectKey = Symbol('ShowTerminial') as InjectionKey> 4 | export const DeviceRotateInjectKey = Symbol('DeviceRotate') as InjectionKey> 5 | 6 | export const ErrorMessageInjectKey = Symbol('ErrorMessage') as InjectionKey> 7 | export const ErrorMessageChangeInjectKey = Symbol('ErrorMessageChange') as InjectionKey<(message: string) => void> 8 | 9 | export const PreviewLoadingInjectKey = Symbol('PreviewLoading') as InjectionKey> 10 | export const PreviewLoadingChangeInjectKey = Symbol('PreviewLoadingChange') as InjectionKey<(loading: boolean) => void> -------------------------------------------------------------------------------- /hooks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "jsx": "preserve", 5 | "lib": ["esnext", "DOM"], 6 | "rootDir": ".", 7 | "module": "esnext", 8 | "moduleResolution": "Bundler", 9 | "types": ["node"], 10 | "allowJs": true, 11 | "strict": true, 12 | "strictNullChecks": true, 13 | "noEmit": true, 14 | "preserveValueImports": false, 15 | "esModuleInterop": true, 16 | "skipDefaultLibCheck": true, 17 | "skipLibCheck": true 18 | }, 19 | "include": [ 20 | "**/*.ts", 21 | "prettier-standalone.d.ts", 22 | "source-map-js.d.ts" 23 | ], 24 | "exclude": [ 25 | "node_modules/**", 26 | "dist/**" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /docs/guide/preview/basic-browser.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | 23 | 24 | --- 25 | defaultPreviewMode: 'browser' 26 | --- 27 | -------------------------------------------------------------------------------- /plugin/src/markdown/index.ts: -------------------------------------------------------------------------------- 1 | import type MarkdownIt from 'markdown-it' 2 | import Container from 'markdown-it-container' 3 | import { transform } from './transform.js'; 4 | 5 | export const pluginMkit = (md: MarkdownIt) => { 6 | md.use(Container, 'demo', { 7 | validate(params: string) { 8 | return !!params.trim().match(/^demo\s*(.*)$/); 9 | }, 10 | render(tokens: MarkdownIt.Token[], idx: number){ 11 | if (tokens[idx].nesting === 1) { 12 | const result = transform(md, tokens[idx]); 13 | // console.log(result) 14 | return result 15 | } else { 16 | return '' 17 | } 18 | } 19 | }) 20 | }; 21 | -------------------------------------------------------------------------------- /docs/en/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "Sutras" 7 | text: "Vitepress Plugin For Component DEMO" 8 | tagline: My great project tagline 9 | actions: 10 | - theme: brand 11 | text: Markdown Examples 12 | link: /markdown-examples 13 | - theme: alt 14 | text: API Examples 15 | link: /api-examples 16 | 17 | features: 18 | - title: Feature A 19 | details: compile user-provided JavaScript in real-time 20 | - title: Feature B 21 | details: Lorem ipsum dolor sit amet, consectetur adipiscing elit 22 | - title: Feature C 23 | details: Lorem ipsum dolor sit amet, consectetur adipiscing elit 24 | --- 25 | 26 | -------------------------------------------------------------------------------- /console/src/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Collapse } from './collapse' 2 | export { default as ConsoleGroup } from './console-group' 3 | export { default as Console } from './console' 4 | export { default as ConsoleProvider } from './provider' 5 | export { default as ConsoleItem } from './console-item' 6 | export { default as ConsoleLink } from './console-link' 7 | export { default as ConsoleTable } from './console-table' 8 | export { default as ConsoleValue } from './console-value' 9 | export { default as ConsoleValueStatic } from './console-value-static' 10 | export { default as GetterField } from './getter-field' 11 | export { default as LocationConsole } from './console-location' 12 | export { default as PropName } from './prop-name' 13 | -------------------------------------------------------------------------------- /hooks/src/hack.ts: -------------------------------------------------------------------------------- 1 | export function hackConsole() { 2 | const original = console.warn 3 | 4 | const ignoresTags = [ 5 | 'Feature flags __VUE_OPTIONS_API__, __VUE_PROD_DEVTOOLS__, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__', 6 | 'An iframe which has both allow-scripts and allow-same-origin', 7 | ] 8 | const ignorePattern = new RegExp( 9 | ignoresTags 10 | .map(tag => tag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) 11 | .join('|'), 12 | 'i', 13 | ) 14 | 15 | console.warn = (...args) => { 16 | const shouldIgnore = args.some( 17 | arg => typeof arg === 'string' && ignorePattern.test(arg), 18 | ) 19 | debugger 20 | if (shouldIgnore) 21 | return 22 | 23 | original(...args) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /console/src/components/console-location/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from 'vue' 2 | // import { createAnchor } from '../createAnchor' 3 | // import { useLinkRender } from '../../hooks' 4 | 5 | const ConsoleLocation = defineComponent({ 6 | name: 'ConsoleLocation', 7 | inheritAttrs: false, 8 | props: { 9 | location: String, 10 | Anchor: Object, 11 | }, 12 | setup() { 13 | // const Anchor = useLinkRender() 14 | // return () => createAnchor(Anchor, { 15 | // class: '', 16 | // target: '_blank', 17 | // href: props.location, 18 | // text: props.location?.slice(props.location.lastIndexOf('/') + 1), 19 | // }) 20 | return () =>
21 | }, 22 | }) 23 | 24 | export default ConsoleLocation 25 | -------------------------------------------------------------------------------- /console/src/core/getStatePromise.ts: -------------------------------------------------------------------------------- 1 | export async function getStatePromise(promise: Promise): Promise< 2 | | { 3 | state: 'pending' 4 | value: undefined 5 | } 6 | | { 7 | state: 'fulfilled' | 'rejected' 8 | value: unknown 9 | } 10 | > { 11 | try { 12 | const address = Object.create(null) 13 | 14 | const result = await Promise.race([promise, address]) 15 | 16 | if (result === address) { 17 | return { 18 | state: 'pending', 19 | value: undefined, 20 | } 21 | } 22 | 23 | return { 24 | state: 'fulfilled', 25 | value: result, 26 | } 27 | } 28 | catch (err) { 29 | return { 30 | state: 'rejected', 31 | value: err, 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /style/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "esnext", 5 | "jsx": "preserve", 6 | "lib": ["esnext", "dom", "dom.iterable"], 7 | "baseUrl": ".", 8 | "module": "esnext", 9 | "moduleResolution": "Bundler", 10 | "resolveJsonModule": true, 11 | "types": ["vite/client"], 12 | "strict": false, 13 | "noUnusedLocals": true, 14 | "declaration": true, 15 | "declarationDir": "./dist/", 16 | "outDir": "./dist", 17 | "esModuleInterop": true, 18 | "verbatimModuleSyntax": true, 19 | "skipLibCheck": true 20 | }, 21 | "include": [ 22 | "src" 23 | ], 24 | "exclude": [ 25 | "**/dist/**", 26 | "**/node_modules/**" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "esnext", 5 | "jsx": "preserve", 6 | "lib": ["esnext", "dom", "dom.iterable"], 7 | "baseUrl": ".", 8 | "module": "esnext", 9 | "moduleResolution": "Bundler", 10 | "resolveJsonModule": true, 11 | "types": ["vite/client"], 12 | "strict": false, 13 | "noUnusedLocals": true, 14 | "outDir": "./dist", 15 | "esModuleInterop": true, 16 | "verbatimModuleSyntax": true, 17 | "skipLibCheck": true 18 | }, 19 | "include": [ 20 | "src", 21 | "shims.d.ts", 22 | "components.d.ts" 23 | ], 24 | "exclude": [ 25 | "scripts", 26 | "**/dist/**", 27 | "**/node_modules/**" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | import tsconfigPaths from 'vite-tsconfig-paths' 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | tsconfigPaths(), 7 | ], 8 | test: { 9 | exclude: [ 10 | '**/node_modules/**', 11 | ], 12 | coverage: { 13 | provider: 'v8', 14 | include: [ 15 | '**/docs/**/*.ts', 16 | '**/plugins/**/src/*.ts', 17 | '**/shared/src/*.ts', 18 | '**/ui/src/*.ts', 19 | ], 20 | exclude: [ 21 | '**/node_modules/**', 22 | '**/dist/**', 23 | '**/scripts/**' 24 | ], 25 | }, 26 | poolOptions: { 27 | threads: { 28 | singleThread: true, 29 | }, 30 | }, 31 | }, 32 | }) 33 | -------------------------------------------------------------------------------- /console/src/renders/index.ts: -------------------------------------------------------------------------------- 1 | export { default as RenderBasic } from './basic.vue' 2 | export { default as RenderCollection } from './collection.vue' 3 | export { default as RenderFunction } from './function.vue' 4 | export { default as RenderRegExp } from './regexp.vue' 5 | export { default as RenderObject } from './object.vue' 6 | export { default as RenderError } from './error.vue' 7 | export { default as RenderArray } from './array/index.vue' 8 | export { default as RenderArrayName } from './array/array-name.vue' 9 | export { default as RenderElement } from './element.vue' 10 | export { default as RenderPromise } from './promise.vue' 11 | export { default as RenderBuffer } from './buffer.vue' 12 | export { default as RenderDefault } from './default.vue' 13 | -------------------------------------------------------------------------------- /plugin/src/markdown/attrs.ts: -------------------------------------------------------------------------------- 1 | export type Attrs = { 2 | identifier: string; 3 | codes: string; 4 | } 5 | 6 | const attrRE = /\b(?\w+)(="(?[^"]*)")?/g; 7 | 8 | export function parseAttrs(attrStr: string): Attrs { 9 | const attrs: Record = {}; 10 | let rez: RegExpExecArray | null = null; 11 | while ((rez = attrRE.exec(attrStr))) { 12 | const { key, value } = rez.groups!; 13 | const newValue = value === void 0 ? true : value; 14 | if (Array.isArray(attrs[key])) { 15 | attrs[key].push(newValue); 16 | } else if (!attrs[key]) { 17 | attrs[key] = newValue; 18 | } else { 19 | attrs[key] = [attrs[key], newValue]; 20 | } 21 | } 22 | return attrs as Attrs 23 | } -------------------------------------------------------------------------------- /shared/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["esnext", "DOM"], 5 | "rootDir": ".", 6 | "module": "esnext", 7 | "moduleResolution": "Bundler", 8 | "types": ["node"], 9 | "allowJs": true, 10 | "strict": true, 11 | "strictNullChecks": true, 12 | "noEmit": true, 13 | "preserveValueImports": false, 14 | "esModuleInterop": true, 15 | "skipDefaultLibCheck": true, 16 | "skipLibCheck": true 17 | }, 18 | "include": [ 19 | "**/*.ts", 20 | "prettier-standalone.d.ts", 21 | "source-map-js.d.ts" 22 | ], 23 | "exclude": [ 24 | "node_modules/**", 25 | "dist/**" 26 | ] 27 | } -------------------------------------------------------------------------------- /plugin/src/vite/config.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import type { UserConfig } from '@sgwm-sutras/shared' 3 | import type { UserConfig as ViteUserConfig } from 'vite' 4 | 5 | export function checkUserConfig(config?: UserConfig) { 6 | if (!config) 7 | return 8 | 9 | if (config.packages) { 10 | if (!Array.isArray(config.packages)) 11 | throw new Error('[sutras userConfig check]: config option "package" has wrong struct!') 12 | } 13 | } 14 | export function getRoot(vite: ViteUserConfig, userConfig?: UserConfig) { 15 | let root = '' 16 | if (userConfig?.root) 17 | root = path.isAbsolute(userConfig.root) ? userConfig.root : path.join(vite.root!, userConfig.root) 18 | 19 | else 20 | root = vite.root! 21 | 22 | return root 23 | } 24 | -------------------------------------------------------------------------------- /console/src/components/console/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from 'vue' 2 | import type { PropType } from 'vue' 3 | import type { ConsoleItemValue } from '../../core/api' 4 | import ConsoleWrapper from '../../layouts/console-wrapper' 5 | import ConsoleDispatcher from '../dispatcher' 6 | 7 | const Console = defineComponent({ 8 | name: 'Console', 9 | inheritAttrs: false, 10 | props: { 11 | data: { 12 | type: Array as PropType, 13 | required: true, 14 | }, 15 | }, 16 | setup(props) { 17 | return () => ( 18 | 19 | {props.data.map((item, index) => ())} 20 | 21 | ) 22 | }, 23 | }) 24 | 25 | export default Console 26 | -------------------------------------------------------------------------------- /console/src/hooks/useIndentLevel.ts: -------------------------------------------------------------------------------- 1 | import { inject, provide } from 'vue' 2 | import type { InjectionKey } from 'vue' 3 | 4 | export interface ConsoleIndentLevel { 5 | level: number 6 | } 7 | 8 | export const consoleIndentLevelDefault: ConsoleIndentLevel = { 9 | level: 0, 10 | } 11 | 12 | export const ConsoleIndentLevelInjectKey = Symbol('ConsoleIndentLevel') as InjectionKey 13 | 14 | export function provideConsoleIndentLevel() { 15 | const { level } = useConsoleIndentLevel() 16 | provide(ConsoleIndentLevelInjectKey, { level: level + 1 }) 17 | return { 18 | level, 19 | } 20 | } 21 | 22 | export function useConsoleIndentLevel(): ConsoleIndentLevel { 23 | return inject(ConsoleIndentLevelInjectKey, consoleIndentLevelDefault) 24 | } 25 | -------------------------------------------------------------------------------- /console/src/hooks/useCollapse.ts: -------------------------------------------------------------------------------- 1 | import { inject, provide, ref } from 'vue' 2 | import type { InjectionKey, Ref } from 'vue' 3 | 4 | export interface ConsoleCollapseState { 5 | expand: Ref 6 | } 7 | 8 | export const consoleCollapseStateDefault: ConsoleCollapseState = { 9 | expand: ref(false), 10 | } 11 | 12 | export const ConsoleCollapseStateInjectKey = Symbol('ConsoleCollapseState') as InjectionKey 13 | 14 | export function provideConsoleCollapseState() { 15 | const expand = ref(false) 16 | provide(ConsoleCollapseStateInjectKey, { expand }) 17 | return { expand } 18 | } 19 | 20 | export function useConsoleCollapseState(): ConsoleCollapseState { 21 | return inject(ConsoleCollapseStateInjectKey, consoleCollapseStateDefault) 22 | } 23 | -------------------------------------------------------------------------------- /console/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "esnext", 5 | "jsx": "preserve", 6 | "lib": ["esnext", "dom", "dom.iterable"], 7 | "baseUrl": ".", 8 | "module": "esnext", 9 | "moduleResolution": "Bundler", 10 | "resolveJsonModule": true, 11 | "types": ["vite/client"], 12 | "strict": false, 13 | "noUnusedLocals": true, 14 | "declaration": true, 15 | "declarationDir": "./dist/", 16 | "outDir": "./dist", 17 | "esModuleInterop": true, 18 | "verbatimModuleSyntax": true, 19 | "skipLibCheck": true 20 | }, 21 | "include": [ 22 | "src", 23 | "shims.d.ts" 24 | ], 25 | "exclude": [ 26 | "**/dist/**", 27 | "**/node_modules/**" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /console/src/assets/error.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/src/renders/buffer.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | -------------------------------------------------------------------------------- /docs/guide/preview/ssr-csr-default.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 24 | 25 | 26 | --- 27 | enableSSR: true 28 | defaultRenderMode: 'server' 29 | --- 30 | -------------------------------------------------------------------------------- /ui/src/layout/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from 'vue' 2 | import { ReplFullscreenKey } from '@sgwm-sutras/hooks' 3 | import FullLayout from './full' 4 | import BlockLayout from './block' 5 | 6 | const Layout = defineComponent({ 7 | setup(_, { slots }) { 8 | const isFullscreen = inject(ReplFullscreenKey) 9 | const RenderLayout = () => { 10 | if (isFullscreen.value) 11 | return {{ ...slots }} 12 | return {{ ...slots }} 13 | } 14 | return () => { 15 | return ( 16 |
19 | 20 |
21 | ) 22 | } 23 | }, 24 | }) 25 | 26 | export default Layout 27 | -------------------------------------------------------------------------------- /console/src/renders/basic.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node.js 相关 2 | node_modules/ 3 | npm-debug.log 4 | yarn-error.log 5 | yarn-debug.log 6 | package-lock.json 7 | yarn.lock 8 | 9 | # 编辑器目录和文件 10 | .vscode/ 11 | .idea/ 12 | *.sublime-workspace 13 | 14 | # 操作系统产生的文件 15 | .DS_Store 16 | Thumbs.db 17 | 18 | # 构建输出 19 | dist/ 20 | /build 21 | /out 22 | cache 23 | 24 | # 测试文件 25 | /coverage 26 | /.nyc_output 27 | 28 | # 日志文件 29 | *.log 30 | 31 | # 个人私密配置文件 32 | .env 33 | .env.local 34 | .env.development.local 35 | .env.test.local 36 | .env.production.local 37 | 38 | # Monorepo 管理工具特定文件 39 | # 如果使用 Lerna 40 | lerna-debug.log 41 | /lerna.json 42 | 43 | # 如果使用 Yarn Workspaces 44 | .yarn/ 45 | .pnp.js 46 | .pnp.cjs 47 | .pnp.mjs 48 | .pnp.loader.mjs 49 | 50 | # 其他常见忽略项 51 | /temp 52 | /tmp 53 | 54 | bundle-analysis.html 55 | pnpm-lock.yaml 56 | -------------------------------------------------------------------------------- /console/src/components/console-badge/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import type { PropType } from 'vue' 3 | import { defineComponent } from 'vue' 4 | import type { ConsoleTypeBasic } from '../../definition' 5 | import './style.scss' 6 | 7 | const ConsoleBadge = defineComponent({ 8 | name: 'ConsoleBadge', 9 | inheritAttrs: false, 10 | props: { 11 | count: Number, 12 | type: String as PropType, 13 | }, 14 | setup(props) { 15 | const ns = useNamespace('console-badge') 16 | const classNames = [ 17 | ns.b(), 18 | ns.m(props.type), 19 | ].join(' ') 20 | return () => ( 21 |
22 | {props.count} 23 |
24 | ) 25 | }, 26 | }) 27 | 28 | export default ConsoleBadge 29 | -------------------------------------------------------------------------------- /console/src/renders/regexp.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | -------------------------------------------------------------------------------- /docs/guide/preview/ssr-csr.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 24 | 25 | 26 | --- 27 | defaultPreviewMode: 'browser' 28 | defaultCodeCollapse: false 29 | enableSSR: true 30 | --- 31 | -------------------------------------------------------------------------------- /plugin/src/vite/injectResolveAlias.ts: -------------------------------------------------------------------------------- 1 | import type { UserConfig } from 'vite' 2 | import type { ResolvedConfig } from '@sgwm-sutras/shared' 3 | 4 | export function injectResolveAlias(userConfig: UserConfig, config: ResolvedConfig) { 5 | if (config.autoResolveAlias) { 6 | userConfig.resolve = userConfig.resolve || {} 7 | userConfig.resolve.alias = userConfig.resolve.alias || {} 8 | const resolvedAlias: Record = {} 9 | config.packages?.forEach((pkg) => { 10 | resolvedAlias[pkg.name] = pkg.path 11 | const alias = pkg.alias as string[] 12 | alias.forEach((alia) => { 13 | resolvedAlias[alia] = pkg.path 14 | }) 15 | }) 16 | userConfig.resolve.alias = { 17 | ...resolvedAlias, 18 | ...userConfig.resolve.alias, 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/demo-browser.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | 23 | 24 | --- 25 | title: Button的类型 26 | badge: warning-browser mode 27 | defaultPreviewMode: 'browser' 28 | --- 29 | 按钮有五种类型:`主按钮`、`次按钮`、`虚线按钮`、`文本按钮`和`链接按钮`。 30 | 主按钮在**同一个操作区域最多出现一次**。 31 | -------------------------------------------------------------------------------- /ui/src/assets/svg/device-rotate.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/src/widgets/code/editor/style.css: -------------------------------------------------------------------------------- 1 | .code-editor { 2 | height: 100%; 3 | width: 100%; 4 | position: relative; 5 | } 6 | 7 | .code-editor > span > div[class*=language-] { 8 | background-color: var(--vp-c-bg); 9 | } 10 | 11 | 12 | .code-editor .editor { 13 | position: absolute; 14 | top: 0; 15 | right: 0; 16 | bottom: 0; 17 | left: 0; 18 | z-index: 10; 19 | padding: 20px 24px; 20 | line-height: var(--vp-code-line-height); 21 | font-family: var(--vp-font-family-mono); 22 | font-size: var(--vp-code-font-size); 23 | caret-color: rgb(156 163 175 / 1); 24 | white-space: pre; 25 | overflow: auto; 26 | width: 100%; 27 | height: 100%; 28 | color: transparent; 29 | background-color: transparent; 30 | tab-size: 4; 31 | resize: none; 32 | overflow: hidden; 33 | } -------------------------------------------------------------------------------- /console/src/components/console-table/style.scss: -------------------------------------------------------------------------------- 1 | @import "../../style/styles.css"; 2 | @import "../../style/wrap.css"; 3 | @import "../../style/vars.css"; 4 | 5 | 6 | @include b('console-table'){ 7 | @include e('table'){ 8 | margin-top: 0!important; 9 | margin-bottom: 4px!important; 10 | border-color: #D3E3FD!important; 11 | width: 100%; 12 | display: table!important; 13 | & th,tr,td { 14 | border-color: #D3E3FD!important; 15 | font-size: 12px!important; 16 | padding: 0 4px!important; 17 | font-weight: lighter!important; 18 | } 19 | & tr { 20 | background-color: var(--vp-c-bg-soft)!important; 21 | } 22 | & tr:nth-child(2n){ 23 | background-color: var(--vp-c-bg)!important; 24 | } 25 | & th,td { 26 | background-color: transparent!important; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /docs/lunaria.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@lunariajs/core/config.schema.json", 3 | "repository": { 4 | "name": "skogkatt/sutras", 5 | "rootDir": "docs" 6 | }, 7 | "files": [ 8 | { 9 | "location": ".vitepress/config/{en,zh,pt}.ts", 10 | "pattern": ".vitepress/config/@lang.ts", 11 | "type": "universal" 12 | }, 13 | { 14 | "location": "**/*.md", 15 | "pattern": "@lang/@path", 16 | "type": "universal" 17 | } 18 | ], 19 | "defaultLocale": { 20 | "label": "简体中文", 21 | "lang": "zh" 22 | }, 23 | "locales": [ 24 | { 25 | "label": "English", 26 | "lang": "en" 27 | }, 28 | { 29 | "label": "Português", 30 | "lang": "pt" 31 | } 32 | ], 33 | "outDir": ".vitepress/dist/_translations", 34 | "ignoreKeywords": ["lunaria-ignore"] 35 | } 36 | -------------------------------------------------------------------------------- /shared/src/demo/index.ts: -------------------------------------------------------------------------------- 1 | import { DemoContext } from './types' 2 | import { File, ParseResult } from '../file' 3 | import { pick } from '../utils' 4 | 5 | export * from './format' 6 | export * from './types' 7 | export * from './transform' 8 | 9 | 10 | export function parseFilesFromDemoContext(context: DemoContext){ 11 | return context.files.map(file => { 12 | const option = { 13 | ...pick(file, [ 14 | 'identifier', 15 | 'filename', 16 | 'extension', 17 | 'isEntry', 18 | 'pathFromEntry', 19 | ]), 20 | parsed: { 21 | ...file.parsed, 22 | code: decodeURIComponent(file.parsed.code) 23 | }, 24 | code: decodeURIComponent(file.code) 25 | } 26 | return new File(option) 27 | }) 28 | } -------------------------------------------------------------------------------- /console/src/core/api/utils.ts: -------------------------------------------------------------------------------- 1 | import { sprintf } from 'sprintf-js' 2 | import type { GroupData } from './types' 3 | 4 | export function isGroup(data: any): data is GroupData { 5 | return typeof data?.['@items']?.length === 'number' 6 | } 7 | 8 | export function printfArgs(args: T) { 9 | if (args.length > 0 && typeof args[0] === 'string') { 10 | const countParaments = args[0].match(/%\w/g)?.length 11 | 12 | if (countParaments) { 13 | const { length } = args 14 | return [ 15 | sprintf( 16 | args[0], 17 | ...args.slice(1, countParaments + 1), 18 | ...(length - 1 < countParaments 19 | ? Array(countParaments - (length - 1)).fill('%s') 20 | : []), 21 | ), 22 | ...args.slice(countParaments + 1), 23 | ] 24 | } 25 | } 26 | 27 | return args 28 | } 29 | -------------------------------------------------------------------------------- /console/src/components/provider/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent } from 'vue' 2 | import type { PropType } from 'vue' 3 | import { type ConsoleLinkParser, type ConsoleTheme, provideConsoleLinkParser, provideConsoleTheme } from '../../hooks' 4 | import type { LinkStore } from '../../core/encode' 5 | 6 | const ConsoleProvider = defineComponent({ 7 | name: 'ConsoleProvider', 8 | inheritAttrs: false, 9 | props: { 10 | anchor: { 11 | type: Object as PropType, 12 | }, 13 | theme: { 14 | type: Object as PropType, 15 | }, 16 | store: { 17 | type: Object as PropType>, 18 | }, 19 | }, 20 | setup(props, { slots }) { 21 | provideConsoleLinkParser(props) 22 | provideConsoleTheme() 23 | return () => slots.default() 24 | }, 25 | }) 26 | 27 | export default ConsoleProvider 28 | -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsCollection.ts: -------------------------------------------------------------------------------- 1 | import type { Collection } from '../definition' 2 | import { getObjectName } from '../utils/getObjectName' 3 | import { getValue } from './getValue' 4 | 5 | const keys = ['size'] 6 | export function getOwnDescriptorsCollection( 7 | collection: Collection, 8 | ) { 9 | const des: Record = {} 10 | 11 | const isFreeser = getObjectName(collection).startsWith('Weak') 12 | 13 | keys.forEach((name) => { 14 | if (isFreeser && name === 'size') 15 | return 16 | 17 | // ([name, meta]) 18 | const value = getValue(collection, name, collection) 19 | const enumerable = false 20 | 21 | if (typeof value !== 'function') { 22 | des[name.toString()] = { 23 | value: (collection as unknown as any)[name], 24 | enumerable, 25 | } 26 | } 27 | }) 28 | 29 | return des 30 | } 31 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/vue-5GL625E2.js: -------------------------------------------------------------------------------- 1 | import { 2 | vue 3 | } from "./chunk-KIF6WBDE.js"; 4 | import "./chunk-OYA7MWUT.js"; 5 | import "./chunk-BGBLOFKN.js"; 6 | import "./chunk-5TD2JSII.js"; 7 | import "./chunk-4C546BJY.js"; 8 | import "./chunk-DX4IKWJU.js"; 9 | import "./chunk-KKV3GLWI.js"; 10 | import "./chunk-QDAQRDRQ.js"; 11 | import "./chunk-2L6RJMOL.js"; 12 | import "./chunk-TEMCRTM6.js"; 13 | import "./chunk-YQWML22X.js"; 14 | import "./chunk-5JVA6SGD.js"; 15 | import "./chunk-VOJAU3C4.js"; 16 | import "./chunk-XBEED437.js"; 17 | import "./chunk-MN6W72E5.js"; 18 | import "./chunk-LLA4QFJM.js"; 19 | import "./chunk-K2AQWIQ7.js"; 20 | import "./chunk-XERGCYM2.js"; 21 | import "./chunk-7K4WEFBJ.js"; 22 | import "./chunk-N3PN3MW6.js"; 23 | import "./chunk-NLFATCOM.js"; 24 | import "./chunk-624QZG55.js"; 25 | export { 26 | vue as default 27 | }; 28 | //# sourceMappingURL=vue-5GL625E2.js.map 29 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/layout/Content.tsx: -------------------------------------------------------------------------------- 1 | import { classNames, useNamespace } from "@sgwm-sutras/style"; 2 | import { defineComponent, inject, computed } from "vue"; 3 | import { ReplMetaKey } from "@sgwm-sutras/hooks"; 4 | 5 | const PreviewContent = defineComponent({ 6 | name: 'PreviewContent', 7 | setup(_, {slots}){ 8 | const ns = useNamespace('preview-content') 9 | const meta = inject(ReplMetaKey) 10 | const style = computed(() => ({ 11 | background: meta?.value?.background, 12 | })) 13 | const className = computed(() => classNames(ns.b(), { 14 | [meta.value.style]: !!meta.value.style, 15 | [ns.m('compact')]: meta.value.style?.includes('compact') 16 | })) 17 | return () => ( 18 |
19 | {slots.default?.()} 20 |
21 | ) 22 | } 23 | }) 24 | 25 | export default PreviewContent -------------------------------------------------------------------------------- /console/src/utils/isTypedArray.ts: -------------------------------------------------------------------------------- 1 | const types = [ 2 | Int8Array, 3 | Uint8Array, 4 | Uint8ClampedArray, 5 | 6 | Int16Array, 7 | Uint16Array, 8 | 9 | Int32Array, 10 | Uint32Array, 11 | 12 | Float32Array, 13 | Float64Array 14 | ] 15 | 16 | // eslint-disable-next-line n/no-unsupported-features/es-builtins 17 | if (typeof BigInt64Array !== "undefined") { 18 | types.push( 19 | // eslint-disable-next-line n/no-unsupported-features/es-builtins 20 | BigInt64Array as unknown as typeof Float64Array, 21 | // eslint-disable-next-line n/no-unsupported-features/es-builtins 22 | BigUint64Array as unknown as typeof Float64Array 23 | ) 24 | } 25 | 26 | export type TypedArray = typeof types[0] 27 | 28 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 29 | export function isTypedArray(arr: any): arr is TypedArray { 30 | return types.some((item) => arr instanceof item) 31 | } 32 | -------------------------------------------------------------------------------- /console/src/assets/warn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/guide/preview/repl.md: -------------------------------------------------------------------------------- 1 | # REPL 2 | 3 | [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) 是 **Read-Eval-Print Loop** 的缩写,**意为“读取-求值-打印循环”**。这是一种简单的、交互式的编程环境,允许用户输入单行代码并立即执行,然后显示结果。这种环境非常适合快速测试代码片段、学习新的编程语言特性或进行实验。 4 | 5 | Sutras为你的文档学习者提供了这种模式。**REPL默认是开启的**,如果你想要关闭它,可以通过Sutras全局配置 **或** demo的独立配置来设置,其中demo的独立配置优先级高于Sutras全局配置: 6 | 7 | **通过全局配置** 8 | 9 | 在你的文档目录下的`.vitepress/config`文件中: 10 | 11 | ```js {8-10} 12 | import { defineConfig } from 'vitepress' 13 | import { pluginVite } from '@sgwm-sutras/plugin' 14 | 15 | defineConfig({ 16 | vite: { 17 | plugins: [ 18 | pluginVite({ 19 | demo: { 20 | enableREPL: false, 21 | } 22 | }) 23 | ] 24 | } 25 | }) 26 | ``` 27 | 28 | **通过demo独立配置** 29 | 30 | 在你的demo入口文件中: 31 | 32 | ```vue{3} 33 | 34 | --- 35 | enableREPL: false 36 | --- 37 | 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /docs/demo-terminal.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | --- 24 | title: Lodash-chunk 25 | badge: danger-terminal mode 26 | defaultPreviewMode: 'terminal' 27 | --- 28 | 将数组(array)拆分成多个 `size` 长度的区块,并将这些区块组成一个新数组。 如果array 无法被分割成全部等长的区块,那么最后剩余的元素将组成一个区块。 29 | 30 | **引入版本** 31 | 3.0.0 32 | 33 | **参数** 34 | - array (Array): 需要处理的数组 35 | - [size=1] (number): 每个数组区块的长度 36 | 37 | **返回** 38 | (Array): 返回一个包含拆分区块的新数组(注:相当于一个二维数组)。 39 | -------------------------------------------------------------------------------- /console/src/components/prop-name/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import { defineComponent } from 'vue' 3 | import './style.scss' 4 | 5 | const PropName = defineComponent({ 6 | name: 'PropName', 7 | inheritAttrs: false, 8 | props: { 9 | hidden: Boolean, 10 | name: String, 11 | preview: Boolean, 12 | }, 13 | setup(props) { 14 | const ns = useNamespace('console-prop-name') 15 | return () => { 16 | const classNames = [ 17 | ns.b(), 18 | props.hidden ? 'propHidden' : '', 19 | props.name.startsWith('[[') ? 'proto' : '', 20 | props.preview ? 'propPreview' : '', 21 | ].filter(Boolean).join(' ') 22 | return ( 23 | 26 | {props.name} 27 | : 28 | 29 | ) 30 | } 31 | }, 32 | }) 33 | 34 | export default PropName 35 | -------------------------------------------------------------------------------- /console/src/renders/promise.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 39 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/ssr-switch/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import Switch from "ant-design-vue/es/switch"; 3 | import {SSRModeInjectKey, SSRModeChangeInjectKey} from '@sgwm-sutras/hooks' 4 | 5 | const SSRSwitch = defineComponent({ 6 | name: 'SSR', 7 | setup(){ 8 | const ssrMode = inject(SSRModeInjectKey) 9 | const setSSRMode = inject(SSRModeChangeInjectKey) 10 | return () => { 11 | return ( 12 |
13 | setSSRMode(checked ? 'server' : 'client')} 19 | /> 20 |
21 | ) 22 | } 23 | } 24 | }) 25 | 26 | export default SSRSwitch -------------------------------------------------------------------------------- /ui/src/layout/block/index.tsx: -------------------------------------------------------------------------------- 1 | import { computed, defineComponent, inject } from 'vue' 2 | import { ReplCollapseKey } from '@sgwm-sutras/hooks' 3 | import './style.scss' 4 | import { useNamespace } from '@sgwm-sutras/style' 5 | 6 | const BlockLayout = defineComponent({ 7 | name: 'BlockLayout', 8 | setup(_, { slots }) { 9 | const collapse = inject(ReplCollapseKey) 10 | const ns = useNamespace('block-layout') 11 | const showCode = computed(() => !collapse.value ) 12 | return () => { 13 | return ( 14 |
15 | {slots.header?.()} 16 |
17 | {slots.preview?.()} 18 | {slots.meta?.()} 19 |
20 | {slots.toolbar?.()} 21 |
22 | { showCode.value && slots.code?.()} 23 |
24 |
25 | ) 26 | } 27 | }, 28 | }) 29 | 30 | export default BlockLayout 31 | -------------------------------------------------------------------------------- /console/src/hooks/useTheme.ts: -------------------------------------------------------------------------------- 1 | import { computed, inject, provide } from 'vue' 2 | import type { InjectionKey } from 'vue' 3 | import { useConsoleIndentLevel } from './useIndentLevel' 4 | 5 | export interface ConsoleTheme { 6 | paddingLeft?: number 7 | indent?: number 8 | } 9 | 10 | function getDefault(): ConsoleTheme { 11 | return { 12 | paddingLeft: 0, 13 | indent: 12, 14 | } 15 | } 16 | 17 | export const ConsoleThemeInjectKey = Symbol('ConsoleTheme') as InjectionKey 18 | 19 | export function provideConsoleTheme() { 20 | return provide(ConsoleThemeInjectKey, getDefault()) 21 | } 22 | 23 | export function useConsoleTheme(): ConsoleTheme { 24 | return inject(ConsoleThemeInjectKey, getDefault()) 25 | } 26 | 27 | export function usePaddingLeft(props: { paddingLeft: number }) { 28 | const { indent } = useConsoleTheme() 29 | const { level } = useConsoleIndentLevel() 30 | return computed(() => (props.paddingLeft ?? 0) + indent * level) 31 | } 32 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tsv-DGBB7FGB.js: -------------------------------------------------------------------------------- 1 | import "./chunk-624QZG55.js"; 2 | 3 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/tsv.mjs 4 | var lang = Object.freeze({ "displayName": "TSV", "fileTypes": ["tsv", "tab"], "name": "tsv", "patterns": [{ "captures": { "1": { "name": "rainbow1" }, "2": { "name": "keyword.rainbow2" }, "3": { "name": "entity.name.function.rainbow3" }, "4": { "name": "comment.rainbow4" }, "5": { "name": "string.rainbow5" }, "6": { "name": "variable.parameter.rainbow6" }, "7": { "name": "constant.numeric.rainbow7" }, "8": { "name": "entity.name.type.rainbow8" }, "9": { "name": "markup.bold.rainbow9" }, "10": { "name": "invalid.rainbow10" } }, "match": "([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)([^\\t]*\\t?)", "name": "rainbowgroup" }], "scopeName": "text.tsv" }); 5 | var tsv = [ 6 | lang 7 | ]; 8 | export { 9 | tsv as default 10 | }; 11 | //# sourceMappingURL=tsv-DGBB7FGB.js.map 12 | -------------------------------------------------------------------------------- /docs/guide/preview/index.md: -------------------------------------------------------------------------------- 1 | # 展示区 2 | 3 | 展示区用于向文档学习者演示你的demo运行结果。 4 | 5 | ## 两种展示模式 6 | 7 | Sutras提供了两种demo展示模式:终端模式、界面模式。 8 | 9 | ### 终端模式 10 | 如果你的library是**js工具类库**,那么通过`js console`输出你的library运行结果可能更合适便捷。详见[终端模式](./terminal) 11 | 12 | ### 界面模式 13 | 如果你的library是**前端组件**、**Hooks**,或者**样式库**,那么通过可视化的UI界面,向学习者展示你的library运行结果是很好的选择。 14 | 15 | 界面模式也包含终端模式的功能,方便你的文档学习者在合适的位置输出demo内部状态。详见[界面模式](./view) 16 | 17 | ## SSR渲染 18 | 19 | Sutras提供了SSR/CSR切换,如果你的libary支持[服务端渲染(SSR)](https://vuejs.org/guide/scaling-up/ssr.html),Sutras可以让你的文档学习者在任何模式下进行REPL操作,详见[服务端渲染](./ssr)。 20 | 21 | ## 设备尺寸 22 | 23 | Sutras在**界面模式**下提供了**设备尺寸切换**以及**设备旋转**功能,如果你的library使用场景是**移动端**,那么这个功能会对你很有帮助,详见[设备尺寸](./device)。 24 | 25 | ## 风格样式 26 | 27 | Sutras针对展示区提供了必要的风格配置,如: 28 | 29 | **紧凑风格(compact)**:展示区默认是有边距的,如果你的demo要展示全局的Layout,那么紧凑风格更适合你。 30 | 31 | **背景色**:展示区背景色默认跟随主题发生变化,如果你的demo需要在特殊背景颜色下展示(如`ghost`),可以通过配置项为demo设置特殊背景。 32 | 33 | 详见[风格样式](./style) 34 | 35 | ## 错误提示 36 | 37 | Sutra在展示区将对demo的运行时错误给予提示,详见[运行时错误](./error) -------------------------------------------------------------------------------- /console/src/core/getOwnDescriptorsTypedArray.ts: -------------------------------------------------------------------------------- 1 | import type { TypedArray } from '../utils/isTypedArray' 2 | import { getValue } from './getValue' 3 | 4 | /* 5 | BYTES_PER_ELEMENT: 1 6 | constructor: ƒ Uint8Array() 7 | buffer: (...) 8 | byteLength: (...) 9 | byteOffset: (...) 10 | length: (...) 11 | Symbol(Symbol.toStringTag): undefined 12 | */ 13 | export const keys = [ 14 | // "BYTES_PER_ELEMENT", 15 | 'buffer', 16 | 'byteLength', 17 | 'byteOffset', 18 | 'length', 19 | Symbol.toStringTag, 20 | ] 21 | export function getOwnDescriptorsTypedArray(typed: TypedArray) { 22 | const des: Record = {} 23 | 24 | keys.forEach((name) => { 25 | // ([name, meta]) 26 | const value = getValue(typed, name, typed) 27 | const enumerable = false 28 | 29 | if (typeof value !== 'function') { 30 | des[name.toString()] = { 31 | value: (typed as unknown as any)[name], 32 | enumerable, 33 | } 34 | } 35 | }) 36 | 37 | return des 38 | } 39 | -------------------------------------------------------------------------------- /docs/guide/preview/layout-demo/menu-data.ts: -------------------------------------------------------------------------------- 1 | import type { ItemType } from 'ant-design-vue'; 2 | 3 | function getItem( 4 | label: string, 5 | key: string, 6 | icon?: any, 7 | children?: ItemType[], 8 | type?: 'group', 9 | ): ItemType { 10 | return { 11 | key, 12 | icon, 13 | children, 14 | label, 15 | type, 16 | } as ItemType; 17 | } 18 | 19 | export const items: ItemType[] = [ 20 | getItem('Navigation One', 'sub1', null, [ 21 | getItem('Option 1', '1'), 22 | getItem('Option 2', '2'), 23 | getItem('Option 3', '3'), 24 | getItem('Option 4', '4'), 25 | ]), 26 | getItem('Navigation Two', 'sub2', null, [ 27 | getItem('Option 5', '5'), 28 | getItem('Option 6', '6'), 29 | getItem('Submenu', 'sub3', null, [getItem('Option 7', '7'), getItem('Option 8', '8')]), 30 | ]), 31 | getItem('Navigation Three', 'sub4', null, [ 32 | getItem('Option 9', '9'), 33 | getItem('Option 10', '10'), 34 | getItem('Option 11', '11'), 35 | getItem('Option 12', '12'), 36 | ]), 37 | ] -------------------------------------------------------------------------------- /docs/guide/writing/layout-demo/menu-data.ts: -------------------------------------------------------------------------------- 1 | import type { ItemType } from 'ant-design-vue'; 2 | 3 | function getItem( 4 | label: string, 5 | key: string, 6 | icon?: any, 7 | children?: ItemType[], 8 | type?: 'group', 9 | ): ItemType { 10 | return { 11 | key, 12 | icon, 13 | children, 14 | label, 15 | type, 16 | } as ItemType; 17 | } 18 | 19 | export const items: ItemType[] = [ 20 | getItem('Navigation One', 'sub1', null, [ 21 | getItem('Option 1', '1'), 22 | getItem('Option 2', '2'), 23 | getItem('Option 3', '3'), 24 | getItem('Option 4', '4'), 25 | ]), 26 | getItem('Navigation Two', 'sub2', null, [ 27 | getItem('Option 5', '5'), 28 | getItem('Option 6', '6'), 29 | getItem('Submenu', 'sub3', null, [getItem('Option 7', '7'), getItem('Option 8', '8')]), 30 | ]), 31 | getItem('Navigation Three', 'sub4', null, [ 32 | getItem('Option 9', '9'), 33 | getItem('Option 10', '10'), 34 | getItem('Option 11', '11'), 35 | getItem('Option 12', '12'), 36 | ]), 37 | ] -------------------------------------------------------------------------------- /plugin/src/vite/parse/path.test.ts: -------------------------------------------------------------------------------- 1 | import fixturez from 'fixturez' 2 | import { findRootSync } from '@manypkg/find-root' 3 | import { test} from 'vitest' 4 | import { getPluginConfig } from '../config' 5 | import { ResolvedConfig } from 'vite' 6 | import { createPathMatcher } from './path' 7 | // 获取当前模块文件的路径 8 | 9 | const {rootDir} = findRootSync(process.cwd()) 10 | 11 | const f = fixturez(rootDir) 12 | 13 | test("test basic", async () => { 14 | let tmpPath = f.copy('basic') 15 | const config = await getPluginConfig({root: tmpPath} as ResolvedConfig, {}) 16 | config.demoDirname = 'demos' 17 | const matcher = createPathMatcher(config) 18 | }) 19 | 20 | test("test monorepo", async () => { 21 | // let tmpPath = f.copy('monorepo') 22 | // const files = matchMemoFile({}, config) 23 | // console.log('files', files) 24 | }) 25 | 26 | test("test complex", async () => { 27 | // let tmpPath = f.copy('complex') 28 | // const files = matchMemoFile({}, config) 29 | // console.log('files', files) 30 | }) 31 | -------------------------------------------------------------------------------- /docs/guide/writing/include.md: -------------------------------------------------------------------------------- 1 | # Demo模块化 2 | 3 | 在Demo书写时,你可能有以下需求: 4 | 5 | - **Demo源码量较大**,不便于维护,也不便于库学习者阅读。 6 | 7 | - **Demo之间可能共用配置数据、业务数据、或其他组件**,这些数据或组件你也期望作为Demo的一部分展示给库学习者,甚至支持他们编辑。 8 | 9 | 在上述情况下,Sutras 支持你将Demo拆分为多个文件。 10 | 11 | ## Demo模块化设置 12 | 13 | 假设你要书写Layout组件基础使用的Demo,其中,Layout.Sider中所包含的Menu数据,你期望独立成一个文件`menu-data.ts`: 14 | 15 | ```text 16 | . 17 | ├─ src 18 | │ ├─ demos 19 | │ │ ├─ layout 20 | │ │ │ ├─ basic.vue /** Layout Demo */ 21 | │ │ │ ├─ menu-data.ts /** MenuData */ 22 | │ │ │ └─ ... 23 | │ │ └─ ... 24 | ``` 25 | 26 | 那么你可以在Demo入口文件`basic.vue`中,通过Demo设置项`includes`来包含`menu-data.ts`文件: 27 | 28 | ```vue{3-4} 29 | 30 | --- 31 | includes: ["menu-data"] // 或 ["menu-data.ts"] 或 ["./menu-data"] 或 ["./menu-data.ts"] 32 | --- 33 | 34 | ``` 35 | 36 | 37 | 38 | 文档中也有[其他使用案例](../preview/view#ts-entry) 39 | 40 | ## 模块热替换(Hot Replacement){#hot-replacement} 41 | 42 | 在REPL模式中,每个模块文件是独立编译的,如上述例子中,你的库学习者编辑了`menu-data.ts`文件后,Sutras将只会对`menu-data.ts`文件进行单独编译。 43 | -------------------------------------------------------------------------------- /console/src/hooks/useValueRender.ts: -------------------------------------------------------------------------------- 1 | import { 2 | RenderArray, 3 | RenderBasic, 4 | RenderCollection, 5 | RenderDefault, 6 | RenderElement, 7 | RenderError, 8 | RenderFunction, 9 | RenderObject, 10 | RenderPromise, 11 | RenderRegExp, 12 | } from '../renders' 13 | 14 | import type { EncodeTypeResult } from '../core/encode' 15 | 16 | const componentMap = { 17 | string: RenderBasic, 18 | number: RenderBasic, 19 | bint: RenderBasic, 20 | symbol: RenderBasic, 21 | nill: RenderBasic, 22 | function: RenderFunction, 23 | collection: RenderCollection, 24 | object: RenderObject, 25 | error: RenderError, 26 | regexp: RenderRegExp, 27 | array: RenderArray, 28 | typedarray: RenderArray, 29 | element: RenderElement, 30 | date: RenderPromise, 31 | promise: RenderPromise, 32 | buffer: RenderPromise, // Ensure this is correct, previously was a mistake 33 | dataview: RenderPromise, 34 | } 35 | 36 | export function useValueRender(data: EncodeTypeResult) { 37 | return componentMap[data['@t']] || RenderDefault 38 | } 39 | -------------------------------------------------------------------------------- /shared/src/demo/types.ts: -------------------------------------------------------------------------------- 1 | import { DemoConfig, FileIdentifier, SourceFile, } from ".."; 2 | import { ImportMap, SFCDocMeta } from "../file"; 3 | 4 | export type DemoToken = { 5 | _id: string; 6 | _basepath: string; 7 | path: string; 8 | isDir: boolean; 9 | local?: boolean 10 | package?: string 11 | component?: string 12 | } 13 | 14 | export type DemoGlobalConfig = { 15 | importMap: ImportMap 16 | } 17 | 18 | export type DemoFile = Omit & { 19 | identifier: string 20 | path: string 21 | importMap: ImportMap 22 | } 23 | 24 | export type DemoPage = { 25 | frontmatter: Record 26 | } 27 | 28 | export type DemoMeta = SFCDocMeta 29 | 30 | export type SiteConfig = { 31 | assetsDir: string 32 | base: string 33 | } 34 | 35 | export type DemoContext = { 36 | identifier: string 37 | package?: string 38 | component?: string 39 | entry: string, 40 | page: DemoPage 41 | meta: DemoMeta 42 | files: DemoFile[] 43 | importMap: ImportMap 44 | site: SiteConfig 45 | } 46 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/error/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import { ErrorMessageInjectKey, ShowTerminialInjectKey } from "../context"; 3 | import Alert from 'ant-design-vue/es/alert' 4 | import Button from 'ant-design-vue/es/button' 5 | import { useNamespace } from "@sgwm-sutras/style"; 6 | import './style.scss' 7 | 8 | const PreviewError = defineComponent({ 9 | name: 'PreviewError', 10 | setup(){ 11 | const ns = useNamespace('preview-error') 12 | const errorMessage = inject(ErrorMessageInjectKey) 13 | const showTerminial = inject(ShowTerminialInjectKey) 14 | return () => { 15 | if(!errorMessage.value){ 16 | return null 17 | } 18 | return ( 19 |
20 | 21 | {{action: () => }} 22 | 23 |
24 | ) 25 | } 26 | } 27 | }) 28 | 29 | export default PreviewError -------------------------------------------------------------------------------- /ui/src/layout/full/style.css: -------------------------------------------------------------------------------- 1 | .full-wrapper { 2 | padding: 24px 36px; 3 | background-color: var(--vp-c-bg); 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | 9 | .full-wrapper>.header{ 10 | flex: 0 0 auto; 11 | margin-bottom: 24px; 12 | } 13 | 14 | .full-wrapper>.main { 15 | flex: 1 1 auto; 16 | overflow: hidden; 17 | } 18 | 19 | /* reset */ 20 | .full-wrapper>.header h2 { 21 | margin: 0; 22 | padding: 0; 23 | border-top: 0; 24 | } 25 | .full-wrapper>.header h2 a { 26 | top: 0; 27 | } 28 | 29 | .full-wrapper .splitpanes.default-theme .splitpanes__pane{ 30 | background-color: transparent; 31 | } 32 | 33 | .full-wrapper .splitpanes.default-theme .splitpanes__splitter { 34 | border: none; 35 | background-color: transparent; 36 | } 37 | 38 | .full-wrapper .splitpanes.default-theme .splitpanes__splitter::before{ 39 | background-color: var(--vp-c-divider); 40 | } 41 | 42 | .full-wrapper .splitpanes.default-theme .splitpanes__splitter::after{ 43 | background-color: var(--vp-c-divider); 44 | } -------------------------------------------------------------------------------- /console/src/components/console-value/index.tsx: -------------------------------------------------------------------------------- 1 | import { useNamespace } from '@sgwm-sutras/style' 2 | import type { FunctionalComponent, PropType } from 'vue' 3 | import { defineComponent } from 'vue' 4 | import type { 5 | EncodeTypeResult, 6 | } from '../../core/encode' 7 | import { useValueRender } from '../../hooks' 8 | import './style.scss' 9 | 10 | const ConsoleValue = defineComponent({ 11 | name: 'ConsoleValue', 12 | inheritAttrs: false, 13 | props: { 14 | data: { 15 | type: Object as PropType, 16 | required: true, 17 | }, 18 | hideNameObject: Boolean, 19 | flat: Boolean, 20 | isLog: Boolean, 21 | }, 22 | setup(props, { slots, attrs }) { 23 | const ns = useNamespace('console-value') 24 | return () => { 25 | const Component: FunctionalComponent = useValueRender(props.data) 26 | return ( 27 |
28 | {{ ...slots }} 29 |
30 | ) 31 | } 32 | }, 33 | }) 34 | 35 | export default ConsoleValue 36 | -------------------------------------------------------------------------------- /console/src/renders/error.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | -------------------------------------------------------------------------------- /docs/uno.config.ts: -------------------------------------------------------------------------------- 1 | import { 2 | defineConfig, 3 | presetAttributify, 4 | presetIcons, 5 | presetUno, 6 | } from 'unocss' 7 | import type {UserConfig} from 'unocss' 8 | import transformerAttributifyJsx from '@unocss/transformer-attributify-jsx' 9 | 10 | export default defineConfig({ 11 | shortcuts: { 12 | 'button-action': 'flex flex-inline gap-2 items-center justify-center px-3 py-0.5 rounded hover:color-$vp-c-brand-2 hover:bg-$vp-c-default-soft', 13 | 'border-base': 'border-color-$vp-c-divider', 14 | 'text-brand': 'color-$vp-c-brand-1', 15 | 'text-brand-yellow': 'color-$vp-c-yellow-1', 16 | 'text-brand-red': 'color-$vp-c-red-1', 17 | }, 18 | blocklist: [ 19 | 'container', 20 | ], 21 | presets: [ 22 | presetUno(), 23 | presetAttributify(), 24 | presetIcons(), 25 | ], 26 | safelist: [ 27 | 'font-mono', 28 | 'mb0!', 29 | 'no-underline!', 30 | ], 31 | transformers: [ 32 | transformerAttributifyJsx({ 33 | blocklist: [/text-[a-zA-Z]*/, 'text-5xl'] 34 | }), // <-- 35 | ], 36 | }) satisfies UserConfig 37 | -------------------------------------------------------------------------------- /style/src/scss/use-bem/function.scss: -------------------------------------------------------------------------------- 1 | @use 'config'; 2 | 3 | @function selectorToString($selector) { 4 | $selector: inspect($selector); 5 | $selector: str-slice($selector, 2, -2); 6 | @return $selector; 7 | } 8 | 9 | @function containsModifier($selector) { 10 | $selector: selectorToString($selector); 11 | 12 | @if str-index($selector, config.$modifier-separator) { 13 | @return true; 14 | } @else { 15 | @return false; 16 | } 17 | } 18 | 19 | @function containWhenFlag($selector) { 20 | $selector: selectorToString($selector); 21 | 22 | @if str-index($selector, '.' + config.$state-prefix) { 23 | @return true; 24 | } @else { 25 | @return false; 26 | } 27 | } 28 | 29 | @function containPseudoClass($selector) { 30 | $selector: selectorToString($selector); 31 | 32 | @if str-index($selector, ':') { 33 | @return true; 34 | } @else { 35 | @return false; 36 | } 37 | } 38 | 39 | @function hitAllSpecialNestRule($selector) { 40 | @return containsModifier($selector) or containWhenFlag($selector) or 41 | containPseudoClass($selector); 42 | } -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/shellsession-UKFQWJ36.js: -------------------------------------------------------------------------------- 1 | import { 2 | shellscript 3 | } from "./chunk-4SM4DCKN.js"; 4 | import "./chunk-624QZG55.js"; 5 | 6 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/shellsession.mjs 7 | var lang = Object.freeze({ "displayName": "Shell Session", "fileTypes": ["sh-session"], "name": "shellsession", "patterns": [{ "captures": { "1": { "name": "entity.other.prompt-prefix.shell-session" }, "2": { "name": "punctuation.separator.prompt.shell-session" }, "3": { "name": "source.shell", "patterns": [{ "include": "source.shell" }] } }, "match": "(?x) ^ (?: ( (?:\\(\\S+\\)\\s*)? (?: sh\\S*? | \\w+\\S+[@:]\\S+(?:\\s+\\S+)? | \\[\\S+?[@:][^\\n]+?\\].*? ) ) \\s* )? ( [>$#%❯➜] | \\p{Greek} ) \\s+ (.*) $" }, { "match": "^.+$", "name": "meta.output.shell-session" }], "scopeName": "text.shell-session", "embeddedLangs": ["shellscript"], "aliases": ["console"] }); 8 | var shellsession = [ 9 | ...shellscript, 10 | lang 11 | ]; 12 | export { 13 | shellsession as default 14 | }; 15 | //# sourceMappingURL=shellsession-UKFQWJ36.js.map 16 | -------------------------------------------------------------------------------- /console/src/core/getLocationCall.ts: -------------------------------------------------------------------------------- 1 | export function getLocationCall(deep = 0): string | undefined { 2 | deep += 5 3 | 4 | // eslint-disable-next-line unicorn/error-message 5 | const lines = new Error().stack?.toString().split(' at ', deep) 6 | 7 | if (!lines) 8 | return 9 | 10 | const mess = (lines[deep - 1] ?? lines[lines.length - 1])?.trim() 11 | 12 | if (!mess) 13 | return 14 | 15 | if (mess.includes(')')) { 16 | const basename = mess.slice( 17 | mess.lastIndexOf('(') + 1, 18 | mess.lastIndexOf(')'), 19 | ) 20 | try { 21 | const url = new URL(basename) 22 | 23 | url.searchParams.delete('t') 24 | 25 | return url.href 26 | } 27 | catch { 28 | return basename 29 | } 30 | } 31 | 32 | const lastIndexSpaceOf = mess.indexOf(' ') 33 | 34 | const basename = mess.slice(lastIndexSpaceOf === -1 ? 0 : lastIndexSpaceOf) 35 | 36 | try { 37 | const url = new URL(basename) 38 | 39 | url.searchParams.delete('t') 40 | 41 | return url.href 42 | } 43 | catch { 44 | return basename 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /shared/src/file/utils.ts: -------------------------------------------------------------------------------- 1 | import { find, browserPath } from '../utils' 2 | import { File, FileExtension } from './types' 3 | 4 | const { join, dirname } = browserPath 5 | 6 | export function findEntryFile(files: File[]){ 7 | return find(files, 'isEntry') 8 | } 9 | 10 | export function langFromExtension(extension: FileExtension){ 11 | return extension.startsWith('.') ? extension.slice(1) : extension 12 | } 13 | 14 | export function isRelativeSourcePath(source: string){ 15 | return source.startsWith('./') || source.startsWith('../') 16 | } 17 | 18 | export function findLocalFile(source: string, file: File, files: File[]){ 19 | const isRelativeSource = isRelativeSourcePath(source) 20 | if(!isRelativeSource){ 21 | return null 22 | } 23 | const relativePath = `.${join(dirname(file.pathFromEntry), source)}` 24 | return find(files, f => { 25 | return f.pathFromEntry.startsWith(relativePath) && ( 26 | f.pathFromEntry === relativePath || 27 | f.pathFromEntry.startsWith(`${relativePath}.`) || 28 | f.pathFromEntry.startsWith(`${relativePath}/index.`) 29 | ) 30 | }) 31 | } -------------------------------------------------------------------------------- /console/src/core/encode/basic.ts: -------------------------------------------------------------------------------- 1 | import type { DBigInt, DNill, DNumber, DString, DSymbol } from '../../definition' 2 | import type { EncoderType } from './types' 3 | 4 | export const encodeString: EncoderType = (data, opt) => { 5 | return { 6 | '@t': 'string', 7 | '@first': opt.first, 8 | '@value': data, 9 | } as DString 10 | } 11 | 12 | export const encodeNumber: EncoderType = (data) => { 13 | return { 14 | '@t': 'number', 15 | '@value': data.toString(), 16 | } as DNumber 17 | } 18 | 19 | export const encodeBigInt: EncoderType = (data) => { 20 | return { 21 | '@t': 'bint', 22 | '@value': `${data.toString()}n`, 23 | } as DBigInt 24 | } 25 | 26 | export const encodeSymbol: EncoderType = (data) => { 27 | return { 28 | '@t': 'symbol', 29 | '@value': `${data.toString()}`, 30 | } as DSymbol 31 | } 32 | 33 | export const encodeUndefined: EncoderType = () => { 34 | return { 35 | '@t': 'nill', 36 | '@value': 'undefined', 37 | } as DNill 38 | } 39 | 40 | export const encodeNull: EncoderType = () => { 41 | return { 42 | '@t': 'nill', 43 | '@value': 'null', 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /docs/guide/preview/terminal-call.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 39 | 40 | 41 | --- 42 | defaultPreviewMode: 'terminal' 43 | --- 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 SharpGoldWaveMaker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /shared/src/file/types/sfc.ts: -------------------------------------------------------------------------------- 1 | import { SandboxConfigType, DemoConfig } from "../../core/config"; 2 | import { tuple } from "../../utils" 3 | 4 | export type SFCScriptLangType = 'js' | 'ts' 5 | 6 | export type SFCDocMeta = { 7 | /** 8 | * @name 标题 9 | */ 10 | title?: string; 11 | /** 12 | * @name 徽章 13 | * @description ${type}-${content} 或 ${content},type: 参见vitepress badge 14 | */ 15 | badge?: string; 16 | /** 17 | * @name 调试模式 18 | * @description 用于标记开发状态,默认dev下为debug模式,prod下关闭debug模式 19 | */ 20 | debug?: string; 21 | /** 22 | * @name 其他需展示的文件路径 23 | * @description 相对路径,需要同时在script中被引用到 24 | */ 25 | includes?: string[]; 26 | /** 27 | * @name 代码高亮 28 | * @description 参见[vitepress](https://vitepress.dev/zh/guide/markdown#line-highlighting-in-code-blocks) 29 | */ 30 | highlight?: string; 31 | } & DemoConfig 32 | 33 | export type SSREnableType = 'clientOnly' | 'serverOnly' | 'both' | true | false 34 | 35 | export type SSRModeType = 'client' | 'server' 36 | 37 | export const badgeTypes = tuple('info' , 'tip' , 'warning' , 'danger') 38 | export type BadgeType = (typeof badgeTypes)[number] -------------------------------------------------------------------------------- /console/src/layouts/console-block/index.tsx: -------------------------------------------------------------------------------- 1 | import { type PropType, defineComponent } from 'vue' 2 | import { useNamespace } from '@sgwm-sutras/style' 3 | import './style.scss' 4 | import { provideConsoleIndentLevel } from '../../hooks' 5 | import type { ConsoleTypeBasic } from '../../definition' 6 | 7 | const ConsoleBlock = defineComponent({ 8 | name: 'ConsoleBlock', 9 | inheritAttrs: false, 10 | props: { 11 | type: String as PropType, 12 | }, 13 | setup(props, { slots }) { 14 | const ns = useNamespace('console-block') 15 | const { level } = provideConsoleIndentLevel() 16 | return () => { 17 | return ( 18 |
19 | { (level === 0 || slots.icon) 20 | && ( 21 |
22 | {slots.icon?.()} 23 |
24 | )} 25 |
26 | {slots.default?.()} 27 |
28 | {slots.extra?.()} 29 |
30 |
31 |
32 | ) 33 | } 34 | }, 35 | }) 36 | 37 | export default ConsoleBlock 38 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/Preview.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject, provide, ref } from "vue"; 2 | import PreviewBrowser from "./browser"; 3 | import { ShowTerminialInjectKey, DeviceRotateInjectKey } from "./context"; 4 | import { TerminalDrawer } from "./terminal"; 5 | import PreviewBlock from "./block"; 6 | import PreviewTerminal from './terminal' 7 | import { PreviewModeInjectKey } from "@sgwm-sutras/hooks"; 8 | 9 | const Preview = defineComponent({ 10 | name: 'Preview', 11 | setup(){ 12 | const showTerminial = ref(false) 13 | const deviceRotate = ref(false) 14 | const previewMode = inject(PreviewModeInjectKey) 15 | provide(ShowTerminialInjectKey, showTerminial) 16 | provide(DeviceRotateInjectKey, deviceRotate) 17 | return () => { 18 | if(previewMode.value === 'terminal'){ 19 | return 20 | } 21 | if(previewMode.value === 'browser'){ 22 | return [ 23 | , 24 | 25 | ] 26 | } 27 | return 28 | } 29 | } 30 | }) 31 | 32 | export default Preview -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/chunk-DX4IKWJU.js: -------------------------------------------------------------------------------- 1 | import { 2 | html 3 | } from "./chunk-XERGCYM2.js"; 4 | 5 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/html-derivative.mjs 6 | var lang = Object.freeze({ "displayName": "HTML (Derivative)", "injections": { "R:text.html - (comment.block, text.html meta.embedded, meta.tag.*.*.html, meta.tag.*.*.*.html, meta.tag.*.*.*.*.html)": { "comment": "Uses R: to ensure this matches after any other injections.", "patterns": [{ "match": "<", "name": "invalid.illegal.bad-angle-bracket.html" }] } }, "name": "html-derivative", "patterns": [{ "include": "text.html.basic#core-minus-invalid" }, { "begin": "(]*)(?)", "endCaptures": { "1": { "name": "punctuation.definition.tag.end.html" } }, "name": "meta.tag.other.unrecognized.html.derivative", "patterns": [{ "include": "text.html.basic#attribute" }] }], "scopeName": "text.html.derivative", "embeddedLangs": ["html"] }); 7 | var html_derivative = [ 8 | ...html, 9 | lang 10 | ]; 11 | 12 | export { 13 | html_derivative 14 | }; 15 | //# sourceMappingURL=chunk-DX4IKWJU.js.map 16 | -------------------------------------------------------------------------------- /shared/src/file/parse/comment.ts: -------------------------------------------------------------------------------- 1 | import { parse } from 'comment-parser' 2 | import { DemoMeta } from '../../demo'; 3 | 4 | 5 | 6 | function parseCommentTagValue(type: string, value: string) { 7 | switch (type) { 8 | case 'boolean': 9 | return value.toLowerCase() === 'true'; 10 | case 'number': 11 | return Number(value); 12 | case 'string': 13 | return value 14 | case 'array': 15 | const items = value.split(/,\s*|,\s*/); 16 | return items.map(item => item.trim()); 17 | default: 18 | return value; 19 | } 20 | } 21 | 22 | export function parseCommentMeta(code: string): DemoMeta{ 23 | const results = parse(code) 24 | const meta = results.reduce((meta, result) => { 25 | const {description, tags} = result 26 | if(description.includes('docs')){ 27 | const thisMeta: Record = {} 28 | tags.forEach(t => { 29 | if(t.tag === 'param'){ 30 | const key = t.name 31 | thisMeta[key] = parseCommentTagValue(t.type, t.description) 32 | } 33 | }) 34 | return Object.assign({}, meta, thisMeta) 35 | } 36 | return meta 37 | }, {} as DemoMeta) 38 | return meta 39 | } 40 | -------------------------------------------------------------------------------- /plugin/src/vite/parse/file.ts: -------------------------------------------------------------------------------- 1 | import { parseFile, type SourceFile, type SFCParseResult } from "@sgwm-sutras/shared" 2 | import { dirname, join } from "node:path"; 3 | import { statSync, readFileSync } from "node:fs" 4 | import { resolvePath } from './resolve' 5 | 6 | export function isDirectory(absPath: string){ 7 | return statSync(absPath).isDirectory() 8 | } 9 | 10 | export async function parseSourceFile(filepath: string, entryPath?: string){ 11 | entryPath = entryPath || filepath 12 | const rawContent = readFileSync(filepath, 'utf-8') 13 | const file = await parseFile(filepath, rawContent, entryPath!) 14 | if(file && file.isEntry){ 15 | const includes = (file.parsed as SFCParseResult)?.docMeta?.includes 16 | if(includes?.length){ 17 | file.includes = ( 18 | await Promise.all(includes.map( async (relaPath: string) => { 19 | const testAbsPath = join(dirname(filepath), relaPath) 20 | const absPath = resolvePath(dirname(filepath), relaPath) || testAbsPath 21 | return parseSourceFile(absPath, entryPath) 22 | })) 23 | ).filter(Boolean) as SourceFile[] 24 | } 25 | } 26 | return file 27 | } -------------------------------------------------------------------------------- /ui/src/assets/svg/browser.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /console/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { createRequire } from 'node:module' 2 | import { resolve } from 'node:path' 3 | import { fileURLToPath } from 'node:url' 4 | import { defineConfig } from 'vite' 5 | import vue from '@vitejs/plugin-vue' 6 | import vuejsx from '@vitejs/plugin-vue-jsx' 7 | import svg from 'vite-svg-loader' 8 | // import { analyzer } from 'vite-bundle-analyzer' 9 | 10 | const require = createRequire(import.meta.url) 11 | const pkg = require('./package.json') 12 | 13 | const ROOT = fileURLToPath(import.meta.url) 14 | const r = (p: string) => resolve(ROOT, '..', p) 15 | 16 | const external = [ 17 | ...Object.keys(pkg.dependencies), 18 | 'vue', 19 | ] 20 | 21 | export default defineConfig({ 22 | build: { 23 | lib: { 24 | entry: r('src/index.ts'), 25 | formats: ['es'], 26 | fileName: 'index', 27 | }, 28 | rollupOptions: { 29 | external, 30 | output: { 31 | globals: { 32 | vue: 'Vue', 33 | }, 34 | }, 35 | }, 36 | }, 37 | css: { 38 | preprocessorOptions: { 39 | scss: { 40 | additionalData: `@use "@sgwm-sutras/style/dist/scss" as *;`, 41 | }, 42 | }, 43 | }, 44 | plugins: [ 45 | vue(), 46 | vuejsx(), 47 | svg(), 48 | // analyzer() 49 | ], 50 | }) 51 | -------------------------------------------------------------------------------- /console/src/components/console-link/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, shallowRef, toRaw, watchEffect } from 'vue' 2 | import type { PropType } from 'vue' 3 | import type { EncodeTypeResult } from '../../core/encode' 4 | import type { DLink } from '../../definition' 5 | import ConsoleValue from '../console-value' 6 | import { useConsoleLinkParser } from '../../hooks' 7 | 8 | const ConsoleLink = defineComponent({ 9 | name: 'ConsoleLink', 10 | inheritAttrs: false, 11 | props: { 12 | link: { 13 | type: Object as PropType, 14 | required: true, 15 | }, 16 | }, 17 | setup(props) { 18 | const data = shallowRef() 19 | const { readLinkObjectAsync } = useConsoleLinkParser() 20 | let loaded = false 21 | watchEffect(() => { 22 | if (props.link && !loaded) { 23 | readLinkObjectAsync(toRaw(props.link))?.then((response) => { 24 | data.value = response 25 | loaded = true 26 | }) 27 | } 28 | }) 29 | return () => { 30 | if (data.value) { 31 | return ( 32 | 36 | ) 37 | } 38 | return 'loading...' 39 | } 40 | }, 41 | }) 42 | 43 | export default ConsoleLink 44 | -------------------------------------------------------------------------------- /console/src/components/dispatcher/index.tsx: -------------------------------------------------------------------------------- 1 | import { type PropType, defineComponent, getCurrentInstance } from 'vue' 2 | import ConsoleItem from '../console-item' 3 | import ConsoleGroup from '../console-group' 4 | import ConsoleTable from '../console-table' 5 | import { isGroup } from '../../core/api' 6 | import type { ConsoleItemValue } from '../../core/api' 7 | 8 | const ConsoleDispatcher = defineComponent({ 9 | name: 'ConsoleDispatcher', 10 | inheritAttrs: false, 11 | props: { 12 | item: Object as PropType, 13 | }, 14 | setup(props) { 15 | const key = getCurrentInstance().vnode.key 16 | const { item } = props 17 | return () => { 18 | if (isGroup(item)) { 19 | return ( 20 | 24 | ) 25 | } 26 | if (item.type === 'table') { 27 | return ( 28 | 32 | ) 33 | } 34 | return ( 35 | 41 | ) 42 | } 43 | }, 44 | }) 45 | 46 | export default ConsoleDispatcher 47 | -------------------------------------------------------------------------------- /console/src/renders/function.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | -------------------------------------------------------------------------------- /console/src/components/getter-field/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, ref, shallowRef, watch } from "vue"; 2 | import type { PropType } from "vue"; 3 | import ConsoleValue from "../console-value"; 4 | import type { EncodeTypeResult } from "../../core/encode"; 5 | import type { DLink } from "../../definition"; 6 | import { useConsoleLinkParser } from "../../hooks"; 7 | import './style.css' 8 | 9 | const GetterField = defineComponent({ 10 | name: 'GetterField', 11 | inheritAttrs: false, 12 | props: { 13 | getter: Object as PropType, 14 | }, 15 | setup(props) { 16 | const getted = ref(false); 17 | const value = shallowRef(); 18 | const {callFnLinkAsync} = useConsoleLinkParser() 19 | 20 | watch(getted, () => { 21 | getted.value = true; 22 | 23 | callFnLinkAsync(props.getter) 24 | .then((response) => { 25 | value.value = response; 26 | }); 27 | }); 28 | return () => { 29 | if(!getted.value || !value.value){ 30 | return ( (getted.value = true)}>(…)) 31 | } 32 | return ( 33 | 37 | ) 38 | } 39 | } 40 | }); 41 | 42 | export default GetterField; 43 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/git-rebase-ZFSD5SAA.js: -------------------------------------------------------------------------------- 1 | import { 2 | shellscript 3 | } from "./chunk-4SM4DCKN.js"; 4 | import "./chunk-624QZG55.js"; 5 | 6 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/git-rebase.mjs 7 | var lang = Object.freeze({ "displayName": "Git Rebase Message", "name": "git-rebase", "patterns": [{ "captures": { "1": { "name": "punctuation.definition.comment.git-rebase" } }, "match": "^\\s*(#).*$\\n?", "name": "comment.line.number-sign.git-rebase" }, { "captures": { "1": { "name": "support.function.git-rebase" }, "2": { "name": "constant.sha.git-rebase" }, "3": { "name": "meta.commit-message.git-rebase" } }, "match": "^\\s*(pick|p|reword|r|edit|e|squash|s|fixup|f|drop|d)\\s+([0-9a-f]+)\\s+(.*)$", "name": "meta.commit-command.git-rebase" }, { "captures": { "1": { "name": "support.function.git-rebase" }, "2": { "patterns": [{ "include": "source.shell" }] } }, "match": "^\\s*(exec|x)\\s+(.*)$", "name": "meta.commit-command.git-rebase" }, { "captures": { "1": { "name": "support.function.git-rebase" } }, "match": "^\\s*(break|b)\\s*$", "name": "meta.commit-command.git-rebase" }], "scopeName": "text.git-rebase", "embeddedLangs": ["shellscript"] }); 8 | var gitRebase = [ 9 | ...shellscript, 10 | lang 11 | ]; 12 | export { 13 | gitRebase as default 14 | }; 15 | //# sourceMappingURL=git-rebase-ZFSD5SAA.js.map 16 | -------------------------------------------------------------------------------- /style/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sgwm-sutras/style", 3 | "version": "0.0.1", 4 | "description": "vitepress plugin for quickly build demo-centric technical documentation", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/SharpGoldWaveMaker/sutras.git" 8 | }, 9 | "keywords": [ 10 | "sutras", 11 | "demo", 12 | "repl", 13 | "vitepress", 14 | "markdown", 15 | "ssg", 16 | "vue", 17 | "vite" 18 | ], 19 | "author": "sgwm_skogkatt ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/SharpGoldWaveMaker/sutras/issues" 23 | }, 24 | "homepage": "https://sharpgoldwavemaker.github.io/sutras.docs", 25 | "type": "module", 26 | "main": "./dist/index.js", 27 | "module": "./dist/index.js", 28 | "types": "./dist/index.d.ts", 29 | "files": [ 30 | "dist" 31 | ], 32 | "exports": { 33 | ".": { 34 | "import": "./dist/index.js" 35 | }, 36 | "./dist/scss": { 37 | "import": "./dist/scss/index.scss" 38 | } 39 | }, 40 | "scripts": { 41 | "build": "tsc && node script.js" 42 | }, 43 | "dependencies": { 44 | "@types/node": "^20.12.3", 45 | "vue": "^3.4.21" 46 | }, 47 | "devDependencies": { 48 | "fast-glob": "^3.3.2", 49 | "fs-extra": "^11.2.0" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /shared/src/file/transform/ts/ts.ts: -------------------------------------------------------------------------------- 1 | import { LRUCache } from 'lru-cache'; 2 | import { format } from 'prettier/standalone' 3 | import { transform } from 'sucrase' 4 | 5 | 6 | const cache = new LRUCache({ max: 1024 }); 7 | 8 | export async function transformTS(rawContent: string): Promise { 9 | if (!rawContent) { 10 | return ''; 11 | } 12 | const cached = cache.get(rawContent) 13 | if(cached){ 14 | return cached 15 | } 16 | 17 | const leading = rawContent.match(/^\s*/)?.[0] || ''; // 获取开头的空白字符 18 | const trailing = rawContent.match(/\s*$/)?.[0] || ''; // 获取结尾的空白字符 19 | 20 | let result = transform(rawContent, { 21 | transforms: [ 22 | 'typescript' 23 | ] 24 | }).code 25 | 26 | // result = await formatterCode(result!) 27 | 28 | result = `${leading}${result}${trailing}` 29 | 30 | cache.set(rawContent, result) 31 | 32 | return result 33 | }; 34 | 35 | 36 | 37 | export async function formatterCode(code: string){ 38 | let result = '' 39 | try { 40 | result = await format(code, { 41 | parser: "typescript", // 指定使用的解析器 42 | }) 43 | }catch(error){ 44 | if (error instanceof Error) { 45 | console.error('格式化时遇到错误', error.message); 46 | } else { 47 | console.error('格式化时遇到错误', error); 48 | } 49 | } 50 | return result 51 | } 52 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/csv-5Y4GJZEP.js: -------------------------------------------------------------------------------- 1 | import "./chunk-624QZG55.js"; 2 | 3 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/csv.mjs 4 | var lang = Object.freeze({ "displayName": "CSV", "fileTypes": ["csv"], "name": "csv", "patterns": [{ "captures": { "1": { "name": "rainbow1" }, "2": { "name": "keyword.rainbow2" }, "3": { "name": "entity.name.function.rainbow3" }, "4": { "name": "comment.rainbow4" }, "5": { "name": "string.rainbow5" }, "6": { "name": "variable.parameter.rainbow6" }, "7": { "name": "constant.numeric.rainbow7" }, "8": { "name": "entity.name.type.rainbow8" }, "9": { "name": "markup.bold.rainbow9" }, "10": { "name": "invalid.rainbow10" } }, "match": '((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$)))?', "name": "rainbowgroup" }], "scopeName": "text.csv" }); 5 | var csv = [ 6 | lang 7 | ]; 8 | export { 9 | csv as default 10 | }; 11 | //# sourceMappingURL=csv-5Y4GJZEP.js.map 12 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/actions/terminal-switch/index.tsx: -------------------------------------------------------------------------------- 1 | import { ReplFullscreenKey } from "@sgwm-sutras/hooks"; 2 | import { computed, defineComponent, inject } from "vue"; 3 | import Terminal from '../../../../assets/svg/terminal.svg' 4 | import './style.scss' 5 | import Tooltip from "ant-design-vue/es/tooltip"; 6 | import { ShowTerminialInjectKey } from "../../context"; 7 | import { classNames, useNamespace } from "@sgwm-sutras/style"; 8 | 9 | const TerminialSwitch = defineComponent({ 10 | name: 'TerminialSwitch', 11 | setup(){ 12 | const isFullscreen = inject(ReplFullscreenKey) 13 | const showTerminial = inject(ShowTerminialInjectKey) 14 | const ns = useNamespace('terminal-switch') 15 | if(isFullscreen?.value){ 16 | return 17 | } 18 | const className = computed(() => classNames(ns.b(), { 19 | [ns.m('active')]: showTerminial.value 20 | })) 21 | return () => { 22 | return ( 23 |
24 | 25 |
showTerminial.value = !showTerminial.value}> 26 | 27 |
28 |
29 |
30 | ) 31 | } 32 | } 33 | }) 34 | 35 | export default TerminialSwitch -------------------------------------------------------------------------------- /ui/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { createRequire } from 'node:module' 2 | import { resolve } from 'node:path' 3 | import { fileURLToPath } from 'node:url' 4 | import { defineConfig } from 'vite' 5 | import dts from 'vite-plugin-dts' 6 | import vue from '@vitejs/plugin-vue' 7 | import vuejsx from '@vitejs/plugin-vue-jsx' 8 | import svg from 'vite-svg-loader' 9 | // import { analyzer } from 'vite-bundle-analyzer' 10 | import windiCSS from 'vite-plugin-windicss' 11 | 12 | const require = createRequire(import.meta.url) 13 | const pkg = require('./package.json') 14 | 15 | const ROOT = fileURLToPath(import.meta.url) 16 | const r = (p: string) => resolve(ROOT, '..', p) 17 | 18 | const external = [ 19 | ...Object.keys(pkg.dependencies), 20 | 'vue', 21 | ] 22 | 23 | export default defineConfig({ 24 | resolve: { 25 | alias: { 26 | '@': r('src'), 27 | } 28 | }, 29 | build: { 30 | lib: { 31 | entry: r('src/index.ts'), 32 | formats: ['es'], 33 | fileName: 'index', 34 | }, 35 | rollupOptions: { 36 | external 37 | }, 38 | }, 39 | css: { 40 | preprocessorOptions: { 41 | scss: { 42 | additionalData: `@use "@sgwm-sutras/style/dist/scss" as *; 43 | @import "@/style/vars.scss";`, 44 | }, 45 | }, 46 | }, 47 | plugins: [ 48 | vue(), 49 | vuejsx(), 50 | svg(), 51 | dts(), 52 | // analyzer(), 53 | windiCSS(), 54 | ], 55 | }) 56 | -------------------------------------------------------------------------------- /console/src/style/vars.css: -------------------------------------------------------------------------------- 1 | :root { 2 | /* colors */ 3 | --c-triangle-fill: #9aa0a6; 4 | 5 | --c-border: #3a3a3a; 6 | 7 | --c-text: #ffffff; 8 | --c-anchor: rgb(177, 177, 177); 9 | 10 | --c-badge: #5db0d7; 11 | --c-badge-warn: #f29766; 12 | --c-badge-error: #f28b82; 13 | 14 | --c-border-warn: #665500; 15 | --c-border-error: #5c0000; 16 | --c-border-table: #494c50; 17 | 18 | --c-text-warn: #f2ab26; 19 | --c-text-debug: #4d88ff; 20 | --c-text-error: #ff5d32; 21 | 22 | --c-bg-table-2np1: #292a2d; 23 | 24 | --c-text-number: #9980dc; 25 | --c-text-bint: #7b896f; 26 | --c-text-size: #9aa09a; 27 | --c-text-string: #35d4c7; 28 | --c-text-char-f: #f29766; 29 | --c-text-propName: #5db0b5; 30 | --c-text-proto: #9aa0a6; 31 | --c-text-propHidden: #45778f; 32 | --c-text-two-dot: #ffffff; 33 | 34 | --c-el-tag: #3aa3cc; 35 | --c-el-attr-key: #7bbbb9; 36 | --c-el-attr-val: #f27739; 37 | --c-el-comment: #896d4b; 38 | --c-el-doctype: #b6b493; 39 | 40 | 41 | --su-console-line-height: 14px; 42 | --su-console-bg: 'transparent'; 43 | --su-console-bg-warning: #332b00; 44 | --su-console-bg-error: #290000; 45 | 46 | --su-console-badge: var(--vp-c-text-1); 47 | --su-console-badge-warn: var(--vp-c-warning-1); 48 | --su-console-badge-error: var(--vp-c-danger-1); 49 | --su-console-badge-debug: var(--vp-c-note-1); 50 | --su-console-badge-text: var(--vp-button-brand-text); 51 | } -------------------------------------------------------------------------------- /ui/src/widgets/actions/fullscreen/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import Tooltip from 'ant-design-vue/es/tooltip' 3 | import { ReplFullscreenKey, ReplFullscreenChangeKey } from '@sgwm-sutras/hooks'; 4 | import FullscreenExpand from '../../../assets/svg/fullscreen_expand.svg' 5 | import FullscreenCollapse from '../../../assets/svg/fullscreen_collapse.svg' 6 | import './style.css' 7 | 8 | const FullscreenAction = defineComponent({ 9 | name: 'FullscreenAction', 10 | setup(){ 11 | const fullscreen = inject(ReplFullscreenKey) 12 | const setFullscreen = inject(ReplFullscreenChangeKey) 13 | return () => { 14 | if(fullscreen.value){ 15 | return ( 16 | 17 | setFullscreen?.(false)}> 18 | 19 | 20 | 21 | ) 22 | } 23 | return ( 24 | 25 | setFullscreen?.(true)}> 26 | 27 | 28 | 29 | ) 30 | } 31 | } 32 | }) 33 | 34 | export default FullscreenAction -------------------------------------------------------------------------------- /console/src/style/styles.css: -------------------------------------------------------------------------------- 1 | .number { 2 | color: var(--c-text-number); 3 | } 4 | .bint, 5 | .nill { 6 | color: var(--c-text-bint); 7 | } 8 | .array-size { 9 | color: var(--c-text-size); 10 | margin-right: 4px; 11 | } 12 | .string, 13 | .regexp, 14 | .symbol { 15 | color: var(--c-text-string); 16 | } 17 | .char-f { 18 | color: var(--c-text-char-f); 19 | } 20 | .function, 21 | .char-f { 22 | font-style: italic; 23 | } 24 | 25 | .propName { 26 | color: var(--c-text-propName); 27 | font-weight: 500; 28 | } 29 | .proto { 30 | color: var(--c-text-proto) !important; 31 | } 32 | .propHidden { 33 | color: var(--c-text-propHidden); 34 | } 35 | .propPreview { 36 | color: var(--c-text-proto); 37 | } 38 | .is { 39 | color: var(--c-text-two-dot); 40 | margin-right: 0.7em; 41 | } 42 | 43 | .comma { 44 | margin-right: 4px; 45 | } 46 | 47 | .element-tag { 48 | color: var(--c-el-tag); 49 | } 50 | 51 | .element-propName { 52 | color: var(--c-el-attr-key); 53 | } 54 | 55 | .element-propValue { 56 | color: var(--c-el-attr-val); 57 | } 58 | 59 | .element-comment { 60 | color: var(--c-el-comment); 61 | } 62 | 63 | .element-doctype { 64 | color: var(--c-el-doctype); 65 | } 66 | 67 | .truncate { 68 | overflow: hidden; 69 | text-overflow: ellipsis; 70 | white-space: nowrap; 71 | } 72 | 73 | .\!ml-0 { 74 | margin-left: 0 !important; 75 | } 76 | 77 | .inline { 78 | display: inline; 79 | } 80 | 81 | .mr-0 { 82 | margin-right: 0; 83 | } 84 | -------------------------------------------------------------------------------- /console/src/definition/data-preview.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | DArray, 3 | DBigInt, 4 | DBuffer, 5 | DCollection, 6 | DDataView, 7 | DDate, 8 | DElement, 9 | DError, 10 | DFunction, 11 | DNill, 12 | DNumber, 13 | DPromise, 14 | DRecord, 15 | DRegExp, 16 | DString, 17 | DSymbol, 18 | DTypedArray, 19 | RealItem, 20 | } from './data' 21 | 22 | export type PRecord = Pick 23 | export type PError = Pick 24 | export type PRegExp = Pick 25 | export type PCollection = Pick 26 | export type PArray = Pick 27 | export type PFunction = Pick 28 | export type PElement = Pick 29 | export type PPromise = Pick 30 | export type PDate = Pick 31 | export type PTypedArray = Pick 32 | export type PBuffer = Pick 33 | export type PDataView = Pick 34 | 35 | export interface PObjReal { 36 | readonly [name: string]: RealItem< 37 | | PRecord 38 | | PError 39 | | PRegExp 40 | | PCollection 41 | | PArray 42 | | PFunction 43 | | PElement 44 | | PPromise 45 | | PDate 46 | | PTypedArray 47 | | PBuffer 48 | | PDataView 49 | | DString 50 | | DNumber 51 | | DBigInt 52 | | DSymbol 53 | | DNill 54 | > 55 | } 56 | -------------------------------------------------------------------------------- /console/src/components/parseLink.ts: -------------------------------------------------------------------------------- 1 | import type { Component, Slot, VNode} from "vue" 2 | 3 | import { createAnchor } from "./createAnchor" 4 | 5 | function formatRelativeLink(value: string): string { 6 | value = value.slice(value.lastIndexOf("/") + 1) 7 | try { 8 | const url = new URL(value) 9 | 10 | url.searchParams.delete("t") 11 | 12 | return url.href 13 | } catch { 14 | return value 15 | } 16 | } 17 | 18 | const rUrl = /(?:[^\s()]+):\/\/[^\s()]+/gi 19 | 20 | export function parseLink( 21 | text: string, 22 | options?: { 23 | minifyLink?: boolean 24 | classes?: string 25 | component?: string | Component | Slot 26 | } 27 | ) { 28 | const minifyLink = options?.minifyLink 29 | const classes = options?.classes ?? "" 30 | const component = options?.component ?? "a" 31 | 32 | // text = text.replace(//g, ">") // block XSS 33 | 34 | const children: (string | VNode)[] = [] 35 | let lastIndex = 0 36 | for (const match of text.matchAll(rUrl)) { 37 | children.push(text.slice(lastIndex, match.index)) 38 | 39 | children.push( 40 | createAnchor(component, { 41 | target: "_blank", 42 | href: match[0], 43 | class: classes, 44 | get text() { 45 | return minifyLink ? formatRelativeLink(match[0]) : match[0] 46 | } 47 | }) 48 | ) 49 | lastIndex = match.index! + match[0].length 50 | } 51 | 52 | children.push(text.slice(lastIndex)) 53 | 54 | return children 55 | } 56 | -------------------------------------------------------------------------------- /ui/src/layout/full/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import './style.css' 3 | import 'splitpanes/dist/splitpanes.css' 4 | import { Splitpanes, Pane } from 'splitpanes' 5 | import { PreviewModeInjectKey } from "@sgwm-sutras/hooks"; 6 | 7 | const FullLayout = defineComponent({ 8 | name: 'FullLayout', 9 | setup(_, {slots}){ 10 | const previewMode = inject(PreviewModeInjectKey) 11 | return () => { 12 | return ( 13 |
14 |
15 | {slots.header?.()} 16 | {slots.meta?.()} 17 | {slots.toolbar?.()} 18 |
19 |
20 | 21 | 22 | 23 | 24 | {slots.preview?.()} 25 | 26 | { previewMode.value === 'browser' && ( 27 | 28 | {slots.terminal?.()} 29 | 30 | ) 31 | } 32 | 33 | 34 | 35 | {slots.code?.()} 36 | 37 | 38 |
39 |
40 | ) 41 | } 42 | } 43 | }) 44 | 45 | export default FullLayout -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/fortran-fixed-form-ZPSSVK44.js: -------------------------------------------------------------------------------- 1 | import { 2 | fortran_free_form 3 | } from "./chunk-QXMAVGRV.js"; 4 | import "./chunk-624QZG55.js"; 5 | 6 | // ../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/fortran-fixed-form.mjs 7 | var lang = Object.freeze({ "displayName": "Fortran (Fixed Form)", "fileTypes": ["f", "F", "f77", "F77", "for", "FOR"], "injections": { "source.fortran.fixed - ( string | comment )": { "patterns": [{ "include": "#line-header" }, { "include": "#line-end-comment" }] } }, "name": "fortran-fixed-form", "patterns": [{ "include": "#comments" }, { "include": "#line-header" }, { "include": "source.fortran.free" }], "repository": { "comments": { "patterns": [{ "begin": "^[cC\\*]", "end": "\\n", "name": "comment.line.fortran" }, { "begin": "^ *!", "end": "\\n", "name": "comment.line.fortran" }] }, "line-end-comment": { "begin": "(?<=^.{72})(?!\\n)", "end": "(?=\\n)", "name": "comment.line-end.fortran" }, "line-header": { "captures": { "1": { "name": "constant.numeric.fortran" }, "2": { "name": "keyword.line-continuation-operator.fortran" }, "3": { "name": "source.fortran.free" }, "4": { "name": "invalid.error.fortran" } }, "match": "^(?!\\s*[!#])(?:([ \\d]{5} )|( {5}.)|(\\t)|(.{1,5}))" } }, "scopeName": "source.fortran.fixed", "embeddedLangs": ["fortran-free-form"], "aliases": ["f", "for", "f77"] }); 8 | var fortranFixedForm = [ 9 | ...fortran_free_form, 10 | lang 11 | ]; 12 | export { 13 | fortranFixedForm as default 14 | }; 15 | //# sourceMappingURL=fortran-fixed-form-ZPSSVK44.js.map 16 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/shellsession-UKFQWJ36.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": ["../../../../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/shellsession.mjs"], 4 | "sourcesContent": ["import shellscript from './shellscript.mjs';\n\nconst lang = Object.freeze({ \"displayName\": \"Shell Session\", \"fileTypes\": [\"sh-session\"], \"name\": \"shellsession\", \"patterns\": [{ \"captures\": { \"1\": { \"name\": \"entity.other.prompt-prefix.shell-session\" }, \"2\": { \"name\": \"punctuation.separator.prompt.shell-session\" }, \"3\": { \"name\": \"source.shell\", \"patterns\": [{ \"include\": \"source.shell\" }] } }, \"match\": \"(?x) ^ (?: ( (?:\\\\(\\\\S+\\\\)\\\\s*)? (?: sh\\\\S*? | \\\\w+\\\\S+[@:]\\\\S+(?:\\\\s+\\\\S+)? | \\\\[\\\\S+?[@:][^\\\\n]+?\\\\].*? ) ) \\\\s* )? ( [>$#%\\u276F\\u279C] | \\\\p{Greek} ) \\\\s+ (.*) $\" }, { \"match\": \"^.+$\", \"name\": \"meta.output.shell-session\" }], \"scopeName\": \"text.shell-session\", \"embeddedLangs\": [\"shellscript\"], \"aliases\": [\"console\"] });\nvar shellsession = [\n ...shellscript,\n lang\n];\n\nexport { shellsession as default };\n"], 5 | "mappings": ";;;;;;AAEA,IAAM,OAAO,OAAO,OAAO,EAAE,eAAe,iBAAiB,aAAa,CAAC,YAAY,GAAG,QAAQ,gBAAgB,YAAY,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,2CAA2C,GAAG,KAAK,EAAE,QAAQ,6CAA6C,GAAG,KAAK,EAAE,QAAQ,gBAAgB,YAAY,CAAC,EAAE,WAAW,eAAe,CAAC,EAAE,EAAE,GAAG,SAAS,oLAA8L,GAAG,EAAE,SAAS,QAAQ,QAAQ,4BAA4B,CAAC,GAAG,aAAa,sBAAsB,iBAAiB,CAAC,aAAa,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;AAC7rB,IAAI,eAAe;AAAA,EACjB,GAAG;AAAA,EACH;AACF;", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "type": "module", 4 | "version": "0.0.4", 5 | "description": "vitepress plugin for quickly build demo-centric technical documentation", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/SharpGoldWaveMaker/sutras.git" 9 | }, 10 | "keywords": [ 11 | "sutras", 12 | "demo", 13 | "repl", 14 | "vitepress", 15 | "markdown", 16 | "ssg", 17 | "vue", 18 | "vite" 19 | ], 20 | "author": "skogkatt ", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/SharpGoldWaveMaker/sutras/issues" 24 | }, 25 | "homepage": "https://sharpgoldwavemaker.github.io/sutras.docs", 26 | "scripts": { 27 | "docs:dev": "rimraf ./.vitepress/cache && vitepress dev", 28 | "docs:build": "vitepress build", 29 | "docs:preview": "vitepress preview" 30 | }, 31 | "dependencies": { 32 | "@ant-design/icons-vue": "^7.0.1", 33 | "@lunariajs/core": "^0.0.31", 34 | "@sgwm-sutras/console": "workspace:^", 35 | "@sgwm-sutras/shared": "workspace:^", 36 | "@sgwm-sutras/ui": "workspace:^", 37 | "ant-design-vue": "^4.1.2", 38 | "dayjs": "^1.11.10", 39 | "unocss": "^0.58.6", 40 | "vue": "^3.4.21" 41 | }, 42 | "devDependencies": { 43 | "@sgwm-sutras/plugin": "workspace:^", 44 | "@sgwm-sutras/style": "workspace:^", 45 | "@vitejs/plugin-vue-jsx": "^3.1.0", 46 | "unplugin-vue-components": "^0.26.0", 47 | "vite-svg-loader": "^5.1.0", 48 | "vitepress": "1.0.0-rc.45" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docs/.vitepress/cache/deps/tsv-DGBB7FGB.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": ["../../../../node_modules/.pnpm/shiki@1.3.0/node_modules/shiki/dist/langs/tsv.mjs"], 4 | "sourcesContent": ["const lang = Object.freeze({ \"displayName\": \"TSV\", \"fileTypes\": [\"tsv\", \"tab\"], \"name\": \"tsv\", \"patterns\": [{ \"captures\": { \"1\": { \"name\": \"rainbow1\" }, \"2\": { \"name\": \"keyword.rainbow2\" }, \"3\": { \"name\": \"entity.name.function.rainbow3\" }, \"4\": { \"name\": \"comment.rainbow4\" }, \"5\": { \"name\": \"string.rainbow5\" }, \"6\": { \"name\": \"variable.parameter.rainbow6\" }, \"7\": { \"name\": \"constant.numeric.rainbow7\" }, \"8\": { \"name\": \"entity.name.type.rainbow8\" }, \"9\": { \"name\": \"markup.bold.rainbow9\" }, \"10\": { \"name\": \"invalid.rainbow10\" } }, \"match\": \"([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)([^\\\\t]*\\\\t?)\", \"name\": \"rainbowgroup\" }], \"scopeName\": \"text.tsv\" });\nvar tsv = [\n lang\n];\n\nexport { tsv as default };\n"], 5 | "mappings": ";;;AAAA,IAAM,OAAO,OAAO,OAAO,EAAE,eAAe,OAAO,aAAa,CAAC,OAAO,KAAK,GAAG,QAAQ,OAAO,YAAY,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,WAAW,GAAG,KAAK,EAAE,QAAQ,mBAAmB,GAAG,KAAK,EAAE,QAAQ,gCAAgC,GAAG,KAAK,EAAE,QAAQ,mBAAmB,GAAG,KAAK,EAAE,QAAQ,kBAAkB,GAAG,KAAK,EAAE,QAAQ,8BAA8B,GAAG,KAAK,EAAE,QAAQ,4BAA4B,GAAG,KAAK,EAAE,QAAQ,4BAA4B,GAAG,KAAK,EAAE,QAAQ,uBAAuB,GAAG,MAAM,EAAE,QAAQ,oBAAoB,EAAE,GAAG,SAAS,sIAAsI,QAAQ,eAAe,CAAC,GAAG,aAAa,WAAW,CAAC;AAC1tB,IAAI,MAAM;AAAA,EACR;AACF;", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /shared/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import { defineConfig } from 'rollup' 3 | import { nodeResolve } from '@rollup/plugin-node-resolve' 4 | import commonjs from '@rollup/plugin-commonjs' 5 | import dts from 'rollup-plugin-dts' 6 | import esbuild from 'rollup-plugin-esbuild' 7 | import { visualizer } from 'rollup-plugin-visualizer'; 8 | 9 | const entries = [ 10 | 'src/index.ts' 11 | ] 12 | const external = [ 13 | '@vue/compiler-sfc', 14 | '@vue/runtime-core', 15 | 'typescript' 16 | ] 17 | 18 | const plugins = [ 19 | esbuild(), 20 | nodeResolve(), 21 | commonjs(), 22 | visualizer({ open: true, filename: './bundle-analysis.html' }), 23 | ] 24 | 25 | export default defineConfig([ 26 | { 27 | input: entries, 28 | output: { 29 | dir: 'dist', 30 | format: 'esm', 31 | entryFileNames: () => { 32 | return '[name].mjs' 33 | }, 34 | chunkFileNames: 'chunks/[name].mjs', 35 | globals: { 36 | vue: 'Vue' 37 | } 38 | }, 39 | plugins: [ 40 | ...plugins, 41 | ], 42 | external, 43 | }, 44 | { 45 | input: entries, 46 | output: { 47 | dir: 'dist', 48 | format: 'esm', 49 | chunkFileNames: 'types/[name].d.mts', 50 | entryFileNames: f => `${f.name.replace(/src[\\\/]/, '')}.d.mts`, 51 | }, 52 | plugins: [ 53 | dts({ 54 | // respectExternal: true, 55 | }) 56 | ], 57 | external, 58 | onwarn: (warning, warn) => { 59 | if (!/Circular|an empty chunk/.test(warning.message)) 60 | warn(warning) 61 | }, 62 | }, 63 | ]) 64 | -------------------------------------------------------------------------------- /ui/src/widgets/preview/block/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject } from "vue"; 2 | import { ReplCodePreviewRendersKey, ReplMetaKey } from '@sgwm-sutras/hooks' 3 | import './style.css' 4 | import PreviewLayout from "../layout"; 5 | import PreviewDevice from "../device"; 6 | import DeviceSwitch from "../actions/device-switch"; 7 | import DeviceRotate from "../actions/device-rotate"; 8 | import PreviewContent from "../layout/Content"; 9 | 10 | const PreviewBlock = defineComponent({ 11 | name: 'PreviewBlock', 12 | setup(){ 13 | const meta = inject(ReplMetaKey) 14 | const renders = inject(ReplCodePreviewRendersKey) 15 | const RenderExtra = () => { 16 | return [ 17 | , 18 | 19 | ] 20 | } 21 | return () => { 22 | return ( 23 | -1} 26 | showHeader={false} 27 | > 28 | {{ 29 | extra: RenderExtra, 30 | default: () => ( 31 | 32 | 33 | {renders.default?.()} 34 | 35 | 36 | ) 37 | }} 38 | 39 | ) 40 | } 41 | } 42 | }) 43 | 44 | export default PreviewBlock -------------------------------------------------------------------------------- /ui/src/widgets/code/preview/index.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, inject, computed, toRefs } from "vue"; 2 | import { ReplCodePreviewRendersKey, ReplCodeShowLangKey, ReplPattenKey} from '@sgwm-sutras/hooks' 3 | import Spin from 'ant-design-vue/es/spin' 4 | import { EditorReadyInjectKey } from "../panel/context"; 5 | 6 | const CodePreviewer = defineComponent({ 7 | name: 'CodePreviewer', 8 | props: { 9 | identifier: String 10 | }, 11 | setup(props){ 12 | const {identifier} = toRefs(props) 13 | const renders = inject(ReplCodePreviewRendersKey) 14 | const showLang = inject(ReplCodeShowLangKey) 15 | const pattern = inject(ReplPattenKey) 16 | const isEditorReady = inject(EditorReadyInjectKey) 17 | const spinning = computed(() => { 18 | return pattern.value === 'editable' && !isEditorReady.value 19 | }) 20 | const renderName = computed(() => { 21 | if(showLang?.value === 'js'){ 22 | const tryName = `codejs-${identifier?.value}` 23 | if(renders[tryName]){ 24 | return tryName 25 | } 26 | } 27 | return `code-${identifier?.value}` 28 | }) 29 | return () => { 30 | return ( 31 | 35 | { renders[renderName.value]?.() } 36 | 37 | ) 38 | } 39 | } 40 | }) 41 | 42 | export default CodePreviewer -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Sutras logo 4 | 5 |

6 |
7 | 8 | # Sutras 9 | 10 | ## 什么是 Sutras? 11 | 12 | Sutras 是专为**快速构建以 demo 为中心的技术文档**而设计的工具。通过简单的配置,Sutras 能自动扫描 Demo,并将运行结果和源代码一致地集成到由 Vitepress 构建的技术文档中。 13 | 14 | 查看[官方文档](https://sharpgoldwavemaker.github.io/sutras.docs/)了解更多信息。 15 | 16 | ### 主要特点 17 | 18 | - **实时源码编辑、编译、执行和反馈**:实现了 REPL,支持快速测试代码片段、深入了解特性或进行概念验证。 19 | - **沙箱环境**:支持将 demo 运行在独立、隔离的环境中。 20 | - **灵活的展示模式**:支持终端和界面两种模式,适用于演示前端库或 JavaScript 工具库。 21 | - **自定义设备尺寸和展示样式**:确保库在预期的设备尺寸上能良好展示。 22 | - **服务端渲染(SSR)**:支持使用 SSR 模式来渲染 Demo。 23 | - **支持单仓库和多仓库架构**:兼容 Yarn、Bolt、Lerna、pnpm、Rush 等技术。 24 | - **Demo 模块化**:支持将复杂的 Demo 拆分为多个文件实现模块化,或多个 Demo 之间共享模块文件。 25 | 26 | ## 快速开始 27 | 28 | 想尝试 Sutras?查看我们的[快速开始指南](https://sharpgoldwavemaker.github.io/sutras.docs/getting-started)。 29 | 30 | ## 常见使用场景 31 | 32 | - 构建组件库文档,例如 ElementPlus 和 Ant Design。 33 | - VueCompositionApi 文档,例如 Vueuse。 34 | - JavaScript 工具库文档,例如 Lodash。 35 | 36 | ## Sutras 的努力方向 37 | 38 | ### 面向库开发者的文档驱动开发模式 39 | 40 | Sutras 提倡在编码前通过撰写文档的方式来明确库的目标和需求,然后为每个特性设计 Demo 并从 Demo 开始研发和测试你的库。 41 | 42 | ### 面向库学习者的高效学习体验 43 | 44 | Sutras 不断优化 Demo 的展示和交互,借鉴如 Storybook 等框架的功能,为学习者提供高效的学习体验。 45 | 46 | ## 性能 47 | 48 | 得益于现代浏览器的支持,Sutras 在沙箱模式下提供了以下优势: 49 | 50 | - **懒加载**:每个 Demo 的编译、执行仅在即将进入视口时开始。 51 | - **局部编译**:只编译 Demo 源码部分,依赖文件在构建时完成。 52 | - **模块热替换**:实现了 Demo 的模块化,并在模块内容发生变化时,只对相应的模块进行重新编译。 53 | - **LRU缓存**:通过对 demo 源码进行解析,实现了分块式 LRU 缓存。 54 | --------------------------------------------------------------------------------