Skip to content
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
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
25 changes: 25 additions & 0 deletions .changeset/v3-major.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"react-code-view": major
"@react-code-view/react": major
"@react-code-view/core": major
"@react-code-view/unplugin": major
---

Major refactor for v3.0.0:

- Hook: stabilize `useCodeExecution` (refs-based options, stable `execute()`, `updateCode` alias)
- Tests: fix TypeScript matcher types and marked renderer signature; remove unused vars
- Docs: update README with requirements, hook example, CI/CD notes
- CI: Node 18 + PNPM, caching; gh-pages publishes `docs/dist`
- Publish: adopt Changesets + npm provenance (OIDC), drop `NODE_AUTH_TOKEN`
- Config: align workspace tsconfig/turbo/vite

BREAKING CHANGES:

- `useCodeExecution` effect behavior stabilized; consumers relying on previous implicit re-execution may need to explicitly update `code` or pass `dependencies`
- Package structure reorganized across `packages/*`; import paths may need updates according to exports

- Imports: `CodeView` is now also a default export in `@react-code-view/react` and re-exported by `react-code-view`; prefer `import CodeView from 'react-code-view'` or adjust named imports accordingly
- Styles: Less entries were removed; switch to `import 'react-code-view/styles'` and optional `import 'react-code-view/styles/highlight'`
- Build integration: Legacy `webpack-md-loader` is removed; migrate to unified `@react-code-view/unplugin` for Vite/Webpack/Rollup/esbuild/Rspack
- Tooling: Minimum requirements updated to Node >=18 and PNPM >=8 for the monorepo/dev workflow
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"root": true,
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "react", "react-hooks"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
},
"ignorePatterns": ["dist", "node_modules", "*.js", "*.cjs"]
}
13 changes: 9 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Enable Corepack (PNPM from packageManager)
run: |
corepack enable

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version: '18.x'
cache: 'pnpm'

- name: Install
run: npm install
run: pnpm install --frozen-lockfile

- name: Build
run: npm run build:docs
run: pnpm docs:build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/assets
publish_dir: ./docs/dist
31 changes: 25 additions & 6 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,32 @@ on:
- main
jobs:
test:
name: 'Test'
name: 'Build & Test'
runs-on: ubuntu-latest
container: node:16

steps:
- uses: actions/checkout@v2
- env:
- uses: actions/checkout@v4

- name: Enable Corepack (PNPM from packageManager)
run: |
corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
HUSKY: 0
run: npm install
- run: npm test

- name: Typecheck
run: pnpm -w typecheck

- name: Build
run: pnpm -w build

- name: Test
run: pnpm -w test --reporter verbose
37 changes: 25 additions & 12 deletions .github/workflows/nodejs-publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# see https://help.github.com/cn/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package
name: Release Packages

on:
workflow_dispatch: {}
push:
tags: ['*']
tags:
- 'v*'

jobs:
publish:
name: 'Publish'
name: 'Publish to npm'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
- uses: actions/checkout@v4

- name: Enable Corepack (PNPM from packageManager)
run: |
corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'

- name: Install dependencies
run: npm install
run: pnpm install --frozen-lockfile
env:
HUSKY: 0

- name: Build
run: npm run build
run: pnpm -w build

- name: Npm Publish
run: npm publish dist
- name: Publish with Changesets
run: pnpm release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
49 changes: 26 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
# Logs
logs
*.log
npm-debug.log*
karma-*

# Runtime data
pids
*.pid
*.seed
# Dependencies
node_modules/
.pnpm-store/

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Build outputs
dist/
*.tsbuildinfo

# Coverage directory used by tools like istanbul
coverage
# IDE
.idea/
.vscode/
*.swp
*.swo

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# OS
.DS_Store
Thumbs.db

# node-waf configuration
.lock-wscript
# Logs
*.log
npm-debug.log*
pnpm-debug.log*

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Test coverage
coverage/

# Dependency directory
node_modules
# Turbo
.turbo/

# Optional npm cache directory
# Environment
.env
.env.local
.env.*.local
.npm

# Optional REPL history
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"printWidth": 100,
"arrowParens": "avoid"
}
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing to React Code View

Thanks for helping improve React Code View! This guide keeps contributions consistent and easy to review.

## Prerequisites
- Node.js 18+
- PNPM 9 (Corepack enabled: `corepack enable`)
- Git

## Setup
```bash
corepack enable
pnpm install
```

## Common Tasks
- Typecheck: `pnpm -w typecheck`
- Lint: `pnpm -w lint`
- Test: `pnpm -w test`
- Build: `pnpm -w build`
- Docs dev: `pnpm docs`
- Docs build: `pnpm docs:build`

## Development Notes
- Monorepo is managed with PNPM + Turbo; prefer `pnpm -w <script>` for workspace-wide tasks.
- Avoid committing generated bundles in `dist/`; keep changes to source and configs.
- Ensure tests pass locally before opening a PR.
- Update or add tests for behavior changes (see `packages/**/__tests__`).

## Changesets & Releases
- For user-visible changes, run `pnpm changeset` and follow the prompts (choose the affected packages and bump type).
- Keep the summary short and mention breaking changes clearly.
- Versioning and publishing are handled via CI; tags trigger the publish workflow.

## Pull Requests
- Base your work on the latest `main` (or the active release branch) and keep commits focused.
- Describe the change, rationale, and testing performed.
- If you add a new feature or breaking change, update `README.md` and relevant docs.

## Coding Style
- TypeScript everywhere; prefer explicit types on public APIs.
- React 18 conventions (hooks, function components).
- Keep imports sorted logically; run linters/formatters as needed.

## Need Help?
- Open a discussion or issue in the repo with reproduction steps and context.
Loading