@zikojs/notebook-runtime-preact 0.1.0 → 0.3.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-preact",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "publishConfig": {
@@ -14,7 +14,13 @@
14
14
  "author": "zakaria elalaoui",
15
15
  "license": "MIT",
16
16
  "type": "module",
17
- "dependencies": {},
17
+ "dependencies": {
18
+ "sucrase": "latest",
19
+ "@codemirror/lang-javascript": "latest"
20
+ },
21
+ "peerDependencies": {
22
+ "preact": "^10.27.2"
23
+ },
18
24
  "scripts": {
19
25
  "test": "echo \"Error: no test specified\" && exit 1"
20
26
  }
package/src/index.js CHANGED
@@ -1,25 +1,22 @@
1
- import { transformPreact } from "./transform.js";
2
- export const ReacIdentifier = 'preact'
1
+ import { transform } from "sucrase";
2
+ import { javascript } from '@codemirror/lang-javascript'
3
3
 
4
- export const preactPlugin = ({
5
- jsxRuntime = "automatic",
6
- importSource = "preact",
7
- } = {}) => ({
8
- name: ReacIdentifier,
4
+ export const PreactIdentifier = "preact";
5
+
6
+ export const preactPlugin = () => ({
7
+ name: PreactIdentifier,
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 !== "preact") {
11
+ if (context.runtime && context.runtime !== PreactIdentifier) {
13
12
  return code;
14
13
  }
15
- return transformPreact(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: "preact",
19
+ production: true,
20
+ }).code;
21
+ },
22
+ });
package/src/transform.js DELETED
@@ -1,14 +0,0 @@
1
- import { transform } from "@babel/standalone";
2
-
3
- export const transformPreact = (code) =>
4
- transform(code, {
5
- plugins: [
6
- [
7
- "transform-react-jsx",
8
- {
9
- runtime: "automatic",
10
- importSource: "preact",
11
- },
12
- ],
13
- ],
14
- }).code;