@sealcode/jdd 0.1.1 → 0.2.2

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/@types/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export type JDDocument = Array<{
10
10
  }>;
11
11
  export interface JDDContext {
12
12
  render_image: (path_to_image: string) => FlatTemplatable;
13
+ render_markdown: (markdown: string) => FlatTemplatable;
13
14
  }
14
15
  export declare const simpleJDDContext: JDDContext;
15
16
  export declare function render(registry: Registry, document: JDDocument, context: JDDContext): import("stream").Readable;
@@ -3,4 +3,5 @@ export declare class Registry {
3
3
  map: Map<string, Component>;
4
4
  add(type: string, component: ComponentConstructor<any>): void;
5
5
  get(type: string): Component | null;
6
+ getAll(): Record<string, Component>;
6
7
  }
package/lib/index.js CHANGED
@@ -16,11 +16,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.render = exports.simpleJDDContext = void 0;
18
18
  const tempstream_1 = require("tempstream");
19
+ const marked_1 = require("marked");
19
20
  __exportStar(require("./component-arguments"), exports);
20
21
  __exportStar(require("./component"), exports);
21
22
  __exportStar(require("./registry"), exports);
22
23
  exports.simpleJDDContext = {
23
24
  render_image: (path) => /* HTML */ `<img src="file://path" />`,
25
+ render_markdown: (string) => marked_1.marked.parse(string),
24
26
  };
25
27
  function render(registry, document, context) {
26
28
  return (0, tempstream_1.tempstream) `${document.map(({ component_name, args }) => {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyD;AAEzD,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B;AAWd,QAAA,gBAAgB,GAAe;IAC3C,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,2BAA2B;CAC9D,CAAC;AAEF,SAAgB,MAAM,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;IACxC,CAAC,CAAC,EAAE,CAAC;AACN,CAAC;AAfD,wBAeC"}
package/lib/registry.js CHANGED
@@ -12,6 +12,9 @@ class Registry {
12
12
  const ret = this.map.get(type);
13
13
  return ret ? ret : null;
14
14
  }
15
+ getAll() {
16
+ return Object.fromEntries(this.map.entries());
17
+ }
15
18
  }
16
19
  exports.Registry = Registry;
17
20
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";;;AAEA,MAAa,QAAQ;IAArB;QACC,QAAG,GAA2B,IAAI,GAAG,EAAE,CAAC;IAUzC,CAAC;IARA,GAAG,CAAC,IAAY,EAAE,SAAoC;QACrD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,IAAY;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACzB,CAAC;CACD;AAXD,4BAWC"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";;;AAEA,MAAa,QAAQ;IAArB;QACC,QAAG,GAA2B,IAAI,GAAG,EAAE,CAAC;IAczC,CAAC;IAZA,GAAG,CAAC,IAAY,EAAE,SAAoC;QACrD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,IAAY;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,MAAM;QACL,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACD;AAfD,4BAeC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/jdd",
3
- "version": "0.1.1",
3
+ "version": "0.2.2",
4
4
  "description": "JSON-Driven Documents",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {