-
Notifications
You must be signed in to change notification settings - Fork 0
/
old-index.js
36 lines (28 loc) · 1.19 KB
/
old-index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// NOTE: old simple embed API:
import { Component, Context } from '@glimmer/opcode-compiler';
import { artifacts } from '@glimmer/program';
import { precompile } from '@glimmer/compiler';
import createHTMLDocument from '@simple-dom/document';
import { AotRuntime, renderAot } from '@glimmer/runtime';
import Serializer from '@simple-dom/serializer';
import voidMap from '@simple-dom/void-map';
let source = `{{#let "hello" "world" as |hello world|}}<p>{{hello}} {{world}}</p>{{/let}}`;
let context = Context();
let component = Compilable(source);
let handle = component.compile(context);
let program = artifacts(context);
let document = createHTMLDocument();
let runtime = AotRuntime(document, payload);
let element = document.createElement('main');
let cursor = { element, nextSibling: null };
let iterator = renderAot(runtime, handle, cursor);
let result = iterator.sync();
function Compilable(source: string): CompilableProgram {
return Component(precompile(source));
}
let serialized = new Serializer(voidMap).serialize(element);
function serialize(element: SimpleElement): string {
return new Serializer(voidMap).serialize(element);
}
console.log(serialize(element));
<main><p>hello world</p></main>