@microsoft/fast-build 0.1.2 → 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/bin/fast.js CHANGED
@@ -214,7 +214,7 @@ async function runBuild(args) {
214
214
  // Render
215
215
  let rendered;
216
216
  if (Object.keys(templatesMap).length > 0) {
217
- rendered = wasm.render_with_templates(entryContent, JSON.stringify(templatesMap), stateContent);
217
+ rendered = wasm.render_entry_with_templates(entryContent, JSON.stringify(templatesMap), stateContent);
218
218
  } else {
219
219
  rendered = wasm.render(entryContent, stateContent);
220
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-build",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "CLI and Node.js API for server-side rendering of FAST declarative HTML templates.",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -15,6 +15,18 @@ export function parse_f_templates(html: string): string;
15
15
  */
16
16
  export function render(entry: string, state: string): string;
17
17
 
18
+ /**
19
+ * Render the top-level **entry HTML** with custom element templates and a JSON state string.
20
+ * Custom elements found at the root level of `entry` receive the full root state rather than
21
+ * building their child state from HTML attributes. For `{{binding}}` attributes on root custom
22
+ * elements, primitive results (`string`, `number`, and `bool`) are preserved in the rendered
23
+ * output, while non-primitive values (`array`, `object`, `null`) are stripped.
24
+ *
25
+ * `templates_json` is a JSON object mapping element names to their HTML template strings.
26
+ * Returns the rendered HTML or throws a JavaScript error.
27
+ */
28
+ export function render_entry_with_templates(entry: string, templates_json: string, state: string): string;
29
+
18
30
  /**
19
31
  * Render a FAST HTML template with custom element templates and a JSON state string.
20
32
  * `templates_json` is a JSON object mapping element names to their HTML template strings,
@@ -55,6 +55,46 @@ function render(entry, state) {
55
55
  }
56
56
  exports.render = render;
57
57
 
58
+ /**
59
+ * Render the top-level **entry HTML** with custom element templates and a JSON state string.
60
+ * Custom elements found at the root level of `entry` receive the full root state rather than
61
+ * building their child state from HTML attributes. For `{{binding}}` attributes on root custom
62
+ * elements, primitive results (`string`, `number`, and `bool`) are preserved in the rendered
63
+ * output, while non-primitive values (`array`, `object`, `null`) are stripped.
64
+ *
65
+ * `templates_json` is a JSON object mapping element names to their HTML template strings.
66
+ * Returns the rendered HTML or throws a JavaScript error.
67
+ * @param {string} entry
68
+ * @param {string} templates_json
69
+ * @param {string} state
70
+ * @returns {string}
71
+ */
72
+ function render_entry_with_templates(entry, templates_json, state) {
73
+ let deferred5_0;
74
+ let deferred5_1;
75
+ try {
76
+ const ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
+ const len0 = WASM_VECTOR_LEN;
78
+ const ptr1 = passStringToWasm0(templates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
79
+ const len1 = WASM_VECTOR_LEN;
80
+ const ptr2 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len2 = WASM_VECTOR_LEN;
82
+ const ret = wasm.render_entry_with_templates(ptr0, len0, ptr1, len1, ptr2, len2);
83
+ var ptr4 = ret[0];
84
+ var len4 = ret[1];
85
+ if (ret[3]) {
86
+ ptr4 = 0; len4 = 0;
87
+ throw takeFromExternrefTable0(ret[2]);
88
+ }
89
+ deferred5_0 = ptr4;
90
+ deferred5_1 = len4;
91
+ return getStringFromWasm0(ptr4, len4);
92
+ } finally {
93
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
94
+ }
95
+ }
96
+ exports.render_entry_with_templates = render_entry_with_templates;
97
+
58
98
  /**
59
99
  * Render a FAST HTML template with custom element templates and a JSON state string.
60
100
  * `templates_json` is a JSON object mapping element names to their HTML template strings,
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const parse_f_templates: (a: number, b: number) => [number, number];
5
5
  export const render: (a: number, b: number, c: number, d: number) => [number, number, number, number];
6
+ export const render_entry_with_templates: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
6
7
  export const render_with_templates: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
7
8
  export const __wbindgen_externrefs: WebAssembly.Table;
8
9
  export const __wbindgen_malloc: (a: number, b: number) => number;