@farm.js/react 0.1.0-beta.36 → 0.1.0-beta.38
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/README.md +33 -0
- package/dist/client.d.mts +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/compiler-runtime.cjs +52 -128
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +1 -13
- package/dist/compiler-runtime.d.ts +1 -13
- package/dist/compiler-runtime.mjs +53 -125
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/server.d.mts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/vite.cjs +38 -186
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +38 -186
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
package/dist/vite.mjs
CHANGED
|
@@ -74,12 +74,9 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
74
74
|
"keyed-rows-hinted": "keyedRowsHintedRuntimeFeature",
|
|
75
75
|
"keyed-rows-append-only": "keyedRowsAppendOnlyRuntimeFeature",
|
|
76
76
|
"keyed-rows-position-hinted": "keyedRowsPositionHintedRuntimeFeature",
|
|
77
|
-
"keyed-rows-plain-position-hinted": "keyedRowsPlainPositionHintedRuntimeFeature",
|
|
78
77
|
"keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
|
|
79
78
|
"keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
|
|
80
79
|
"keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
|
|
81
|
-
"keyed-rows-plain-reorder-hinted": "keyedRowsPlainReorderHintedRuntimeFeature",
|
|
82
|
-
"keyed-rows-plain-map-reorder-hinted": "keyedRowsPlainMapReorderHintedRuntimeFeature",
|
|
83
80
|
"keyed-rows-map-reorder-hinted": "keyedRowsMapReorderHintedRuntimeFeature",
|
|
84
81
|
"keyed-rows-all-hinted": "keyedRowsAllHintedRuntimeFeature",
|
|
85
82
|
"keyed-rows-mapped-rolling-window-hinted": "keyedRowsMappedRollingWindowHintedRuntimeFeature",
|
|
@@ -186,12 +183,6 @@ function runtimeFeaturesForPlans(plans, keyedUpdateHints, keyedArrayFilterHints,
|
|
|
186
183
|
features.add("keyed-rows-filter-only");
|
|
187
184
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-prepend-hinted" && keyedTargetKinds.size === 0 && !keyedMapOrAppendHints) {
|
|
188
185
|
features.add("keyed-rows-prepend-only");
|
|
189
|
-
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-position-hinted" && keyedTargetKinds.size === 0) {
|
|
190
|
-
features.add("keyed-rows-plain-position-hinted");
|
|
191
|
-
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
192
|
-
features.add("keyed-rows-plain-reorder-hinted");
|
|
193
|
-
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-map-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
194
|
-
features.add("keyed-rows-plain-map-reorder-hinted");
|
|
195
186
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-filter-hinted" && keyedTargetKinds.size === 1 && keyedTargetKinds.has("identity")) {
|
|
196
187
|
features.add(
|
|
197
188
|
keyedMapOrAppendHints ? "keyed-rows-identity-filter-hinted" : "keyed-rows-identity-filter-only"
|
|
@@ -249,14 +240,6 @@ function collectStateDependencies(expression, statesByValue) {
|
|
|
249
240
|
return [...dependencies].sort((left, right) => left - right);
|
|
250
241
|
}
|
|
251
242
|
function referencesIdentifier(expression, name) {
|
|
252
|
-
let possible = false;
|
|
253
|
-
types.traverseFast(expression, (node) => {
|
|
254
|
-
if ((types.isIdentifier(node) || types.isJSXIdentifier(node)) && node.name === name) {
|
|
255
|
-
possible = true;
|
|
256
|
-
return types.traverseFast.stop;
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
if (!possible) return false;
|
|
260
243
|
let referenced = false;
|
|
261
244
|
traverse(expressionFile(cloneExpression(expression)), {
|
|
262
245
|
ReferencedIdentifier(path) {
|
|
@@ -336,10 +319,12 @@ function isPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
|
336
319
|
}
|
|
337
320
|
function containsPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
338
321
|
let found = false;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
322
|
+
traverse(expressionFile(cloneExpression(expression)), {
|
|
323
|
+
CallExpression(path) {
|
|
324
|
+
if (!isPotentialKeyedMembershipCall(path.node, reactiveByValue)) return;
|
|
325
|
+
found = true;
|
|
326
|
+
path.stop();
|
|
327
|
+
}
|
|
343
328
|
});
|
|
344
329
|
return found;
|
|
345
330
|
}
|
|
@@ -352,10 +337,12 @@ function isPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
|
352
337
|
}
|
|
353
338
|
function containsPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
354
339
|
let found = false;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
340
|
+
traverse(expressionFile(cloneExpression(expression)), {
|
|
341
|
+
CallExpression(path) {
|
|
342
|
+
if (!isPotentialKeyedMapLookupCall(path.node, reactiveByValue)) return;
|
|
343
|
+
found = true;
|
|
344
|
+
path.stop();
|
|
345
|
+
}
|
|
359
346
|
});
|
|
360
347
|
return found;
|
|
361
348
|
}
|
|
@@ -432,15 +419,6 @@ function keyedMapLookupTarget(binding, keyCallback, renderCallback, reactiveByVa
|
|
|
432
419
|
return valid && target && calls > 0 ? { dependency: target.index, value: types.identifier(target.valueName) } : void 0;
|
|
433
420
|
}
|
|
434
421
|
function collectReferencedLocals(expression, names) {
|
|
435
|
-
if (names.size === 0) return [];
|
|
436
|
-
let possible = false;
|
|
437
|
-
types.traverseFast(expression, (node) => {
|
|
438
|
-
if ((types.isIdentifier(node) || types.isJSXIdentifier(node)) && names.has(node.name)) {
|
|
439
|
-
possible = true;
|
|
440
|
-
return types.traverseFast.stop;
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
if (!possible) return [];
|
|
444
422
|
const references = /* @__PURE__ */ new Set();
|
|
445
423
|
traverse(expressionFile(cloneExpression(expression)), {
|
|
446
424
|
ReferencedIdentifier(path) {
|
|
@@ -452,7 +430,6 @@ function collectReferencedLocals(expression, names) {
|
|
|
452
430
|
return [...references];
|
|
453
431
|
}
|
|
454
432
|
function rewriteDerivedAccess(expression, derivedByName) {
|
|
455
|
-
if (derivedByName.size === 0) return cloneExpression(expression);
|
|
456
433
|
const file = expressionFile(cloneExpression(expression));
|
|
457
434
|
traverse(file, {
|
|
458
435
|
ReferencedIdentifier(path) {
|
|
@@ -711,7 +688,7 @@ function keyedMapUpdatePipeline(expression, parameterName, safeGlobals) {
|
|
|
711
688
|
return outerCallbacks.reverse();
|
|
712
689
|
}
|
|
713
690
|
function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
714
|
-
if (hintedStateIndices.size === 0) return { root, count: 0 };
|
|
691
|
+
if (hintedStateIndices.size === 0) return { root: types.cloneNode(root, true), count: 0 };
|
|
715
692
|
const file = expressionFile(types.cloneNode(root, true));
|
|
716
693
|
let count = 0;
|
|
717
694
|
traverse(file, {
|
|
@@ -783,7 +760,7 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
|
|
|
783
760
|
};
|
|
784
761
|
}
|
|
785
762
|
function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
786
|
-
if (hintedStateIndices.size === 0) return { root, count: 0 };
|
|
763
|
+
if (hintedStateIndices.size === 0) return { root: types.cloneNode(root, true), count: 0 };
|
|
787
764
|
const file = expressionFile(types.cloneNode(root, true));
|
|
788
765
|
let count = 0;
|
|
789
766
|
traverse(file, {
|
|
@@ -855,7 +832,7 @@ function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter,
|
|
|
855
832
|
}
|
|
856
833
|
function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
857
834
|
if (hintedStateIndices.size === 0) {
|
|
858
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
835
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
859
836
|
}
|
|
860
837
|
const file = expressionFile(types.cloneNode(root, true));
|
|
861
838
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -933,7 +910,7 @@ function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter,
|
|
|
933
910
|
}
|
|
934
911
|
function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesBySetter, sliceHelperIdentifier, rollingWindowHelperIdentifier, safeGlobals) {
|
|
935
912
|
if (hintedStateIndices.size === 0) {
|
|
936
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
913
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
937
914
|
}
|
|
938
915
|
const file = expressionFile(types.cloneNode(root, true));
|
|
939
916
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -1052,7 +1029,7 @@ function validateKeyedArrayPositionExpression(expression, safeGlobals) {
|
|
|
1052
1029
|
function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter, helperIdentifier, batchInsertHelperIdentifier, windowReplaceHelperIdentifier, safeGlobals) {
|
|
1053
1030
|
if (hintedStateIndices.size === 0) {
|
|
1054
1031
|
return {
|
|
1055
|
-
root,
|
|
1032
|
+
root: types.cloneNode(root, true),
|
|
1056
1033
|
count: 0,
|
|
1057
1034
|
batchInsertCount: 0,
|
|
1058
1035
|
windowReplaceCount: 0,
|
|
@@ -1149,7 +1126,7 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
1149
1126
|
}
|
|
1150
1127
|
function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter, helperIdentifier) {
|
|
1151
1128
|
if (hintedStateIndices.size === 0) {
|
|
1152
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
1129
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
1153
1130
|
}
|
|
1154
1131
|
const file = expressionFile(types.cloneNode(root, true));
|
|
1155
1132
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -1290,7 +1267,7 @@ function keyedArrayReorderPipeline(expression, parameterName, safeGlobals) {
|
|
|
1290
1267
|
function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesBySetter, filterHelperIdentifier, mapHelperIdentifier, mapReorderHelperIdentifier, mappedStructuralHelperIdentifier, reorderHelperIdentifier, structuralReorderHelperIdentifier, sliceHelperIdentifier, sortHelperIdentifier, structuralSortHelperIdentifier, safeGlobals, allowMapPipelines) {
|
|
1291
1268
|
if (hintedStateIndices.size === 0) {
|
|
1292
1269
|
return {
|
|
1293
|
-
root,
|
|
1270
|
+
root: types.cloneNode(root, true),
|
|
1294
1271
|
filterCount: 0,
|
|
1295
1272
|
mapCount: 0,
|
|
1296
1273
|
mapReorderCount: 0,
|
|
@@ -1480,7 +1457,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
|
|
|
1480
1457
|
};
|
|
1481
1458
|
}
|
|
1482
1459
|
function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
1483
|
-
if (!allowed) return { root, mapCount: 0 };
|
|
1460
|
+
if (!allowed) return { root: types.cloneNode(root, true), mapCount: 0 };
|
|
1484
1461
|
const file = expressionFile(types.cloneNode(root, true));
|
|
1485
1462
|
let mapCount = 0;
|
|
1486
1463
|
const containsHelperCall = (updater, helperNames) => {
|
|
@@ -1576,7 +1553,7 @@ function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
|
|
|
1576
1553
|
function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, filterIdentifier, sliceIdentifier, allowed) {
|
|
1577
1554
|
if (!allowed) {
|
|
1578
1555
|
return {
|
|
1579
|
-
root,
|
|
1556
|
+
root: types.cloneNode(root, true),
|
|
1580
1557
|
mapCount: 0,
|
|
1581
1558
|
structuralCount: 0,
|
|
1582
1559
|
stateIndices: /* @__PURE__ */ new Set()
|
|
@@ -1673,7 +1650,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
|
|
|
1673
1650
|
function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, appendIdentifier, mappedStructuralAppendIdentifier, structuralAppendMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
|
|
1674
1651
|
if (!allowed) {
|
|
1675
1652
|
return {
|
|
1676
|
-
root,
|
|
1653
|
+
root: types.cloneNode(root, true),
|
|
1677
1654
|
mapCount: 0,
|
|
1678
1655
|
mappedStructuralAppendCount: 0,
|
|
1679
1656
|
structuralAppendMapCount: 0,
|
|
@@ -1797,7 +1774,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
|
|
|
1797
1774
|
function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, prependIdentifier, mappedStructuralPrependIdentifier, structuralPrependMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
|
|
1798
1775
|
if (!allowed) {
|
|
1799
1776
|
return {
|
|
1800
|
-
root,
|
|
1777
|
+
root: types.cloneNode(root, true),
|
|
1801
1778
|
mapCount: 0,
|
|
1802
1779
|
mappedStructuralPrependCount: 0,
|
|
1803
1780
|
structuralPrependMapCount: 0,
|
|
@@ -1923,7 +1900,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
1923
1900
|
return {
|
|
1924
1901
|
chainedMapCount: 0,
|
|
1925
1902
|
chainedRollingWindowCount: 0,
|
|
1926
|
-
root,
|
|
1903
|
+
root: types.cloneNode(root, true),
|
|
1927
1904
|
leadingMapCount: 0,
|
|
1928
1905
|
mappedRollingWindowCount: 0,
|
|
1929
1906
|
rollingWindowCount: 0,
|
|
@@ -2081,7 +2058,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
2081
2058
|
function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, filterIdentifier, sliceIdentifier, mapPipelineIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
2082
2059
|
if (!allowed) {
|
|
2083
2060
|
return {
|
|
2084
|
-
root,
|
|
2061
|
+
root: types.cloneNode(root, true),
|
|
2085
2062
|
reorderCount: 0,
|
|
2086
2063
|
sortCount: 0,
|
|
2087
2064
|
replacedMapReorderCount: 0,
|
|
@@ -2211,7 +2188,7 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
|
|
|
2211
2188
|
function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
2212
2189
|
if (!allowed) {
|
|
2213
2190
|
return {
|
|
2214
|
-
root,
|
|
2191
|
+
root: types.cloneNode(root, true),
|
|
2215
2192
|
mapCount: 0,
|
|
2216
2193
|
mapReorderCount: 0,
|
|
2217
2194
|
mapSortCount: 0
|
|
@@ -2324,7 +2301,7 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
|
|
|
2324
2301
|
}
|
|
2325
2302
|
function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
2326
2303
|
if (hintedStateIndices.size === 0) {
|
|
2327
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2304
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2328
2305
|
}
|
|
2329
2306
|
const file = expressionFile(types.cloneNode(root, true));
|
|
2330
2307
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -2384,7 +2361,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
|
|
|
2384
2361
|
}
|
|
2385
2362
|
function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
2386
2363
|
if (hintedStateIndices.size === 0) {
|
|
2387
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2364
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2388
2365
|
}
|
|
2389
2366
|
const file = expressionFile(types.cloneNode(root, true));
|
|
2390
2367
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -2446,7 +2423,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
|
|
|
2446
2423
|
}
|
|
2447
2424
|
function rewriteKeyedArrayFilterHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
2448
2425
|
if (hintedStateIndices.size === 0) {
|
|
2449
|
-
return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2426
|
+
return { root: types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
2450
2427
|
}
|
|
2451
2428
|
const file = expressionFile(types.cloneNode(root, true));
|
|
2452
2429
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
@@ -2751,7 +2728,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
|
|
|
2751
2728
|
return types.isArrowFunctionExpression(prepared) || types.isFunctionExpression(prepared) ? { updater: prepared, mutations } : void 0;
|
|
2752
2729
|
}
|
|
2753
2730
|
function rewriteKeyedCollectionUpdateHints(root, targetKinds, states, statesBySetter, updateHelper, mutationHelper, globalCollections) {
|
|
2754
|
-
if (targetKinds.size === 0) return { root, count: 0 };
|
|
2731
|
+
if (targetKinds.size === 0) return { root: types.cloneNode(root, true), count: 0 };
|
|
2755
2732
|
const file = expressionFile(types.cloneNode(root, true));
|
|
2756
2733
|
let count = 0;
|
|
2757
2734
|
for (const [stateIndex, kind] of targetKinds) {
|
|
@@ -3286,45 +3263,6 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
|
|
|
3286
3263
|
const expression = file.program.body[0].expression;
|
|
3287
3264
|
return types.isJSXElement(expression) ? expression : types.cloneNode(root, true);
|
|
3288
3265
|
}
|
|
3289
|
-
var FOREIGN_ELEMENT_NAMES = new Set(
|
|
3290
|
-
[
|
|
3291
|
-
"animate animateMotion animateTransform circle clipPath defs desc ellipse",
|
|
3292
|
-
"feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix",
|
|
3293
|
-
"feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood",
|
|
3294
|
-
"feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode",
|
|
3295
|
-
"feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile",
|
|
3296
|
-
"feTurbulence filter foreignObject g image line linearGradient marker mask",
|
|
3297
|
-
"metadata mpath path pattern polygon polyline radialGradient rect set stop svg",
|
|
3298
|
-
"switch symbol text textPath tspan use view",
|
|
3299
|
-
"math maction menclose merror mfrac mi mmultiscripts mn mo mover mpadded",
|
|
3300
|
-
"mphantom mprescripts mroot mrow ms mspace msqrt mstyle msub msubsup msup",
|
|
3301
|
-
"mtable mtd mtext mtr munder munderover semantics annotation"
|
|
3302
|
-
].join(" ").split(" ")
|
|
3303
|
-
);
|
|
3304
|
-
function markForeignContent(programPath) {
|
|
3305
|
-
let depth = 0;
|
|
3306
|
-
programPath.traverse({
|
|
3307
|
-
JSXElement: {
|
|
3308
|
-
enter(path) {
|
|
3309
|
-
if (depth > 0) path.node.extra = { ...path.node.extra, farmForeignContent: true };
|
|
3310
|
-
const name = path.node.openingElement.name;
|
|
3311
|
-
if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth++;
|
|
3312
|
-
},
|
|
3313
|
-
exit(path) {
|
|
3314
|
-
const name = path.node.openingElement.name;
|
|
3315
|
-
if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth--;
|
|
3316
|
-
}
|
|
3317
|
-
}
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
function isForeignContent(element) {
|
|
3321
|
-
const name = element.openingElement.name;
|
|
3322
|
-
return element.extra?.farmForeignContent === true || types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
|
|
3323
|
-
}
|
|
3324
|
-
function reactOwnedAttribute(name, attribute) {
|
|
3325
|
-
if (name === "defaultValue" || name === "defaultChecked") return true;
|
|
3326
|
-
return (name === "spellCheck" || name === "draggable") && !types.isStringLiteral(attribute.value);
|
|
3327
|
-
}
|
|
3328
3266
|
function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
|
|
3329
3267
|
if (renderCallback.async || renderCallback.generator || renderCallback.params.length < 1 || renderCallback.params.length > 2 || !types.isIdentifier(renderCallback.params[0]) || renderCallback.params[1] !== void 0 && !types.isIdentifier(renderCallback.params[1])) {
|
|
3330
3268
|
return {
|
|
@@ -3344,7 +3282,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3344
3282
|
if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3345
3283
|
return "compiled keyed rows support host elements only";
|
|
3346
3284
|
}
|
|
3347
|
-
if (
|
|
3285
|
+
if (tag.name === "svg") return "compiled keyed rows do not support SVG yet";
|
|
3348
3286
|
const attributeNames = new Set(
|
|
3349
3287
|
element.openingElement.attributes.filter((attribute) => types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3350
3288
|
);
|
|
@@ -3374,7 +3312,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3374
3312
|
}
|
|
3375
3313
|
const name = jsxAttributeName(attribute);
|
|
3376
3314
|
if (!name) return "compiled keyed rows do not support namespaced JSX attributes";
|
|
3377
|
-
if (name === "ref" || name === "dangerouslySetInnerHTML"
|
|
3315
|
+
if (name === "ref" || name === "dangerouslySetInnerHTML") {
|
|
3378
3316
|
return `compiled keyed row ${name} requires React ownership`;
|
|
3379
3317
|
}
|
|
3380
3318
|
if (name === "key") continue;
|
|
@@ -3742,7 +3680,7 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3742
3680
|
if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3743
3681
|
return "compiler-owned conditionals support host elements only";
|
|
3744
3682
|
}
|
|
3745
|
-
if (
|
|
3683
|
+
if (tag.name === "svg") return "compiler-owned conditionals do not support SVG yet";
|
|
3746
3684
|
for (const attribute of element.openingElement.attributes) {
|
|
3747
3685
|
if (types.isJSXSpreadAttribute(attribute)) {
|
|
3748
3686
|
if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
|
|
@@ -3750,9 +3688,6 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3750
3688
|
}
|
|
3751
3689
|
const name = jsxAttributeName(attribute);
|
|
3752
3690
|
if (!name) return "compiler-owned conditionals do not support namespaced JSX attributes";
|
|
3753
|
-
if (reactOwnedAttribute(name, attribute)) {
|
|
3754
|
-
return `compiler-owned conditional ${name} requires React ownership`;
|
|
3755
|
-
}
|
|
3756
3691
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3757
3692
|
if (statefulOnly && (!types.isJSXExpressionContainer(attribute.value) || types.isJSXEmptyExpression(attribute.value.expression) || !needsStaticBinding(attribute.value.expression))) {
|
|
3758
3693
|
continue;
|
|
@@ -3865,18 +3800,13 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
3865
3800
|
if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3866
3801
|
return "recursive compiler-owned blocks support host elements only";
|
|
3867
3802
|
}
|
|
3868
|
-
if (
|
|
3869
|
-
return "recursive compiler-owned blocks do not support SVG yet";
|
|
3870
|
-
}
|
|
3803
|
+
if (tag.name === "svg") return "recursive compiler-owned blocks do not support SVG yet";
|
|
3871
3804
|
for (const attribute of element.openingElement.attributes) {
|
|
3872
3805
|
if (types.isJSXSpreadAttribute(attribute)) {
|
|
3873
3806
|
return "recursive compiler-owned blocks do not support JSX attribute spreads";
|
|
3874
3807
|
}
|
|
3875
3808
|
const name = jsxAttributeName(attribute);
|
|
3876
3809
|
if (!name) return "recursive compiler-owned blocks do not support namespaced attributes";
|
|
3877
|
-
if (reactOwnedAttribute(name, attribute)) {
|
|
3878
|
-
return `recursive compiler-owned block ${name} requires React ownership`;
|
|
3879
|
-
}
|
|
3880
3810
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3881
3811
|
return `recursive compiler-owned block ${name} requires React ownership`;
|
|
3882
3812
|
}
|
|
@@ -4237,7 +4167,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, statesByValue, safeGlobal
|
|
|
4237
4167
|
}
|
|
4238
4168
|
function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4239
4169
|
const containerName = container.openingElement.name;
|
|
4240
|
-
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4170
|
+
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg") {
|
|
4241
4171
|
return void 0;
|
|
4242
4172
|
}
|
|
4243
4173
|
if (container.openingElement.attributes.some(
|
|
@@ -4302,7 +4232,7 @@ function analyzeHostConditionalContainer(container, statesByValue, safeGlobals,
|
|
|
4302
4232
|
}
|
|
4303
4233
|
function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals, allowSingleRange, listNames, parent, allocateId) {
|
|
4304
4234
|
const containerName = container.openingElement.name;
|
|
4305
|
-
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4235
|
+
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
|
|
4306
4236
|
(attribute) => types.isJSXSpreadAttribute(attribute) || types.isJSXAttribute(attribute) && types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4307
4237
|
)) {
|
|
4308
4238
|
return void 0;
|
|
@@ -4398,7 +4328,7 @@ function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals
|
|
|
4398
4328
|
}
|
|
4399
4329
|
function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4400
4330
|
const containerName = container.openingElement.name;
|
|
4401
|
-
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4331
|
+
if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
|
|
4402
4332
|
(attribute) => types.isJSXSpreadAttribute(attribute) || types.isJSXAttribute(attribute) && types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4403
4333
|
)) {
|
|
4404
4334
|
return void 0;
|
|
@@ -4950,57 +4880,6 @@ function canCloneKeyedRows(plan) {
|
|
|
4950
4880
|
};
|
|
4951
4881
|
return cloneable(plan.row);
|
|
4952
4882
|
}
|
|
4953
|
-
function keyedRowBindingTargets(plan) {
|
|
4954
|
-
if (!canCloneKeyedRows(plan)) return void 0;
|
|
4955
|
-
const root = types.identifier("row");
|
|
4956
|
-
const targets = /* @__PURE__ */ new Map([["", root]]);
|
|
4957
|
-
const statements = [];
|
|
4958
|
-
let independentReads = 0;
|
|
4959
|
-
for (const binding of plan.bindings) {
|
|
4960
|
-
const path = [];
|
|
4961
|
-
for (const index of binding.path) {
|
|
4962
|
-
independentReads += index + 1;
|
|
4963
|
-
for (let sibling = 0; sibling <= index; sibling += 1) {
|
|
4964
|
-
const key = [...path, sibling].join(".");
|
|
4965
|
-
if (targets.has(key)) continue;
|
|
4966
|
-
if (statements.length === 32) return void 0;
|
|
4967
|
-
const parent = targets.get(
|
|
4968
|
-
sibling === 0 ? path.join(".") : [...path, sibling - 1].join(".")
|
|
4969
|
-
);
|
|
4970
|
-
const target = types.identifier(`target${statements.length}`);
|
|
4971
|
-
statements.push(
|
|
4972
|
-
types.variableDeclaration("const", [
|
|
4973
|
-
types.variableDeclarator(
|
|
4974
|
-
target,
|
|
4975
|
-
types.optionalMemberExpression(
|
|
4976
|
-
parent,
|
|
4977
|
-
types.identifier(sibling === 0 ? "firstElementChild" : "nextElementSibling"),
|
|
4978
|
-
false,
|
|
4979
|
-
true
|
|
4980
|
-
)
|
|
4981
|
-
)
|
|
4982
|
-
])
|
|
4983
|
-
);
|
|
4984
|
-
targets.set(key, target);
|
|
4985
|
-
}
|
|
4986
|
-
path.push(index);
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
if (statements.length >= independentReads) return void 0;
|
|
4990
|
-
return types.arrowFunctionExpression(
|
|
4991
|
-
[root],
|
|
4992
|
-
types.blockStatement([
|
|
4993
|
-
...statements,
|
|
4994
|
-
types.returnStatement(
|
|
4995
|
-
types.arrayExpression(
|
|
4996
|
-
plan.bindings.map(
|
|
4997
|
-
(binding) => types.logicalExpression("??", targets.get(binding.path.join(".")), types.nullLiteral())
|
|
4998
|
-
)
|
|
4999
|
-
)
|
|
5000
|
-
)
|
|
5001
|
-
])
|
|
5002
|
-
);
|
|
5003
|
-
}
|
|
5004
4883
|
function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFilterHintedStateIndices, keyedArrayPrependHintedStateIndices, keyedArrayPositionHintedStateIndices, keyedArrayReorderHintedStateIndices) {
|
|
5005
4884
|
const name = types.jsxMemberExpression(
|
|
5006
4885
|
types.jsxIdentifier(blockRuntime.name),
|
|
@@ -5018,7 +4897,6 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
5018
4897
|
...plan.conditionals.map((conditional) => conditional.test)
|
|
5019
4898
|
]);
|
|
5020
4899
|
const delegatedEvents = canDelegateKeyedRowEvents(plan);
|
|
5021
|
-
const bindingTargets = keyedRowBindingTargets(plan);
|
|
5022
4900
|
const renderSource = keyedRowsRenderSource(plan, eventFactory, conditionalFactory);
|
|
5023
4901
|
const renderFactoryParameters = plan.conditionals.length > 0 ? [types.cloneNode(eventFactory), types.cloneNode(conditionalFactory)] : plan.events.length > 0 ? [types.cloneNode(eventFactory)] : [];
|
|
5024
4902
|
return types.jsxElement(
|
|
@@ -5139,7 +5017,6 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
5139
5017
|
types.jsxExpressionContainer(types.booleanLiteral(true))
|
|
5140
5018
|
)
|
|
5141
5019
|
] : [],
|
|
5142
|
-
...bindingTargets ? [types.jsxAttribute(types.jsxIdentifier("targets"), types.jsxExpressionContainer(bindingTargets))] : [],
|
|
5143
5020
|
...canCloneKeyedRows(plan) ? [
|
|
5144
5021
|
types.jsxAttribute(
|
|
5145
5022
|
types.jsxIdentifier("cloneRows"),
|
|
@@ -7583,7 +7460,6 @@ async function compileReactModule(code, id, options) {
|
|
|
7583
7460
|
visitor: {
|
|
7584
7461
|
Program(programPath) {
|
|
7585
7462
|
const moduleDirectives = new Set(directiveValues(programPath.node));
|
|
7586
|
-
markForeignContent(programPath);
|
|
7587
7463
|
const useStateNames = /* @__PURE__ */ new Set();
|
|
7588
7464
|
const reactNames = /* @__PURE__ */ new Set();
|
|
7589
7465
|
const listNames = /* @__PURE__ */ new Set();
|
|
@@ -7608,10 +7484,6 @@ async function compileReactModule(code, id, options) {
|
|
|
7608
7484
|
}
|
|
7609
7485
|
const candidates = collectCandidates(programPath);
|
|
7610
7486
|
const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
|
|
7611
|
-
const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
|
|
7612
|
-
const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
|
|
7613
|
-
"createProductionComponent"
|
|
7614
|
-
);
|
|
7615
7487
|
const keyedMapUpdateIdentifier = programPath.scope.generateUidIdentifier(
|
|
7616
7488
|
"createCompilerKeyedMapUpdate"
|
|
7617
7489
|
);
|
|
@@ -7756,34 +7628,14 @@ async function compileReactModule(code, id, options) {
|
|
|
7756
7628
|
const hasKeyedArrayStructuralPrependHints = optimizationCounts.keyedArrayPrependHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
|
|
7757
7629
|
const hasUnmappedKeyedArrayPrependHints = optimizationCounts.keyedArrayPrependHints > compilerUsage.keyedArrayMappedStructuralPrependHints;
|
|
7758
7630
|
if (compiled.length > 0) {
|
|
7759
|
-
programPath.unshiftContainer(
|
|
7760
|
-
"body",
|
|
7761
|
-
types.variableDeclaration("const", [
|
|
7762
|
-
types.variableDeclarator(
|
|
7763
|
-
types.cloneNode(createComponentIdentifier),
|
|
7764
|
-
types.conditionalExpression(
|
|
7765
|
-
types.memberExpression(
|
|
7766
|
-
types.metaProperty(types.identifier("import"), types.identifier("meta")),
|
|
7767
|
-
types.identifier("hot")
|
|
7768
|
-
),
|
|
7769
|
-
types.cloneNode(createRefreshComponentIdentifier),
|
|
7770
|
-
types.cloneNode(createProductionComponentIdentifier)
|
|
7771
|
-
)
|
|
7772
|
-
)
|
|
7773
|
-
])
|
|
7774
|
-
);
|
|
7775
7631
|
programPath.unshiftContainer(
|
|
7776
7632
|
"body",
|
|
7777
7633
|
types.importDeclaration(
|
|
7778
7634
|
[
|
|
7779
7635
|
types.importSpecifier(
|
|
7780
|
-
|
|
7636
|
+
createComponentIdentifier,
|
|
7781
7637
|
types.identifier("createCompiledComponentWithFeatures")
|
|
7782
7638
|
),
|
|
7783
|
-
types.importSpecifier(
|
|
7784
|
-
createProductionComponentIdentifier,
|
|
7785
|
-
types.identifier("createCompiledComponentWithoutRefresh")
|
|
7786
|
-
),
|
|
7787
7639
|
...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
|
|
7788
7640
|
types.importSpecifier(
|
|
7789
7641
|
keyedMapUpdateIdentifier,
|