From f71100b28c9406ddfcdd1abbb1148a1a2bc2b169 Mon Sep 17 00:00:00 2001 From: Jim Hamill Date: Tue, 15 Jul 2025 04:07:59 +0000 Subject: [PATCH] Misc Playground/Docs fixes --- CONTRIBUTING.md | 15 ++++++- package-lock.json | 19 +-------- packages/docs/src/.vitepress/config.ts | 2 + .../theme/components/CodeSandbox.vue | 16 +------- .../theme/components/CodeSandboxTemplate.html | 26 +++++++++--- packages/docs/src/contributing.md | 2 + packages/docs/src/index.md | 3 ++ packages/docs/src/playground.md | 5 +-- packages/primitives/rollup.config.js | 13 ++++++ packages/stack/dts.config.json | 14 ------- packages/stack/package.json | 2 +- packages/stack/rollup.config.js | 13 ++++++ .../src/blockchain/blockchain-electrum.ts | 40 ++++++++----------- 13 files changed, 87 insertions(+), 83 deletions(-) create mode 100644 packages/docs/src/contributing.md delete mode 100644 packages/stack/dts.config.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e9fd55..0e0d4ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,7 +77,7 @@ These guidelines represent best practices. While exceptions may occasionally be - Often mask underlying issues that should be properly resolved - Can lead to unintended side-effects throughout the codebase -4. Avoid additional dependencies. +5. Avoid additional dependencies. Try to avoid pulling in additional packages. Not only can this bloat the project, but can also cause compatibility issues between environments (Web, Node, ESM, etc). We want `@xocash/stack` to "just work" without devs having to tailor build configurations. @@ -87,7 +87,18 @@ These guidelines represent best practices. While exceptions may occasionally be - Does not drag in additional dependencies itself (note that `devDependencies` are fine. These will not be installed when leveraged from our packages). - If the package being used **is heavy** and we have no other choice but to use it, consider whether we should package it separately to avoid problems. For example, if we build a `BlockchainBCHN` adapter, we will likely want to package this on its own under `@xocash/blockchain-bchn` as it only works in NodeJS environments. -5. "When in Rome..." +6. DO NOT use Typescript "enums". + + TypeScript enums have several issues that make them problematic: + + - They generate unnecessary runtime code and don't tree-shake well, increasing bundle size + - Numeric enums allow unsafe reverse lookups and can be assigned any number value + - They don't work well with module augmentation and can cause circular dependency issues + - They're not compatible with Node.js's --experimental-strip-types feature, which only removes type annotations and doesn't transform enum syntax + + Recommended alternatives: Use const objects with `as const` assertions or string literal union types instead, which work seamlessly with Node's type stripping. + +7. "When in Rome..." For conventions not explicitly mentioned, follow the "when in Rome" principle. Try to identify and use the patterns and conventions that are already established elsewhere in the codebase. diff --git a/package-lock.json b/package-lock.json index 6d0c0c2..cce27f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6649,23 +6649,6 @@ "url": "https://dotenvx.com" } }, - "node_modules/dts-bundle-generator": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/dts-bundle-generator/-/dts-bundle-generator-9.5.1.tgz", - "integrity": "sha512-DxpJOb2FNnEyOzMkG11sxO2dmxPjthoVWxfKqWYJ/bI/rT1rvTMktF5EKjAYrRZu6Z6t3NhOUZ0sZ5ZXevOfbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "typescript": ">=5.0.2", - "yargs": "^17.6.0" - }, - "bin": { - "dts-bundle-generator": "dist/bin/dts-bundle-generator.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -14834,6 +14817,7 @@ "version": "0.0.1", "license": "ISC", "dependencies": { + "@bitauth/libauth": "^3.0.0", "@electrum-cash/network": "^4.1.1", "@electrum-cash/protocol": "2.1.0-development.8075178089", "@generalprotocols/oracle-client": "^0.0.1", @@ -14845,7 +14829,6 @@ }, "devDependencies": { "@types/better-sqlite3": "^7.6.12", - "dts-bundle-generator": "^9.5.1", "rollup": "^4.45.0", "rollup-plugin-dts": "^6.2.1" } diff --git a/packages/docs/src/.vitepress/config.ts b/packages/docs/src/.vitepress/config.ts index 09eb1d2..14bf0dc 100644 --- a/packages/docs/src/.vitepress/config.ts +++ b/packages/docs/src/.vitepress/config.ts @@ -123,6 +123,7 @@ export default withMermaid({ // TODO: Re-enable once we release documentation // { text: 'Documentation', link: '/quick-start' }, { text: 'Tools', link: '/tools/primitives' }, + { text: 'Playground', link: '/playground' }, ], sidebar: { @@ -134,6 +135,7 @@ export default withMermaid({ { text: 'Quick Start', link: '/quick-start' }, { text: 'Architecture', link: '/architecture' }, { text: 'Best Practices', link: '/api-examples' }, + { text: 'Contributing', link: '/contributing' }, ], }, { diff --git a/packages/docs/src/.vitepress/theme/components/CodeSandbox.vue b/packages/docs/src/.vitepress/theme/components/CodeSandbox.vue index 5628cf7..e4bea37 100644 --- a/packages/docs/src/.vitepress/theme/components/CodeSandbox.vue +++ b/packages/docs/src/.vitepress/theme/components/CodeSandbox.vue @@ -373,7 +373,7 @@ defineExpose({ display: flex; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; - margin-bottom: 1em; + overflow-y: hidden; } .editor-container { @@ -385,20 +385,6 @@ defineExpose({ overflow: hidden; /* Contain overflow */ } -.editor-container .ace_editor { - background: transparent !important; - font-family: var(--vp-font-family-mono); - line-height: var(--vp-code-line-height); - font-size: var(--vp-code-font-size); - flex: 1 1 auto; /* Allow editor to grow */ - overflow: auto; /* Enable scrolling */ - min-height: 3em; -} - -.editor-container .ace_editor .ace_gutter { - background: transparent !important; -} - .editor-buttons { position: absolute; padding:10px; diff --git a/packages/docs/src/.vitepress/theme/components/CodeSandboxTemplate.html b/packages/docs/src/.vitepress/theme/components/CodeSandboxTemplate.html index c53cbd2..9807448 100644 --- a/packages/docs/src/.vitepress/theme/components/CodeSandboxTemplate.html +++ b/packages/docs/src/.vitepress/theme/components/CodeSandboxTemplate.html @@ -3,7 +3,13 @@ Code Sandbox - diff --git a/packages/docs/src/contributing.md b/packages/docs/src/contributing.md new file mode 100644 index 0000000..6e7336a --- /dev/null +++ b/packages/docs/src/contributing.md @@ -0,0 +1,2 @@ + + diff --git a/packages/docs/src/index.md b/packages/docs/src/index.md index ced9619..a41b478 100644 --- a/packages/docs/src/index.md +++ b/packages/docs/src/index.md @@ -10,6 +10,9 @@ hero: - theme: brand text: Tools link: /tools/primitives + - theme: brand + text: Playground + link: /playground ---