Skip to content

Commit c8970e0

Browse files
authored
New core tags: <do>, <log>, <debug> (#2209)
1 parent ae53dc1 commit c8970e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+584
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./template.marko";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { value as _value, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/dom";
2+
const _y = /* @__PURE__ */_value("y", (_scope, y) => {
3+
debugger;
4+
});
5+
const _x = /* @__PURE__ */_value("x", (_scope, x) => {
6+
debugger;
7+
});
8+
const _setup = _scope => {
9+
debugger;
10+
_x(_scope, 0);
11+
_y(_scope, 0);
12+
};
13+
export const template = "<!><!>";
14+
export const walks = /* */"DD";
15+
export const setup = _setup;
16+
export default /* @__PURE__ */_createTemplate( /* @__PURE__ */_createRenderer(template, walks, setup), "packages/translator-tags/src/__tests__/fixtures/debug-tag/template.marko");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { nextScopeId as _nextScopeId, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/html";
2+
const _renderer = /* @__PURE__ */_createRenderer((input, _tagVar) => {
3+
const _scope0_id = _nextScopeId();
4+
debugger;
5+
const x = 0;
6+
debugger;
7+
const y = 0;
8+
debugger;
9+
});
10+
export default /* @__PURE__ */_createTemplate(_renderer, "packages/translator-tags/src/__tests__/fixtures/debug-tag/template.marko");
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<debug/>
2+
<const/x=0/>
3+
<debug=x/>
4+
<let/y=0/>
5+
<debug=y/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const skip_ssr = true;
2+
export const skip_csr = true;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render undefined
2+
```html
3+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
4+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Render undefined
2+
```html
3+
<!---->
4+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
5+
```
6+
7+
# Mutations
8+
```
9+
inserted #comment0, #text1
10+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { init } from "@marko/runtime-tags/debug/dom";
2+
import "./template.marko";
3+
init();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import log from "./test-log";
2+
function fromStatic() {
3+
log.static += "rendered";
4+
}
5+
import { queueSource as _queueSource, data as _data, value as _value, register as _register, queueEffect as _queueEffect, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/dom";
6+
const _logOutput = /* @__PURE__ */_value("logOutput", (_scope, logOutput) => _data(_scope["#text/0"], logOutput));
7+
const _str = /* @__PURE__ */_value("str", (_scope, str) => log.let += str);
8+
const _fromConst = /* @__PURE__ */_value("fromConst", (_scope, fromConst) => fromConst(_scope));
9+
const _setup_effect = _register("packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko_0", _scope => _queueSource(_scope, _logOutput, JSON.stringify(log)));
10+
const _setup = _scope => {
11+
log.block += "rendered";
12+
fromStatic(_scope);
13+
_queueEffect(_scope, _setup_effect);
14+
_fromConst(_scope, function () {
15+
log.const += "rendered";
16+
});
17+
_str(_scope, "rendered");
18+
_logOutput(_scope, JSON.stringify(log));
19+
};
20+
export const template = "<!><!>";
21+
export const walks = /* replace, over(1) */"D%b";
22+
export const setup = _setup;
23+
export default /* @__PURE__ */_createTemplate( /* @__PURE__ */_createRenderer(template, walks, setup), "packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko");
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import log from "./test-log";
2+
function fromStatic() {
3+
log.static += "rendered";
4+
}
5+
import { escapeXML as _escapeXML, markResumeNode as _markResumeNode, write as _write, writeEffect as _writeEffect, nextScopeId as _nextScopeId, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/html";
6+
const _renderer = /* @__PURE__ */_createRenderer((input, _tagVar) => {
7+
const _scope0_id = _nextScopeId();
8+
log.block += "rendered";
9+
const fromConst = function () {
10+
log.const += "rendered";
11+
};
12+
fromConst();
13+
const str = "rendered";
14+
log.let += str;
15+
fromStatic();
16+
const logOutput = JSON.stringify(log);
17+
_write(`<!>${_escapeXML(logOutput)}${_markResumeNode(_scope0_id, "#text/0")}`);
18+
_writeEffect(_scope0_id, "packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko_0");
19+
});
20+
export default /* @__PURE__ */_createTemplate(_renderer, "packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render undefined
2+
```html
3+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
4+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Render undefined
2+
```html
3+
<!---->
4+
<html>
5+
<head />
6+
<body>
7+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
8+
<!--M*0 #text/0-->
9+
<script>
10+
(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko_0",])
11+
</script>
12+
</body>
13+
</html>
14+
```
15+
16+
# Mutations
17+
```
18+
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./template.marko";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render "End"
2+
```html
3+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
4+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Write
2+
<!>{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}<!M*0 #text/0><script>(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko_0",])</script>
3+
4+
5+
# Render "End"
6+
```html
7+
<!---->
8+
<html>
9+
<head />
10+
<body>
11+
{"let":"rendered","const":"rendered","static":"rendered","block":"rendered"}
12+
<!--M*0 #text/0-->
13+
<script>
14+
(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/do-tag/template.marko_0",])
15+
</script>
16+
</body>
17+
</html>
18+
```
19+
20+
# Mutations
21+
```
22+
inserted #document/#comment0
23+
inserted #document/html1
24+
inserted #document/html1/head0
25+
inserted #document/html1/body1
26+
inserted #document/html1/body1/#text0
27+
inserted #document/html1/body1/#comment1
28+
inserted #document/html1/body1/script2
29+
inserted #document/html1/body1/script2/#text0
30+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import log from "./test-log";
2+
3+
<do() { log.block += "rendered"}/>
4+
<const/fromConst() { log.const += "rendered"}/>
5+
<do=fromConst/>
6+
<let/str="rendered"/>
7+
<do() { log.let += str}/>
8+
static function fromStatic() { log.static += "rendered"}
9+
<do=fromStatic/>
10+
11+
<let/logOutput = JSON.stringify(log)/>
12+
<effect() { logOutput = JSON.stringify(log) }/>
13+
-- ${logOutput}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
let: "",
3+
const: "",
4+
static: "",
5+
block: "",
6+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render undefined
2+
```html
3+
{"identifier":true,"tag var":true,"static var":true}
4+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Render undefined
2+
```html
3+
<!---->
4+
{"identifier":true,"tag var":true,"static var":true}
5+
```
6+
7+
# Mutations
8+
```
9+
inserted #comment0, #text1
10+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { init } from "@marko/runtime-tags/debug/dom";
2+
import "./template.marko";
3+
init();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import testLog from "./test-log";
2+
const staticVar = "static var";
3+
import { queueSource as _queueSource, data as _data, value as _value, register as _register, queueEffect as _queueEffect, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/dom";
4+
const _output = /* @__PURE__ */_value("output", (_scope, output) => _data(_scope["#text/0"], output));
5+
const _tagVar = /* @__PURE__ */_value("tagVar", (_scope, tagVar) => console.log(tagVar));
6+
const _setup_effect = _register("packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko_0", _scope => _queueSource(_scope, _output, JSON.stringify(testLog)));
7+
const _setup = _scope => {
8+
console.log("identifier");
9+
console.log(staticVar);
10+
_queueEffect(_scope, _setup_effect);
11+
_tagVar(_scope, "tag var");
12+
_output(_scope, JSON.stringify(testLog));
13+
};
14+
export const template = "<!><!>";
15+
export const walks = /* replace, over(1) */"D%b";
16+
export const setup = _setup;
17+
export default /* @__PURE__ */_createTemplate( /* @__PURE__ */_createRenderer(template, walks, setup), "packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import testLog from "./test-log";
2+
const staticVar = "static var";
3+
import { escapeXML as _escapeXML, markResumeNode as _markResumeNode, write as _write, writeEffect as _writeEffect, nextScopeId as _nextScopeId, createRenderer as _createRenderer, createTemplate as _createTemplate } from "@marko/runtime-tags/debug/html";
4+
const _renderer = /* @__PURE__ */_createRenderer((input, _tagVar) => {
5+
const _scope0_id = _nextScopeId();
6+
console.log("identifier");
7+
const tagVar = "tag var";
8+
console.log(tagVar);
9+
console.log(staticVar);
10+
const output = JSON.stringify(testLog);
11+
_write(`<!>${_escapeXML(output)}${_markResumeNode(_scope0_id, "#text/0")}`);
12+
_writeEffect(_scope0_id, "packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko_0");
13+
});
14+
export default /* @__PURE__ */_createTemplate(_renderer, "packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render undefined
2+
```html
3+
{"identifier":true,"tag var":true,"static var":true}
4+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Render undefined
2+
```html
3+
<!---->
4+
<html>
5+
<head />
6+
<body>
7+
{"identifier":true,"tag var":true,"static var":true}
8+
<!--M*0 #text/0-->
9+
<script>
10+
(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko_0",])
11+
</script>
12+
</body>
13+
</html>
14+
```
15+
16+
# Mutations
17+
```
18+
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./template.marko";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Render "End"
2+
```html
3+
{"identifier":true,"tag var":true,"static var":true}
4+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Write
2+
<!>{"identifier":true,"tag var":true,"static var":true}<!M*0 #text/0><script>(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko_0",])</script>
3+
4+
5+
# Render "End"
6+
```html
7+
<!---->
8+
<html>
9+
<head />
10+
<body>
11+
{"identifier":true,"tag var":true,"static var":true}
12+
<!--M*0 #text/0-->
13+
<script>
14+
(M$h=[]).push(null,[0,"packages/translator-tags/src/__tests__/fixtures/log-tag/template.marko_0",])
15+
</script>
16+
</body>
17+
</html>
18+
```
19+
20+
# Mutations
21+
```
22+
inserted #document/#comment0
23+
inserted #document/html1
24+
inserted #document/html1/head0
25+
inserted #document/html1/body1
26+
inserted #document/html1/body1/#text0
27+
inserted #document/html1/body1/#comment1
28+
inserted #document/html1/body1/script2
29+
inserted #document/html1/body1/script2/#text0
30+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import testLog from './test-log';
2+
3+
const log = console.log;
4+
5+
export const before = () => {
6+
// const testLog = require('./test-log').default;
7+
console.log = function(msg: keyof typeof testLog) {
8+
testLog[msg] = true;
9+
}
10+
}
11+
12+
export const after = () => {
13+
console.log = log;
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import testLog from "./test-log"
2+
3+
<log="identifier"/>
4+
<const/tagVar="tag var"/>
5+
<log=tagVar/>
6+
static const staticVar = "static var";
7+
<log=staticVar/>
8+
9+
<let/output=JSON.stringify(testLog)/>
10+
<effect() { output = JSON.stringify(testLog) }/>
11+
-- ${output}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
"identifier": false,
3+
"tag var": false,
4+
"static var": false
5+
}

0 commit comments

Comments
 (0)