@alloy-js/core 0.10.0 → 0.12.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/CHANGELOG.md +28 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +100 -19
- package/dist/src/code.js +1 -2
- package/dist/src/components/Block.js +2 -5
- package/dist/src/components/Declaration.js +2 -4
- package/dist/src/components/For.d.ts +2 -2
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/components/For.js +1 -2
- package/dist/src/components/Indent.js +2 -4
- package/dist/src/components/List.js +2 -5
- package/dist/src/components/MemberDeclaration.js +2 -4
- package/dist/src/components/MemberName.js +1 -2
- package/dist/src/components/MemberScope.js +2 -4
- package/dist/src/components/Name.js +1 -2
- package/dist/src/components/Output.js +2 -4
- package/dist/src/components/Prose.js +1 -2
- package/dist/src/components/ReferenceOrContent.d.ts +8 -0
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -0
- package/dist/src/components/ReferenceOrContent.js +11 -0
- package/dist/src/components/Scope.js +2 -4
- package/dist/src/components/Show.js +1 -2
- package/dist/src/components/SourceDirectory.js +2 -4
- package/dist/src/components/SourceFile.js +2 -5
- package/dist/src/components/StatementList.js +2 -4
- package/dist/src/components/Switch.d.ts +1 -1
- package/dist/src/components/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch.js +1 -2
- package/dist/src/components/Wrap.js +2 -4
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -2
- package/dist/src/components/stc/index.d.ts +1 -0
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +2 -2
- package/dist/src/components/stc/sti.js +1 -2
- package/dist/src/context/assignment.js +1 -2
- package/dist/src/context/binder.js +1 -2
- package/dist/src/context/declaration.js +1 -2
- package/dist/src/context/index.js +1 -2
- package/dist/src/context/member-declaration.js +1 -2
- package/dist/src/context/member-scope.js +1 -2
- package/dist/src/context/name-policy.js +1 -2
- package/dist/src/context/scope.js +1 -2
- package/dist/src/context/source-directory.js +1 -2
- package/dist/src/context/source-file.js +1 -2
- package/dist/src/context.js +1 -2
- package/dist/src/debug.js +13 -15
- package/dist/src/index.browser.js +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/jsx-runtime.d.ts +1 -1
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +10 -5
- package/dist/src/name-policy.js +1 -2
- package/dist/src/refkey.js +1 -2
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +6 -2
- package/dist/src/scheduler.d.ts +8 -0
- package/dist/src/scheduler.d.ts.map +1 -0
- package/dist/src/scheduler.js +17 -0
- package/dist/src/slot.js +1 -2
- package/dist/src/stc.js +1 -2
- package/dist/src/sti.js +1 -2
- package/dist/src/tap.js +1 -2
- package/dist/src/tsdoc-metadata.json +1 -1
- package/dist/src/utils.js +2 -4
- package/dist/src/write-output.browser.js +1 -2
- package/dist/src/write-output.js +1 -2
- package/dist/test/browser-build.test.js +85 -0
- package/dist/test/children.test.js +27 -0
- package/dist/test/components/block.test.js +45 -0
- package/dist/test/components/declaration.test.js +32 -0
- package/dist/test/components/list.test.js +86 -0
- package/dist/test/components/prose.test.js +25 -0
- package/dist/test/components/reference-or-content.test.d.ts +2 -0
- package/dist/test/components/reference-or-content.test.d.ts.map +1 -0
- package/dist/test/components/reference-or-content.test.js +149 -0
- package/dist/test/components/slot.test.js +134 -0
- package/dist/test/components/source-file.test.js +64 -0
- package/dist/test/components/wrap.test.js +35 -0
- package/dist/test/control-flow/for.test.js +219 -0
- package/dist/test/control-flow/match.test.js +67 -0
- package/dist/test/control-flow/show.test.js +29 -0
- package/dist/test/name-policy.test.js +19 -0
- package/dist/test/props-with-defaults.test.js +93 -0
- package/dist/test/reactivity/circular-reactives.test.d.ts +2 -0
- package/dist/test/reactivity/circular-reactives.test.d.ts.map +1 -0
- package/dist/test/reactivity/circular-reactives.test.js +31 -0
- package/dist/test/reactivity/cleanup.test.js +82 -0
- package/dist/test/reactivity/memo.test.js +16 -0
- package/dist/test/reactivity/ref-rendering.test.js +37 -0
- package/dist/test/reactivity/test.test.js +61 -0
- package/dist/test/reactivity/untrack.test.js +26 -0
- package/dist/test/refkey.test.js +25 -0
- package/dist/test/rendering/basic.test.js +96 -0
- package/dist/test/rendering/code.test.js +55 -0
- package/dist/test/rendering/formatting.test.js +402 -0
- package/dist/test/rendering/indent.test.js +90 -0
- package/dist/test/rendering/memoization.test.js +27 -0
- package/dist/test/rendering/refkeys.test.js +32 -0
- package/dist/test/split-props.test.js +77 -0
- package/dist/test/stc.test.js +34 -0
- package/dist/test/symbols.test.js +877 -0
- package/dist/test/utils.test.d.ts.map +1 -1
- package/dist/test/utils.test.js +223 -0
- package/dist/testing/extend-expect.js +1 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/render.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -22
- package/src/binder.ts +100 -17
- package/src/components/For.tsx +6 -6
- package/src/components/ReferenceOrContent.tsx +22 -0
- package/src/components/index.tsx +1 -0
- package/src/components/stc/index.ts +1 -0
- package/src/debug.ts +12 -13
- package/src/jsx-runtime.ts +24 -14
- package/src/render.ts +5 -0
- package/src/scheduler.ts +24 -0
- package/temp/api.json +216 -15
- package/test/components/declaration.test.tsx +2 -0
- package/test/components/list.test.tsx +0 -1
- package/test/components/reference-or-content.test.tsx +138 -0
- package/test/control-flow/for.test.tsx +34 -4
- package/test/reactivity/circular-reactives.test.tsx +32 -0
- package/test/reactivity/cleanup.test.tsx +5 -0
- package/test/reactivity/untrack.test.ts +3 -0
- package/test/rendering/memoization.test.tsx +2 -0
- package/test/symbols.test.ts +392 -13
- package/test/utils.test.tsx +2 -0
- package/babel.config.cjs +0 -4
- package/dist/src/binder.js.map +0 -1
- package/dist/src/code.js.map +0 -1
- package/dist/src/components/Block.js.map +0 -1
- package/dist/src/components/Declaration.js.map +0 -1
- package/dist/src/components/For.js.map +0 -1
- package/dist/src/components/Indent.js.map +0 -1
- package/dist/src/components/List.js.map +0 -1
- package/dist/src/components/MemberDeclaration.js.map +0 -1
- package/dist/src/components/MemberName.js.map +0 -1
- package/dist/src/components/MemberScope.js.map +0 -1
- package/dist/src/components/Name.js.map +0 -1
- package/dist/src/components/Output.js.map +0 -1
- package/dist/src/components/Prose.js.map +0 -1
- package/dist/src/components/Scope.js.map +0 -1
- package/dist/src/components/Show.js.map +0 -1
- package/dist/src/components/SourceDirectory.js.map +0 -1
- package/dist/src/components/SourceFile.js.map +0 -1
- package/dist/src/components/StatementList.js.map +0 -1
- package/dist/src/components/Switch.js.map +0 -1
- package/dist/src/components/Wrap.js.map +0 -1
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/components/stc/index.js.map +0 -1
- package/dist/src/components/stc/sti.js.map +0 -1
- package/dist/src/context/assignment.js.map +0 -1
- package/dist/src/context/binder.js.map +0 -1
- package/dist/src/context/declaration.js.map +0 -1
- package/dist/src/context/index.js.map +0 -1
- package/dist/src/context/member-declaration.js.map +0 -1
- package/dist/src/context/member-scope.js.map +0 -1
- package/dist/src/context/name-policy.js.map +0 -1
- package/dist/src/context/scope.js.map +0 -1
- package/dist/src/context/source-directory.js.map +0 -1
- package/dist/src/context/source-file.js.map +0 -1
- package/dist/src/context.js.map +0 -1
- package/dist/src/debug.js.map +0 -1
- package/dist/src/index.browser.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/jsx-runtime.js.map +0 -1
- package/dist/src/name-policy.js.map +0 -1
- package/dist/src/refkey.js.map +0 -1
- package/dist/src/render.js.map +0 -1
- package/dist/src/slot.js.map +0 -1
- package/dist/src/stc.js.map +0 -1
- package/dist/src/sti.js.map +0 -1
- package/dist/src/tap.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/src/write-output.browser.js.map +0 -1
- package/dist/src/write-output.js.map +0 -1
- package/dist/testing/extend-expect.js.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/render.js.map +0 -1
- package/dist/testing/vitest.d.js.map +0 -1
|
@@ -8,5 +8,4 @@ import { createNamedContext, useContext } from "../context.js";
|
|
|
8
8
|
export const MemberDeclarationContext = createNamedContext("MemberDeclaration");
|
|
9
9
|
export function useMemberDeclaration() {
|
|
10
10
|
return useContext(MemberDeclarationContext);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=member-declaration.js.map
|
|
11
|
+
}
|
package/dist/src/context.js
CHANGED
package/dist/src/debug.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isReactive } from "@vue/reactivity";
|
|
2
|
-
import { Chalk } from "chalk";
|
|
3
2
|
import Table from "cli-table3";
|
|
3
|
+
import pc from "picocolors";
|
|
4
4
|
import { contextsByKey } from "./context.js";
|
|
5
5
|
import { getContext } from "./jsx-runtime.js";
|
|
6
6
|
const debug = {
|
|
@@ -32,11 +32,11 @@ function debugStack() {
|
|
|
32
32
|
table.push([{
|
|
33
33
|
hAlign: "right",
|
|
34
34
|
content: "props"
|
|
35
|
-
}, props && Object.keys(props).length > 0 ? dumpValue(props) :
|
|
35
|
+
}, props && Object.keys(props).length > 0 ? dumpValue(props) : pc.gray("(none)")]);
|
|
36
36
|
table.push([{
|
|
37
37
|
hAlign: "right",
|
|
38
38
|
content: "contexts"
|
|
39
|
-
}, foundContexts.length > 0 ? foundContexts.map(c => printContext(c, true)).join("\n") :
|
|
39
|
+
}, foundContexts.length > 0 ? foundContexts.map(c => printContext(c, true)).join("\n") : pc.gray("(none)")]);
|
|
40
40
|
process.stdout.write(table.toString() + "\n\n");
|
|
41
41
|
foundContexts = [];
|
|
42
42
|
}
|
|
@@ -73,38 +73,37 @@ function findContextOwner(context) {
|
|
|
73
73
|
return currentContext?.componentOwner?.component.name ?? "unknown";
|
|
74
74
|
}
|
|
75
75
|
globalThis.debug = debug;
|
|
76
|
-
const chalk = new Chalk();
|
|
77
76
|
const style = {
|
|
78
77
|
value: {
|
|
79
78
|
primitive(value) {
|
|
80
79
|
switch (typeof value) {
|
|
81
80
|
case "string":
|
|
82
|
-
return
|
|
81
|
+
return pc.blue(`"${value}"`);
|
|
83
82
|
case "object":
|
|
84
83
|
case "undefined":
|
|
85
|
-
return
|
|
84
|
+
return pc.gray(String(value));
|
|
86
85
|
default:
|
|
87
|
-
return
|
|
86
|
+
return pc.blue(String(value));
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
89
|
symbol(value) {
|
|
91
|
-
return
|
|
90
|
+
return pc.gray(String(value));
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
93
|
context: {
|
|
95
94
|
name(name) {
|
|
96
|
-
return
|
|
95
|
+
return pc.bgBlack(` ${pc.white(name)} `);
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
98
|
component: {
|
|
100
99
|
name(name) {
|
|
101
|
-
return
|
|
100
|
+
return pc.bgBlue(` <${pc.white(name)}> `);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
};
|
|
105
104
|
function reactiveTag(value) {
|
|
106
105
|
if (isReactive(value)) {
|
|
107
|
-
return " " +
|
|
106
|
+
return " " + pc.greenBright(`reactive`) + " ";
|
|
108
107
|
}
|
|
109
108
|
return "";
|
|
110
109
|
}
|
|
@@ -120,7 +119,7 @@ function dumpValue(value, level = 0) {
|
|
|
120
119
|
if (value === null) {
|
|
121
120
|
return style.value.primitive(null) + reactiveTag(value);
|
|
122
121
|
} else {
|
|
123
|
-
if (level > 0) return
|
|
122
|
+
if (level > 0) return pc.gray(`{ ... }` + reactiveTag(value));
|
|
124
123
|
const table = kvTable(" ");
|
|
125
124
|
for (const [key, propValue] of Object.entries(value)) {
|
|
126
125
|
table.push([{
|
|
@@ -130,7 +129,7 @@ function dumpValue(value, level = 0) {
|
|
|
130
129
|
return table.toString();
|
|
131
130
|
}
|
|
132
131
|
case "function":
|
|
133
|
-
return
|
|
132
|
+
return pc.gray("ƒ ()");
|
|
134
133
|
case "undefined":
|
|
135
134
|
return style.value.primitive(undefined);
|
|
136
135
|
}
|
|
@@ -159,5 +158,4 @@ function kvTable(sep = " ") {
|
|
|
159
158
|
"padding-right": 0
|
|
160
159
|
}
|
|
161
160
|
});
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=debug.js.map
|
|
161
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export * from "./index.js"; // Re-export everything
|
|
2
|
-
export { writeOutput } from "./write-output.browser.js"; // Override writeOutput for browsers
|
|
3
|
-
//# sourceMappingURL=index.browser.js.map
|
|
2
|
+
export { writeOutput } from "./write-output.browser.js"; // Override writeOutput for browsers
|
package/dist/src/index.js
CHANGED
|
@@ -236,7 +236,7 @@ export declare namespace JSX {
|
|
|
236
236
|
export declare function jsx(type: Component<any>, props: Record<string, unknown>): ComponentCreator<Record<string, unknown>>;
|
|
237
237
|
export declare const jsxs: typeof jsx;
|
|
238
238
|
export declare function createComponent<TProps extends Props = Props>(C: Component<TProps>, props: TProps): ComponentCreator<TProps>;
|
|
239
|
-
export declare function taggedComponent<TProps = Props>(tag: symbol, component: Component<TProps>): Component<TProps
|
|
239
|
+
export declare function taggedComponent<TProps = Props>(tag: symbol, component: Component<TProps>): Component<TProps> & Required<Pick<Component<TProps>, "tag">>;
|
|
240
240
|
export declare const intrinsicElementKey: unique symbol;
|
|
241
241
|
export type IndentIntrinsicElement = IntrinsicElementBase<"indent">;
|
|
242
242
|
export type IndentIfBreakIntrinsicElement = IntrinsicElementBase<"indentIfBreak">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,GAAG,EAMJ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM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C,EAC7D,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAyCxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CA8C5E"}
|
package/dist/src/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Much of the implementations in this file are inspired by vuerx-js
|
|
2
2
|
// See: https://github.com/ryansolid/vuerx-jsx.
|
|
3
3
|
import { computed, isReactive, pauseTracking, proxyRefs, resetTracking, shallowRef, stop, toRefs, effect as vueEffect } from "@vue/reactivity";
|
|
4
|
+
import { scheduler } from "./scheduler.js";
|
|
4
5
|
if (globalThis.ALLOY) {
|
|
5
6
|
throw new Error("Multiple versions of the JSX Runtime have been loaded. This will likely cause undesirable behavior.");
|
|
6
7
|
}
|
|
@@ -62,10 +63,10 @@ export function effect(fn, current) {
|
|
|
62
63
|
for (let k = 0, len = d.length; k < len; k++) d[k]();
|
|
63
64
|
|
|
64
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
65
|
-
final && stop(
|
|
66
|
+
final && stop(runner);
|
|
66
67
|
};
|
|
67
68
|
onCleanup(() => cleanupFn(true));
|
|
68
|
-
const
|
|
69
|
+
const runner = vueEffect(() => {
|
|
69
70
|
cleanupFn(false);
|
|
70
71
|
const oldContext = globalContext;
|
|
71
72
|
globalContext = context;
|
|
@@ -74,7 +75,12 @@ export function effect(fn, current) {
|
|
|
74
75
|
} finally {
|
|
75
76
|
globalContext = oldContext;
|
|
76
77
|
}
|
|
77
|
-
}, {
|
|
78
|
+
}, {
|
|
79
|
+
scheduler: scheduler(() => runner)
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// allow recursive effects (recursive option does nothing, possible bug)
|
|
83
|
+
runner.effect.flags |= 1 << 5;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
/**
|
|
@@ -319,5 +325,4 @@ export function defaultProps(props, defaults) {
|
|
|
319
325
|
}
|
|
320
326
|
function shouldDebug() {
|
|
321
327
|
return typeof process !== "undefined" && !!process.env?.ALLOY_DEBUG;
|
|
322
|
-
}
|
|
323
|
-
//# sourceMappingURL=jsx-runtime.js.map
|
|
328
|
+
}
|
package/dist/src/name-policy.js
CHANGED
package/dist/src/refkey.js
CHANGED
package/dist/src/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAIpC,OAAO,EAEL,QAAQ,EACR,OAAO,EAcR,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAIpC,OAAO,EAEL,QAAQ,EACR,OAAO,EAcR,MAAM,kBAAkB,CAAC;AAwB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,eAAe,GAAG,UAAU,CAAC,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAID,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,uBAE7D;AAED,eAAO,MAAM,YAAY,eAAW,CAAC;AAErC,MAAM,WAAW,SAAS;IACxB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrB,SAAS,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IACrD,KAAK,CAAC,CACJ,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,GAAG,GACxC,GAAG,CAAC;IACP,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,YAAY,GAAG,SAAS,CAAC,GACtD,SAAS,CAMX;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAE5D;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC,EAAE,CAAC;AAOzE,wBAAgB,MAAM,CACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAuFjB;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,oBAY5C;AAyPD,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;CACnB;AAOD,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,gBAAgB,UAc3E"}
|
package/dist/src/render.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useContext } from "./context.js";
|
|
|
5
5
|
import { SourceFileContext } from "./context/source-file.js";
|
|
6
6
|
import { effect, getContext, getElementCache, isComponentCreator, isCustomContext, isIntrinsicElement, popStack, printRenderStack, pushStack, root, untrack } from "./jsx-runtime.js";
|
|
7
7
|
import { isRefkey } from "./refkey.js";
|
|
8
|
+
import { flushJobs } from "./scheduler.js";
|
|
8
9
|
const {
|
|
9
10
|
builders: {
|
|
10
11
|
align,
|
|
@@ -127,6 +128,7 @@ function traceRender(phase, message) {
|
|
|
127
128
|
}
|
|
128
129
|
export function render(children, options) {
|
|
129
130
|
const tree = renderTree(children);
|
|
131
|
+
flushJobs();
|
|
130
132
|
let rootDirectory = undefined;
|
|
131
133
|
|
|
132
134
|
// when passing Output, the first render tree child is the Output component.
|
|
@@ -403,6 +405,9 @@ export function printTree(tree, options) {
|
|
|
403
405
|
...defaultPrintTreeOptions,
|
|
404
406
|
...Object.fromEntries(Object.entries(options ?? {}).filter(([_, v]) => v !== undefined))
|
|
405
407
|
};
|
|
408
|
+
|
|
409
|
+
// make sure queue is empty
|
|
410
|
+
flushJobs();
|
|
406
411
|
const d = printTreeWorker(tree);
|
|
407
412
|
return doc.printer.printDocToString(d, options).formatted;
|
|
408
413
|
}
|
|
@@ -419,5 +424,4 @@ function printTreeWorker(tree) {
|
|
|
419
424
|
}
|
|
420
425
|
}
|
|
421
426
|
return doc;
|
|
422
|
-
}
|
|
423
|
-
//# sourceMappingURL=render.js.map
|
|
427
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactiveEffectRunner } from "@vue/reactivity";
|
|
2
|
+
export interface QueueJob {
|
|
3
|
+
(): any;
|
|
4
|
+
}
|
|
5
|
+
export declare function scheduler(jobGetter: () => ReactiveEffectRunner): () => void;
|
|
6
|
+
export declare function queueJob(job: QueueJob): void;
|
|
7
|
+
export declare function flushJobs(): void;
|
|
8
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,GAAG,CAAC;CACT;AAGD,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,oBAAoB,cAI9D;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,QAIrC;AAED,wBAAgB,SAAS,SAKxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const queue = new Set();
|
|
2
|
+
export function scheduler(jobGetter) {
|
|
3
|
+
return () => {
|
|
4
|
+
queueJob(jobGetter());
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function queueJob(job) {
|
|
8
|
+
// the set is serving an important purpose here in deduping the effects we run
|
|
9
|
+
// (which in effect coalesces multiple update effects together).
|
|
10
|
+
queue.add(job);
|
|
11
|
+
}
|
|
12
|
+
export function flushJobs() {
|
|
13
|
+
for (const job of queue) {
|
|
14
|
+
queue.delete(job);
|
|
15
|
+
job();
|
|
16
|
+
}
|
|
17
|
+
}
|
package/dist/src/slot.js
CHANGED
package/dist/src/stc.js
CHANGED
package/dist/src/sti.js
CHANGED
package/dist/src/tap.js
CHANGED
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
import { toRaw } from "@vue/reactivity";
|
|
4
3
|
import { createCustomContext, isComponentCreator, memo, onCleanup, root, untrack } from "./jsx-runtime.js";
|
|
5
4
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -238,5 +237,4 @@ export function baseListPropsToMapJoinArgs(props) {
|
|
|
238
237
|
joiner,
|
|
239
238
|
ender
|
|
240
239
|
};
|
|
241
|
-
}
|
|
242
|
-
//# sourceMappingURL=utils.js.map
|
|
240
|
+
}
|
package/dist/src/write-output.js
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
5
|
+
const testDir = join(__dirname, ".temp", "vite-test-project");
|
|
6
|
+
describe("Browser Build Test", () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
// Cleanup previous runs
|
|
9
|
+
if (existsSync(testDir)) {
|
|
10
|
+
rmSync(testDir, {
|
|
11
|
+
recursive: true,
|
|
12
|
+
force: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Create a temporary Vite project
|
|
17
|
+
mkdirSync(testDir, {
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
20
|
+
execSync("npm init -y", {
|
|
21
|
+
cwd: testDir
|
|
22
|
+
});
|
|
23
|
+
execSync("npm install vite", {
|
|
24
|
+
cwd: testDir
|
|
25
|
+
});
|
|
26
|
+
execSync("npm install ../../..", {
|
|
27
|
+
cwd: testDir
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a minimal Vite app
|
|
31
|
+
writeFileSync(join(testDir, "index.js"), `
|
|
32
|
+
import { writeOutput } from "@alloy-js/core";
|
|
33
|
+
console.log("Alloy-js core imported successfully!", writeOutput);
|
|
34
|
+
`);
|
|
35
|
+
writeFileSync(join(testDir, "vite.config.js"), `
|
|
36
|
+
import { defineConfig } from "vite";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
build: {
|
|
40
|
+
outDir: "dist",
|
|
41
|
+
target: "esnext",
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
// Create an index.html file
|
|
47
|
+
writeFileSync(join(testDir, "index.html"), `
|
|
48
|
+
<!DOCTYPE html>
|
|
49
|
+
<html lang="en">
|
|
50
|
+
<head>
|
|
51
|
+
<meta charset="UTF-8">
|
|
52
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
53
|
+
<title>Vite Test</title>
|
|
54
|
+
</head>
|
|
55
|
+
<body>
|
|
56
|
+
<script type="module" src="/index.js"></script>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
59
|
+
`);
|
|
60
|
+
writeFileSync(join(testDir, "package.json"), JSON.stringify({
|
|
61
|
+
type: "module",
|
|
62
|
+
scripts: {
|
|
63
|
+
build: "vite build"
|
|
64
|
+
}
|
|
65
|
+
}, null, 2));
|
|
66
|
+
});
|
|
67
|
+
it("Vite should build successfully", () => {
|
|
68
|
+
// Run Vite build process and wait for completion
|
|
69
|
+
expect(() => {
|
|
70
|
+
execSync("npm run build", {
|
|
71
|
+
cwd: testDir,
|
|
72
|
+
stdio: "inherit"
|
|
73
|
+
});
|
|
74
|
+
}).not.toThrow();
|
|
75
|
+
});
|
|
76
|
+
afterAll(() => {
|
|
77
|
+
// Ensure testDir exists before attempting to remove it
|
|
78
|
+
if (existsSync(testDir)) {
|
|
79
|
+
rmSync(testDir, {
|
|
80
|
+
recursive: true,
|
|
81
|
+
force: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { children, printTree, renderTree } from "@alloy-js/core";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
it("handles a single element", () => {
|
|
5
|
+
function Foo(props) {
|
|
6
|
+
return children(() => props.children);
|
|
7
|
+
}
|
|
8
|
+
const res = renderTree(_$createComponent(Foo, {
|
|
9
|
+
children: "a b c"
|
|
10
|
+
}));
|
|
11
|
+
expect(printTree(res)).toBe("a b c");
|
|
12
|
+
});
|
|
13
|
+
it("handles a multiple elements", () => {
|
|
14
|
+
function Foo(props) {
|
|
15
|
+
const c = children(() => props.children);
|
|
16
|
+
return c;
|
|
17
|
+
}
|
|
18
|
+
function Bar() {
|
|
19
|
+
return "Bar";
|
|
20
|
+
}
|
|
21
|
+
const res = renderTree(_$createComponent(Foo, {
|
|
22
|
+
get children() {
|
|
23
|
+
return [_$createComponent(Bar, {}), _$createComponent(Bar, {})];
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
expect(printTree(res)).toBe(`BarBar`);
|
|
27
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import { Block } from "../../src/components/Block.js";
|
|
4
|
+
import "../../testing/extend-expect.js";
|
|
5
|
+
it("renders properly with no children", () => {
|
|
6
|
+
const template = _$createComponent(Block, {
|
|
7
|
+
get children() {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
expect(template).toRenderTo(`{}`);
|
|
12
|
+
});
|
|
13
|
+
it("renders properly with children", () => {
|
|
14
|
+
const template = _$createComponent(Block, {
|
|
15
|
+
children: "Contents!!"
|
|
16
|
+
});
|
|
17
|
+
expect(template).toRenderTo(`
|
|
18
|
+
{
|
|
19
|
+
Contents!!
|
|
20
|
+
}
|
|
21
|
+
`);
|
|
22
|
+
});
|
|
23
|
+
it("renders properly with newline and no children", () => {
|
|
24
|
+
const template = ["class", _$createComponent(Block, {
|
|
25
|
+
newline: true,
|
|
26
|
+
get children() {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
})];
|
|
30
|
+
expect(template).toRenderTo(`
|
|
31
|
+
class {}
|
|
32
|
+
`);
|
|
33
|
+
});
|
|
34
|
+
it("renders properly with newline and no children", () => {
|
|
35
|
+
const template = ["class", _$createComponent(Block, {
|
|
36
|
+
newline: true,
|
|
37
|
+
children: "contents!!"
|
|
38
|
+
})];
|
|
39
|
+
expect(template).toRenderTo(`
|
|
40
|
+
class
|
|
41
|
+
{
|
|
42
|
+
contents!!
|
|
43
|
+
}
|
|
44
|
+
`);
|
|
45
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import { Output } from "../../src/components/Output.js";
|
|
4
|
+
import { Declaration, ref, renderTree, Scope, useBinder } from "../../src/index.js";
|
|
5
|
+
import { flushJobs } from "../../src/scheduler.js";
|
|
6
|
+
import { createTap } from "../../src/tap.js";
|
|
7
|
+
it("creates and cleans up a symbol", () => {
|
|
8
|
+
const GetBinder = createTap(() => {
|
|
9
|
+
return useBinder();
|
|
10
|
+
});
|
|
11
|
+
const binderRef = GetBinder.ref;
|
|
12
|
+
const doDecl = ref(true);
|
|
13
|
+
const template = _$createComponent(Output, {
|
|
14
|
+
get children() {
|
|
15
|
+
return [_$createComponent(GetBinder, {}), _$createComponent(Scope, {
|
|
16
|
+
name: "foo",
|
|
17
|
+
get children() {
|
|
18
|
+
return _$memo(() => !!doDecl.value)() ? _$createComponent(Declaration, {
|
|
19
|
+
name: "foo"
|
|
20
|
+
}) : "";
|
|
21
|
+
}
|
|
22
|
+
})];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
renderTree(template);
|
|
26
|
+
const binder = binderRef.value;
|
|
27
|
+
const subScope = [...binder.globalScope.children][0];
|
|
28
|
+
expect(subScope.symbols.size).toBe(1);
|
|
29
|
+
doDecl.value = false;
|
|
30
|
+
flushJobs();
|
|
31
|
+
expect(subScope.symbols.size).toBe(0);
|
|
32
|
+
});
|