@zikojs/notebook-runtime-react 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zikojs/notebook-runtime-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "publishConfig": {
@@ -15,8 +15,8 @@
15
15
  "license": "MIT",
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@babel/standalone": "latest",
19
- "esbuild-wasm": "^0.28.2"
18
+ "sucrase": "latest",
19
+ "@codemirror/lang-javascript": "latest"
20
20
  },
21
21
  "scripts": {
22
22
  "test": "echo \"Error: no test specified\" && exit 1"
package/src/index.js CHANGED
@@ -1,25 +1,22 @@
1
- import { transformReact } from "./transform.js";
2
- export const ReacIdentifier = 'react'
1
+ import { transform } from "sucrase";
2
+ import { javascript } from '@codemirror/lang-javascript'
3
3
 
4
- export const reactPlugin = ({
5
- jsxRuntime = "automatic",
6
- importSource = "react",
7
- } = {}) => ({
8
- name: ReacIdentifier,
4
+ export const ReactIdentifier = "react";
5
+
6
+ export const reactPlugin = () => ({
7
+ name: ReactIdentifier,
8
+ language: javascript({ jsx: true }),
9
9
 
10
10
  async transform(code, context) {
11
- // CRITICAL: Only transform if this cell's runtime is explicitly "react"
12
- if (context.runtime && context.runtime !== "react") {
11
+ if (context.runtime && context.runtime !== ReactIdentifier) {
13
12
  return code;
14
13
  }
15
- return transformReact(code, { jsxRuntime, importSource });
16
- },
17
14
 
18
- // async afterEvaluate(result, context) {
19
- // if (context.runtime && context.runtime !== "react") {
20
- // return result;
21
- // }
22
- // // ... rest of React afterEvaluate logic
23
- // }
24
-
25
- });
15
+ return transform(code, {
16
+ transforms: ["jsx"],
17
+ jsxRuntime: "automatic",
18
+ jsxImportSource: "react",
19
+ production: true,
20
+ }).code;
21
+ },
22
+ });
package/src/transform.js DELETED
@@ -1,21 +0,0 @@
1
- import { transform } from "@babel/standalone";
2
-
3
- export const transformReact = (
4
- code,
5
- {
6
- jsxRuntime = "automatic",
7
- importSource = "react",
8
- } = {},
9
- ) => {
10
- return transform(code, {
11
- plugins: [
12
- [
13
- "transform-react-jsx",
14
- {
15
- runtime: jsxRuntime,
16
- importSource,
17
- },
18
- ],
19
- ],
20
- }).code;
21
- };