@jsnote-zeina/local-api 1.0.0 → 1.0.1

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.
@@ -16,6 +16,23 @@ exports.createCellsRouter = void 0;
16
16
  const express_1 = __importDefault(require("express"));
17
17
  const promises_1 = __importDefault(require("fs/promises"));
18
18
  const path_1 = __importDefault(require("path"));
19
+ const defaultCells = [
20
+ {
21
+ content: 'JSNote-Zeina\n----------\nThis is an interactive coding environment. You can write Javascript, see it executed, and write coprehensive documentation using markdown.\n\n- Click any text cell (including this one) to edit it\n- The code in each code editor is all joined into one file. If you define a variable in cell #1, you can refer to it in any following code cell!\n- You can show any React component, string, number, or anything else by calling the `show `function. This is a function built into this environment. Call show multiple times to show multiple values\n- Re-order or delete cells using the buttons on the top right \n- Add new cells by hovering on the divider between each cell\n\nAll of your changes get saved to the file you opened Jbook with. So if you ran `npx jsnote-zeina serve test.js` , all of the text and code you write will be saved to the `test.js` file.',
22
+ type: 'text',
23
+ id: 'ohbrr',
24
+ },
25
+ {
26
+ content: "import { useState } from 'react';\r\nconst Counter = () => {\r\n const [count, setCount] = useState(0);\r\n return (\r\n <div>\r\n <button onClick={() => setCount(count + 1)}>Click </button>\r\n <h3>Count: {count} </h3>\r\n </div>\r\n );\r\n};\r\n\r\nshow(<Counter />);",
27
+ type: 'code',
28
+ id: 'yvorb',
29
+ },
30
+ {
31
+ content: 'const App = () => {\r\n return (\r\n <div>\r\n <h3> App says Hello </h3>\r\n <i> Counter component will be rendered below... </i>\r\n <hr />\r\n {/* Counter was declared in an earlier cell -\r\n We can reference it here! */}\r\n <Counter />\r\n </div>\r\n );\r\n};\r\n\r\nshow(<App />);',
32
+ type: 'code',
33
+ id: 'toeeq',
34
+ },
35
+ ];
19
36
  const createCellsRouter = (filename, dir) => {
20
37
  const router = express_1.default.Router();
21
38
  router.use(express_1.default.json());
@@ -33,8 +50,8 @@ const createCellsRouter = (filename, dir) => {
33
50
  if (isLocalApiError(err)) {
34
51
  if (err.code === 'ENOENT') {
35
52
  // Create a file and add default cells
36
- yield promises_1.default.writeFile(fullPath, '[]', 'utf-8');
37
- res.send([]);
53
+ const newFile = yield promises_1.default.writeFile(fullPath, JSON.stringify(defaultCells), 'utf-8');
54
+ res.send(JSON.stringify(defaultCells));
38
55
  }
39
56
  else {
40
57
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsnote-zeina/local-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"
@@ -28,5 +28,5 @@
28
28
  "express": "^4.19.2",
29
29
  "http-proxy-middleware": "^3.0.0"
30
30
  },
31
- "gitHead": "f1b8bb3eeaac9d9800122679a99164ffbb655bbe"
31
+ "gitHead": "c917f9837ac91b26442e0c1b41444228d240e5af"
32
32
  }