@alloy-js/core 0.19.0-dev.12 → 0.19.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/index.d.ts +0 -4
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +0 -4
- package/dist/src/components/stc/index.d.ts +0 -4
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +0 -4
- package/dist/src/context/source-directory.d.ts +3 -3
- package/dist/src/context/source-directory.d.ts.map +1 -1
- package/dist/src/context/source-file.d.ts +0 -4
- package/dist/src/context/source-file.d.ts.map +1 -1
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/debug.js +1 -4
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.browser.d.ts.map +1 -1
- package/dist/src/index.browser.js +2 -2
- package/dist/src/render.d.ts +2 -10
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +1 -20
- package/dist/src/scheduler.d.ts +0 -6
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +0 -36
- package/dist/src/write-output.browser.d.ts +2 -0
- package/dist/src/write-output.browser.d.ts.map +1 -0
- package/dist/src/write-output.browser.js +4 -0
- package/dist/src/write-output.d.ts +1 -1
- package/dist/src/write-output.d.ts.map +1 -1
- package/dist/src/write-output.js +21 -40
- package/dist/test/components/source-file.test.d.ts.map +1 -1
- package/dist/test/rendering/formatting.test.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +54 -60
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/index.tsx +0 -4
- package/src/components/stc/index.ts +0 -4
- package/src/context/source-directory.ts +3 -5
- package/src/context/source-file.ts +0 -5
- package/src/debug.ts +1 -4
- package/src/index.browser.ts +1 -1
- package/src/render.ts +5 -44
- package/src/scheduler.ts +0 -39
- package/src/write-output.browser.ts +4 -0
- package/src/write-output.ts +19 -49
- package/temp/api.json +423 -1886
- package/test/components/source-file.test.tsx +2 -5
- package/test/rendering/formatting.test.tsx +3 -9
- package/testing/extend-expect.ts +58 -74
- package/testing/vitest.d.ts +0 -4
- package/dist/src/components/AppendFile.d.ts +0 -90
- package/dist/src/components/AppendFile.d.ts.map +0 -1
- package/dist/src/components/AppendFile.js +0 -226
- package/dist/src/components/CopyFile.d.ts +0 -12
- package/dist/src/components/CopyFile.d.ts.map +0 -1
- package/dist/src/components/CopyFile.js +0 -15
- package/dist/src/components/TemplateFile.d.ts +0 -84
- package/dist/src/components/TemplateFile.d.ts.map +0 -1
- package/dist/src/components/TemplateFile.js +0 -133
- package/dist/src/components/UpdateFile.d.ts +0 -34
- package/dist/src/components/UpdateFile.d.ts.map +0 -1
- package/dist/src/components/UpdateFile.js +0 -66
- package/dist/src/host/alloy-host.browser.d.ts +0 -11
- package/dist/src/host/alloy-host.browser.d.ts.map +0 -1
- package/dist/src/host/alloy-host.browser.js +0 -31
- package/dist/src/host/alloy-host.d.ts +0 -11
- package/dist/src/host/alloy-host.d.ts.map +0 -1
- package/dist/src/host/alloy-host.js +0 -143
- package/dist/src/host/interface.d.ts +0 -144
- package/dist/src/host/interface.d.ts.map +0 -1
- package/dist/src/host/interface.js +0 -1
- package/dist/src/resource.d.ts +0 -80
- package/dist/src/resource.d.ts.map +0 -1
- package/dist/src/resource.js +0 -118
- package/dist/test/components/append-file.test.d.ts +0 -2
- package/dist/test/components/append-file.test.d.ts.map +0 -1
- package/dist/test/components/append-file.test.js +0 -281
- package/dist/test/components/copy-file.test.d.ts +0 -2
- package/dist/test/components/copy-file.test.d.ts.map +0 -1
- package/dist/test/components/copy-file.test.js +0 -94
- package/dist/test/components/template-file.test.d.ts +0 -2
- package/dist/test/components/template-file.test.d.ts.map +0 -1
- package/dist/test/components/template-file.test.js +0 -133
- package/dist/test/components/update-file.test.d.ts +0 -2
- package/dist/test/components/update-file.test.d.ts.map +0 -1
- package/dist/test/components/update-file.test.js +0 -169
- package/src/components/AppendFile.tsx +0 -294
- package/src/components/CopyFile.tsx +0 -29
- package/src/components/TemplateFile.tsx +0 -193
- package/src/components/UpdateFile.tsx +0 -86
- package/src/host/alloy-host.browser.ts +0 -56
- package/src/host/alloy-host.ts +0 -160
- package/src/host/interface.ts +0 -153
- package/src/resource.ts +0 -152
- package/test/components/append-file.test.tsx +0 -275
- package/test/components/copy-file.test.tsx +0 -98
- package/test/components/template-file.test.tsx +0 -127
- package/test/components/update-file.test.tsx +0 -214
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from "./AppendFile.jsx";
|
|
2
1
|
export * from "./Block.js";
|
|
3
|
-
export * from "./CopyFile.jsx";
|
|
4
2
|
export * from "./Declaration.js";
|
|
5
3
|
export * from "./For.js";
|
|
6
4
|
export * from "./Indent.jsx";
|
|
@@ -18,7 +16,5 @@ export * from "./SourceDirectory.js";
|
|
|
18
16
|
export * from "./SourceFile.js";
|
|
19
17
|
export * from "./StatementList.jsx";
|
|
20
18
|
export * from "./Switch.jsx";
|
|
21
|
-
export * from "./TemplateFile.jsx";
|
|
22
|
-
export * from "./UpdateFile.jsx";
|
|
23
19
|
export * from "./Wrap.jsx";
|
|
24
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from "./AppendFile.js";
|
|
2
1
|
export * from "./Block.js";
|
|
3
|
-
export * from "./CopyFile.js";
|
|
4
2
|
export * from "./Declaration.js";
|
|
5
3
|
export * from "./For.js";
|
|
6
4
|
export * from "./Indent.js";
|
|
@@ -18,6 +16,4 @@ export * from "./SourceDirectory.js";
|
|
|
18
16
|
export * from "./SourceFile.js";
|
|
19
17
|
export * from "./StatementList.js";
|
|
20
18
|
export * from "./Switch.js";
|
|
21
|
-
export * from "./TemplateFile.js";
|
|
22
|
-
export * from "./UpdateFile.js";
|
|
23
19
|
export * from "./Wrap.js";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as base from "../index.js";
|
|
2
|
-
export declare const AppendFile: import("../../stc.js").StcSignature<base.AppendFileProps>;
|
|
3
2
|
export declare const Block: import("../../stc.js").StcSignature<base.BlockProps>;
|
|
4
|
-
export declare const CopyFile: import("../../stc.js").StcSignature<base.CopyFileProps>;
|
|
5
3
|
export declare const Declaration: import("../../stc.js").StcSignature<base.DeclarationProps>;
|
|
6
4
|
export declare const For: <T extends base.ForSupportedCollections | (() => base.ForSupportedCollections) | import("@vue/reactivity").Ref<base.ForSupportedCollections>, U extends import("@alloy-js/core/jsx-runtime").Children>(props: Omit<base.ForProps<T, U>, "children"> & Partial<Pick<base.ForProps<T, U>, "children">>) => import("../../stc.js").StcComponentCreator<base.ForProps<T, U>>;
|
|
7
5
|
export declare const Indent: import("../../stc.js").StcSignature<base.IndentProps>;
|
|
@@ -18,8 +16,6 @@ export declare const StatementList: import("../../stc.js").StcSignature<base.Sta
|
|
|
18
16
|
export declare const SourceDirectory: import("../../stc.js").StcSignature<base.SourceDirectoryProps>;
|
|
19
17
|
export declare const SourceFile: import("../../stc.js").StcSignature<base.SourceFileProps>;
|
|
20
18
|
export declare const Switch: import("../../stc.js").StcSignature<base.SwitchProps>;
|
|
21
|
-
export declare const TemplateFile: import("../../stc.js").StcSignature<base.TemplateFileProps>;
|
|
22
|
-
export declare const UpdateFile: import("../../stc.js").StcSignature<base.UpdateFileProps>;
|
|
23
19
|
export declare const Wrap: <TProps>(props: Omit<base.WrapProps<TProps>, "children"> & Partial<Pick<base.WrapProps<TProps>, "children">>) => import("../../stc.js").StcComponentCreator<base.WrapProps<TProps>>;
|
|
24
20
|
export declare const ReferenceOrContent: import("../../stc.js").StcSignature<base.ReferenceOrContentProps>;
|
|
25
21
|
export * from "./sti.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,KAAK,sDAAkB,CAAC;AACrC,eAAO,MAAM,WAAW,4DAAwB,CAAC;AACjD,eAAO,MAAM,GAAG,0WAAgB,CAAC;AACjC,eAAO,MAAM,MAAM,uDAAmB,CAAC;AACvC,eAAO,MAAM,IAAI,qDAAiB,CAAC;AACnC,eAAO,MAAM,iBAAiB,kEAA8B,CAAC;AAC7D,eAAO,MAAM,UAAU,yCAAuB,CAAC;AAC/C,eAAO,MAAM,WAAW,4DAAwB,CAAC;AACjD,eAAO,MAAM,IAAI,yCAAiB,CAAC;AACnC,eAAO,MAAM,MAAM,uDAAmB,CAAC;AACvC,eAAO,MAAM,KAAK,iDAAkB,CAAC;AACrC,eAAO,MAAM,KAAK,sDAAkB,CAAC;AACrC,eAAO,MAAM,IAAI,qDAAiB,CAAC;AACnC,eAAO,MAAM,aAAa,8DAA0B,CAAC;AACrD,eAAO,MAAM,eAAe,gEAA4B,CAAC;AACzD,eAAO,MAAM,UAAU,2DAAuB,CAAC;AAC/C,eAAO,MAAM,MAAM,uDAAmB,CAAC;AACvC,eAAO,MAAM,IAAI,qLAAiB,CAAC;AACnC,eAAO,MAAM,kBAAkB,mEAA+B,CAAC;AAE/D,cAAc,UAAU,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { stc } from "../../stc.js";
|
|
2
2
|
import * as base from "../index.js";
|
|
3
|
-
export const AppendFile = stc(base.AppendFile);
|
|
4
3
|
export const Block = stc(base.Block);
|
|
5
|
-
export const CopyFile = stc(base.CopyFile);
|
|
6
4
|
export const Declaration = stc(base.Declaration);
|
|
7
5
|
export const For = stc(base.For);
|
|
8
6
|
export const Indent = stc(base.Indent);
|
|
@@ -19,8 +17,6 @@ export const StatementList = stc(base.StatementList);
|
|
|
19
17
|
export const SourceDirectory = stc(base.SourceDirectory);
|
|
20
18
|
export const SourceFile = stc(base.SourceFile);
|
|
21
19
|
export const Switch = stc(base.Switch);
|
|
22
|
-
export const TemplateFile = stc(base.TemplateFile);
|
|
23
|
-
export const UpdateFile = stc(base.UpdateFile);
|
|
24
20
|
export const Wrap = stc(base.Wrap);
|
|
25
21
|
export const ReferenceOrContent = stc(base.ReferenceOrContent);
|
|
26
22
|
export * from "./sti.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ComponentContext } from "../context.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SourceFileContext } from "./source-file.js";
|
|
3
3
|
export interface SourceDirectoryContext {
|
|
4
|
-
contents: (SourceDirectoryContext | SourceFileContext
|
|
5
|
-
addContent(content: SourceDirectoryContext | SourceFileContext
|
|
4
|
+
contents: (SourceDirectoryContext | SourceFileContext)[];
|
|
5
|
+
addContent(content: SourceDirectoryContext | SourceFileContext): void;
|
|
6
6
|
path: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const SourceDirectoryContext: ComponentContext<SourceDirectoryContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-directory.d.ts","sourceRoot":"","sources":["../../../src/context/source-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"source-directory.d.ts","sourceRoot":"","sources":["../../../src/context/source-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,sBAAsB,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACzD,UAAU,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,GAAG,IAAI,CAAC;IACtE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,sBAAsB,CACrC,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { ComponentContext } from "../context.js";
|
|
2
2
|
import type { Refkey } from "../refkey.js";
|
|
3
3
|
import { ComponentDefinition } from "../runtime/component.js";
|
|
4
|
-
export interface CopyFileContext {
|
|
5
|
-
path: string;
|
|
6
|
-
sourcePath: string;
|
|
7
|
-
}
|
|
8
4
|
export interface SourceFileContext {
|
|
9
5
|
path: string;
|
|
10
6
|
filetype: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/context/source-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/context/source-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,mBAAmB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB,CAChC,CAAC"}
|
package/dist/src/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,SAAS,EAAE;QACT,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,IAAI,IAAI,CAAC;QACb,KAAK,IAAI,IAAI,CAAC;QACd,MAAM,IAAI,IAAI,CAAC;QACf,OAAO,IAAI,IAAI,CAAC;KACjB,CAAC;CACH;AAoGD,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,KAAK,EAAE,cAAc,CAAC;CAC3B;AA4FD,wBAAgB,WAAW,YAE1B"}
|
package/dist/src/debug.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import { isReactive } from "@vue/reactivity";
|
|
2
3
|
import Table from "cli-table3";
|
|
3
4
|
import pc from "picocolors";
|
|
@@ -7,15 +8,12 @@ const debug = {
|
|
|
7
8
|
component: {
|
|
8
9
|
stack: debugStack,
|
|
9
10
|
tree() {
|
|
10
|
-
//eslint-disable-next-line no-console
|
|
11
11
|
console.log("tree");
|
|
12
12
|
},
|
|
13
13
|
watch() {
|
|
14
|
-
//eslint-disable-next-line no-console
|
|
15
14
|
console.log("watch");
|
|
16
15
|
},
|
|
17
16
|
render() {
|
|
18
|
-
//eslint-disable-next-line no-console
|
|
19
17
|
console.log("render");
|
|
20
18
|
},
|
|
21
19
|
context: debugContext
|
|
@@ -49,7 +47,6 @@ function debugStack() {
|
|
|
49
47
|
function debugContext() {
|
|
50
48
|
let currentContext = getContext();
|
|
51
49
|
while (currentContext !== null) {
|
|
52
|
-
//eslint-disable-next-line no-console
|
|
53
50
|
console.log(printContext(currentContext));
|
|
54
51
|
currentContext = currentContext.owner;
|
|
55
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.browser.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export
|
|
1
|
+
export * from "./index.js"; // Re-export everything
|
|
2
|
+
export { writeOutput } from "./write-output.browser.js"; // Override writeOutput for browsers
|
package/dist/src/render.d.ts
CHANGED
|
@@ -85,18 +85,12 @@ export interface OutputDirectory {
|
|
|
85
85
|
path: string;
|
|
86
86
|
contents: (OutputDirectory | OutputFile)[];
|
|
87
87
|
}
|
|
88
|
-
export interface
|
|
88
|
+
export interface OutputFile {
|
|
89
89
|
kind: "file";
|
|
90
|
-
path: string;
|
|
91
|
-
}
|
|
92
|
-
export interface CopyOutputFile extends OutputFileBase {
|
|
93
|
-
sourcePath: string;
|
|
94
|
-
}
|
|
95
|
-
export interface ContentOutputFile extends OutputFileBase {
|
|
96
90
|
contents: string;
|
|
91
|
+
path: string;
|
|
97
92
|
filetype: string;
|
|
98
93
|
}
|
|
99
|
-
export type OutputFile = ContentOutputFile | CopyOutputFile;
|
|
100
94
|
export declare function getContextForRenderNode(node: RenderedTextTree): Context | undefined;
|
|
101
95
|
export declare const printHookTag: unique symbol;
|
|
102
96
|
export interface PrintHook {
|
|
@@ -109,8 +103,6 @@ export declare function createRenderTreeHook(subtree: RenderedTextTree, hooks: O
|
|
|
109
103
|
export declare function isPrintHook(type: unknown): type is PrintHook;
|
|
110
104
|
export type RenderedTextTree = (string | RenderedTextTree | PrintHook)[];
|
|
111
105
|
export declare function render(children: Children, options?: PrintTreeOptions): OutputDirectory;
|
|
112
|
-
export declare function renderAsync(children: Children, options?: PrintTreeOptions): Promise<OutputDirectory>;
|
|
113
|
-
export declare function sourceFilesForTree(tree: RenderedTextTree, options?: PrintTreeOptions): OutputDirectory;
|
|
114
106
|
export declare function renderTree(children: Children): RenderedTextTree;
|
|
115
107
|
export interface PrintTreeOptions {
|
|
116
108
|
/**
|
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;AAKpC,OAAO,EACL,OAAO,EAQR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,QAAQ,EACR,SAAS,EAET,KAAK,EACN,MAAM,wBAAwB,CAAC;AA0BhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAO,MAAM,UAAU,CAAC;AAKpC,OAAO,EACL,OAAO,EAQR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,QAAQ,EACR,SAAS,EAET,KAAK,EACN,MAAM,wBAAwB,CAAC;AA0BhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAEzE,wBAAgB,MAAM,CACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAuFjB;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,oBAY5C;AA4QD,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;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
|
@@ -8,7 +8,7 @@ import { effect, getContext, getElementCache, isCustomContext, root, untrack } f
|
|
|
8
8
|
import { isRefkey } from "./refkey.js";
|
|
9
9
|
import { isComponentCreator } from "./runtime/component.js";
|
|
10
10
|
import { isIntrinsicElement } from "./runtime/intrinsic.js";
|
|
11
|
-
import { flushJobs
|
|
11
|
+
import { flushJobs } from "./scheduler.js";
|
|
12
12
|
import { trace, TracePhase } from "./tracer.js";
|
|
13
13
|
const {
|
|
14
14
|
builders: {
|
|
@@ -129,14 +129,6 @@ export function isPrintHook(type) {
|
|
|
129
129
|
export function render(children, options) {
|
|
130
130
|
const tree = renderTree(children);
|
|
131
131
|
flushJobs();
|
|
132
|
-
return sourceFilesForTree(tree, options);
|
|
133
|
-
}
|
|
134
|
-
export async function renderAsync(children, options) {
|
|
135
|
-
const tree = renderTree(children);
|
|
136
|
-
await flushJobsAsync();
|
|
137
|
-
return sourceFilesForTree(tree, options);
|
|
138
|
-
}
|
|
139
|
-
export function sourceFilesForTree(tree, options) {
|
|
140
132
|
let rootDirectory = undefined;
|
|
141
133
|
|
|
142
134
|
// when passing Output, the first render tree child is the Output component.
|
|
@@ -182,17 +174,6 @@ export function sourceFilesForTree(tree, options) {
|
|
|
182
174
|
})
|
|
183
175
|
};
|
|
184
176
|
currentDirectory.contents.push(sourceFile);
|
|
185
|
-
} else if (context.meta?.copyFile) {
|
|
186
|
-
if (!currentDirectory) {
|
|
187
|
-
// This shouldn't happen if you're using the Output component.
|
|
188
|
-
throw new Error("Copy file doesn't have parent directory. Make sure you have used the Output component.");
|
|
189
|
-
}
|
|
190
|
-
const sourceFile = {
|
|
191
|
-
kind: "file",
|
|
192
|
-
path: context.meta?.copyFile.path,
|
|
193
|
-
sourcePath: context.meta?.copyFile.sourcePath
|
|
194
|
-
};
|
|
195
|
-
currentDirectory.contents.push(sourceFile);
|
|
196
177
|
} else {
|
|
197
178
|
recurse(currentDirectory);
|
|
198
179
|
}
|
package/dist/src/scheduler.d.ts
CHANGED
|
@@ -4,11 +4,5 @@ export interface QueueJob {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function scheduler(jobGetter: () => ReactiveEffectRunner, immediate?: boolean): () => void;
|
|
6
6
|
export declare function queueJob(job: QueueJob, immediate?: boolean): void;
|
|
7
|
-
/**
|
|
8
|
-
* Register a promise that the scheduler should wait for during flushJobs.
|
|
9
|
-
* This is used by async resources to ensure the scheduler waits for their completion.
|
|
10
|
-
*/
|
|
11
|
-
export declare function trackPromise(promise: Promise<any>): void;
|
|
12
7
|
export declare function flushJobs(): void;
|
|
13
|
-
export declare function flushJobsAsync(): Promise<void>;
|
|
14
8
|
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAID,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,oBAAoB,EACrC,SAAS,UAAQ,cAKlB;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,UAAQ,QASxD;AAED,wBAAgB,SAAS,SAKxB"}
|
package/dist/src/scheduler.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const immediateQueue = new Set();
|
|
2
2
|
const queue = new Set();
|
|
3
|
-
const pendingPromises = new Set();
|
|
4
3
|
export function scheduler(jobGetter, immediate = false) {
|
|
5
4
|
return () => {
|
|
6
5
|
queueJob(jobGetter(), immediate);
|
|
@@ -16,46 +15,11 @@ export function queueJob(job, immediate = false) {
|
|
|
16
15
|
queue.add(job);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Register a promise that the scheduler should wait for during flushJobs.
|
|
22
|
-
* This is used by async resources to ensure the scheduler waits for their completion.
|
|
23
|
-
*/
|
|
24
|
-
export function trackPromise(promise) {
|
|
25
|
-
pendingPromises.add(promise);
|
|
26
|
-
void promise.finally(() => {
|
|
27
|
-
pendingPromises.delete(promise);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
18
|
export function flushJobs() {
|
|
31
|
-
// First, run all synchronous jobs
|
|
32
19
|
let job;
|
|
33
20
|
while ((job = takeJob()) !== null) {
|
|
34
21
|
job();
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
// If there are no pending promises, we're done
|
|
38
|
-
if (pendingPromises.size > 0) {
|
|
39
|
-
throw new Error("Asynchronous jobs were found but render was called synchronously. Use `asyncRender` instead.");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export async function flushJobsAsync() {
|
|
43
|
-
// Keep running jobs until both the queues are empty and all promises are resolved
|
|
44
|
-
while (true) {
|
|
45
|
-
// First, run all synchronous jobs
|
|
46
|
-
let job;
|
|
47
|
-
while ((job = takeJob()) !== null) {
|
|
48
|
-
job();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// If there are no pending promises, we're done
|
|
52
|
-
if (pendingPromises.size === 0) {
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Wait for all current promises to complete
|
|
57
|
-
await Promise.allSettled(Array.from(pendingPromises));
|
|
58
|
-
}
|
|
59
23
|
}
|
|
60
24
|
function takeJob() {
|
|
61
25
|
if (immediateQueue.size > 0) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-output.browser.d.ts","sourceRoot":"","sources":["../../src/write-output.browser.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAW,QAG7D"}
|
|
@@ -3,5 +3,5 @@ import { OutputDirectory } from "./render.js";
|
|
|
3
3
|
* Write the output from {@link render} to the file system.
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
export declare function writeOutput(output: OutputDirectory, basePath?: string):
|
|
6
|
+
export declare function writeOutput(output: OutputDirectory, basePath?: string): void;
|
|
7
7
|
//# sourceMappingURL=write-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../src/write-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../src/write-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAE,MAAW,QAwBzE"}
|
package/dist/src/write-output.js
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { relative, resolve } from "pathe";
|
|
3
3
|
import { traverseOutput } from "./utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Write the output from {@link render} to the file system.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
const ops = [];
|
|
8
|
+
export function writeOutput(output, basePath = "") {
|
|
10
9
|
traverseOutput(output, {
|
|
11
10
|
visitDirectory(directory) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
11
|
+
const path = resolve(basePath, directory.path);
|
|
12
|
+
if (existsSync(path)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.log("create", relative(process.cwd(), path));
|
|
17
|
+
mkdirSync(path, {
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
21
20
|
},
|
|
22
21
|
visitFile(file) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
await AlloyHost.write(path, file.contents);
|
|
34
|
-
} else {
|
|
35
|
-
// copy file
|
|
36
|
-
const source = resolve(basePath, file.sourcePath);
|
|
37
|
-
const target = resolve(basePath, file.path);
|
|
38
|
-
if (await AlloyHost.exists(target)) {
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
|
-
console.log("copy over", relative(process.cwd(), target));
|
|
41
|
-
} else {
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
|
-
console.log("copy", relative(process.cwd(), target));
|
|
44
|
-
}
|
|
45
|
-
await AlloyHost.mkdir(dirname(target));
|
|
46
|
-
await AlloyHost.write(target, AlloyHost.read(source).stream());
|
|
47
|
-
}
|
|
48
|
-
})());
|
|
22
|
+
const path = resolve(basePath, file.path);
|
|
23
|
+
if (existsSync(path)) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log("overwrite", relative(process.cwd(), path));
|
|
26
|
+
} else {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log("create", relative(process.cwd(), path));
|
|
29
|
+
}
|
|
30
|
+
writeFileSync(path, file.contents);
|
|
49
31
|
}
|
|
50
32
|
});
|
|
51
|
-
return Promise.all(ops);
|
|
52
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.test.d.ts","sourceRoot":"","sources":["../../../test/components/source-file.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-file.test.d.ts","sourceRoot":"","sources":["../../../test/components/source-file.test.tsx"],"names":[],"mappings":"AAUA,OAAO,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.test.d.ts","sourceRoot":"","sources":["../../../test/rendering/formatting.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatting.test.d.ts","sourceRoot":"","sources":["../../../test/rendering/formatting.test.tsx"],"names":[],"mappings":"AAEA,OAAO,gCAAgC,CAAC"}
|
|
@@ -1,81 +1,68 @@
|
|
|
1
1
|
import { getContextForRenderNode, printTree, renderTree } from "@alloy-js/core";
|
|
2
2
|
import "vitest";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
|
-
import { flushJobs, flushJobsAsync } from "../src/scheduler.js";
|
|
5
4
|
import { dedent } from "./render.js";
|
|
6
5
|
expect.extend({
|
|
7
6
|
toRenderTo(received, expectedRaw, renderOptions) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
const message = () => `Render is${isNot ? " not" : ""} incorrect`;
|
|
8
|
+
const {
|
|
9
|
+
isNot
|
|
10
|
+
} = this;
|
|
11
|
+
const actual = renderAsFiles(received, renderOptions);
|
|
12
|
+
if (typeof expectedRaw === "string") {
|
|
13
|
+
const expected = dedent(expectedRaw);
|
|
14
|
+
let actualStr;
|
|
15
|
+
if (typeof actual === "string") {
|
|
16
|
+
actualStr = actual;
|
|
17
|
+
} else if (Object.keys(actual).length === 1) {
|
|
18
|
+
// If we have a single file, we can use its content directly.
|
|
19
|
+
actualStr = Object.values(actual)[0];
|
|
20
|
+
} else {
|
|
21
|
+
return {
|
|
22
|
+
pass: false,
|
|
23
|
+
message,
|
|
24
|
+
actual,
|
|
25
|
+
expected
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
pass: actualStr === expected,
|
|
30
|
+
message,
|
|
31
|
+
actual: actualStr,
|
|
32
|
+
expected
|
|
33
|
+
};
|
|
34
|
+
} else if (typeof actual === "object" && typeof expectedRaw === "object") {
|
|
35
|
+
const expected = expectedRaw;
|
|
36
|
+
const dedentExpected = {};
|
|
37
|
+
for (const [key, value] of Object.entries(expected)) {
|
|
38
|
+
dedentExpected[key] = dedent(value);
|
|
39
|
+
}
|
|
40
|
+
const pass = Object.keys(actual).length === Object.keys(expected).length && Object.entries(actual).every(([key, value]) => {
|
|
41
|
+
return dedentExpected[key] === value;
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
pass,
|
|
45
|
+
message,
|
|
46
|
+
actual,
|
|
47
|
+
expected: dedentExpected
|
|
48
|
+
};
|
|
30
49
|
} else {
|
|
31
50
|
return {
|
|
32
51
|
pass: false,
|
|
33
52
|
message,
|
|
34
53
|
actual,
|
|
35
|
-
expected
|
|
54
|
+
expected: expectedRaw
|
|
36
55
|
};
|
|
37
56
|
}
|
|
38
|
-
return {
|
|
39
|
-
pass: actualStr === expected,
|
|
40
|
-
message,
|
|
41
|
-
actual: actualStr,
|
|
42
|
-
expected
|
|
43
|
-
};
|
|
44
|
-
} else if (typeof actual === "object" && typeof expectedRaw === "object") {
|
|
45
|
-
const expected = expectedRaw;
|
|
46
|
-
const dedentExpected = {};
|
|
47
|
-
for (const [key, value] of Object.entries(expected)) {
|
|
48
|
-
dedentExpected[key] = dedent(value);
|
|
49
|
-
}
|
|
50
|
-
const pass = Object.keys(actual).length === Object.keys(expected).length && Object.entries(actual).every(([key, value]) => {
|
|
51
|
-
return dedentExpected[key] === value;
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
pass,
|
|
55
|
-
message,
|
|
56
|
-
actual,
|
|
57
|
-
expected: dedentExpected
|
|
58
|
-
};
|
|
59
|
-
} else {
|
|
60
|
-
return {
|
|
61
|
-
pass: false,
|
|
62
|
-
message,
|
|
63
|
-
actual,
|
|
64
|
-
expected: expectedRaw
|
|
65
|
-
};
|
|
66
57
|
}
|
|
67
|
-
}
|
|
68
|
-
function
|
|
58
|
+
});
|
|
59
|
+
function renderAsFiles(received, options) {
|
|
69
60
|
const files = {};
|
|
61
|
+
const tree = renderTree(received);
|
|
62
|
+
|
|
70
63
|
// when passing Output, the first render tree child is the Output component.
|
|
71
64
|
const rootRenderOptions = Array.isArray(tree) ? getContextForRenderNode(tree[0])?.meta?.printOptions ?? {} : {};
|
|
72
65
|
collectSourceFiles(tree);
|
|
73
|
-
// If we found no source files, we return the tree as a string.
|
|
74
|
-
if (Object.keys(files).length === 0) {
|
|
75
|
-
return printTree(tree, options);
|
|
76
|
-
} else {
|
|
77
|
-
return files;
|
|
78
|
-
}
|
|
79
66
|
function collectSourceFiles(root) {
|
|
80
67
|
if (!Array.isArray(root)) {
|
|
81
68
|
return;
|
|
@@ -96,4 +83,11 @@ function getFilesFromTree(tree, options) {
|
|
|
96
83
|
}
|
|
97
84
|
}
|
|
98
85
|
}
|
|
86
|
+
|
|
87
|
+
// If we found no source files, we return the tree as a string.
|
|
88
|
+
if (Object.keys(files).length === 0) {
|
|
89
|
+
return printTree(tree, options);
|
|
90
|
+
} else {
|
|
91
|
+
return files;
|
|
92
|
+
}
|
|
99
93
|
}
|