Skip to content

feat(playground): integrate dob-render and simplify tailwind config #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
"@ckb-ccc/ccc": "workspace:*",
"@ckb-ccc/connector-react": "workspace:*",
"@monaco-editor/react": "^4.6.0",
"@nervina-labs/dob-render": "^0.2.3",
"@shikijs/monaco": "^3.2.1",
"axios": "^1.7.7",
"bech32": "^2.0.0",
"isomorphic-ws": "^5.0.0",
"lucide-react": "^0.438.0",
"monaco-editor": "^0.51.0",
"next": "14.2.8",
"prettier": "^3.5.1",
"react": "^18",
"react-dom": "^18",
"typescript": "^5",
"@shikijs/monaco": "^3.2.1",
"shiki": "^3.2.1",
"prettier": "^3.5.1"
"typescript": "^5"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
13 changes: 13 additions & 0 deletions packages/playground/src/app/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const CCCSource = require.context(
/^\.\/[^\/]*\/(dist\.commonjs\/.*\.d\.ts|package.json)$/,
);

const DobRenderSource = require.context(
"!!raw-loader!../../../node_modules/@nervina-labs/dob-render/dist",
true,
/^\.\/.*\.d\.ts$/,
);

export function Editor({
value,
onChange,
Expand Down Expand Up @@ -128,6 +134,13 @@ export function Editor({
);
});

DobRenderSource.keys().forEach((key: string) => {
monaco.languages.typescript.typescriptDefaults.addExtraLib(
DobRenderSource(key).default,
`file:///node_modules/@nervina-labs/dob-render/${key.replace("./", "")}`,
);
});

monaco.languages.typescript.typescriptDefaults.addExtraLib(
"import { ccc } from '@ckb-ccc/core'; export function render(...msgs: unknown[]): Promise<void>; export const signer: ccc.Signer; export const client: ccc.Client;",
"file:///node_modules/@ckb-ccc/playground/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions packages/playground/src/app/execute/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ccc } from "@ckb-ccc/connector-react";
import * as cccLib from "@ckb-ccc/ccc";
import * as cccAdvancedLib from "@ckb-ccc/ccc/advanced";
import * as dobRenderLib from "@nervina-labs/dob-render";
import * as React from "react";
import ts from "typescript";
import { vlqDecode } from "./vlq";
Expand Down Expand Up @@ -59,6 +60,7 @@ export async function execute(
"@ckb-ccc/core/advanced": cccAdvancedLib,
"@ckb-ccc/ccc": cccLib,
"@ckb-ccc/ccc/advanced": cccAdvancedLib,
"@nervina-labs/dob-render": dobRenderLib,
"@ckb-ccc/playground": {
render: async (...msgs: unknown[]) => {
display("info", msgs);
Expand Down
5 changes: 5 additions & 0 deletions packages/playground/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const config: Config = {
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
],
safelist: [
{
pattern: /./, // Include all Tailwind classes
}
],
theme: {
extend: {
colors: {
Expand Down
Loading