@learnpack/learnpack 5.0.215 → 5.0.217

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.
@@ -518,6 +518,9 @@
518
518
  .mb-6 {
519
519
  margin-bottom: calc(var(--spacing) * 6);
520
520
  }
521
+ .ml-2 {
522
+ margin-left: calc(var(--spacing) * 2);
523
+ }
521
524
  .ml-6 {
522
525
  margin-left: calc(var(--spacing) * 6);
523
526
  }
@@ -1022,6 +1025,9 @@
1022
1025
  .whitespace-pre-line {
1023
1026
  white-space: pre-line;
1024
1027
  }
1028
+ .text-black {
1029
+ color: var(--color-black);
1030
+ }
1025
1031
  .text-blue-400 {
1026
1032
  color: var(--color-blue-400);
1027
1033
  }
@@ -10,8 +10,8 @@
10
10
  />
11
11
 
12
12
  <title>Learnpack Creator: Craft tutorials in seconds!</title>
13
- <script type="module" crossorigin src="/creator/assets/index-DxwqeFD3.js"></script>
14
- <link rel="stylesheet" crossorigin href="/creator/assets/index-Bnq3eZ3T.css">
13
+ <script type="module" crossorigin src="/creator/assets/index-CZrxF_55.js"></script>
14
+ <link rel="stylesheet" crossorigin href="/creator/assets/index-DmpsXknz.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -1 +1 @@
1
- {"version":"5.0.215","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
1
+ {"version":"5.0.217","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.215",
4
+ "version": "5.0.217",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -453,7 +453,7 @@ export default class ServeCommand extends SessionCommand {
453
453
 
454
454
  // Servir archivos estáticos
455
455
  // app.use(express.static(distPath))
456
- app.use(express.json())
456
+ app.use(express.json({ limit: "20mb" }))
457
457
  app.use(cors())
458
458
 
459
459
  const appPath = path.resolve(__dirname, "../ui/_app")
@@ -603,6 +603,41 @@ export default class ServeCommand extends SessionCommand {
603
603
  res.json({ id, status: "SUCCESS" })
604
604
  })
605
605
 
606
+ app.post("/webhooks/:courseSlug/images/:imageId", async (req, res) => {
607
+ const { courseSlug, imageId } = req.params
608
+ const body = req.body
609
+ console.log("RECEIVING IMAGE WEBHOOK", body)
610
+
611
+ const imageUrl = body.image_url
612
+ const imagePath = `courses/${courseSlug}/.learn/assets/${imageId}`
613
+
614
+ const imageFile = bucket.file(imagePath)
615
+ const [exists] = await imageFile.exists()
616
+ if (!exists) {
617
+ // Descargar la imagen
618
+ const response = await fetch(imageUrl)
619
+ if (!response.ok) {
620
+ return res.status(400).json({
621
+ status: "ERROR",
622
+ message: "No se pudo descargar la imagen",
623
+ })
624
+ }
625
+
626
+ const buffer = await response.arrayBuffer()
627
+
628
+ // Guardar la imagen en el bucket
629
+ await imageFile.save(new Uint8Array(buffer), {
630
+ contentType: "image/png",
631
+ })
632
+ }
633
+
634
+ emitToNotification(imageId, {
635
+ status: "SUCCESS",
636
+ message: "Image generated successfully",
637
+ })
638
+ res.json({ status: "SUCCESS" })
639
+ })
640
+
606
641
  app.post(
607
642
  "/webhooks/:courseSlug/exercise-processor/:lessonID/:rigoToken",
608
643
  async (req, res) => {
@@ -181,6 +181,9 @@ const FileUploader: React.FC<FileUploaderProps> = ({
181
181
  const setUploadedFiles = useStore((state) => state.setUploadedFiles)
182
182
  const [isDragging, setIsDragging] = useState(false)
183
183
  const [isLoading, setIsLoading] = useState(false)
184
+ const [limitExceededBehavior, setLimitExceededBehavior] = useState<
185
+ "firstImages" | "cancel"
186
+ >("firstImages")
184
187
 
185
188
  const extractTextFromFile = async (file: File): Promise<ParsedFile> => {
186
189
  const { type, name } = file
@@ -203,6 +206,7 @@ const FileUploader: React.FC<FileUploaderProps> = ({
203
206
  : window.location.origin
204
207
  }/notifications/${resultId}`
205
208
  formData.append("webhook_callback_url", webhookUrl)
209
+ formData.append("limit_exceeded_behavior", limitExceededBehavior)
206
210
 
207
211
  const loadingToast = toast.loading(`Processing ${file.name}...`)
208
212
  try {
@@ -226,9 +230,17 @@ const FileUploader: React.FC<FileUploaderProps> = ({
226
230
  notificationId: resultId,
227
231
  }
228
232
  } catch (err: any) {
229
- toast.error(`❌ ${file.name} failed: ${err.message}`, {
230
- id: loadingToast,
231
- })
233
+ console.log(err.response.data, "ERROR IN FILE UPLOADER")
234
+ if (err.response.data.error_code === "too_many_images") {
235
+ toast.error(`❌ ${t("uploader.files.maxImagesPerPDFError")}`, {
236
+ id: loadingToast,
237
+ })
238
+ } else {
239
+ toast.error(t("uploader.files.errorProcessingPDF"), {
240
+ id: loadingToast,
241
+ })
242
+ }
243
+
232
244
  return { name, text: "", status: "ERROR", notificationId: "" }
233
245
  }
234
246
  }
@@ -309,6 +321,26 @@ const FileUploader: React.FC<FileUploaderProps> = ({
309
321
  onDrop={handleDrop}
310
322
  className={isDragging ? "border-blue-600 bg-blue-50" : ""}
311
323
  />
324
+ <p className="text-xs text-gray-500">
325
+ {t("uploader.files.maxImagesPerPDFWarning")}
326
+
327
+ <select
328
+ className="bg-white text-black ml-2 p-1 rounded-md"
329
+ value={limitExceededBehavior}
330
+ onChange={(e) =>
331
+ setLimitExceededBehavior(
332
+ e.target.value as "firstImages" | "cancel"
333
+ )
334
+ }
335
+ >
336
+ <option value="firstImages">
337
+ {t("uploader.files.useOnlyFirstImages")}
338
+ </option>
339
+ <option value="cancel">
340
+ {t("uploader.files.cancelAndUploadAnother")}
341
+ </option>
342
+ </select>
343
+ </p>
312
344
  <button
313
345
  disabled={uploadedFiles.some((file) => file.status !== "SUCCESS")}
314
346
  className="bg-blue-500 text-white px-4 py-2 rounded-md cursor-pointer disabled:opacity-50"
@@ -54,10 +54,15 @@
54
54
  },
55
55
  "files": {
56
56
  "description": "Upload files",
57
- "descriptionLong": "Upload a PDF or DOCX file or drag it here",
57
+ "descriptionLong": "Upload a PDF file or drag it here",
58
58
  "processing": "Processing...",
59
59
  "drop": "Drop it here",
60
- "finish": "🚀 Finish"
60
+ "finish": "🚀 Finish",
61
+ "maxImagesPerPDFWarning": "⚠️ Only 15 images per PDF are supported in LearnPack beta. You can select what to do if the PDF exceeds this limit.",
62
+ "useOnlyFirstImages": "Use only the first 15 images",
63
+ "cancelAndUploadAnother": "Cancel and upload another PDF",
64
+ "maxImagesPerPDFError": "❌ Only 15 images per PDF are supported in LearnPack beta and this PDF exceeds the limit.",
65
+ "errorProcessingPDF": "❌ Error processing PDF, please try again, if the problem persists, try with a different file."
61
66
  },
62
67
  "youtube": {
63
68
  "description": "Share a Youtube link",
@@ -110,4 +115,4 @@
110
115
  "youDontHaveAnAccount": "You don't have an account?",
111
116
  "registerHere": "Register here."
112
117
  }
113
- }
118
+ }
@@ -54,10 +54,15 @@
54
54
  },
55
55
  "files": {
56
56
  "description": "Subir archivos",
57
- "descriptionLong": "Subir un archivo PDF o DOCX o arrastralo aquí",
57
+ "descriptionLong": "Subir un archivo PDF o arrastralo aquí",
58
58
  "processing": "Procesando...",
59
59
  "drop": "Arrastra el archivo aquí",
60
- "finish": "🚀 Finalizar"
60
+ "finish": "🚀 Finalizar",
61
+ "maxImagesPerPDFWarning": "⚠️ Solo se admiten 15 imágenes por PDF en LearnPack beta. Puedes seleccionar qué hacer si el PDF excede este límite.",
62
+ "useOnlyFirstImages": "Usar solo las primeras 15 imágenes",
63
+ "cancelAndUploadAnother": "Cancelar y subir otro PDF",
64
+ "maxImagesPerPDFError": "❌ Solo se admiten 15 imágenes por PDF en LearnPack beta y este PDF excede el límite.",
65
+ "errorProcessingPDF": "❌ Error procesando PDF, por favor intenta de nuevo, si el problema persiste, intenta con un archivo diferente."
61
66
  },
62
67
  "youtube": {
63
68
  "description": "Compartir un enlace de Youtube",
@@ -2,7 +2,8 @@ export const DEV_MODE = false
2
2
 
3
3
  export const RIGOBOT_HOST = DEV_MODE
4
4
  ? "https://rigobot-test-cca7d841c9d8.herokuapp.com"
5
- : "https://rigobot.herokuapp.com"
5
+ : // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us120.gitpod.io"
6
+ "https://rigobot.herokuapp.com"
6
7
 
7
8
  export const BREATHECODE_HOST = DEV_MODE
8
9
  ? "https://breathecode-test.herokuapp.com"
@@ -1,5 +1,5 @@
1
1
  import axios from "axios"
2
- import { BREATHECODE_HOST, RIGOBOT_HOST } from "./constants"
2
+ import { BREATHECODE_HOST, DEV_MODE, RIGOBOT_HOST } from "./constants"
3
3
  import { Lesson } from "../components/LessonItem"
4
4
  import { randomUUID } from "./creatorUtils"
5
5
  import { Syllabus } from "./store"
@@ -267,6 +267,13 @@ export function getFilenameFromUrl(url: string): string {
267
267
  }
268
268
  }
269
269
 
270
+ export const makeCallbackUrl = (slug: string) => {
271
+ if (DEV_MODE) {
272
+ return `https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us120.gitpod.io/v1/learnpack/tools/images/callback?slug=${slug}`
273
+ }
274
+ return `${window.location.origin}/api/v1/webhooks/images`
275
+ }
276
+
270
277
  type TGenerateImageParams = {
271
278
  prompt: string
272
279
  }
@@ -280,6 +287,7 @@ export const generateImage = async (
280
287
  `${RIGOBOT_HOST}/v1/learnpack/tools/images`,
281
288
  {
282
289
  prompt,
290
+ webhook_callback_url: "https://www.learnpack.co/api/v1/webhooks/images",
283
291
  },
284
292
  {
285
293
  headers: {