@alloy-js/core 0.5.0 → 0.6.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 +44 -0
- package/babel.config.cjs +4 -1
- package/dist/src/binder.d.ts +5 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +14 -0
- package/dist/src/binder.js.map +1 -1
- package/dist/src/code.d.ts +2 -2
- package/dist/src/code.d.ts.map +1 -1
- package/dist/src/code.js +4 -4
- package/dist/src/code.js.map +1 -1
- package/dist/src/components/Block.d.ts +25 -0
- package/dist/src/components/Block.d.ts.map +1 -0
- package/dist/src/components/Block.js +25 -0
- package/dist/src/components/Block.js.map +1 -0
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +4 -0
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/For.d.ts +44 -0
- package/dist/src/components/For.d.ts.map +1 -0
- package/dist/src/components/For.js +41 -0
- package/dist/src/components/For.js.map +1 -0
- package/dist/src/components/Indent.d.ts +5 -9
- package/dist/src/components/Indent.d.ts.map +1 -1
- package/dist/src/components/Indent.js +7 -18
- package/dist/src/components/Indent.js.map +1 -1
- package/dist/src/components/List.d.ts +38 -0
- package/dist/src/components/List.d.ts.map +1 -0
- package/dist/src/components/List.js +40 -0
- package/dist/src/components/List.js.map +1 -0
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js.map +1 -1
- package/dist/src/components/MemberName.js +1 -1
- package/dist/src/components/MemberName.js.map +1 -1
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js.map +1 -1
- package/dist/src/components/Name.js +1 -1
- package/dist/src/components/Name.js.map +1 -1
- package/dist/src/components/Output.d.ts +2 -1
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +9 -1
- package/dist/src/components/Output.js.map +1 -1
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js.map +1 -1
- package/dist/src/components/Show.d.ts +8 -0
- package/dist/src/components/Show.d.ts.map +1 -0
- package/dist/src/components/Show.js +4 -0
- package/dist/src/components/Show.js.map +1 -0
- package/dist/src/components/SourceDirectory.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.js +1 -0
- package/dist/src/components/SourceDirectory.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +2 -6
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +6 -13
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/StatementList.d.ts +9 -0
- package/dist/src/components/StatementList.d.ts.map +1 -0
- package/dist/src/components/StatementList.js +17 -0
- package/dist/src/components/StatementList.js.map +1 -0
- package/dist/src/components/Switch.d.ts +41 -0
- package/dist/src/components/Switch.d.ts.map +1 -0
- package/dist/src/components/Switch.js +41 -0
- package/dist/src/components/Switch.js.map +1 -0
- package/dist/src/components/Wrap.d.ts +20 -0
- package/dist/src/components/Wrap.d.ts.map +1 -0
- package/dist/src/components/Wrap.js +15 -0
- package/dist/src/components/Wrap.js.map +1 -0
- package/dist/src/components/index.d.ts +8 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +7 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/stc/index.d.ts +77 -6
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +17 -1
- package/dist/src/components/stc/index.js.map +1 -1
- package/dist/src/context/index.d.ts +0 -1
- package/dist/src/context/index.d.ts.map +1 -1
- package/dist/src/context/index.js +0 -1
- package/dist/src/context/index.js.map +1 -1
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +3 -3
- package/dist/src/context.js.map +1 -1
- package/dist/src/index.browser.d.ts +3 -0
- package/dist/src/index.browser.d.ts.map +1 -0
- package/dist/src/index.browser.js +3 -0
- package/dist/src/index.browser.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/jsx-runtime.d.ts +133 -8
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +102 -12
- package/dist/src/jsx-runtime.js.map +1 -1
- package/dist/src/render.d.ts +107 -132
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +269 -177
- package/dist/src/render.js.map +1 -1
- package/dist/src/stc.d.ts +14 -0
- package/dist/src/stc.d.ts.map +1 -0
- package/dist/src/stc.js +52 -0
- package/dist/src/stc.js.map +1 -0
- package/dist/src/utils.d.ts +22 -15
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +95 -59
- package/dist/src/utils.js.map +1 -1
- package/dist/test/browser-build.test.d.ts +2 -0
- package/dist/test/browser-build.test.d.ts.map +1 -0
- package/dist/test/components/block.test.d.ts +2 -0
- package/dist/test/components/block.test.d.ts.map +1 -0
- package/dist/test/components/declaration.test.d.ts +2 -0
- package/dist/test/components/declaration.test.d.ts.map +1 -0
- package/dist/test/components/list.test.d.ts +2 -0
- package/dist/test/components/list.test.d.ts.map +1 -0
- package/dist/test/components/wrap.test.d.ts +2 -0
- package/dist/test/components/wrap.test.d.ts.map +1 -0
- package/dist/test/control-flow/for.test.d.ts +2 -0
- package/dist/test/control-flow/for.test.d.ts.map +1 -0
- package/dist/test/control-flow/match.test.d.ts +2 -0
- package/dist/test/control-flow/match.test.d.ts.map +1 -0
- package/dist/test/control-flow/show.test.d.ts +2 -0
- package/dist/test/control-flow/show.test.d.ts.map +1 -0
- package/dist/test/reactivity/cleanup.test.d.ts +2 -0
- package/dist/test/reactivity/cleanup.test.d.ts.map +1 -0
- package/dist/test/reactivity/memo.test.d.ts +2 -0
- package/dist/test/reactivity/memo.test.d.ts.map +1 -0
- package/dist/test/reactivity/untrack.test.d.ts +2 -0
- package/dist/test/reactivity/untrack.test.d.ts.map +1 -0
- package/dist/test/rendering/formatting.test.d.ts +2 -0
- package/dist/test/rendering/formatting.test.d.ts.map +1 -0
- package/dist/test/rendering/memoization.test.d.ts +2 -0
- package/dist/test/rendering/memoization.test.d.ts.map +1 -0
- package/dist/test/split-props.test.d.ts +2 -0
- package/dist/test/split-props.test.d.ts.map +1 -0
- package/dist/test/stc.test.d.ts.map +1 -1
- package/dist/test/utils.test.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +4 -4
- package/dist/testing/extend-expect.js.map +1 -1
- package/dist/testing/render.d.ts +2 -3
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +2 -4
- package/dist/testing/render.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -8
- package/src/binder.ts +21 -0
- package/src/code.ts +17 -12
- package/src/components/Block.tsx +44 -0
- package/src/components/Declaration.tsx +10 -4
- package/src/components/For.tsx +81 -0
- package/src/components/Indent.tsx +20 -27
- package/src/components/List.tsx +94 -0
- package/src/components/MemberDeclaration.tsx +9 -6
- package/src/components/MemberScope.tsx +4 -2
- package/src/components/Output.tsx +25 -13
- package/src/components/Scope.tsx +4 -2
- package/src/components/Show.tsx +11 -0
- package/src/components/SourceDirectory.tsx +5 -1
- package/src/components/SourceFile.tsx +12 -16
- package/src/components/StatementList.tsx +16 -0
- package/src/components/Switch.tsx +62 -0
- package/src/components/Wrap.tsx +29 -0
- package/src/components/index.tsx +8 -1
- package/src/components/stc/index.ts +18 -1
- package/src/context/index.ts +0 -1
- package/src/context.ts +2 -3
- package/src/index.browser.ts +2 -0
- package/src/index.ts +1 -0
- package/src/jsx-runtime.ts +241 -23
- package/src/render.ts +378 -198
- package/src/stc.ts +95 -0
- package/src/utils.ts +162 -95
- package/temp/api.json +8318 -3301
- package/test/browser-build.test.ts +91 -0
- package/test/children.test.tsx +8 -10
- package/test/components/block.test.tsx +48 -0
- package/test/components/declaration.test.tsx +37 -0
- package/test/components/list.test.tsx +91 -0
- package/test/components/slot.test.tsx +31 -25
- package/test/components/source-file.test.tsx +11 -31
- package/test/components/wrap.test.tsx +42 -0
- package/test/control-flow/for.test.tsx +194 -0
- package/test/control-flow/match.test.tsx +49 -0
- package/test/control-flow/show.test.tsx +25 -0
- package/test/name-policy.test.tsx +5 -5
- package/test/reactivity/cleanup.test.tsx +91 -0
- package/test/reactivity/memo.test.tsx +17 -0
- package/test/reactivity/ref-rendering.test.tsx +3 -8
- package/test/reactivity/test.test.tsx +7 -6
- package/test/reactivity/untrack.test.ts +33 -0
- package/test/rendering/basic.test.tsx +25 -47
- package/test/rendering/code.test.tsx +3 -3
- package/test/rendering/formatting.test.tsx +487 -0
- package/test/rendering/indent.test.tsx +42 -529
- package/test/rendering/memoization.test.tsx +30 -0
- package/test/split-props.test.ts +87 -0
- package/test/stc.test.tsx +29 -8
- package/test/symbols.test.ts +73 -0
- package/test/utils.test.tsx +129 -20
- package/testing/extend-expect.ts +14 -4
- package/testing/render.ts +2 -4
- package/testing/vitest.d.ts +6 -1
- package/vitest.config.ts +1 -1
- package/dist/src/context/indent.d.ts +0 -5
- package/dist/src/context/indent.d.ts.map +0 -1
- package/dist/src/context/indent.js +0 -8
- package/dist/src/context/indent.js.map +0 -1
- package/dist/test/rendering/linebreaks.test.d.ts +0 -2
- package/dist/test/rendering/linebreaks.test.d.ts.map +0 -1
- package/src/context/indent.ts +0 -17
- package/test/rendering/linebreaks.test.tsx +0 -72
package/dist/src/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Much of the implementations in this file are inspired by vuerx-js
|
|
2
2
|
// See: https://github.com/ryansolid/vuerx-jsx.
|
|
3
|
-
import { pauseTracking, resetTracking, shallowRef, stop, effect as vueEffect } from "@vue/reactivity";
|
|
3
|
+
import { isReactive, pauseTracking, proxyRefs, resetTracking, shallowRef, stop, toRefs, effect as vueEffect } from "@vue/reactivity";
|
|
4
4
|
if (globalThis.ALLOY) {
|
|
5
5
|
throw new Error("Multiple versions of the JSX Runtime have been loaded. This will likely cause undesirable behavior.");
|
|
6
6
|
}
|
|
@@ -9,17 +9,22 @@ let globalContext = null;
|
|
|
9
9
|
export function getContext() {
|
|
10
10
|
return globalContext;
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export function getElementCache() {
|
|
13
|
+
return getContext().elementCache;
|
|
14
|
+
}
|
|
15
|
+
export function root(fn, options) {
|
|
16
|
+
const context = {
|
|
17
|
+
componentOwner: options?.componentOwner,
|
|
15
18
|
disposables: [],
|
|
16
19
|
owner: globalContext,
|
|
17
|
-
context: {}
|
|
20
|
+
context: {},
|
|
21
|
+
elementCache: new Map()
|
|
18
22
|
};
|
|
23
|
+
globalContext = context;
|
|
19
24
|
let ret;
|
|
20
25
|
try {
|
|
21
26
|
ret = untrack(() => fn(() => {
|
|
22
|
-
for (const d of
|
|
27
|
+
for (const d of context.disposables) {
|
|
23
28
|
d();
|
|
24
29
|
}
|
|
25
30
|
}));
|
|
@@ -41,23 +46,25 @@ export function memo(fn, equal) {
|
|
|
41
46
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
42
47
|
(!equal || prev !== res) && (o.value = res);
|
|
43
48
|
return res;
|
|
44
|
-
});
|
|
49
|
+
}, undefined);
|
|
45
50
|
return () => o.value;
|
|
46
51
|
}
|
|
47
52
|
export function effect(fn, current) {
|
|
48
53
|
const context = {
|
|
49
|
-
src: "effect",
|
|
50
54
|
context: {},
|
|
51
55
|
disposables: [],
|
|
52
|
-
owner: globalContext
|
|
56
|
+
owner: globalContext,
|
|
57
|
+
elementCache: new Map()
|
|
53
58
|
};
|
|
54
59
|
const cleanupFn = final => {
|
|
55
60
|
const d = context.disposables;
|
|
56
61
|
context.disposables = [];
|
|
57
62
|
for (let k = 0, len = d.length; k < len; k++) d[k]();
|
|
63
|
+
|
|
58
64
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
59
65
|
final && stop(c);
|
|
60
66
|
};
|
|
67
|
+
onCleanup(() => cleanupFn(true));
|
|
61
68
|
const c = vueEffect(() => {
|
|
62
69
|
cleanupFn(false);
|
|
63
70
|
const oldContext = globalContext;
|
|
@@ -67,14 +74,50 @@ export function effect(fn, current) {
|
|
|
67
74
|
} finally {
|
|
68
75
|
globalContext = oldContext;
|
|
69
76
|
}
|
|
70
|
-
});
|
|
71
|
-
cleanup(() => cleanupFn(true));
|
|
77
|
+
}, {});
|
|
72
78
|
}
|
|
73
|
-
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Register a cleanup function which is called when the current reactive scope
|
|
82
|
+
* is recalculated or disposed. This is useful to clean up any side effects
|
|
83
|
+
* created in the reactive scope.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
*
|
|
87
|
+
* When onCleanup is called inside a component definition, the provided function
|
|
88
|
+
* is called when the component is removed from the tree. This can be useful to
|
|
89
|
+
* clean up any side effects created as a result of rendering the component. For
|
|
90
|
+
* example, if rendering a component creates a symbol, `onCleanup` can be used
|
|
91
|
+
* to remove the symbol when the component is removed from the tree.
|
|
92
|
+
*
|
|
93
|
+
* When onCleanup is called inside a memo or effect, the function is called when
|
|
94
|
+
* the effect is refreshed (e.g. when a memo or computed recalculates) or
|
|
95
|
+
* disposed (e.g. it is no longer needed because it is attached to a component
|
|
96
|
+
* which was removed).
|
|
97
|
+
*/
|
|
98
|
+
export function onCleanup(fn) {
|
|
74
99
|
if (globalContext != null) {
|
|
75
100
|
globalContext.disposables.push(fn);
|
|
76
101
|
}
|
|
77
102
|
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a custom reactive context for the children returned by
|
|
106
|
+
* the provided context.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
const CUSTOM_CONTEXT_SYM = Symbol();
|
|
110
|
+
export function createCustomContext(useCallback) {
|
|
111
|
+
return {
|
|
112
|
+
[CUSTOM_CONTEXT_SYM]: true,
|
|
113
|
+
useCustomContext(useCb) {
|
|
114
|
+
useCallback(useCb);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function isCustomContext(child) {
|
|
119
|
+
return typeof child === "object" && child !== null && Object.hasOwn(child, CUSTOM_CONTEXT_SYM);
|
|
120
|
+
}
|
|
78
121
|
// debugging utilities
|
|
79
122
|
const renderStack = [];
|
|
80
123
|
export function pushStack(component, props) {
|
|
@@ -154,6 +197,17 @@ export function taggedComponent(tag, component) {
|
|
|
154
197
|
component.tag = tag;
|
|
155
198
|
return component;
|
|
156
199
|
}
|
|
200
|
+
export const intrinsicElementKey = Symbol();
|
|
201
|
+
export function createIntrinsic(name, props) {
|
|
202
|
+
return {
|
|
203
|
+
[intrinsicElementKey]: true,
|
|
204
|
+
name,
|
|
205
|
+
props
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export function isIntrinsicElement(type) {
|
|
209
|
+
return typeof type === "object" && type !== null && intrinsicElementKey in type;
|
|
210
|
+
}
|
|
157
211
|
export function mergeProps(...sources) {
|
|
158
212
|
const target = {};
|
|
159
213
|
for (let i = 0; i < sources.length; i++) {
|
|
@@ -179,6 +233,42 @@ export function mergeProps(...sources) {
|
|
|
179
233
|
}
|
|
180
234
|
return target;
|
|
181
235
|
}
|
|
236
|
+
export function splitProps(props, ...keys) {
|
|
237
|
+
if (isReactive(props)) {
|
|
238
|
+
const refs = untrack(() => toRefs(props));
|
|
239
|
+
const remainingKeys = new Set(Object.keys(refs));
|
|
240
|
+
const result = keys.map(keySet => {
|
|
241
|
+
const resultSet = {};
|
|
242
|
+
for (const key of keySet) {
|
|
243
|
+
resultSet[key] = refs[key];
|
|
244
|
+
remainingKeys.delete(key);
|
|
245
|
+
}
|
|
246
|
+
return proxyRefs(resultSet);
|
|
247
|
+
});
|
|
248
|
+
const remaining = {};
|
|
249
|
+
for (const key of remainingKeys) {
|
|
250
|
+
remaining[key] = refs[key];
|
|
251
|
+
}
|
|
252
|
+
return [...result, proxyRefs(remaining)];
|
|
253
|
+
}
|
|
254
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
255
|
+
const remainingKeys = new Set(Object.keys(descriptors));
|
|
256
|
+
const result = keys.map(keySet => {
|
|
257
|
+
const resultSet = {};
|
|
258
|
+
for (const key of keySet) {
|
|
259
|
+
if (key in descriptors) {
|
|
260
|
+
Object.defineProperty(resultSet, key, descriptors[key]);
|
|
261
|
+
remainingKeys.delete(key);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return resultSet;
|
|
265
|
+
});
|
|
266
|
+
const remaining = {};
|
|
267
|
+
for (const key of remainingKeys) {
|
|
268
|
+
Object.defineProperty(remaining, key, descriptors[key]);
|
|
269
|
+
}
|
|
270
|
+
return [...result, remaining];
|
|
271
|
+
}
|
|
182
272
|
function shouldDebug() {
|
|
183
273
|
return typeof process !== "undefined" && !!process.env?.ALLOY_DEBUG;
|
|
184
274
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","names":["pauseTracking","resetTracking","shallowRef","stop","effect","vueEffect","globalThis","ALLOY","Error","globalContext","getContext","root","fn","componentOwner","disposables","owner","
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":["isReactive","pauseTracking","proxyRefs","resetTracking","shallowRef","stop","toRefs","effect","vueEffect","globalThis","ALLOY","Error","globalContext","getContext","getElementCache","elementCache","root","fn","options","context","componentOwner","disposables","owner","Map","ret","untrack","d","v","memo","equal","o","prev","res","value","undefined","current","cleanupFn","final","k","len","length","c","onCleanup","oldContext","push","CUSTOM_CONTEXT_SYM","Symbol","createCustomContext","useCallback","useCustomContext","useCb","isCustomContext","child","Object","hasOwn","renderStack","pushStack","component","props","shouldDebug","popStack","pop","printRenderStack","console","error","i","name","inspectProps","JSON","stringify","fromEntries","entries","map","key","safeValue","isComponentCreator","item","JSX","jsx","type","createComponent","jsxs","C","creator","tag","taggedComponent","intrinsicElementKey","createIntrinsic","isIntrinsicElement","mergeProps","sources","target","source","descriptors","getOwnPropertyDescriptors","defineProperty","enumerable","get","s","splitProps","keys","refs","remainingKeys","Set","result","keySet","resultSet","delete","remaining","process","env","ALLOY_DEBUG"],"sources":["../../src/jsx-runtime.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA,SACEA,UAAU,EACVC,aAAa,EACbC,SAAS,EAETC,aAAa,EACbC,UAAU,EACVC,IAAI,EACJC,MAAM,EACNC,MAAM,IAAIC,SAAS,QACd,iBAAiB;AAIxB,IAAKC,UAAU,CAASC,KAAK,EAAE;EAC7B,MAAM,IAAIC,KAAK,CACb,qGACF,CAAC;AACH;AACCF,UAAU,CAASC,KAAK,GAAG,IAAI;AA4BhC,IAAIE,aAA6B,GAAG,IAAI;AACxC,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B,OAAOD,aAAa;AACtB;AAEA,OAAO,SAASE,eAAeA,CAAA,EAAG;EAChC,OAAOD,UAAU,CAAC,CAAC,CAAEE,YAAY;AACnC;AAYA,OAAO,SAASC,IAAIA,CAAIC,EAAwB,EAAEC,OAAqB,EAAK;EAC1E,MAAMC,OAAgB,GAAG;IACvBC,cAAc,EAAEF,OAAO,EAAEE,cAAc;IACvCC,WAAW,EAAE,EAAE;IACfC,KAAK,EAAEV,aAAa;IACpBO,OAAO,EAAE,CAAC,CAAC;IACXJ,YAAY,EAAE,IAAIQ,GAAG,CAAC;EACxB,CAAC;EAEDX,aAAa,GAAGO,OAAO;EACvB,IAAIK,GAAG;EACP,IAAI;IACFA,GAAG,GAAGC,OAAO,CAAC,MACZR,EAAE,CAAC,MAAM;MACP,KAAK,MAAMS,CAAC,IAAIP,OAAO,CAAEE,WAAW,EAAE;QACpCK,CAAC,CAAC,CAAC;MACL;IACF,CAAC,CACH,CAAC;EACH,CAAC,SAAS;IACRd,aAAa,GAAGA,aAAa,CAAEU,KAAK;EACtC;EAEA,OAAOE,GAAG;AACZ;AAEA,OAAO,SAASC,OAAOA,CAAIR,EAAW,EAAK;EACzChB,aAAa,CAAC,CAAC;EACf,MAAM0B,CAA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AEC,WAAW;AACrE","ignoreList":[]}
|
package/dist/src/render.d.ts
CHANGED
|
@@ -1,132 +1,83 @@
|
|
|
1
|
+
import { Doc } from "prettier";
|
|
1
2
|
import { Children, Context } from "./jsx-runtime.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* "\n ",
|
|
81
|
-
* createComponent(Foo, {}),
|
|
82
|
-
* "\n"
|
|
83
|
-
* ]
|
|
84
|
-
* }
|
|
85
|
-
* })
|
|
86
|
-
* ]
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* ### Render tree
|
|
90
|
-
* ```
|
|
91
|
-
* [ // node for Indent
|
|
92
|
-
* [ // node for Context Provider
|
|
93
|
-
* " ", // indent from the children of Indent
|
|
94
|
-
* [ // component for Foo
|
|
95
|
-
* "Foo" // result of calling Foo
|
|
96
|
-
* ],
|
|
97
|
-
* "\n ", // indent and line break from the children of Ident
|
|
98
|
-
* [ "Foo" ] // second foo component
|
|
99
|
-
* ]
|
|
100
|
-
* ]
|
|
101
|
-
* ```
|
|
102
|
-
* ### Rendered text
|
|
103
|
-
* ```
|
|
104
|
-
* FooFoo
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* ## Implicit indentation
|
|
108
|
-
*
|
|
109
|
-
* ### Input
|
|
110
|
-
* ```
|
|
111
|
-
* <>
|
|
112
|
-
* base
|
|
113
|
-
* <Foo /> <Foo />
|
|
114
|
-
* </>
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* ### Render tree
|
|
118
|
-
* ```
|
|
119
|
-
* [ // node for top-level fragment
|
|
120
|
-
* "base\n ", // contents of fragment, including trailing indent
|
|
121
|
-
* [ // node for implicitly created Indent component
|
|
122
|
-
* [ // node for its context provider [ "Foo" ], // contents of Foo "\n"
|
|
123
|
-
* ]
|
|
124
|
-
* ```
|
|
125
|
-
* ## Rendered text
|
|
126
|
-
* ```
|
|
127
|
-
* base
|
|
128
|
-
* Foo Foo
|
|
129
|
-
* ```
|
|
4
|
+
* Turning components into source text involves three different trees produced
|
|
5
|
+
* sequentially:
|
|
6
|
+
*
|
|
7
|
+
* 1. Component tree, built by the nesting of components
|
|
8
|
+
* 2. Rendered text tree, produced by *rendering* the component tree
|
|
9
|
+
* 3. Document tree, produced by *printing* the rendered text tree
|
|
10
|
+
*
|
|
11
|
+
* Finally, the document tree is converted to text via `prettier`. Let's look at
|
|
12
|
+
* each of these trees and the conversions in detail.
|
|
13
|
+
*
|
|
14
|
+
* # Component tree
|
|
15
|
+
*
|
|
16
|
+
* The component tree is built by JSX or STC templates. The nodes in this tree
|
|
17
|
+
* are defined by the type `Child` and are one of the following
|
|
18
|
+
*
|
|
19
|
+
* ## Primitive values
|
|
20
|
+
*
|
|
21
|
+
* Strings in the tree are placed into the rendered text tree as-is. Numbers are
|
|
22
|
+
* converted to strings. Falsy primitive values and booleans are converted to
|
|
23
|
+
* empty strings (and may cause a line break to be ignored, see below).
|
|
24
|
+
*
|
|
25
|
+
* ## Nullary functions
|
|
26
|
+
*
|
|
27
|
+
* Nullary functions represent computed or reactive values in the component
|
|
28
|
+
* tree, such as expressions placed into a JSX template with curly brackets.
|
|
29
|
+
* Nullary functions return `Children` which are then recursively rendered.
|
|
30
|
+
* Nullary functions are invoked in an effect which will update the rendered
|
|
31
|
+
* text tree when any reactive dependencies change.
|
|
32
|
+
*
|
|
33
|
+
* ## Component creators
|
|
34
|
+
*
|
|
35
|
+
* Component creators are a special kind of nullary function which instantiate
|
|
36
|
+
* components in order to get their children which are then recursively
|
|
37
|
+
* rendered. Component creators have some special rendering behavior, such as
|
|
38
|
+
* tracking the stack of rendered components. Like other nullary functions,
|
|
39
|
+
* component creators are invoked in an effect which will update the rendered
|
|
40
|
+
* text tree when any reactive dependencies change.
|
|
41
|
+
*
|
|
42
|
+
* ## Refs
|
|
43
|
+
*
|
|
44
|
+
* Refs are wrapped in a nullary function and rendered in an effect which will
|
|
45
|
+
* update the rendered text tree when the ref's value changes. This is
|
|
46
|
+
* essentially a syntactic convenience, allowing JSX templates to contain
|
|
47
|
+
* `\{ someRef \}` instead of `\{ someRef.value \}`.
|
|
48
|
+
*
|
|
49
|
+
* ## Refkey
|
|
50
|
+
*
|
|
51
|
+
* Refkeys are replaced with a component creator for the Reference component
|
|
52
|
+
* associated with the current source file. This allows creating references by
|
|
53
|
+
* placing them directly in the component tree e.g. `{ someRefkey }`.
|
|
54
|
+
*
|
|
55
|
+
* ## CustomContext
|
|
56
|
+
*
|
|
57
|
+
* CustomContext is a special kind of component which allows rendering children
|
|
58
|
+
* within a custom reactive context. This enables components to manually manage
|
|
59
|
+
* the lifetime of their reactive contexts.
|
|
60
|
+
*
|
|
61
|
+
* ## IntrinsicElement
|
|
62
|
+
*
|
|
63
|
+
* Various intrinsic elements exist to control formatting. These elements
|
|
64
|
+
* provide Print Hooks that are called during Printing.
|
|
65
|
+
*
|
|
66
|
+
* # Rendered Text Tree
|
|
67
|
+
*
|
|
68
|
+
* This tree is a nested array structure containing the rendered output of all
|
|
69
|
+
* the components in the component tree. This structure is updated reactively
|
|
70
|
+
* when reactive dependencies change. The nodes in this tree are predominantly
|
|
71
|
+
* strings, but can also be Print Hooks.
|
|
72
|
+
*
|
|
73
|
+
* This tree is built by the `renderTree` function.
|
|
74
|
+
*
|
|
75
|
+
* # Document Tree
|
|
76
|
+
*
|
|
77
|
+
* This tree is constructed by calling `printTree` on the rendered text tree.
|
|
78
|
+
* The rendered text tree is walked and the appropriate Prettier builders are
|
|
79
|
+
* called to produce a document tree. The result is then passed to Prettier's
|
|
80
|
+
* `printDocToString` function to produce the final source text.
|
|
130
81
|
*/
|
|
131
82
|
export interface OutputDirectory {
|
|
132
83
|
kind: "directory";
|
|
@@ -139,9 +90,33 @@ export interface OutputFile {
|
|
|
139
90
|
path: string;
|
|
140
91
|
filetype: string;
|
|
141
92
|
}
|
|
142
|
-
export declare function getContextForRenderNode(node:
|
|
143
|
-
export
|
|
144
|
-
export
|
|
145
|
-
|
|
146
|
-
|
|
93
|
+
export declare function getContextForRenderNode(node: RenderedTextTree): Context | undefined;
|
|
94
|
+
export declare const printHookTag: unique symbol;
|
|
95
|
+
export interface PrintHook {
|
|
96
|
+
[printHookTag]: true;
|
|
97
|
+
transform?(tree: RenderedTextTree): RenderedTextTree;
|
|
98
|
+
print?(tree: RenderedTextTree, print: (subtree: RenderedTextTree) => Doc): Doc;
|
|
99
|
+
subtree: RenderedTextTree;
|
|
100
|
+
}
|
|
101
|
+
export declare function createRenderTreeHook(subtree: RenderedTextTree, hooks: Omit<PrintHook, typeof printHookTag | "subtree">): PrintHook;
|
|
102
|
+
export declare function isPrintHook(type: unknown): type is PrintHook;
|
|
103
|
+
export type RenderedTextTree = (string | RenderedTextTree | PrintHook)[];
|
|
104
|
+
export declare function render(children: Children, options?: PrintTreeOptions): OutputDirectory;
|
|
105
|
+
export declare function renderTree(children: Children): RenderedTextTree;
|
|
106
|
+
export interface PrintTreeOptions {
|
|
107
|
+
/**
|
|
108
|
+
* The number of characters the printer will wrap on. Defaults to 100
|
|
109
|
+
* characters.
|
|
110
|
+
*/
|
|
111
|
+
printWidth?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Whether to use tabs instead of spaces for indentation. Defaults to false.
|
|
114
|
+
*/
|
|
115
|
+
useTabs?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The number of spaces to use for indentation. Defaults to 2 spaces.
|
|
118
|
+
*/
|
|
119
|
+
tabWidth?: number;
|
|
120
|
+
}
|
|
121
|
+
export declare function printTree(tree: RenderedTextTree, options?: PrintTreeOptions): string;
|
|
147
122
|
//# sourceMappingURL=render.d.ts.map
|
package/dist/src/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"
|
|
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;AAsB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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