@alloy-js/core 0.22.0-dev.1 → 0.22.0-dev.3
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/dist/src/components/Block.d.ts.map +1 -1
- package/dist/src/components/Block.js +24 -7
- package/dist/src/components/Block.js.map +1 -1
- package/dist/src/components/Indent.d.ts.map +1 -1
- package/dist/src/components/Indent.js +2 -1
- package/dist/src/components/Indent.js.map +1 -1
- package/dist/src/components/Prose.d.ts.map +1 -1
- package/dist/src/components/Prose.js +2 -1
- package/dist/src/components/Prose.js.map +1 -1
- package/dist/src/content-slot.d.ts +51 -0
- package/dist/src/content-slot.d.ts.map +1 -0
- package/dist/src/content-slot.js +69 -0
- package/dist/src/content-slot.js.map +1 -0
- package/dist/src/content-slot.test.d.ts +2 -0
- package/dist/src/content-slot.test.d.ts.map +1 -0
- package/dist/src/content-slot.test.js +57 -0
- package/dist/src/content-slot.test.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/reactivity.d.ts +15 -1
- package/dist/src/reactivity.d.ts.map +1 -1
- package/dist/src/reactivity.js +20 -8
- package/dist/src/reactivity.js.map +1 -1
- package/dist/src/render.d.ts +1 -0
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +66 -2
- package/dist/src/render.js.map +1 -1
- package/dist/src/symbols/decl.d.ts +8 -0
- package/dist/src/symbols/decl.d.ts.map +1 -0
- package/dist/src/symbols/decl.js +22 -0
- package/dist/src/symbols/decl.js.map +1 -0
- package/dist/src/symbols/index.d.ts +1 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +1 -0
- package/dist/src/symbols/index.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +212 -15
- package/dist/src/utils.js.map +1 -1
- package/dist/test/components/block.test.d.ts.map +1 -1
- package/dist/test/components/block.test.js +18 -1
- package/dist/test/components/block.test.js.map +1 -1
- package/dist/test/components/list.test.d.ts.map +1 -1
- package/dist/test/components/list.test.js +80 -1
- package/dist/test/components/list.test.js.map +1 -1
- package/dist/test/control-flow/for.test.js +32 -2
- package/dist/test/control-flow/for.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/Block.tsx +18 -6
- package/src/components/Indent.tsx +4 -2
- package/src/components/Prose.tsx +2 -1
- package/src/content-slot.test.tsx +65 -0
- package/src/content-slot.tsx +91 -0
- package/src/index.ts +1 -0
- package/src/reactivity.ts +38 -5
- package/src/render.ts +80 -3
- package/src/symbols/decl.ts +25 -0
- package/src/symbols/index.ts +1 -0
- package/src/utils.tsx +240 -16
- package/temp/api.json +469 -0
- package/test/components/block.test.tsx +21 -1
- package/test/components/list.test.tsx +76 -1
- package/test/control-flow/for.test.tsx +43 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Block.d.ts","sourceRoot":"","sources":["../../../src/components/Block.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Block.d.ts","sourceRoot":"","sources":["../../../src/components/Block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YA4BtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { computed } from "@vue/reactivity";
|
|
3
|
-
import {
|
|
3
|
+
import { createContentSlot } from "../content-slot.js";
|
|
4
4
|
import { Indent } from "./Indent.js";
|
|
5
5
|
/**
|
|
6
6
|
* Create an indented block of source text. The block has `opener` text which is
|
|
@@ -8,19 +8,36 @@ import { Indent } from "./Indent.js";
|
|
|
8
8
|
* added after the block, which defaults to `"}"`.
|
|
9
9
|
*/
|
|
10
10
|
export function Block(props) {
|
|
11
|
-
const
|
|
11
|
+
const ContentSlot = createContentSlot();
|
|
12
|
+
const leadingNewline = computed(() => {
|
|
13
|
+
if (!props.newline) return false;
|
|
14
|
+
|
|
15
|
+
// When inline, we want a newline only when content breaks, otherwise a nothing..
|
|
16
|
+
if (props.inline) return _$createIntrinsic("sbr", {});
|
|
17
|
+
|
|
18
|
+
// When not inline, we want a hardline when the slot has contents otherwise a space.
|
|
19
|
+
if (ContentSlot.hasContent) return _$createIntrinsic("hbr", {});
|
|
20
|
+
return " ";
|
|
21
|
+
});
|
|
12
22
|
return _$createIntrinsic("group", {
|
|
13
23
|
get children() {
|
|
14
|
-
return [
|
|
24
|
+
return [leadingNewline, _$memo(() => props.opener ?? "{"), _$createComponent(Indent, {
|
|
25
|
+
get hardline() {
|
|
26
|
+
return !props.inline && ContentSlot.hasContent;
|
|
27
|
+
},
|
|
15
28
|
get line() {
|
|
16
|
-
return props.inline &&
|
|
29
|
+
return props.inline && ContentSlot.hasContent;
|
|
17
30
|
},
|
|
18
31
|
get softline() {
|
|
19
|
-
return
|
|
32
|
+
return !props.inline || ContentSlot.isEmpty;
|
|
20
33
|
},
|
|
21
34
|
trailingBreak: true,
|
|
22
35
|
get children() {
|
|
23
|
-
return
|
|
36
|
+
return _$createComponent(ContentSlot, {
|
|
37
|
+
get children() {
|
|
38
|
+
return props.children;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
24
41
|
}
|
|
25
42
|
}), _$memo(() => props.closer ?? "}")];
|
|
26
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["computed","
|
|
1
|
+
{"version":3,"names":["computed","createContentSlot","Indent","Block","props","ContentSlot","leadingNewline","newline","inline","_$createIntrinsic","hasContent","children","_$memo","opener","_$createComponent","hardline","line","softline","isEmpty","trailingBreak","closer"],"sources":["../../../src/components/Block.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,iBAAiB;AAE1B,SAASC,MAAM;AA0Bf;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CAACC,KAAiB,EAAE;EACvC,MAAMC,WAAW,GAAGJ,iBAAiB,CAAC,CAAC;EACvC,MAAMK,cAAc,GAAGN,QAAQ,CAAC,MAAM;IACpC,IAAI,CAACI,KAAK,CAACG,OAAO,EAAE,OAAO,KAAK;;IAEhC;IACA,IAAIH,KAAK,CAACI,MAAM,EAAE,OAAAC,iBAAA;;IAElB;IACA,IAAIJ,WAAW,CAACK,UAAU,EAAE,OAAAD,iBAAA;IAE5B,OAAO,GAAG;EACZ,CAAC,CAAC;EACF,OAAAA,iBAAA;IAAA,IAAAE,SAAA;MAAA,QAEKL,cAAc,EAAAM,MAAA,OACdR,KAAK,CAACS,MAAM,IAAI,GAAG,GAAAC,iBAAA,CACnBZ,MAAM;QAAA,IACLa,QAAQA,CAAA;UAAA,OAAE,CAACX,KAAK,CAACI,MAAM,IAAIH,WAAW,CAACK,UAAU;QAAA;QAAA,IACjDM,IAAIA,CAAA;UAAA,OAAEZ,KAAK,CAACI,MAAM,IAAIH,WAAW,CAACK,UAAU;QAAA;QAAA,IAC5CO,QAAQA,CAAA;UAAA,OAAE,CAACb,KAAK,CAACI,MAAM,IAAIH,WAAW,CAACa,OAAO;QAAA;QAC9CC,aAAa;QAAA,IAAAR,SAAA;UAAA,OAAAG,iBAAA,CAEZT,WAAW;YAAA,IAAAM,SAAA;cAAA,OAAEP,KAAK,CAACO,QAAQ;YAAA;UAAA;QAAA;MAAA,IAAAC,MAAA,OAE7BR,KAAK,CAACgB,MAAM,IAAI,GAAG;IAAA;EAAA;AAG1B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indent.d.ts","sourceRoot":"","sources":["../../../src/components/Indent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Indent.d.ts","sourceRoot":"","sources":["../../../src/components/Indent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,YAkBxC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { computed } from "@vue/reactivity";
|
|
2
3
|
/**
|
|
3
4
|
* Create an indented block of source text. The indented block starts a new line
|
|
4
5
|
* at the new indentation level and, with `trailingBreak`, ends with a new line
|
|
@@ -6,7 +7,7 @@ import { createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/
|
|
|
6
7
|
* break suitable for typical blocks of statements but can be configured.
|
|
7
8
|
*/
|
|
8
9
|
export function Indent(props) {
|
|
9
|
-
const breakElem = props.nobreak ? "" : props.hardline ? _$createIntrinsic("hbr", {}) : props.softline ? _$createIntrinsic("sbr", {}) : props.line ? _$createIntrinsic("br", {}) : _$createIntrinsic("hbr", {});
|
|
10
|
+
const breakElem = computed(() => props.nobreak ? "" : props.hardline ? _$createIntrinsic("hbr", {}) : props.softline ? _$createIntrinsic("sbr", {}) : props.line ? _$createIntrinsic("br", {}) : _$createIntrinsic("hbr", {}));
|
|
10
11
|
return [_$createIntrinsic("indent", {
|
|
11
12
|
get children() {
|
|
12
13
|
return [breakElem, _$memo(() => props.children)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Indent","props","breakElem","nobreak","hardline","_$createIntrinsic","softline","line","children","_$memo","trailingBreak"],"sources":["../../../src/components/Indent.tsx"],"sourcesContent":[null],"mappings":";
|
|
1
|
+
{"version":3,"names":["computed","Indent","props","breakElem","nobreak","hardline","_$createIntrinsic","softline","line","children","_$memo","trailingBreak"],"sources":["../../../src/components/Indent.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAoC1C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,KAAkB,EAAE;EACzC,MAAMC,SAAS,GAAGH,QAAQ,CAAC,MACzBE,KAAK,CAACE,OAAO,GAAG,EAAE,GAChBF,KAAK,CAACG,QAAQ,GAAAC,iBAAA,cACdJ,KAAK,CAACK,QAAQ,GAAAD,iBAAA,cACdJ,KAAK,CAACM,IAAI,GAAAF,iBAAA,aAAAA,iBAAA,WAEd,CAAC;EAED,QAAAA,iBAAA;IAAA,IAAAG,SAAA;MAAA,QAGON,SAAS,EAAAO,MAAA,OACTR,KAAK,CAACO,QAAQ;IAAA;EAAA,IAAAC,MAAA,OAEhBR,KAAK,CAACS,aAAa,IAAIR,SAAS;AAGvC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prose.d.ts","sourceRoot":"","sources":["../../../src/components/Prose.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Prose.d.ts","sourceRoot":"","sources":["../../../src/components/Prose.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,YAuBjC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { computed } from "@vue/reactivity";
|
|
3
|
+
import { childrenArray } from "../utils.js";
|
|
3
4
|
/**
|
|
4
5
|
* Create a block of text which will break once a word exceeds the configured line width.
|
|
5
6
|
* The children are expected to be strings, and a <br /> is added between each word.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["computed","childrenArray","Prose","props","brokenChildren","children","map","child","trim","split","word","index","array","_$memo","length","_$createIntrinsic","flat","value"],"sources":["../../../src/components/Prose.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa;AAMtB;AACA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CAACC,KAAY,EAAE;EAClC,MAAMC,cAAc,GAAGJ,QAAQ,CAAC,MAAM;IACpC,MAAMK,QAAQ,GAAGJ,aAAa,CAAC,MAAME,KAAK,CAACE,QAAQ,CAAC;IACpD,OAAOA,QAAQ,CACZC,GAAG,CAAEC,KAAK,IAAK;MACd,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAOA,KAAK,CACTC,IAAI,CAAC,CAAC,CACNC,KAAK,CAAC,KAAK,CAAC,CACZH,GAAG,CAAC,CAACI,IAAI,EAAEC,KAAK,EAAEC,KAAK,MAEnBF,IAAI,EAAAG,MAAA,OACJA,MAAA,OAAAF,KAAK,GAAGC,KAAK,CAACE,MAAM,GAAG,CAAC,OAAAC,iBAAA,UAAU,EAEtC,CAAC;MACN;MAEA,OAAOR,KAAK;IACd,CAAC,CAAC,CACDS,IAAI,CAAC,CAAC,CAAC;EACZ,CAAC,CAAC;EAEF,OAAAD,iBAAA;IAAA,IAAAV,SAAA;MAAA,OAAcD,cAAc,CAACa,KAAK;IAAA;EAAA;AACpC","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Ref } from "@vue/reactivity";
|
|
2
|
+
import { Children, Component } from "./runtime/component.js";
|
|
3
|
+
export interface ContentSlot {
|
|
4
|
+
(props: {
|
|
5
|
+
children: Children;
|
|
6
|
+
}): Children;
|
|
7
|
+
/**
|
|
8
|
+
* A ref indicating whether the slot is currently empty.
|
|
9
|
+
*/
|
|
10
|
+
ref: Ref<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the slot is currently empty.
|
|
13
|
+
*/
|
|
14
|
+
isEmpty: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the slot has any content.
|
|
17
|
+
*/
|
|
18
|
+
hasContent: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A component that will render its contents when the content slot is empty.
|
|
21
|
+
*/
|
|
22
|
+
WhenEmpty: Component<{}>;
|
|
23
|
+
/**
|
|
24
|
+
* A component that will render its contents when the content slot has content.
|
|
25
|
+
*/
|
|
26
|
+
WhenHasContent: Component<{}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a component which tracks whether any content is placed inside of it.
|
|
30
|
+
* The component exposes a ref `isEmpty` which indicates whether the slot is
|
|
31
|
+
* empty, as well as convenience accessors `isEmpty` and `hasContent`.
|
|
32
|
+
* Additionally, it provides two sub-components, `WhenEmpty` and
|
|
33
|
+
* `WhenHasContent`, which render their contents conditionally based on whether
|
|
34
|
+
* the slot is empty.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const ContentSlot = createContentSlot();
|
|
40
|
+
*
|
|
41
|
+
* <>
|
|
42
|
+
* <ContentSlot.WhenEmpty>The slot is empty!</ContentSlot.WhenEmpty>
|
|
43
|
+
* <ContentSlot.WhenHasContent>The slot has content!</ContentSlot.WhenHasContent>
|
|
44
|
+
* <ContentSlot>
|
|
45
|
+
* {someCondition && "Here is some content!"}
|
|
46
|
+
* </ContentSlot>
|
|
47
|
+
* </>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createContentSlot(): ContentSlot;
|
|
51
|
+
//# sourceMappingURL=content-slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-slot.d.ts","sourceRoot":"","sources":["../../src/content-slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EAAc,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,QAAQ,CAAC;IAC1C;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IAEzB;;OAEG;IACH,cAAc,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAmC/C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { effect, shallowRef } from "@vue/reactivity";
|
|
3
|
+
import { Show } from "./components/Show.js";
|
|
4
|
+
import { getContext } from "./reactivity.js";
|
|
5
|
+
/**
|
|
6
|
+
* Create a component which tracks whether any content is placed inside of it.
|
|
7
|
+
* The component exposes a ref `isEmpty` which indicates whether the slot is
|
|
8
|
+
* empty, as well as convenience accessors `isEmpty` and `hasContent`.
|
|
9
|
+
* Additionally, it provides two sub-components, `WhenEmpty` and
|
|
10
|
+
* `WhenHasContent`, which render their contents conditionally based on whether
|
|
11
|
+
* the slot is empty.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const ContentSlot = createContentSlot();
|
|
17
|
+
*
|
|
18
|
+
* <>
|
|
19
|
+
* <ContentSlot.WhenEmpty>The slot is empty!</ContentSlot.WhenEmpty>
|
|
20
|
+
* <ContentSlot.WhenHasContent>The slot has content!</ContentSlot.WhenHasContent>
|
|
21
|
+
* <ContentSlot>
|
|
22
|
+
* {someCondition && "Here is some content!"}
|
|
23
|
+
* </ContentSlot>
|
|
24
|
+
* </>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function createContentSlot() {
|
|
28
|
+
const isEmpty = shallowRef(false);
|
|
29
|
+
function ContentSlot(props) {
|
|
30
|
+
const context = getContext();
|
|
31
|
+
effect(() => {
|
|
32
|
+
isEmpty.value = context.isEmpty.value;
|
|
33
|
+
});
|
|
34
|
+
return props.children;
|
|
35
|
+
}
|
|
36
|
+
ContentSlot.ref = isEmpty;
|
|
37
|
+
ContentSlot.WhenEmpty = function WhenEmpty(props) {
|
|
38
|
+
return _$createComponent(Show, {
|
|
39
|
+
get when() {
|
|
40
|
+
return isEmpty.value;
|
|
41
|
+
},
|
|
42
|
+
get children() {
|
|
43
|
+
return props.children;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
ContentSlot.WhenHasContent = function WhenHasContent(props) {
|
|
48
|
+
return _$createComponent(Show, {
|
|
49
|
+
get when() {
|
|
50
|
+
return !isEmpty.value;
|
|
51
|
+
},
|
|
52
|
+
get children() {
|
|
53
|
+
return props.children;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(ContentSlot, "isEmpty", {
|
|
58
|
+
get() {
|
|
59
|
+
return isEmpty.value;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(ContentSlot, "hasContent", {
|
|
63
|
+
get() {
|
|
64
|
+
return !isEmpty.value;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return ContentSlot;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=content-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["effect","shallowRef","Show","getContext","createContentSlot","isEmpty","ContentSlot","props","context","value","children","ref","WhenEmpty","_$createComponent","when","WhenHasContent","Object","defineProperty","get"],"sources":["../../src/content-slot.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,EAAOC,UAAU,QAAQ,iBAAiB;AACzD,SAASC,IAAI;AACb,SAASC,UAAU,QAAQ,iBAAiB;AA+B5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAgB;EAC/C,MAAMC,OAAO,GAAGJ,UAAU,CAAU,KAAK,CAAC;EAE1C,SAASK,WAAWA,CAACC,KAA6B,EAAE;IAClD,MAAMC,OAAO,GAAGL,UAAU,CAAC,CAAE;IAC7BH,MAAM,CAAC,MAAM;MACXK,OAAO,CAACI,KAAK,GAAGD,OAAO,CAACH,OAAO,CAAEI,KAAK;IACxC,CAAC,CAAC;IAEF,OAAOF,KAAK,CAACG,QAAQ;EACvB;EACAJ,WAAW,CAACK,GAAG,GAAGN,OAAO;EACzBC,WAAW,CAACM,SAAS,GAAG,SAASA,SAASA,CAACL,KAA6B,EAAE;IACxE,OAAAM,iBAAA,CAAQX,IAAI;MAAA,IAACY,IAAIA,CAAA;QAAA,OAAET,OAAO,CAACI,KAAK;MAAA;MAAA,IAAAC,SAAA;QAAA,OAAGH,KAAK,CAACG,QAAQ;MAAA;IAAA;EACnD,CAAC;EAEDJ,WAAW,CAACS,cAAc,GAAG,SAASA,cAAcA,CAACR,KAEpD,EAAE;IACD,OAAAM,iBAAA,CAAQX,IAAI;MAAA,IAACY,IAAIA,CAAA;QAAA,OAAE,CAACT,OAAO,CAACI,KAAK;MAAA;MAAA,IAAAC,SAAA;QAAA,OAAGH,KAAK,CAACG,QAAQ;MAAA;IAAA;EACpD,CAAC;EAEDM,MAAM,CAACC,cAAc,CAACX,WAAW,EAAE,SAAS,EAAE;IAC5CY,GAAGA,CAAA,EAAG;MACJ,OAAOb,OAAO,CAACI,KAAK;IACtB;EACF,CAAC,CAAC;EAEFO,MAAM,CAACC,cAAc,CAACX,WAAW,EAAE,YAAY,EAAE;IAC/CY,GAAGA,CAAA,EAAG;MACJ,OAAO,CAACb,OAAO,CAACI,KAAK;IACvB;EACF,CAAC,CAAC;EAEF,OAAOH,WAAW;AACpB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-slot.test.d.ts","sourceRoot":"","sources":["../../src/content-slot.test.tsx"],"names":[],"mappings":"AAEA,OAAO,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { ref } from "@vue/reactivity";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import "../testing/extend-expect.js";
|
|
5
|
+
import { Show } from "./components/Show.js";
|
|
6
|
+
import { createContentSlot } from "./content-slot.js";
|
|
7
|
+
import { printTree, renderTree } from "./render.js";
|
|
8
|
+
it("knows when its empty", () => {
|
|
9
|
+
const ContentSlot = createContentSlot();
|
|
10
|
+
expect([_$memo(() => ContentSlot.hasContent && "{"), _$createComponent(ContentSlot, {
|
|
11
|
+
children: "hi"
|
|
12
|
+
}), _$memo(() => ContentSlot.hasContent && "}")]).toRenderTo(`
|
|
13
|
+
{hi}
|
|
14
|
+
`);
|
|
15
|
+
expect([_$memo(() => ContentSlot.hasContent && "{"), _$createComponent(ContentSlot, {
|
|
16
|
+
children: false
|
|
17
|
+
}), _$memo(() => ContentSlot.hasContent && "}")]).toRenderTo(``);
|
|
18
|
+
});
|
|
19
|
+
it("is reactive", () => {
|
|
20
|
+
const ContentSlot = createContentSlot();
|
|
21
|
+
const showContent = ref(false);
|
|
22
|
+
const tree = renderTree([_$memo(() => ContentSlot.isEmpty && "It's empty!"), _$createComponent(ContentSlot, {
|
|
23
|
+
get children() {
|
|
24
|
+
return _$createComponent(Show, {
|
|
25
|
+
get when() {
|
|
26
|
+
return showContent.value;
|
|
27
|
+
},
|
|
28
|
+
children: "Content!"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
})]);
|
|
32
|
+
expect(printTree(tree)).toBe(`It's empty!`);
|
|
33
|
+
showContent.value = true;
|
|
34
|
+
expect(printTree(tree)).toBe(`Content!`);
|
|
35
|
+
});
|
|
36
|
+
it("works with WhenEmpty and WhenHasContent", () => {
|
|
37
|
+
const ContentSlot = createContentSlot();
|
|
38
|
+
const showContent = ref(false);
|
|
39
|
+
const tree = renderTree([_$createComponent(ContentSlot.WhenEmpty, {
|
|
40
|
+
children: "It's empty!"
|
|
41
|
+
}), _$createComponent(ContentSlot.WhenHasContent, {
|
|
42
|
+
children: "Has content!"
|
|
43
|
+
}), _$createComponent(ContentSlot, {
|
|
44
|
+
get children() {
|
|
45
|
+
return _$createComponent(Show, {
|
|
46
|
+
get when() {
|
|
47
|
+
return showContent.value;
|
|
48
|
+
},
|
|
49
|
+
children: "Content!"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})]);
|
|
53
|
+
expect(printTree(tree)).toBe(`It's empty!`);
|
|
54
|
+
showContent.value = true;
|
|
55
|
+
expect(printTree(tree)).toBe(`Has content!Content!`);
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=content-slot.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ref","expect","it","Show","createContentSlot","printTree","renderTree","ContentSlot","_$memo","hasContent","_$createComponent","children","toRenderTo","showContent","tree","isEmpty","when","value","toBe","WhenEmpty","WhenHasContent"],"sources":["../../src/content-slot.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,QAAQ,iBAAiB;AACrC,SAASC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACnC,OAAO,6BAA6B;AACpC,SAASC,IAAI;AACb,SAASC,iBAAiB;AAC1B,SAASC,SAAS,EAAEC,UAAU,QAAQ,aAAa;AAEnDJ,EAAE,CAAC,sBAAsB,EAAE,MAAM;EAC/B,MAAMK,WAAW,GAAGH,iBAAiB,CAAC,CAAC;EAEvCH,MAAM,EAAAO,MAAA,OAEDD,WAAW,CAACE,UAAU,IAAI,GAAG,GAAAC,iBAAA,CAC7BH,WAAW;IAAAI,QAAA;EAAA,IAAAH,MAAA,OACXD,WAAW,CAACE,UAAU,IAAI,GAAG,EAElC,CAAC,CAACG,UAAU,CAAC;AACf;AACA,GAAG,CAAC;EAEFX,MAAM,EAAAO,MAAA,OAEDD,WAAW,CAACE,UAAU,IAAI,GAAG,GAAAC,iBAAA,CAC7BH,WAAW;IAAAI,QAAA,EAAE;EAAK,IAAAH,MAAA,OAClBD,WAAW,CAACE,UAAU,IAAI,GAAG,EAElC,CAAC,CAACG,UAAU,CAAC,EAAE,CAAC;AAClB,CAAC,CAAC;AAEFV,EAAE,CAAC,aAAa,EAAE,MAAM;EACtB,MAAMK,WAAW,GAAGH,iBAAiB,CAAC,CAAC;EACvC,MAAMS,WAAW,GAAGb,GAAG,CAAC,KAAK,CAAC;EAE9B,MAAMc,IAAI,GAAGR,UAAU,EAAAE,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ed, isProxy, isReactive, isRef, rea
|
|
|
2
2
|
export * from "./binder.js";
|
|
3
3
|
export * from "./code.js";
|
|
4
4
|
export * from "./components/index.js";
|
|
5
|
+
export * from "./content-slot.js";
|
|
5
6
|
export * from "./context.js";
|
|
6
7
|
export * from "./context/index.js";
|
|
7
8
|
export * from "./library-symbol-reference.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,EACR,GAAG,EACH,eAAe,EACf,UAAU,EACV,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,MAAM,GACZ,MAAM,iBAAiB,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,EACR,GAAG,EACH,eAAe,EACf,UAAU,EACV,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,MAAM,GACZ,MAAM,iBAAiB,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,YAAY,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { TrackOpTypes, TriggerOpTypes, computed, isProxy, isReactive, isRef, rea
|
|
|
2
2
|
export * from "./binder.js";
|
|
3
3
|
export * from "./code.js";
|
|
4
4
|
export * from "./components/index.js";
|
|
5
|
+
export * from "./content-slot.js";
|
|
5
6
|
export * from "./context.js";
|
|
6
7
|
export * from "./context/index.js";
|
|
7
8
|
export * from "./library-symbol-reference.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TrackOpTypes","TriggerOpTypes","computed","isProxy","isReactive","isRef","reactive","ref","shallowReactive","shallowRef","toRaw","toRef","toRefs","track","trigger","watch"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,YAAY,EACZC,cAAc,EACdC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,GAAG,EACHC,eAAe,EACfC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,KAAK,QAOA,iBAAiB;AACxB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,cAAc;AAC5B,cAAc,oBAAoB;AAClC,cAAc,+BAA+B;AAC7C,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,OAAO,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["TrackOpTypes","TriggerOpTypes","computed","isProxy","isReactive","isRef","reactive","ref","shallowReactive","shallowRef","toRaw","toRef","toRefs","track","trigger","watch"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,YAAY,EACZC,cAAc,EACdC,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,GAAG,EACHC,eAAe,EACfC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,KAAK,QAOA,iBAAiB;AACxB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,cAAc;AAC5B,cAAc,oBAAoB;AAClC,cAAc,+BAA+B;AAC7C,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,OAAO,YAAY","ignoreList":[]}
|
package/dist/src/reactivity.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShallowReactive } from "@vue/reactivity";
|
|
1
|
+
import { Ref, ShallowReactive } from "@vue/reactivity";
|
|
2
2
|
import type { RenderedTextTree } from "./render.js";
|
|
3
3
|
import type { Children, ComponentCreator } from "./runtime/component.js";
|
|
4
4
|
import type { OutputSymbol } from "./symbols/output-symbol.js";
|
|
@@ -31,6 +31,19 @@ export interface Context {
|
|
|
31
31
|
* The symbol that this component has taken.
|
|
32
32
|
*/
|
|
33
33
|
takenSymbols?: ShallowReactive<Set<OutputSymbol>>;
|
|
34
|
+
/**
|
|
35
|
+
* The number of child nodes that have content. When zero, this component is
|
|
36
|
+
* semantically empty.
|
|
37
|
+
*/
|
|
38
|
+
childrenWithContent: number;
|
|
39
|
+
/**
|
|
40
|
+
* A ref that indicates whether the component is empty.
|
|
41
|
+
*/
|
|
42
|
+
isEmpty?: Ref<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether this context is a root context
|
|
45
|
+
*/
|
|
46
|
+
isRoot: boolean;
|
|
34
47
|
}
|
|
35
48
|
export declare function getContext(): Context | null;
|
|
36
49
|
export interface RootOptions {
|
|
@@ -71,5 +84,6 @@ export type CustomContextChildrenCallback = (child: Children) => void;
|
|
|
71
84
|
declare const CUSTOM_CONTEXT_SYM: unique symbol;
|
|
72
85
|
export declare function createCustomContext(useCallback: (useChildren: CustomContextChildrenCallback) => void): CustomContext;
|
|
73
86
|
export declare function isCustomContext(child: Children): child is CustomContext;
|
|
87
|
+
export declare function refId(ref: Ref<unknown>): number;
|
|
74
88
|
export {};
|
|
75
89
|
//# sourceMappingURL=reactivity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["../../src/reactivity.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["../../src/reactivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,GAAG,EAEH,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAW/D,wBAAgB,eAAe,iBAE9B;AAED,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,CAAC,MAAM,OAAO,CAAC,GACf,aAAa,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAElE,MAAM,WAAW,UAAU;IACzB,IAAI,IAAI,CAAC;CACV;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAGtB,OAAO,CAAC,EAAE,MAAM,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C,EAAE,IAAI,CAAC;IAC3B,gBAAgB,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,IAAI,CAAC;CAClE;AAED,MAAM,MAAM,6BAA6B,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AACtE,QAAA,MAAM,kBAAkB,eAAW,CAAC;AAEpC,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,CAAC,WAAW,EAAE,6BAA6B,KAAK,IAAI,GAChE,aAAa,CAOf;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,IAAI,aAAa,CAMvE;AAKD,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,MAAM,CAO/C"}
|
package/dist/src/reactivity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pauseTracking, resetTracking, shallowRef, stop, effect as vueEffect } from "@vue/reactivity";
|
|
1
|
+
import { isRef, pauseTracking, ref, resetTracking, shallowRef, stop, effect as vueEffect } from "@vue/reactivity";
|
|
2
2
|
import { scheduler } from "./scheduler.js";
|
|
3
3
|
import { trace, TracePhase } from "./tracer.js";
|
|
4
4
|
|
|
@@ -22,7 +22,10 @@ export function root(fn, options) {
|
|
|
22
22
|
context: {},
|
|
23
23
|
elementCache: new Map(),
|
|
24
24
|
takesSymbols: false,
|
|
25
|
-
takenSymbols: undefined
|
|
25
|
+
takenSymbols: undefined,
|
|
26
|
+
childrenWithContent: 0,
|
|
27
|
+
isEmpty: ref(true),
|
|
28
|
+
isRoot: true
|
|
26
29
|
};
|
|
27
30
|
globalContext = context;
|
|
28
31
|
let ret;
|
|
@@ -60,7 +63,9 @@ export function effect(fn, current) {
|
|
|
60
63
|
owner: globalContext,
|
|
61
64
|
elementCache: new Map(),
|
|
62
65
|
takesSymbols: false,
|
|
63
|
-
takenSymbols: undefined
|
|
66
|
+
takenSymbols: undefined,
|
|
67
|
+
childrenWithContent: 0,
|
|
68
|
+
isRoot: false
|
|
64
69
|
};
|
|
65
70
|
const cleanupFn = final => {
|
|
66
71
|
const d = context.disposables;
|
|
@@ -87,18 +92,15 @@ export function effect(fn, current) {
|
|
|
87
92
|
scheduler: scheduler(),
|
|
88
93
|
onTrack(event) {
|
|
89
94
|
trace(TracePhase.effect.track, () => {
|
|
90
|
-
return `tracking ${event.target}, ${String(event.key)}`;
|
|
95
|
+
return `tracking ${isRef(event.target) ? `Ref:${refId(event.target)}` : event.target}, ${String(event.key)}`;
|
|
91
96
|
});
|
|
92
97
|
},
|
|
93
98
|
onTrigger(event) {
|
|
94
99
|
trace(TracePhase.effect.trigger, () => {
|
|
95
|
-
return `triggering ${event.target}, ${String(event.key)}`;
|
|
100
|
+
return `triggering ${isRef(event.target) ? `Ref:${refId(event.target)}` : event.target}, ${String(event.key)}`;
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
});
|
|
99
|
-
|
|
100
|
-
// allow recursive effects (recursive option does nothing, possible bug)
|
|
101
|
-
runner.effect.flags |= 1 << 5;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/**
|
|
@@ -142,4 +144,14 @@ export function createCustomContext(useCallback) {
|
|
|
142
144
|
export function isCustomContext(child) {
|
|
143
145
|
return typeof child === "object" && child !== null && Object.hasOwn(child, CUSTOM_CONTEXT_SYM);
|
|
144
146
|
}
|
|
147
|
+
const seenRefs = new WeakMap();
|
|
148
|
+
let refIdCounter = 1;
|
|
149
|
+
export function refId(ref) {
|
|
150
|
+
let id = seenRefs.get(ref);
|
|
151
|
+
if (id === undefined) {
|
|
152
|
+
id = refIdCounter++;
|
|
153
|
+
seenRefs.set(ref, id);
|
|
154
|
+
}
|
|
155
|
+
return id;
|
|
156
|
+
}
|
|
145
157
|
//# sourceMappingURL=reactivity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pauseTracking","resetTracking","shallowRef","stop","effect","vueEffect","scheduler","trace","TracePhase","globalThis","__ALLOY__","Error","getElementCache","getContext","elementCache","globalContext","root","fn","options","context","componentOwner","disposables","owner","Map","takesSymbols","takenSymbols","undefined","ret","untrack","d","v","memo","equal","o","prev","res","value","current","cleanupFn","final","k","len","length","runner","onCleanup","oldContext","flags","onTrack","event","track","target","String","key","onTrigger","trigger","push","CUSTOM_CONTEXT_SYM","Symbol","createCustomContext","useCallback","useCustomContext","useCb","isCustomContext","child","Object","hasOwn"],"sources":["../../src/reactivity.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,aAAa,EAEbC,aAAa,EAEbC,UAAU,EACVC,IAAI,EACJC,MAAM,IAAIC,SAAS,QACd,iBAAiB;AAGxB,SAASC,SAAS,QAAQ,gBAAgB;AAE1C,SAASC,KAAK,EAAEC,UAAU,QAAQ,aAAa;;AAE/C;AACA,IAAKC,UAAU,CAASC,SAAS,EAAE;EACjC,MAAM,IAAIC,KAAK,CACb,sGACF,CAAC;AACH;AACCF,UAAU,CAASC,SAAS,GAAG,IAAI;AAEpC,OAAO,SAASE,eAAeA,CAAA,EAAG;EAChC,OAAOC,UAAU,CAAC,CAAC,CAAEC,YAAY;AACnC;
|
|
1
|
+
{"version":3,"names":["isRef","pauseTracking","ref","resetTracking","shallowRef","stop","effect","vueEffect","scheduler","trace","TracePhase","globalThis","__ALLOY__","Error","getElementCache","getContext","elementCache","globalContext","root","fn","options","context","componentOwner","disposables","owner","Map","takesSymbols","takenSymbols","undefined","childrenWithContent","isEmpty","isRoot","ret","untrack","d","v","memo","equal","o","prev","res","value","current","cleanupFn","final","k","len","length","runner","onCleanup","oldContext","flags","onTrack","event","track","target","refId","String","key","onTrigger","trigger","push","CUSTOM_CONTEXT_SYM","Symbol","createCustomContext","useCallback","useCustomContext","useCb","isCustomContext","child","Object","hasOwn","seenRefs","WeakMap","refIdCounter","id","get","set"],"sources":["../../src/reactivity.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,KAAK,EACLC,aAAa,EAEbC,GAAG,EAEHC,aAAa,EAEbC,UAAU,EACVC,IAAI,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AACA;AACA;;AAOA,MAAM2C,kBAAkB,GAAGC,MAAM,CAAC,CAAC;AAEnC,OAAO,SAASC,mBAAmBA,CACjCC,WAAiE,EAClD;EACf,OAAO;IACL,CAACH,kBAAkB,GAAG,IAAI;IAC1BI,gBAAgBA,CAACC,KAAmC,EAAQ;MAC1DF,WAAW,CAACE,KAAK,CAAC;IACpB;EACF,CAAC;AACH;AAEA,OAAO,SAASC,eAAeA,CAACC,KAAe,EAA0B;EACvE,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACdC,MAAM,CAACC,MAAM,CAACF,KAAK,EAAEP,kBAAkB,CAAC;AAE5C;AAEA,MAAMU,QAAQ,GAAG,IAAIC,OAAO,CAAuB,CAAC;AACpD,IAAIC,YAAY,GAAG,CAAC;AAEpB,OAAO,SAASlB,KAAKA,CAACtD,GAAiB,EAAU;EAC/C,IAAIyE,EAAE,GAAGH,QAAQ,CAACI,GAAG,CAAC1E,GAAG,CAAC;EAC1B,IAAIyE,EAAE,KAAK/C,SAAS,EAAE;IACpB+C,EAAE,GAAGD,YAAY,EAAE;IACnBF,QAAQ,CAACK,GAAG,CAAC3E,GAAG,EAAEyE,EAAE,CAAC;EACvB;EACA,OAAOA,EAAE;AACX","ignoreList":[]}
|
package/dist/src/render.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export declare function render(children: Children, options?: PrintTreeOptions):
|
|
|
112
112
|
export declare function renderAsync(children: Children, options?: PrintTreeOptions): Promise<OutputDirectory>;
|
|
113
113
|
export declare function sourceFilesForTree(tree: RenderedTextTree, options?: PrintTreeOptions): OutputDirectory;
|
|
114
114
|
export declare function renderTree(children: Children): RenderedTextTree;
|
|
115
|
+
export declare function notifyContentState(): void;
|
|
115
116
|
export interface PrintTreeOptions {
|
|
116
117
|
/**
|
|
117
118
|
* The number of characters the printer will wrap on. Defaults to 100
|
package/dist/src/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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AACD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,oBAY5C;AA4BD,wBAAgB,kBAAkB,SAqDjC;AAoRD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAOD,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,gBAAgB,UAoB3E;AA2BD,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,QAGhE;AAED,wBAAgB,QAAQ,SAGvB;AAED,wBAAgB,gBAAgB,SAU/B"}
|
package/dist/src/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRef } from "@vue/reactivity";
|
|
1
|
+
import { isRef, ref } from "@vue/reactivity";
|
|
2
2
|
import { doc } from "prettier";
|
|
3
3
|
import prettier from "prettier/doc.js";
|
|
4
4
|
import { useContext } from "./context.js";
|
|
@@ -229,10 +229,66 @@ function renderWorker(node, children) {
|
|
|
229
229
|
appendChild(node, children);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
+
function contentAdded() {
|
|
233
|
+
const context = getContext();
|
|
234
|
+
context.childrenWithContent++;
|
|
235
|
+
}
|
|
236
|
+
export function notifyContentState() {
|
|
237
|
+
untrack(() => {
|
|
238
|
+
const startContext = getContext();
|
|
239
|
+
if (startContext.childrenWithContent === 0) {
|
|
240
|
+
if (startContext.isEmpty.value === true) {
|
|
241
|
+
// it was already empty, no work to do.
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (startContext.isEmpty) {
|
|
245
|
+
startContext.isEmpty.value = true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// otherwise we need to decrement the content counts up the tree.
|
|
249
|
+
let current = startContext.owner;
|
|
250
|
+
while (current) {
|
|
251
|
+
if (current.childrenWithContent === 0) {
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
current.childrenWithContent--;
|
|
255
|
+
if (current.isEmpty) {
|
|
256
|
+
current.isEmpty.value = true;
|
|
257
|
+
}
|
|
258
|
+
current = current.owner;
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
if (startContext.isEmpty.value === false) {
|
|
262
|
+
// it was already non-empty, no work to do.
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (startContext.isEmpty && startContext.isEmpty.value) {
|
|
266
|
+
startContext.isEmpty.value = false;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// otherwise we need to increment the content counts up the tree.
|
|
270
|
+
let current = startContext.owner;
|
|
271
|
+
while (current) {
|
|
272
|
+
current.childrenWithContent++;
|
|
273
|
+
if (current.childrenWithContent > 1) {
|
|
274
|
+
// This isn't the first content so we have no work to do
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
if (current.isEmpty && current.isEmpty.value) {
|
|
278
|
+
current.isEmpty.value = false;
|
|
279
|
+
}
|
|
280
|
+
current = current.owner;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
232
285
|
function appendChild(node, rawChild) {
|
|
233
286
|
trace(TracePhase.render.appendChild, () => debugPrintChild(rawChild));
|
|
234
287
|
const child = normalizeChild(rawChild);
|
|
235
288
|
if (typeof child === "string") {
|
|
289
|
+
if (child !== "") {
|
|
290
|
+
contentAdded();
|
|
291
|
+
}
|
|
236
292
|
node.push(child);
|
|
237
293
|
} else {
|
|
238
294
|
const cache = getElementCache();
|
|
@@ -248,6 +304,7 @@ function appendChild(node, rawChild) {
|
|
|
248
304
|
renderWorker(newNode, children);
|
|
249
305
|
node.push(newNode);
|
|
250
306
|
cache.set(child, newNode);
|
|
307
|
+
notifyContentState();
|
|
251
308
|
});
|
|
252
309
|
} else if (isIntrinsicElement(child)) {
|
|
253
310
|
trace(TracePhase.render.appendChild, () => "IntrinsicElement: " + debugPrintChild(child));
|
|
@@ -345,6 +402,8 @@ function appendChild(node, rawChild) {
|
|
|
345
402
|
effect(() => {
|
|
346
403
|
trace(TracePhase.render.appendChild, () => "Component: " + debugPrintChild(child));
|
|
347
404
|
const context = getContext();
|
|
405
|
+
context.childrenWithContent = 0;
|
|
406
|
+
context.isEmpty ??= ref(true);
|
|
348
407
|
if (context) context.componentOwner = child;
|
|
349
408
|
const componentRoot = [];
|
|
350
409
|
pushStack(child.component, child.props);
|
|
@@ -352,7 +411,8 @@ function appendChild(node, rawChild) {
|
|
|
352
411
|
popStack();
|
|
353
412
|
node.push(componentRoot);
|
|
354
413
|
cache.set(child, componentRoot);
|
|
355
|
-
|
|
414
|
+
notifyContentState();
|
|
415
|
+
trace(TracePhase.render.appendChild, () => "Component done: " + debugPrintChild(child) + ", empty: " + context.isEmpty.value);
|
|
356
416
|
});
|
|
357
417
|
} else if (typeof child === "function") {
|
|
358
418
|
trace(TracePhase.render.appendChild, () => "Memo: " + child.toString());
|
|
@@ -363,10 +423,14 @@ function appendChild(node, rawChild) {
|
|
|
363
423
|
while (typeof res === "function" && !isComponentCreator(res)) {
|
|
364
424
|
res = res();
|
|
365
425
|
}
|
|
426
|
+
const context = getContext();
|
|
427
|
+
context.childrenWithContent = 0;
|
|
428
|
+
context.isEmpty ??= ref(true);
|
|
366
429
|
const newNodes = [];
|
|
367
430
|
renderWorker(newNodes, res);
|
|
368
431
|
node[index] = newNodes;
|
|
369
432
|
cache.set(child, newNodes);
|
|
433
|
+
notifyContentState();
|
|
370
434
|
return newNodes;
|
|
371
435
|
});
|
|
372
436
|
} else {
|