@alloy-js/core 0.8.0 → 0.10.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 +14 -0
- package/dist/src/binder.d.ts +1 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +15 -0
- package/dist/src/binder.js.map +1 -1
- 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.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/jsx-runtime.d.ts +2 -2
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +5 -2
- package/dist/src/jsx-runtime.js.map +1 -1
- package/dist/src/stc.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/binder.ts +24 -0
- package/src/components/For.tsx +6 -1
- package/src/index.ts +2 -0
- package/src/jsx-runtime.ts +10 -3
- package/src/stc.ts +5 -5
- package/temp/api.json +146 -10
- package/test/control-flow/for.test.tsx +17 -0
package/src/stc.ts
CHANGED
|
@@ -32,9 +32,9 @@ export function stc<T extends {}>(
|
|
|
32
32
|
Component: ComponentDefinition<T>,
|
|
33
33
|
): StcSignature<T> {
|
|
34
34
|
return (...args) => {
|
|
35
|
-
const fn: StcComponentCreator<T> = () => Component(args[0] as any
|
|
35
|
+
const fn: StcComponentCreator<T> = (() => Component(args[0] as T)) as any;
|
|
36
36
|
fn.component = Component;
|
|
37
|
-
fn.props = args[0]
|
|
37
|
+
fn.props = args[0]! as T;
|
|
38
38
|
fn.code = (template, ...substitutions): ComponentCreator<T> => {
|
|
39
39
|
const propsWithChildren = {
|
|
40
40
|
...(args[0] ?? {}),
|
|
@@ -43,7 +43,7 @@ export function stc<T extends {}>(
|
|
|
43
43
|
|
|
44
44
|
const fn = () => Component(propsWithChildren as any);
|
|
45
45
|
fn.component = Component;
|
|
46
|
-
fn.props = args[0]
|
|
46
|
+
fn.props = args[0]! as T;
|
|
47
47
|
return fn;
|
|
48
48
|
};
|
|
49
49
|
fn.text = (template, ...substitutions) => {
|
|
@@ -54,7 +54,7 @@ export function stc<T extends {}>(
|
|
|
54
54
|
|
|
55
55
|
const fn = () => Component(propsWithChildren as any);
|
|
56
56
|
fn.component = Component;
|
|
57
|
-
fn.props = args[0]
|
|
57
|
+
fn.props = args[0]! as T;
|
|
58
58
|
return fn;
|
|
59
59
|
};
|
|
60
60
|
fn.children = (...children: Children[]): ComponentCreator<T> => {
|
|
@@ -65,7 +65,7 @@ export function stc<T extends {}>(
|
|
|
65
65
|
|
|
66
66
|
const fn = () => Component(propsWithChildren as any);
|
|
67
67
|
fn.component = Component;
|
|
68
|
-
fn.props = args[0]
|
|
68
|
+
fn.props = args[0]! as T;
|
|
69
69
|
return fn;
|
|
70
70
|
};
|
|
71
71
|
|
package/temp/api.json
CHANGED
|
@@ -1197,6 +1197,79 @@
|
|
|
1197
1197
|
],
|
|
1198
1198
|
"name": "findSymbolName"
|
|
1199
1199
|
},
|
|
1200
|
+
{
|
|
1201
|
+
"kind": "MethodSignature",
|
|
1202
|
+
"canonicalReference": "@alloy-js/core!Binder#getSymbolForRefkey:member(1)",
|
|
1203
|
+
"docComment": "",
|
|
1204
|
+
"excerptTokens": [
|
|
1205
|
+
{
|
|
1206
|
+
"kind": "Content",
|
|
1207
|
+
"text": "getSymbolForRefkey<TSymbol extends "
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"kind": "Reference",
|
|
1211
|
+
"text": "OutputSymbol",
|
|
1212
|
+
"canonicalReference": "@alloy-js/core!OutputSymbol:interface"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
"kind": "Content",
|
|
1216
|
+
"text": ">(refkey: "
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
"kind": "Reference",
|
|
1220
|
+
"text": "Refkey",
|
|
1221
|
+
"canonicalReference": "@alloy-js/core!Refkey:type"
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
"kind": "Content",
|
|
1225
|
+
"text": "): "
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
"kind": "Reference",
|
|
1229
|
+
"text": "Ref",
|
|
1230
|
+
"canonicalReference": "@vue/reactivity!Ref:interface"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
"kind": "Content",
|
|
1234
|
+
"text": "<TSymbol | undefined>"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"kind": "Content",
|
|
1238
|
+
"text": ";"
|
|
1239
|
+
}
|
|
1240
|
+
],
|
|
1241
|
+
"isOptional": false,
|
|
1242
|
+
"returnTypeTokenRange": {
|
|
1243
|
+
"startIndex": 5,
|
|
1244
|
+
"endIndex": 7
|
|
1245
|
+
},
|
|
1246
|
+
"releaseTag": "Public",
|
|
1247
|
+
"overloadIndex": 1,
|
|
1248
|
+
"parameters": [
|
|
1249
|
+
{
|
|
1250
|
+
"parameterName": "refkey",
|
|
1251
|
+
"parameterTypeTokenRange": {
|
|
1252
|
+
"startIndex": 3,
|
|
1253
|
+
"endIndex": 4
|
|
1254
|
+
},
|
|
1255
|
+
"isOptional": false
|
|
1256
|
+
}
|
|
1257
|
+
],
|
|
1258
|
+
"typeParameters": [
|
|
1259
|
+
{
|
|
1260
|
+
"typeParameterName": "TSymbol",
|
|
1261
|
+
"constraintTokenRange": {
|
|
1262
|
+
"startIndex": 1,
|
|
1263
|
+
"endIndex": 2
|
|
1264
|
+
},
|
|
1265
|
+
"defaultTypeTokenRange": {
|
|
1266
|
+
"startIndex": 0,
|
|
1267
|
+
"endIndex": 0
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
],
|
|
1271
|
+
"name": "getSymbolForRefkey"
|
|
1272
|
+
},
|
|
1200
1273
|
{
|
|
1201
1274
|
"kind": "PropertySignature",
|
|
1202
1275
|
"canonicalReference": "@alloy-js/core!Binder#globalScope:member",
|
|
@@ -2647,9 +2720,8 @@
|
|
|
2647
2720
|
"text": "props: "
|
|
2648
2721
|
},
|
|
2649
2722
|
{
|
|
2650
|
-
"kind": "
|
|
2651
|
-
"text": "
|
|
2652
|
-
"canonicalReference": "@alloy-js/core!Props:type"
|
|
2723
|
+
"kind": "Content",
|
|
2724
|
+
"text": "TProps"
|
|
2653
2725
|
},
|
|
2654
2726
|
{
|
|
2655
2727
|
"kind": "Content",
|
|
@@ -5686,6 +5758,15 @@
|
|
|
5686
5758
|
"text": "Set",
|
|
5687
5759
|
"canonicalReference": "!Set:interface"
|
|
5688
5760
|
},
|
|
5761
|
+
{
|
|
5762
|
+
"kind": "Content",
|
|
5763
|
+
"text": "<infer U> ? [value: U] : T extends "
|
|
5764
|
+
},
|
|
5765
|
+
{
|
|
5766
|
+
"kind": "Reference",
|
|
5767
|
+
"text": "IterableIterator",
|
|
5768
|
+
"canonicalReference": "!IterableIterator:interface"
|
|
5769
|
+
},
|
|
5689
5770
|
{
|
|
5690
5771
|
"kind": "Content",
|
|
5691
5772
|
"text": "<infer U> ? [value: U] : []"
|
|
@@ -5713,7 +5794,7 @@
|
|
|
5713
5794
|
],
|
|
5714
5795
|
"typeTokenRange": {
|
|
5715
5796
|
"startIndex": 1,
|
|
5716
|
-
"endIndex":
|
|
5797
|
+
"endIndex": 14
|
|
5717
5798
|
}
|
|
5718
5799
|
},
|
|
5719
5800
|
{
|
|
@@ -5938,6 +6019,15 @@
|
|
|
5938
6019
|
"text": "Set",
|
|
5939
6020
|
"canonicalReference": "!Set:interface"
|
|
5940
6021
|
},
|
|
6022
|
+
{
|
|
6023
|
+
"kind": "Content",
|
|
6024
|
+
"text": "<any> | "
|
|
6025
|
+
},
|
|
6026
|
+
{
|
|
6027
|
+
"kind": "Reference",
|
|
6028
|
+
"text": "IterableIterator",
|
|
6029
|
+
"canonicalReference": "!IterableIterator:interface"
|
|
6030
|
+
},
|
|
5941
6031
|
{
|
|
5942
6032
|
"kind": "Content",
|
|
5943
6033
|
"text": "<any>"
|
|
@@ -5952,7 +6042,7 @@
|
|
|
5952
6042
|
"name": "ForSupportedCollections",
|
|
5953
6043
|
"typeTokenRange": {
|
|
5954
6044
|
"startIndex": 1,
|
|
5955
|
-
"endIndex":
|
|
6045
|
+
"endIndex": 8
|
|
5956
6046
|
}
|
|
5957
6047
|
},
|
|
5958
6048
|
{
|
|
@@ -6988,12 +7078,33 @@
|
|
|
6988
7078
|
"excerptTokens": [
|
|
6989
7079
|
{
|
|
6990
7080
|
"kind": "Content",
|
|
6991
|
-
"text": "export declare function isComponentCreator
|
|
7081
|
+
"text": "export declare function isComponentCreator<TProps = "
|
|
7082
|
+
},
|
|
7083
|
+
{
|
|
7084
|
+
"kind": "Content",
|
|
7085
|
+
"text": "any"
|
|
7086
|
+
},
|
|
7087
|
+
{
|
|
7088
|
+
"kind": "Content",
|
|
7089
|
+
"text": ">(item: "
|
|
6992
7090
|
},
|
|
6993
7091
|
{
|
|
6994
7092
|
"kind": "Content",
|
|
6995
7093
|
"text": "unknown"
|
|
6996
7094
|
},
|
|
7095
|
+
{
|
|
7096
|
+
"kind": "Content",
|
|
7097
|
+
"text": ", component?: "
|
|
7098
|
+
},
|
|
7099
|
+
{
|
|
7100
|
+
"kind": "Reference",
|
|
7101
|
+
"text": "Component",
|
|
7102
|
+
"canonicalReference": "@alloy-js/core!Component:interface"
|
|
7103
|
+
},
|
|
7104
|
+
{
|
|
7105
|
+
"kind": "Content",
|
|
7106
|
+
"text": "<TProps>"
|
|
7107
|
+
},
|
|
6997
7108
|
{
|
|
6998
7109
|
"kind": "Content",
|
|
6999
7110
|
"text": "): "
|
|
@@ -7012,6 +7123,10 @@
|
|
|
7012
7123
|
"text": "ComponentCreator",
|
|
7013
7124
|
"canonicalReference": "@alloy-js/core!ComponentCreator:interface"
|
|
7014
7125
|
},
|
|
7126
|
+
{
|
|
7127
|
+
"kind": "Content",
|
|
7128
|
+
"text": "<TProps>"
|
|
7129
|
+
},
|
|
7015
7130
|
{
|
|
7016
7131
|
"kind": "Content",
|
|
7017
7132
|
"text": ";"
|
|
@@ -7019,8 +7134,8 @@
|
|
|
7019
7134
|
],
|
|
7020
7135
|
"fileUrlPath": "src/jsx-runtime.ts",
|
|
7021
7136
|
"returnTypeTokenRange": {
|
|
7022
|
-
"startIndex":
|
|
7023
|
-
"endIndex":
|
|
7137
|
+
"startIndex": 8,
|
|
7138
|
+
"endIndex": 12
|
|
7024
7139
|
},
|
|
7025
7140
|
"releaseTag": "Public",
|
|
7026
7141
|
"overloadIndex": 1,
|
|
@@ -7028,10 +7143,31 @@
|
|
|
7028
7143
|
{
|
|
7029
7144
|
"parameterName": "item",
|
|
7030
7145
|
"parameterTypeTokenRange": {
|
|
7031
|
-
"startIndex":
|
|
7032
|
-
"endIndex":
|
|
7146
|
+
"startIndex": 3,
|
|
7147
|
+
"endIndex": 4
|
|
7033
7148
|
},
|
|
7034
7149
|
"isOptional": false
|
|
7150
|
+
},
|
|
7151
|
+
{
|
|
7152
|
+
"parameterName": "component",
|
|
7153
|
+
"parameterTypeTokenRange": {
|
|
7154
|
+
"startIndex": 5,
|
|
7155
|
+
"endIndex": 7
|
|
7156
|
+
},
|
|
7157
|
+
"isOptional": true
|
|
7158
|
+
}
|
|
7159
|
+
],
|
|
7160
|
+
"typeParameters": [
|
|
7161
|
+
{
|
|
7162
|
+
"typeParameterName": "TProps",
|
|
7163
|
+
"constraintTokenRange": {
|
|
7164
|
+
"startIndex": 0,
|
|
7165
|
+
"endIndex": 0
|
|
7166
|
+
},
|
|
7167
|
+
"defaultTypeTokenRange": {
|
|
7168
|
+
"startIndex": 1,
|
|
7169
|
+
"endIndex": 2
|
|
7170
|
+
}
|
|
7035
7171
|
}
|
|
7036
7172
|
],
|
|
7037
7173
|
"name": "isComponentCreator"
|
|
@@ -34,6 +34,23 @@ it("handles map entries", () => {
|
|
|
34
34
|
`);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
it("handles iterators", () => {
|
|
38
|
+
const iterator = new Map([["a", { name: "foo" }]]).entries();
|
|
39
|
+
const template = (
|
|
40
|
+
<For each={iterator}>
|
|
41
|
+
{([key, value]) => (
|
|
42
|
+
<>
|
|
43
|
+
{key}: {value.name}
|
|
44
|
+
</>
|
|
45
|
+
)}
|
|
46
|
+
</For>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(template).toRenderTo(`
|
|
50
|
+
a: foo
|
|
51
|
+
`);
|
|
52
|
+
});
|
|
53
|
+
|
|
37
54
|
it("handles maps", () => {
|
|
38
55
|
const map = new Map([["a", { name: "foo" }]]);
|
|
39
56
|
const template = (
|