json-canvas-viewer 4.2.1 → 4.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.
Files changed (40) hide show
  1. package/dist/chimp.js +4 -4
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/kernel/BaseModule.js +1 -1
  5. package/dist/kernel/BaseModule.js.map +1 -1
  6. package/dist/kernel/Controller.d.ts +2 -2
  7. package/dist/kernel/Controller.js +1 -1
  8. package/dist/kernel/Controller.js.map +1 -1
  9. package/dist/kernel/DataManager.d.ts +1 -5
  10. package/dist/kernel/DataManager.js +1 -1
  11. package/dist/kernel/DataManager.js.map +1 -1
  12. package/dist/kernel/InteractionHandler.d.ts +1 -1
  13. package/dist/kernel/InteractionHandler.js +1 -1
  14. package/dist/kernel/InteractionHandler.js.map +1 -1
  15. package/dist/kernel/OverlayManager.d.ts +4 -4
  16. package/dist/kernel/OverlayManager.js +1 -1
  17. package/dist/kernel/OverlayManager.js.map +1 -1
  18. package/dist/kernel/Renderer.d.ts +1 -8
  19. package/dist/kernel/Renderer.js +2 -2
  20. package/dist/kernel/Renderer.js.map +1 -1
  21. package/dist/kernel/StyleManager.d.ts +1 -1
  22. package/dist/kernel/StyleManager.js +1 -1
  23. package/dist/kernel/StyleManager.js.map +1 -1
  24. package/dist/kernel/index.d.ts +3 -4
  25. package/dist/kernel/index.js +1 -1
  26. package/dist/kernel/index.js.map +1 -1
  27. package/dist/kernel/types.d.ts +1 -1
  28. package/dist/kernel/utilities.d.ts +6 -6
  29. package/dist/kernel/utilities.js +1 -1
  30. package/dist/kernel/utilities.js.map +1 -1
  31. package/dist/modules/Controls/index.js.map +1 -1
  32. package/dist/modules/DebugPanel/index.js.map +1 -1
  33. package/dist/modules/Minimap/index.js.map +1 -1
  34. package/dist/modules/MistouchPreventer/index.js.map +1 -1
  35. package/dist/utilities/fetch-canvas.js.map +1 -1
  36. package/dist/utilities/parser.js.map +1 -1
  37. package/dist/utilities/render-to-string.d.ts +0 -1
  38. package/dist/utilities/render-to-string.js +1 -1
  39. package/dist/utilities/render-to-string.js.map +1 -1
  40. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"render-to-string.js","names":[],"sources":["../../src/utilities/render-to-string.ts"],"sourcesContent":["import type { JSONCanvas, JSONCanvasFileNode, JSONCanvasNode, Parser } from '@repo/shared';\n\nexport default async function renderToString(options: {\n\tcanvas: JSONCanvas;\n\tattachments?: Record<string, string>;\n\tattachmentDir?: string;\n\tparser?: Parser;\n}) {\n\tconst render = async (node: JSONCanvasNode) =>\n\t\tawait renderer(node, options.parser ?? ((markdown: string) => markdown));\n\tconst nodes = options.canvas.nodes ?? [];\n\tconst basePath = options.attachmentDir ?? './';\n\tnodes.forEach((node) => {\n\t\tif (node.type === 'file' && !node.file.startsWith('http')) {\n\t\t\tconst file = node.file.split('/');\n\t\t\tconst name = file.pop() ?? '';\n\t\t\tnode.file = options.attachments?.[name] ?? basePath + name;\n\t\t}\n\t});\n\tconst renderedContent: Array<string> = [];\n\tawait Promise.all(nodes.map(async (node) => renderedContent.push(await render(node))));\n\treturn renderedContent.join('');\n}\n\nasync function renderer(node: JSONCanvasNode, parse: Parser) {\n\tswitch (node.type) {\n\t\tcase 'text': {\n\t\t\treturn await parse(node.text);\n\t\t}\n\t\tcase 'file': {\n\t\t\treturn await fileProcessor(node, parse);\n\t\t}\n\t\tcase 'link': {\n\t\t\treturn `<a href=\"${node.url}\" target=\"_blank\" rel=\"nofollow\">${node.url}</a>`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn '';\n\t\t}\n\t}\n}\n\nasync function fileProcessor(node: JSONCanvasFileNode, parse: Parser) {\n\tif (/\\.md$/i.exec(node.file)) return await loadMarkdown(node.file, parse);\n\telse if (/\\.(png|jpg|jpeg|gif|svg|webp)$/i.exec(node.file))\n\t\treturn `<img src=\"${node.file}\" alt=\"${node.file.split('/').pop()}\">`;\n\telse if (/\\.(mp3|wav)$/i.exec(node.file)) return `<audio src=\"${node.file}\" controls></audio>`;\n\treturn '';\n}\n\nasync function loadMarkdown(path: string, parse: Parser) {\n\tlet parsedContent: string;\n\ttry {\n\t\tconst response = await fetch(path);\n\t\tconst result = await response.text();\n\t\tconst frontmatterMatch = /^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/.exec(result);\n\t\tparsedContent = await parse(frontmatterMatch ? frontmatterMatch[2] : result);\n\t} catch {\n\t\tparsedContent = 'Failed to load content.';\n\t}\n\treturn parsedContent;\n}\n"],"mappings":"AAEA,eAA8B,EAAe,EAK1C,CACF,IAAM,EAAS,KAAO,IACrB,MAAM,EAAS,EAAM,EAAQ,SAAY,GAAqB,GAAU,CACnE,EAAQ,EAAQ,OAAO,OAAS,EAAE,CAClC,EAAW,EAAQ,eAAiB,KAC1C,EAAM,QAAS,GAAS,CACvB,GAAI,EAAK,OAAS,QAAU,CAAC,EAAK,KAAK,WAAW,OAAO,CAAE,CAE1D,IAAM,EADO,EAAK,KAAK,MAAM,IACZ,CAAC,KAAK,EAAI,GAC3B,EAAK,KAAO,EAAQ,cAAc,IAAS,EAAW,IAEtD,CACF,IAAM,EAAiC,EAAE,CAEzC,OADA,MAAM,QAAQ,IAAI,EAAM,IAAI,KAAO,IAAS,EAAgB,KAAK,MAAM,EAAO,EAAK,CAAC,CAAC,CAAC,CAC/E,EAAgB,KAAK,GAAG,CAGhC,eAAe,EAAS,EAAsB,EAAe,CAC5D,OAAQ,EAAK,KAAb,CACC,IAAK,OACJ,OAAO,MAAM,EAAM,EAAK,KAAK,CAE9B,IAAK,OACJ,OAAO,MAAM,EAAc,EAAM,EAAM,CAExC,IAAK,OACJ,MAAO,YAAY,EAAK,IAAI,mCAAmC,EAAK,IAAI,MAEzE,QACC,MAAO,IAKV,eAAe,EAAc,EAA0B,EAAe,CAKrE,MAJI,SAAS,KAAK,EAAK,KAAK,CAAS,MAAM,EAAa,EAAK,KAAM,EAAM,CAChE,kCAAkC,KAAK,EAAK,KAAK,CAClD,aAAa,EAAK,KAAK,SAAS,EAAK,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,IAC1D,gBAAgB,KAAK,EAAK,KAAK,CAAS,eAAe,EAAK,KAAK,qBACnE,GAGR,eAAe,EAAa,EAAc,EAAe,CACxD,IAAI,EACJ,GAAI,CAEH,IAAM,EAAS,MAAM,MADE,MAAM,EAAK,EACJ,MAAM,CAC9B,EAAmB,oCAAoC,KAAK,EAAO,CACzE,EAAgB,MAAM,EAAM,EAAmB,EAAiB,GAAK,EAAO,MACrE,CACP,EAAgB,0BAEjB,OAAO"}
1
+ {"version":3,"file":"render-to-string.js","names":[],"sources":["../../src/utilities/render-to-string.ts"],"sourcesContent":["import type { JSONCanvas, JSONCanvasFileNode, JSONCanvasNode, Parser } from '@repo/shared';\n\nexport default async function renderToString(options: {\n\tcanvas: JSONCanvas;\n\tattachments?: Record<string, string>;\n\tparser?: Parser;\n}) {\n\tconst render = async (node: JSONCanvasNode) =>\n\t\tawait renderer(node, options.parser ?? ((markdown: string) => markdown));\n\tconst nodes = options.canvas.nodes ?? [];\n\tnodes.forEach((node) => {\n\t\tif (node.type !== 'file' || node.file.includes('://')) return;\n\t\tconst userDefinedPath = options.attachments?.[node.file];\n\t\tif (userDefinedPath) node.file = userDefinedPath;\n\t});\n\tconst renderedContent: Array<string> = [];\n\tawait Promise.all(nodes.map(async (node) => renderedContent.push(await render(node))));\n\treturn renderedContent.join('');\n}\n\nasync function renderer(node: JSONCanvasNode, parse: Parser) {\n\tswitch (node.type) {\n\t\tcase 'text': {\n\t\t\treturn await parse(node.text);\n\t\t}\n\t\tcase 'file': {\n\t\t\treturn await fileProcessor(node, parse);\n\t\t}\n\t\tcase 'link': {\n\t\t\treturn `<a href=\"${node.url}\" target=\"_blank\" rel=\"nofollow\">${node.url}</a>`;\n\t\t}\n\t\tdefault: {\n\t\t\treturn '';\n\t\t}\n\t}\n}\n\nasync function fileProcessor(node: JSONCanvasFileNode, parse: Parser) {\n\tif (/\\.md$/i.exec(node.file)) return await loadMarkdown(node.file, parse);\n\telse if (/\\.(png|jpg|jpeg|gif|svg|webp)$/i.exec(node.file))\n\t\treturn `<img src=\"${node.file}\" alt=\"${node.file.split('/').pop()}\">`;\n\telse if (/\\.(mp3|wav)$/i.exec(node.file)) return `<audio src=\"${node.file}\" controls></audio>`;\n\treturn '';\n}\n\nasync function loadMarkdown(path: string, parse: Parser) {\n\tlet parsedContent: string;\n\ttry {\n\t\tconst response = await fetch(path);\n\t\tconst result = await response.text();\n\t\tconst frontmatterMatch = /^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/.exec(result);\n\t\tparsedContent = await parse(frontmatterMatch ? frontmatterMatch[2] : result);\n\t} catch {\n\t\tparsedContent = 'Failed to load content.';\n\t}\n\treturn parsedContent;\n}\n"],"mappings":"AAEA,eAA8B,EAAe,EAI1C,CACF,IAAM,EAAS,KAAO,IACrB,MAAM,EAAS,EAAM,EAAQ,SAAY,GAAqB,EAAS,EAClE,EAAQ,EAAQ,OAAO,OAAS,CAAC,EACvC,EAAM,QAAS,GAAS,CACvB,GAAI,EAAK,OAAS,QAAU,EAAK,KAAK,SAAS,KAAK,EAAG,OACvD,IAAM,EAAkB,EAAQ,cAAc,EAAK,MAC/C,IAAiB,EAAK,KAAO,EAClC,CAAC,EACD,IAAM,EAAiC,CAAC,EAExC,OADA,MAAM,QAAQ,IAAI,EAAM,IAAI,KAAO,IAAS,EAAgB,KAAK,MAAM,EAAO,CAAI,CAAC,CAAC,CAAC,EAC9E,EAAgB,KAAK,EAAE,CAC/B,CAEA,eAAe,EAAS,EAAsB,EAAe,CAC5D,OAAQ,EAAK,KAAb,CACC,IAAK,OACJ,OAAO,MAAM,EAAM,EAAK,IAAI,EAE7B,IAAK,OACJ,OAAO,MAAM,EAAc,EAAM,CAAK,EAEvC,IAAK,OACJ,MAAO,YAAY,EAAK,IAAI,mCAAmC,EAAK,IAAI,MAEzE,QACC,MAAO,EAET,CACD,CAEA,eAAe,EAAc,EAA0B,EAAe,CAKrE,MAJI,SAAS,KAAK,EAAK,IAAI,EAAU,MAAM,EAAa,EAAK,KAAM,CAAK,EAC/D,kCAAkC,KAAK,EAAK,IAAI,EACjD,aAAa,EAAK,KAAK,SAAS,EAAK,KAAK,MAAM,GAAG,EAAE,IAAI,EAAE,IAC1D,gBAAgB,KAAK,EAAK,IAAI,EAAU,eAAe,EAAK,KAAK,qBACnE,EACR,CAEA,eAAe,EAAa,EAAc,EAAe,CACxD,IAAI,EACJ,GAAI,CAEH,IAAM,EAAS,MAAM,MADE,MAAM,CAAI,GACH,KAAK,EAC7B,EAAmB,oCAAoC,KAAK,CAAM,EACxE,EAAgB,MAAM,EAAM,EAAmB,EAAiB,GAAK,CAAM,CAC5E,MAAQ,CACP,EAAgB,yBACjB,CACA,OAAO,CACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-canvas-viewer",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "An extensible web-based viewer for JSON Canvas, easy to embed into websites.",
5
5
  "keywords": [
6
6
  "frontend",