@farm.js/core 0.1.63 → 0.1.65
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/{agent-mcp-handler-OV4WRFBL.cjs → agent-mcp-handler-OXT73ZBY.cjs} +5 -5
- package/dist/{agent-mcp-handler-7QMX2LUY.mjs → agent-mcp-handler-QLFDDTYN.mjs} +4 -4
- package/dist/{agent-mcp.d-CCQ-wKwg.d.mts → agent-mcp.d-CO_ABmNK.d.mts} +1 -1
- package/dist/{agent-mcp.d-DOJCBSh9.d.ts → agent-mcp.d-QD2WZ9BS.d.ts} +1 -1
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/analyzer-GHWK46LX.cjs +16 -0
- package/dist/{analyzer-WNPQPWFR.mjs → analyzer-PE33SK5W.mjs} +3 -2
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/{app-manifest.d-BaA0omsv.d.mts → app-manifest.d-BpKxiU_E.d.mts} +1 -1
- package/dist/{app-manifest.d-poayV4lq.d.ts → app-manifest.d-DDmNkYQQ.d.ts} +1 -1
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/{app.d-DdWxeIGU.d.mts → app.d-kuoVWhWM.d.mts} +4 -4
- package/dist/{app.d-D4Dn03E3.d.ts → app.d-x68Cwr0_.d.ts} +4 -4
- package/dist/{chunk-LT4VAF5Z.cjs → chunk-2C5L5RPM.cjs} +7 -6
- package/dist/{chunk-BA2IA32Q.mjs → chunk-2L54YV25.mjs} +13 -11
- package/dist/{chunk-5IKQ7BIR.cjs → chunk-32RPJAAS.cjs} +16 -16
- package/dist/{chunk-QN5WRQSQ.cjs → chunk-3KJPIO5D.cjs} +610 -3102
- package/dist/{chunk-EENTT56C.mjs → chunk-6X5NKNBE.mjs} +43 -38
- package/dist/{chunk-RFYL5OLP.mjs → chunk-72JSHQQQ.mjs} +1 -1
- package/dist/{chunk-LA45FN37.mjs → chunk-7GYCZRTH.mjs} +386 -2878
- package/dist/chunk-7QVRWGBL.cjs +3704 -0
- package/dist/{chunk-PRFNLQSP.cjs → chunk-7XGWBPQQ.cjs} +4 -4
- package/dist/{chunk-FNHN3RBD.cjs → chunk-A3G5IY2W.cjs} +1 -1
- package/dist/{chunk-EYLC6GD6.cjs → chunk-C7DCMGC4.cjs} +12 -12
- package/dist/chunk-CJNAUEVC.mjs +34 -0
- package/dist/{chunk-LFFSDZ4Y.cjs → chunk-CZF4XIRZ.cjs} +3 -3
- package/dist/{chunk-7FFW7DC4.mjs → chunk-E2TSYUHV.mjs} +4 -4
- package/dist/{chunk-55U5QIXQ.mjs → chunk-FIR62CR3.mjs} +1 -1
- package/dist/{chunk-MEQN6DDA.cjs → chunk-FJWN7RV4.cjs} +5 -5
- package/dist/{chunk-VVTJTMGQ.cjs → chunk-GL7N5UHF.cjs} +4 -4
- package/dist/{chunk-4DIKLG56.mjs → chunk-GRBJ7VKH.mjs} +1 -1
- package/dist/{chunk-UR25Z5Z6.mjs → chunk-HCGWDRZO.mjs} +1 -1
- package/dist/{chunk-GPKBUME5.mjs → chunk-HKNYNSOK.mjs} +2 -2
- package/dist/{chunk-U6WCUVSV.cjs → chunk-IMK32ERL.cjs} +23 -21
- package/dist/chunk-IOEXXZK3.mjs +88 -0
- package/dist/{chunk-IOF4KXMP.mjs → chunk-IP2KHSGF.mjs} +205 -26
- package/dist/{chunk-YSXTNSXS.mjs → chunk-K7OZAVOI.mjs} +7 -6
- package/dist/{chunk-KVW2M6PI.mjs → chunk-KL7SHLQB.mjs} +1 -1
- package/dist/{chunk-UZZ6IEQP.mjs → chunk-MESQF2JC.mjs} +2 -2
- package/dist/{chunk-DZPR2W6U.cjs → chunk-O6L3YYPM.cjs} +5 -5
- package/dist/{chunk-6BJJYOFL.cjs → chunk-OLIGNTWU.cjs} +7 -7
- package/dist/{chunk-5L7I6AMY.cjs → chunk-OSFIUSYK.cjs} +5 -5
- package/dist/{chunk-LA6O5EL2.mjs → chunk-Q75QPLBA.mjs} +1 -1
- package/dist/{chunk-O5FCWI6O.mjs → chunk-QHRCR44V.mjs} +2 -2
- package/dist/{chunk-E72UD6ME.mjs → chunk-RVGSVQWT.mjs} +1 -1
- package/dist/{chunk-Z74NNER4.cjs → chunk-T4M52BA5.cjs} +164 -159
- package/dist/{chunk-PCXIJKPM.mjs → chunk-TNBJ4LZG.mjs} +2 -2
- package/dist/{chunk-PAKCHVUS.mjs → chunk-TPA2PV5J.mjs} +3 -35
- package/dist/{chunk-Y2YBNQ3D.cjs → chunk-TRIDJQ6A.cjs} +6 -6
- package/dist/{chunk-PVJX4UPA.cjs → chunk-TZOGZKI7.cjs} +411 -295
- package/dist/{chunk-O27PLNQZ.cjs → chunk-UJ3R2AH2.cjs} +4 -4
- package/dist/{chunk-BPNOYILC.cjs → chunk-UVV3I5QA.cjs} +3 -35
- package/dist/{chunk-CBDRR3J3.mjs → chunk-VHHLKIDZ.mjs} +166 -50
- package/dist/{chunk-T4TBK5NY.mjs → chunk-VQ4NWOWO.mjs} +2 -2
- package/dist/{chunk-ZZ2QKCKW.mjs → chunk-WAY6LOQH.mjs} +1 -1
- package/dist/chunk-WBTHHTBO.cjs +88 -0
- package/dist/{chunk-IWRLV46X.cjs → chunk-WMTBBQHY.cjs} +4 -4
- package/dist/{chunk-LWWDTBGL.cjs → chunk-WNXVWXG3.cjs} +2 -2
- package/dist/{chunk-CI4UNQHO.cjs → chunk-XBSKPLHF.cjs} +2 -2
- package/dist/{chunk-QAS7KE7J.cjs → chunk-Y5TOT5F6.cjs} +5 -5
- package/dist/{chunk-ANXU3D32.cjs → chunk-YD4J37RN.cjs} +403 -32
- package/dist/{chunk-XICXQXYE.mjs → chunk-YUW7F6SK.mjs} +2 -2
- package/dist/chunk-ZAUOOGER.mjs +3704 -0
- package/dist/{chunk-DPE53XWL.mjs → chunk-ZEXE4TGY.mjs} +1 -1
- package/dist/chunk-ZIHWAN55.cjs +34 -0
- package/dist/{chunk-GVOMPU3Y.cjs → chunk-ZQQK4U66.cjs} +213 -34
- package/dist/{chunk-S2NUYHRY.mjs → chunk-ZX2JHEWW.mjs} +384 -13
- package/dist/{client-component.d-CSEFlHfG.d.mts → client-component.d-D74pqdea.d.mts} +2 -2
- package/dist/{client-component.d-CQLvqLAJ.d.ts → client-component.d-D8VcypQA.d.ts} +2 -2
- package/dist/{client-plugins.d-BgPUYPc9.d.ts → client-plugins.d-CXElzotB.d.ts} +8 -1
- package/dist/{client-plugins.d-BTF0gZm4.d.mts → client-plugins.d-D4-6hNx7.d.mts} +8 -1
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/desktop.d.mts +2 -2
- package/dist/desktop.d.ts +2 -2
- package/dist/{devtools-HDKTYIZF.mjs → devtools-PUVZB3F2.mjs} +7 -6
- package/dist/{devtools-ZHN5JLVI.cjs → devtools-SGYOG36E.cjs} +8 -7
- package/dist/docs.cjs +10 -9
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +9 -8
- package/dist/environment/vite.cjs +9 -2
- package/dist/environment/vite.d.mts +3 -0
- package/dist/environment/vite.d.ts +3 -0
- package/dist/environment/vite.mjs +8 -1
- package/dist/index.cjs +29 -27
- package/dist/{index.d-Coow7bD4.d.ts → index.d-A_x10zGS.d.ts} +1 -1
- package/dist/{index.d-Dbjx0ku7.d.mts → index.d-SSgYDv4D.d.mts} +1 -1
- package/dist/index.d.mts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.mjs +28 -26
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +27 -25
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +26 -24
- package/dist/internal/cli-runtime.cjs +10 -9
- package/dist/internal/cli-runtime.mjs +9 -8
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.d.mts +4 -4
- package/dist/internal/client-runtime.d.ts +4 -4
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +9 -8
- package/dist/internal/config-runtime.d.mts +4 -4
- package/dist/internal/config-runtime.d.ts +4 -4
- package/dist/internal/config-runtime.mjs +8 -7
- package/dist/internal/infra-analytics-runtime.cjs +9 -9
- package/dist/internal/infra-analytics-runtime.mjs +7 -7
- package/dist/internal/native-server-fns.cjs +5 -4
- package/dist/internal/native-server-fns.mjs +4 -3
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +11 -11
- package/dist/internal/production-runtime.d.mts +20 -12
- package/dist/internal/production-runtime.d.ts +20 -12
- package/dist/internal/production-runtime.mjs +10 -10
- package/dist/markdown.cjs +2 -2
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/mobile.d.mts +2 -2
- package/dist/mobile.d.ts +2 -2
- package/dist/{native-tree-Z2WYUJEV.cjs → native-tree-HE2FLS72.cjs} +3 -3
- package/dist/{native-tree-AS5L3ID3.mjs → native-tree-YF2DSPKM.mjs} +2 -2
- package/dist/{navigation-delegate.d-Ca_BV0Wu.d.mts → navigation-delegate.d-DQVYKoaZ.d.mts} +1 -1
- package/dist/{navigation-delegate.d-aHiPI6GL.d.ts → navigation-delegate.d-GghbHJuK.d.ts} +1 -1
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/plugin.cjs +18 -17
- package/dist/plugin.d.mts +3 -3
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.mjs +17 -16
- package/dist/{production-runtime.d-C0rF7a10.d.ts → production-runtime.d-Bzns3NW9.d.ts} +1 -1
- package/dist/{production-runtime.d-CnAsSWgF.d.mts → production-runtime.d-DiFa5vHW.d.mts} +1 -1
- package/dist/{render-plan.d-BxeITFT1.d.ts → render-plan.d-CL_Ikfg_.d.ts} +1 -1
- package/dist/{render-plan.d-Z-93m5GZ.d.mts → render-plan.d-CcF0MeCf.d.mts} +1 -1
- package/dist/renderer-client.d.mts +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/{request.d-X7Q1vmGF.d.ts → request.d-B1RnTLri.d.ts} +1 -1
- package/dist/{request.d-8_fMFNEb.d.mts → request.d-DarDOCk9.d.mts} +1 -1
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/{route-rendering.d-BUr3Jp8S.d.ts → route-rendering.d-BTUYCIj4.d.ts} +1 -1
- package/dist/{route-rendering.d-BInmBmul.d.mts → route-rendering.d-D_2Ual0-.d.mts} +1 -1
- package/dist/{router.d-crorSRiW.d.ts → router.d-CMANF6da.d.ts} +1 -1
- package/dist/{router.d-CZQmbpHx.d.mts → router.d-Cuv1jntg.d.mts} +1 -1
- package/dist/{routes.d-BknKQcTu.d.ts → routes.d-B6yFe6jm.d.ts} +1 -1
- package/dist/{routes.d-D1IrO9KK.d.mts → routes.d-c2HKfrfL.d.mts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/{rsc-pipeline-3MPRULGA.mjs → rsc-pipeline-T3PWURLJ.mjs} +9 -8
- package/dist/{rsc-pipeline-RHEZNBFQ.cjs → rsc-pipeline-V4ANLRAA.cjs} +10 -9
- package/dist/{runtime-OZKFZQCU.cjs → runtime-5AROV2C3.cjs} +29 -17
- package/dist/{runtime-X5UR7VHP.mjs → runtime-LRIQ3XH7.mjs} +26 -14
- package/dist/{runtime.d-CCsjTZJW.d.ts → runtime.d-C3RQUj6_.d.ts} +1 -1
- package/dist/{runtime.d-CETtpLb-.d.mts → runtime.d-wvh4ngU0.d.mts} +1 -1
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server.cjs +42 -41
- package/dist/server.d.mts +9 -9
- package/dist/server.d.ts +9 -9
- package/dist/server.mjs +26 -25
- package/dist/{spa-router.d-CtSHzXlC.d.mts → spa-router.d-WU_qS5gJ.d.mts} +2 -2
- package/dist/{spa-router.d-CCADbSqJ.d.ts → spa-router.d-m8H_Kl_B.d.ts} +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{utils.d-CjyE-npA.d.ts → utils.d-C9dQD5Zg.d.ts} +1 -1
- package/dist/{utils.d-zFPHKFFJ.d.mts → utils.d-W9IiEqmW.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +21 -19
- package/dist/vite.d.mts +4 -4
- package/dist/vite.d.ts +4 -4
- package/dist/vite.mjs +20 -18
- package/package.json +1 -1
- package/dist/analyzer-KEA5JVDR.cjs +0 -15
- package/dist/chunk-NK2VWS7P.cjs +0 -954
- package/dist/chunk-ZQ5BDNKW.mjs +0 -954
|
@@ -3,19 +3,26 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkWBTHHTBOcjs = require('./chunk-WBTHHTBO.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
|
|
7
14
|
|
|
8
15
|
var _chunkV727H3RIcjs = require('./chunk-V727H3RI.cjs');
|
|
9
16
|
|
|
10
17
|
|
|
11
|
-
var
|
|
18
|
+
var _chunkA3G5IY2Wcjs = require('./chunk-A3G5IY2W.cjs');
|
|
12
19
|
|
|
13
20
|
// src/mobile/analyzer.ts
|
|
14
21
|
var _crypto = require('crypto');
|
|
15
22
|
var _fs = require('fs');
|
|
16
23
|
var _promises = require('fs/promises');
|
|
17
24
|
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
18
|
-
var ANALYZER_VERSION = `
|
|
25
|
+
var ANALYZER_VERSION = `6:${_chunkA3G5IY2Wcjs.FARM_VERSION}`;
|
|
19
26
|
var INTRINSIC_KINDS = {};
|
|
20
27
|
for (const tag of "div section main article header footer nav aside figure hr li".split(" ")) {
|
|
21
28
|
INTRINSIC_KINDS[tag] = "View";
|
|
@@ -29,6 +36,8 @@ Object.assign(INTRINSIC_KINDS, {
|
|
|
29
36
|
a: "Pressable",
|
|
30
37
|
input: "TextInput",
|
|
31
38
|
textarea: "TextInput",
|
|
39
|
+
// Native-tier screens submit forms as a browser would (native-tree.ts).
|
|
40
|
+
form: "View",
|
|
32
41
|
ul: "List",
|
|
33
42
|
ol: "List"
|
|
34
43
|
});
|
|
@@ -162,6 +171,8 @@ var MAPPED_COMPONENTS = {
|
|
|
162
171
|
};
|
|
163
172
|
var SERVER_FN_FACTORIES = /* @__PURE__ */ new Set(["createServerFn", "createServerQuery"]);
|
|
164
173
|
var SCRIPT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
174
|
+
var COMPONENT_EXTENSIONS = [".vue", ".svelte"];
|
|
175
|
+
var isModuleFile = (file) => [...SCRIPT_EXTENSIONS, ...COMPONENT_EXTENSIONS].some((extension) => file.endsWith(extension));
|
|
165
176
|
var STYLE_FILE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)(?:\?.*)?$/i;
|
|
166
177
|
var ASSET_FILE = /\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|json|woff2?|ttf|otf|mp3|wav|txt)(?:\?.*)?$/i;
|
|
167
178
|
var STYLE_PROPERTIES = new Set(
|
|
@@ -310,7 +321,7 @@ var SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
|
310
321
|
"typeArguments",
|
|
311
322
|
"decorators"
|
|
312
323
|
]);
|
|
313
|
-
function analyzeSource(file, source, parseSync) {
|
|
324
|
+
function analyzeSource(file, source, parseSync, lang = scriptLang(file)) {
|
|
314
325
|
const facts = {
|
|
315
326
|
imports: [],
|
|
316
327
|
blockers: [],
|
|
@@ -333,15 +344,51 @@ function analyzeSource(file, source, parseSync) {
|
|
|
333
344
|
});
|
|
334
345
|
};
|
|
335
346
|
const needsDevice = (node, message) => block(node, "client-logic", message, "native");
|
|
336
|
-
|
|
347
|
+
let formDepth = 0;
|
|
348
|
+
const serverFunctions = /* @__PURE__ */ new Set();
|
|
349
|
+
const serverActionReference = (expression) => {
|
|
350
|
+
if (_optionalChain([expression, 'optionalAccess', _2 => _2.type]) === "Identifier") {
|
|
351
|
+
if (serverFunctions.has(expression.name)) return {};
|
|
352
|
+
const binding = imported.get(expression.name);
|
|
353
|
+
return binding ? { source: binding.source } : void 0;
|
|
354
|
+
}
|
|
355
|
+
if (_optionalChain([expression, 'optionalAccess', _3 => _3.type]) === "MemberExpression" && expression.object.type === "Identifier") {
|
|
356
|
+
const binding = imported.get(expression.object.name);
|
|
357
|
+
return _optionalChain([binding, 'optionalAccess', _4 => _4.name]) === "*" ? { source: binding.source } : void 0;
|
|
358
|
+
}
|
|
359
|
+
return void 0;
|
|
360
|
+
};
|
|
361
|
+
const result = parseSync(file, source, { lang });
|
|
337
362
|
if (result.errors.length > 0) {
|
|
338
363
|
const error = result.errors[0];
|
|
339
|
-
const offset = _nullishCoalesce(_optionalChain([error, 'access',
|
|
364
|
+
const offset = _nullishCoalesce(_optionalChain([error, 'access', _5 => _5.labels, 'optionalAccess', _6 => _6[0], 'optionalAccess', _7 => _7.start]), () => ( 0));
|
|
340
365
|
facts.blockers.push({ ...locate(starts, offset), rule: "parse-error", message: error.message });
|
|
341
366
|
return facts;
|
|
342
367
|
}
|
|
343
368
|
const program = result.program;
|
|
344
369
|
const wins = /* @__PURE__ */ new Set();
|
|
370
|
+
const usesServer = (body) => _optionalChain([body, 'optionalAccess', _8 => _8.type]) === "BlockStatement" && body.body.some(
|
|
371
|
+
(statement) => statement.type === "ExpressionStatement" && statement.directive === "use server"
|
|
372
|
+
);
|
|
373
|
+
const findServerFunctions = (node) => {
|
|
374
|
+
if (!node || typeof node !== "object") return;
|
|
375
|
+
if (Array.isArray(node)) {
|
|
376
|
+
for (const child of node) findServerFunctions(child);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const current = node;
|
|
380
|
+
if (current.type === "FunctionDeclaration" && current.id && usesServer(current.body)) {
|
|
381
|
+
serverFunctions.add(current.id.name);
|
|
382
|
+
} else if (current.type === "VariableDeclarator" && _optionalChain([current, 'access', _9 => _9.id, 'optionalAccess', _10 => _10.type]) === "Identifier" && (_optionalChain([current, 'access', _11 => _11.init, 'optionalAccess', _12 => _12.type]) === "ArrowFunctionExpression" || _optionalChain([current, 'access', _13 => _13.init, 'optionalAccess', _14 => _14.type]) === "FunctionExpression") && usesServer(current.init.body)) {
|
|
383
|
+
serverFunctions.add(current.id.name);
|
|
384
|
+
}
|
|
385
|
+
for (const [key, value] of Object.entries(current)) {
|
|
386
|
+
if (key !== "type" && key !== "start" && key !== "end" && value && typeof value === "object") {
|
|
387
|
+
findServerFunctions(value);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
findServerFunctions(program);
|
|
345
392
|
const imported = /* @__PURE__ */ new Map();
|
|
346
393
|
const topLevel = /* @__PURE__ */ new Set();
|
|
347
394
|
const declared = /* @__PURE__ */ new Set();
|
|
@@ -381,10 +428,10 @@ function analyzeSource(file, source, parseSync) {
|
|
|
381
428
|
}
|
|
382
429
|
const declaration = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? statement.declaration : statement;
|
|
383
430
|
if (!declaration) continue;
|
|
384
|
-
if (_optionalChain([declaration, 'access',
|
|
431
|
+
if (_optionalChain([declaration, 'access', _15 => _15.id, 'optionalAccess', _16 => _16.name]) && /Function|Class/.test(declaration.type)) {
|
|
385
432
|
topLevel.add(declaration.id.name);
|
|
386
433
|
}
|
|
387
|
-
if (_optionalChain([declaration, 'access',
|
|
434
|
+
if (_optionalChain([declaration, 'access', _17 => _17.id, 'optionalAccess', _18 => _18.name]) && declaration.async) asyncFunctions.add(declaration.id.name);
|
|
388
435
|
if (statement.type === "ExportDefaultDeclaration" && declaration.type === "Identifier") {
|
|
389
436
|
defaultName = declaration.name;
|
|
390
437
|
}
|
|
@@ -392,10 +439,10 @@ function analyzeSource(file, source, parseSync) {
|
|
|
392
439
|
for (const declarator of declaration.declarations) {
|
|
393
440
|
if (declarator.id.type !== "Identifier") continue;
|
|
394
441
|
const init = declarator.init;
|
|
395
|
-
if (_optionalChain([init, 'optionalAccess',
|
|
396
|
-
const callee = _optionalChain([init, 'optionalAccess',
|
|
397
|
-
const calleeName = _optionalChain([callee, 'optionalAccess',
|
|
398
|
-
if (/Function/.test(_nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
442
|
+
if (_optionalChain([init, 'optionalAccess', _19 => _19.async])) asyncFunctions.add(declarator.id.name);
|
|
443
|
+
const callee = _optionalChain([init, 'optionalAccess', _20 => _20.type]) === "CallExpression" ? init.callee : void 0;
|
|
444
|
+
const calleeName = _optionalChain([callee, 'optionalAccess', _21 => _21.type]) === "MemberExpression" ? callee.property.name : _optionalChain([callee, 'optionalAccess', _22 => _22.name]);
|
|
445
|
+
if (/Function/.test(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _23 => _23.type]), () => ( ""))) || calleeName && /^(?:memo|forwardRef|lazy)$/.test(calleeName)) {
|
|
399
446
|
topLevel.add(declarator.id.name);
|
|
400
447
|
}
|
|
401
448
|
}
|
|
@@ -428,7 +475,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
428
475
|
const binding = imported.get(root);
|
|
429
476
|
if (binding) {
|
|
430
477
|
const member = tag.includes(".") ? binding.name === "*" ? tag.split(".")[1] : "" : binding.name;
|
|
431
|
-
kind = _optionalChain([MAPPED_COMPONENTS, 'access',
|
|
478
|
+
kind = _optionalChain([MAPPED_COMPONENTS, 'access', _24 => _24[binding.source], 'optionalAccess', _25 => _25[member]]);
|
|
432
479
|
if (!kind) {
|
|
433
480
|
const fromApp = /^(?:\.|\/|@\/|~|#)/.test(binding.source);
|
|
434
481
|
if (!fromApp) {
|
|
@@ -464,6 +511,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
464
511
|
const props = {};
|
|
465
512
|
const style = [];
|
|
466
513
|
const events = [];
|
|
514
|
+
let submits = false;
|
|
467
515
|
for (const attribute of opening.attributes) {
|
|
468
516
|
if (attribute.type === "JSXSpreadAttribute") {
|
|
469
517
|
if (isIntrinsic)
|
|
@@ -486,11 +534,23 @@ function analyzeSource(file, source, parseSync) {
|
|
|
486
534
|
continue;
|
|
487
535
|
}
|
|
488
536
|
if ((name === "action" || name === "formAction") && isIntrinsic) {
|
|
489
|
-
|
|
537
|
+
if (staticString(value) === void 0) {
|
|
538
|
+
const reference = serverActionReference(
|
|
539
|
+
_optionalChain([value, 'optionalAccess', _26 => _26.type]) === "JSXExpressionContainer" ? value.expression : void 0
|
|
540
|
+
);
|
|
541
|
+
if (reference) {
|
|
542
|
+
(_nullishCoalesce(facts.formActions, () => ( (facts.formActions = [])))).push({
|
|
543
|
+
...reference.source !== void 0 ? { source: reference.source } : {},
|
|
544
|
+
...locate(starts, attribute.start),
|
|
545
|
+
message: `${name} on <${tag}>`
|
|
546
|
+
});
|
|
547
|
+
} else block(attribute, "form-action", `${name} on <${tag}>`);
|
|
548
|
+
}
|
|
549
|
+
submits = true;
|
|
490
550
|
continue;
|
|
491
551
|
}
|
|
492
552
|
if (/^on[A-Z]/.test(name)) {
|
|
493
|
-
if (isIntrinsic && kind && !_optionalChain([MAPPED_EVENTS, 'access',
|
|
553
|
+
if (isIntrinsic && kind && !_optionalChain([MAPPED_EVENTS, 'access', _27 => _27[kind], 'optionalAccess', _28 => _28.has, 'call', _29 => _29(name)])) {
|
|
494
554
|
block(attribute, "dom-event", `${name} on <${tag}> has no native event`);
|
|
495
555
|
} else {
|
|
496
556
|
needsDevice(attribute, `${name} on <${tag}> runs on the device`);
|
|
@@ -518,7 +578,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
518
578
|
continue;
|
|
519
579
|
}
|
|
520
580
|
if (name === "style") {
|
|
521
|
-
const expression = _optionalChain([value, 'optionalAccess',
|
|
581
|
+
const expression = _optionalChain([value, 'optionalAccess', _30 => _30.type]) === "JSXExpressionContainer" ? value.expression : null;
|
|
522
582
|
if (!expression || expression.type !== "ObjectExpression") {
|
|
523
583
|
block(attribute, "runtime-style", `<${tag}> style is not an object literal`);
|
|
524
584
|
continue;
|
|
@@ -560,7 +620,8 @@ function analyzeSource(file, source, parseSync) {
|
|
|
560
620
|
}
|
|
561
621
|
if (tag === "input" && name === "type") {
|
|
562
622
|
const type = staticString(value);
|
|
563
|
-
|
|
623
|
+
const formType = formDepth > 0 && (type === "hidden" || type === "submit");
|
|
624
|
+
if (!formType && (type === void 0 || !INPUT_TYPES.has(type))) {
|
|
564
625
|
block(
|
|
565
626
|
attribute,
|
|
566
627
|
"unmapped-element",
|
|
@@ -570,13 +631,29 @@ function analyzeSource(file, source, parseSync) {
|
|
|
570
631
|
}
|
|
571
632
|
const literal = value === null ? true : staticString(value);
|
|
572
633
|
if (literal !== void 0) props[name] = literal;
|
|
573
|
-
else if (_optionalChain([value, 'optionalAccess',
|
|
634
|
+
else if (_optionalChain([value, 'optionalAccess', _31 => _31.type]) === "JSXExpressionContainer" && value.expression.type === "Literal" && (typeof value.expression.value === "number" || typeof value.expression.value === "boolean")) {
|
|
574
635
|
props[name] = value.expression.value;
|
|
575
636
|
} else props[name] = "{expr}";
|
|
576
637
|
}
|
|
577
638
|
if (kind === "TextInput" && events.some((event) => event === "onChange" || event === "onInput")) {
|
|
578
639
|
wins.add("input");
|
|
579
640
|
}
|
|
641
|
+
const inForm = formDepth > 0;
|
|
642
|
+
const buttonType = tag === "button" ? _nullishCoalesce(props.type, () => ( "submit")) : void 0;
|
|
643
|
+
if (isIntrinsic && (tag === "button" || kind === "TextInput") && events.length === 0 && !submits && props.type !== "hidden" && (!inForm || buttonType !== void 0 && buttonType !== "submit")) {
|
|
644
|
+
block(
|
|
645
|
+
opening,
|
|
646
|
+
"inert-control",
|
|
647
|
+
inForm ? `<button type="${String(buttonType)}"> does nothing on a native-tier screen` : `<${tag}> has no link or form to submit on a native-tier screen`,
|
|
648
|
+
"native"
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
if (isIntrinsic && tag === "form") {
|
|
652
|
+
const method = typeof props.method === "string" ? props.method.toLowerCase() : "get";
|
|
653
|
+
if (props.method === "{expr}" || method !== "get" && method !== "post") {
|
|
654
|
+
block(opening, "form-action", `<form method="${String(props.method)}">`, "native");
|
|
655
|
+
}
|
|
656
|
+
}
|
|
580
657
|
if (Object.keys(props).length > 0) node.props = props;
|
|
581
658
|
if (style.length > 0) node.style = style;
|
|
582
659
|
if (events.length > 0) node.events = events;
|
|
@@ -593,7 +670,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
593
670
|
return void 0;
|
|
594
671
|
case "JSXElement": {
|
|
595
672
|
const ui = classifyElement(node);
|
|
596
|
-
if (INLINE_BOX_TAGS.has(ui.tag) && parent && parent.kind !== "Fragment" && parent.kind !== "Component" && !_optionalChain([parent, 'access',
|
|
673
|
+
if (INLINE_BOX_TAGS.has(ui.tag) && parent && parent.kind !== "Fragment" && parent.kind !== "Component" && !_optionalChain([parent, 'access', _32 => _32.style, 'optionalAccess', _33 => _33.some, 'call', _34 => _34((token) => token === "flex" || token === "inline-flex")]) && hasBoxStyle(ui)) {
|
|
597
674
|
block(
|
|
598
675
|
node.openingElement,
|
|
599
676
|
"class-name",
|
|
@@ -604,7 +681,10 @@ function analyzeSource(file, source, parseSync) {
|
|
|
604
681
|
for (const attribute of node.openingElement.attributes) {
|
|
605
682
|
visit(attribute.type === "JSXSpreadAttribute" ? attribute.argument : attribute.value);
|
|
606
683
|
}
|
|
684
|
+
const form = ui.tag === "form";
|
|
685
|
+
if (form) formDepth += 1;
|
|
607
686
|
visitChildren(node.children, ui);
|
|
687
|
+
if (form) formDepth -= 1;
|
|
608
688
|
append(parent, ui);
|
|
609
689
|
return ui;
|
|
610
690
|
}
|
|
@@ -684,7 +764,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
684
764
|
if (calleeName === "setInterval") wins.add("timer");
|
|
685
765
|
if (callee.type === "Identifier" && SERVER_FN_FACTORIES.has(callee.name)) {
|
|
686
766
|
const binding = imported.get(callee.name);
|
|
687
|
-
if (_optionalChain([binding, 'optionalAccess',
|
|
767
|
+
if (_optionalChain([binding, 'optionalAccess', _35 => _35.source, 'access', _36 => _36.startsWith, 'call', _37 => _37("@farm.js/core")])) callsServerFactory = true;
|
|
688
768
|
}
|
|
689
769
|
if (calleeName === "map" && callee.type === "MemberExpression" && parent) {
|
|
690
770
|
const before = facts.elements.total;
|
|
@@ -749,11 +829,11 @@ function analyzeSource(file, source, parseSync) {
|
|
|
749
829
|
const isDefault = statement.type === "ExportDefaultDeclaration";
|
|
750
830
|
const declaration = statement.type === "ExportNamedDeclaration" || isDefault ? statement.declaration : statement;
|
|
751
831
|
const roots = [];
|
|
752
|
-
if (_optionalChain([declaration, 'optionalAccess',
|
|
832
|
+
if (_optionalChain([declaration, 'optionalAccess', _38 => _38.type]) === "FunctionDeclaration" || isDefault && /Function/.test(_nullishCoalesce(_optionalChain([declaration, 'optionalAccess', _39 => _39.type]), () => ( "")))) {
|
|
753
833
|
roots.push([isDefault ? "default" : declaration.id.name, declaration]);
|
|
754
|
-
} else if (_optionalChain([declaration, 'optionalAccess',
|
|
834
|
+
} else if (_optionalChain([declaration, 'optionalAccess', _40 => _40.type]) === "VariableDeclaration") {
|
|
755
835
|
for (const declarator of declaration.declarations) {
|
|
756
|
-
if (declarator.id.type === "Identifier" && /Function/.test(_nullishCoalesce(_optionalChain([declarator, 'access',
|
|
836
|
+
if (declarator.id.type === "Identifier" && /Function/.test(_nullishCoalesce(_optionalChain([declarator, 'access', _41 => _41.init, 'optionalAccess', _42 => _42.type]), () => ( "")))) {
|
|
757
837
|
roots.push([declarator.id.name, declarator]);
|
|
758
838
|
}
|
|
759
839
|
}
|
|
@@ -769,7 +849,7 @@ function analyzeSource(file, source, parseSync) {
|
|
|
769
849
|
facts.components[name] = holder.children.length === 1 ? holder.children[0] : holder;
|
|
770
850
|
}
|
|
771
851
|
}
|
|
772
|
-
if (isDefault && _optionalChain([declaration, 'optionalAccess',
|
|
852
|
+
if (isDefault && _optionalChain([declaration, 'optionalAccess', _43 => _43.type]) === "Identifier") {
|
|
773
853
|
facts.components.default = { kind: "Component", tag: declaration.name };
|
|
774
854
|
}
|
|
775
855
|
}
|
|
@@ -780,6 +860,278 @@ function analyzeSource(file, source, parseSync) {
|
|
|
780
860
|
facts.blockers.sort((left, right) => left.line - right.line || left.column - right.column);
|
|
781
861
|
return facts;
|
|
782
862
|
}
|
|
863
|
+
var COMPONENT_STRUCTURE = /* @__PURE__ */ new Set([
|
|
864
|
+
"template",
|
|
865
|
+
"slot",
|
|
866
|
+
"Transition",
|
|
867
|
+
"TransitionGroup",
|
|
868
|
+
"KeepAlive",
|
|
869
|
+
"Suspense",
|
|
870
|
+
"svelte:head",
|
|
871
|
+
"svelte:fragment",
|
|
872
|
+
"svelte:options",
|
|
873
|
+
"svelte:window",
|
|
874
|
+
"svelte:body",
|
|
875
|
+
"svelte:document",
|
|
876
|
+
"svelte:boundary"
|
|
877
|
+
]);
|
|
878
|
+
var COMPONENT_DYNAMIC = /* @__PURE__ */ new Set(["component", "svelte:element", "svelte:component", "Teleport"]);
|
|
879
|
+
var VOID_ELEMENTS = new Set(
|
|
880
|
+
"area base br col embed hr img input link meta source track wbr".split(" ")
|
|
881
|
+
);
|
|
882
|
+
function analyzeComponentSource(file, source, parseSync) {
|
|
883
|
+
const blocks = _chunkWBTHHTBOcjs.readFarmComponentBlocks.call(void 0, file, source);
|
|
884
|
+
const name = blocks.kind === "vue" ? "Vue" : "Svelte";
|
|
885
|
+
const scripts = _chunkWBTHHTBOcjs.keepFarmComponentRanges.call(void 0, source, blocks.scripts);
|
|
886
|
+
const typed = blocks.scripts.some((script) => script.attributes.lang === "tsx") ? "tsx" : "ts";
|
|
887
|
+
const facts = analyzeSource(file, scripts, parseSync, typed);
|
|
888
|
+
facts.blockers = facts.blockers.filter((blocker) => blocker.rule !== "client-logic");
|
|
889
|
+
const starts = lineStarts(source);
|
|
890
|
+
const block = (offset, rule, message, only) => facts.blockers.push({ ...locate(starts, offset), rule, message, ...only ? { only } : {} });
|
|
891
|
+
facts.blockers.push({
|
|
892
|
+
line: 1,
|
|
893
|
+
column: 1,
|
|
894
|
+
rule: "renderer-component",
|
|
895
|
+
message: `a ${name} component has no React Native port`,
|
|
896
|
+
only: "react-native"
|
|
897
|
+
});
|
|
898
|
+
for (const script of _chunkWBTHHTBOcjs.farmComponentModuleScripts.call(void 0, blocks)) {
|
|
899
|
+
const hydrate = /\bexport\s+const\s+hydrate\s*=\s*true\b/.exec(
|
|
900
|
+
source.slice(script.start, script.end)
|
|
901
|
+
);
|
|
902
|
+
if (hydrate) {
|
|
903
|
+
block(
|
|
904
|
+
script.start + hydrate.index,
|
|
905
|
+
"client-logic",
|
|
906
|
+
"it exports hydrate = true, which hydrates the page in the browser",
|
|
907
|
+
"native"
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
const styles = blocks.styles.filter((style) => !style.attributes.lang || style.attributes.lang === "css").map((style) => source.slice(style.start, style.end));
|
|
912
|
+
if (styles.length > 0) facts.styles = styles;
|
|
913
|
+
for (const style of blocks.styles) {
|
|
914
|
+
if (style.attributes.lang && style.attributes.lang !== "css") {
|
|
915
|
+
block(
|
|
916
|
+
style.start,
|
|
917
|
+
"css-import",
|
|
918
|
+
`<style lang="${String(style.attributes.lang)}"> is not CSS`
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
const imported = /* @__PURE__ */ new Set();
|
|
923
|
+
for (const script of blocks.scripts) {
|
|
924
|
+
const text = source.slice(script.start, script.end);
|
|
925
|
+
for (const match of text.matchAll(/\bimport\s+(?:type\s+)?([\w$]+)\s*(?:,|from\b)/g)) {
|
|
926
|
+
imported.add(match[1]);
|
|
927
|
+
}
|
|
928
|
+
for (const match of text.matchAll(/\bimport\s+(?:[\w$]+\s*,\s*)?\{([^}]*)\}/g)) {
|
|
929
|
+
for (const part of match[1].split(",")) {
|
|
930
|
+
const local = _optionalChain([part, 'access', _44 => _44.trim, 'call', _45 => _45(), 'access', _46 => _46.split, 'call', _47 => _47(/\s+as\s+/), 'access', _48 => _48.pop, 'call', _49 => _49(), 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()]);
|
|
931
|
+
if (local) imported.add(local);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
const pascal = (tag) => tag.replace(/(^|-)([a-z])/g, (_, __, letter) => letter.toUpperCase());
|
|
936
|
+
let formDepth = 0;
|
|
937
|
+
const open = [];
|
|
938
|
+
for (const range of blocks.markup) {
|
|
939
|
+
const markup = source.slice(range.start, range.end);
|
|
940
|
+
let index = 0;
|
|
941
|
+
while (index < markup.length) {
|
|
942
|
+
const at = range.start + index;
|
|
943
|
+
if (markup.startsWith("<!--", index)) {
|
|
944
|
+
const end = markup.indexOf("-->", index + 4);
|
|
945
|
+
index = end === -1 ? markup.length : end + 3;
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
if (markup[index] === "{") {
|
|
949
|
+
const end = closeBrace(markup, index);
|
|
950
|
+
if (blocks.kind === "svelte" && /^\{@html\b/.test(markup.slice(index))) {
|
|
951
|
+
block(at, "dangerously-set-inner-html", "{@html} renders raw HTML");
|
|
952
|
+
}
|
|
953
|
+
index = end;
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
if (markup[index] !== "<") {
|
|
957
|
+
index += 1;
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
const closing = markup[index + 1] === "/";
|
|
961
|
+
const nameMatch = /^[A-Za-z][\w:.-]*/.exec(markup.slice(index + (closing ? 2 : 1)));
|
|
962
|
+
if (!nameMatch) {
|
|
963
|
+
index += 1;
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
const tag = nameMatch[0];
|
|
967
|
+
let cursor = index + (closing ? 2 : 1) + tag.length;
|
|
968
|
+
const attributes = [];
|
|
969
|
+
let selfClosing = false;
|
|
970
|
+
while (cursor < markup.length && markup[cursor] !== ">") {
|
|
971
|
+
const char = markup[cursor];
|
|
972
|
+
if (/\s/.test(char)) {
|
|
973
|
+
cursor += 1;
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
if (char === "/" && markup[cursor + 1] === ">") {
|
|
977
|
+
selfClosing = true;
|
|
978
|
+
cursor += 1;
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
if (char === "{") {
|
|
982
|
+
attributes.push({ name: "{", dynamic: true, offset: range.start + cursor });
|
|
983
|
+
cursor = closeBrace(markup, cursor);
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
const attrName = _nullishCoalesce(_optionalChain([/^[^\s=/>]+/, 'access', _52 => _52.exec, 'call', _53 => _53(markup.slice(cursor)), 'optionalAccess', _54 => _54[0]]), () => ( char));
|
|
987
|
+
const attrOffset = range.start + cursor;
|
|
988
|
+
cursor += attrName.length;
|
|
989
|
+
while (/\s/.test(_nullishCoalesce(markup[cursor], () => ( "")))) cursor += 1;
|
|
990
|
+
let value2;
|
|
991
|
+
let braced = false;
|
|
992
|
+
if (markup[cursor] === "=") {
|
|
993
|
+
cursor += 1;
|
|
994
|
+
while (/\s/.test(_nullishCoalesce(markup[cursor], () => ( "")))) cursor += 1;
|
|
995
|
+
const quote = markup[cursor];
|
|
996
|
+
if (quote === '"' || quote === "'") {
|
|
997
|
+
const end = markup.indexOf(quote, cursor + 1);
|
|
998
|
+
value2 = markup.slice(cursor + 1, end === -1 ? markup.length : end);
|
|
999
|
+
cursor = end === -1 ? markup.length : end + 1;
|
|
1000
|
+
} else if (quote === "{") {
|
|
1001
|
+
const end = closeBrace(markup, cursor);
|
|
1002
|
+
value2 = markup.slice(cursor, end);
|
|
1003
|
+
braced = true;
|
|
1004
|
+
cursor = end;
|
|
1005
|
+
} else {
|
|
1006
|
+
value2 = _nullishCoalesce(_optionalChain([/^[^\s>]+/, 'access', _55 => _55.exec, 'call', _56 => _56(markup.slice(cursor)), 'optionalAccess', _57 => _57[0]]), () => ( ""));
|
|
1007
|
+
cursor += value2.length;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
const dynamic = braced || attrName.startsWith(":") || attrName.startsWith("v-bind:") || attrName.startsWith("@") || attrName.startsWith("v-on:") || blocks.kind === "svelte" && value2 !== void 0 && /\{/.test(value2);
|
|
1011
|
+
attributes.push({ name: attrName, value: value2, dynamic, offset: attrOffset });
|
|
1012
|
+
}
|
|
1013
|
+
index = cursor + 1;
|
|
1014
|
+
if (closing) {
|
|
1015
|
+
const position = open.lastIndexOf(tag);
|
|
1016
|
+
if (position !== -1) {
|
|
1017
|
+
for (const closed of open.splice(position)) if (closed === "form") formDepth -= 1;
|
|
1018
|
+
}
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
const element = !selfClosing && !VOID_ELEMENTS.has(tag.toLowerCase());
|
|
1022
|
+
if (element) open.push(tag);
|
|
1023
|
+
if (tag === "form" && element) formDepth += 1;
|
|
1024
|
+
for (const attribute of attributes) {
|
|
1025
|
+
if (attribute.name === "v-html") {
|
|
1026
|
+
block(attribute.offset, "dangerously-set-inner-html", "v-html renders raw HTML");
|
|
1027
|
+
}
|
|
1028
|
+
if (attribute.name.toLowerCase() === "contenteditable") {
|
|
1029
|
+
block(attribute.offset, "content-editable", "contentEditable");
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
if (COMPONENT_STRUCTURE.has(tag)) continue;
|
|
1033
|
+
if (COMPONENT_DYNAMIC.has(tag) || attributes.some((attribute) => attribute.name === "is")) {
|
|
1034
|
+
block(at, "dynamic-component", `<${tag}> picks what it renders at runtime`);
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
const intrinsic = /^[a-z][a-z0-9]*$/.test(tag);
|
|
1038
|
+
if (!intrinsic) {
|
|
1039
|
+
if (!imported.has(tag) && !imported.has(pascal(tag))) {
|
|
1040
|
+
block(at, "dynamic-component", `<${tag}> is not a component this file imports`);
|
|
1041
|
+
}
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
const kind = INTRINSIC_KINDS[tag];
|
|
1045
|
+
if (!facts.tags.includes(tag)) facts.tags.push(tag);
|
|
1046
|
+
facts.elements.total += 1;
|
|
1047
|
+
if (!kind) {
|
|
1048
|
+
block(at, "unmapped-element", `<${tag}> has no native mapping`);
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
facts.elements.mapped += 1;
|
|
1052
|
+
facts.elements.byKind[kind] = (_nullishCoalesce(facts.elements.byKind[kind], () => ( 0))) + 1;
|
|
1053
|
+
const value = (attr) => attributes.find((attribute) => attribute.name.toLowerCase() === attr);
|
|
1054
|
+
const boundAttribute = (attr) => attributes.find(
|
|
1055
|
+
(attribute) => attribute.dynamic && (attribute.name === `:${attr}` || attribute.name === `v-bind:${attr}` || attribute.name === attr) || attr === "class" && attribute.name.startsWith("class:")
|
|
1056
|
+
);
|
|
1057
|
+
const classes = value("class");
|
|
1058
|
+
if (boundAttribute("class")) {
|
|
1059
|
+
block(at, "runtime-class-name", `<${tag}> builds its class names at runtime`);
|
|
1060
|
+
} else if (_optionalChain([classes, 'optionalAccess', _58 => _58.value])) {
|
|
1061
|
+
for (const token of classes.value.split(/\s+/).filter(Boolean)) {
|
|
1062
|
+
const problem = classifyClass(token);
|
|
1063
|
+
if (problem && /^class ".*" is not in the native Tailwind subset$/.test(problem)) {
|
|
1064
|
+
facts.appClasses.push({ name: token, ...locate(starts, classes.offset) });
|
|
1065
|
+
} else if (problem) block(classes.offset, "class-name", problem);
|
|
1066
|
+
else {
|
|
1067
|
+
const native = _chunkV727H3RIcjs.farmNativeClassProblem.call(void 0, token);
|
|
1068
|
+
if (native) block(classes.offset, "class-name", native, "native");
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
const style = value("style");
|
|
1073
|
+
if (boundAttribute("style")) {
|
|
1074
|
+
block(at, "runtime-style", `<${tag}> style is computed at runtime`);
|
|
1075
|
+
} else if (_optionalChain([style, 'optionalAccess', _59 => _59.value])) {
|
|
1076
|
+
for (const declaration of _chunkV727H3RIcjs.resolveFarmNativeInlineStyle.call(void 0, style.value).unsupported) {
|
|
1077
|
+
block(
|
|
1078
|
+
style.offset,
|
|
1079
|
+
"style",
|
|
1080
|
+
`<${tag}> style "${declaration}" has no native-tier style`,
|
|
1081
|
+
"native"
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
const type = value("type");
|
|
1086
|
+
if (tag === "input") {
|
|
1087
|
+
const inputType = _optionalChain([type, 'optionalAccess', _60 => _60.dynamic]) ? void 0 : (_nullishCoalesce(_optionalChain([type, 'optionalAccess', _61 => _61.value]), () => ( "text"))).toLowerCase();
|
|
1088
|
+
const formType = formDepth > 0 && (inputType === "hidden" || inputType === "submit");
|
|
1089
|
+
if (!formType && (inputType === void 0 || !INPUT_TYPES.has(inputType))) {
|
|
1090
|
+
block(
|
|
1091
|
+
at,
|
|
1092
|
+
"unmapped-element",
|
|
1093
|
+
`<input type="${_nullishCoalesce(inputType, () => ( "{expr}"))}"> has no native mapping`
|
|
1094
|
+
);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
if (inputType === "hidden") continue;
|
|
1098
|
+
}
|
|
1099
|
+
const buttonType = tag === "button" ? (_nullishCoalesce(_optionalChain([type, 'optionalAccess', _62 => _62.value]), () => ( "submit"))).toLowerCase() : void 0;
|
|
1100
|
+
if ((tag === "button" || kind === "TextInput") && !value("action") && !value("formaction") && (formDepth === 0 || buttonType !== void 0 && buttonType !== "submit")) {
|
|
1101
|
+
block(
|
|
1102
|
+
at,
|
|
1103
|
+
"inert-control",
|
|
1104
|
+
formDepth > 0 ? `<button type="${buttonType}"> does nothing on a native-tier screen` : `<${tag}> has no link or form to submit on a native-tier screen`,
|
|
1105
|
+
"native"
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
if (tag === "form") {
|
|
1109
|
+
const method = value("method");
|
|
1110
|
+
const methodValue = (_nullishCoalesce(_optionalChain([method, 'optionalAccess', _63 => _63.value]), () => ( "get"))).toLowerCase();
|
|
1111
|
+
if (_optionalChain([method, 'optionalAccess', _64 => _64.dynamic]) || methodValue !== "get" && methodValue !== "post") {
|
|
1112
|
+
block(at, "form-action", `<form method="${_nullishCoalesce(_optionalChain([method, 'optionalAccess', _65 => _65.value]), () => ( "{expr}"))}">`, "native");
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return facts;
|
|
1118
|
+
}
|
|
1119
|
+
function closeBrace(text, start) {
|
|
1120
|
+
let depth = 0;
|
|
1121
|
+
for (let index = start; index < text.length; index += 1) {
|
|
1122
|
+
const char = text[index];
|
|
1123
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
1124
|
+
const end = text.indexOf(char, index + 1);
|
|
1125
|
+
if (end === -1) return text.length;
|
|
1126
|
+
index = end;
|
|
1127
|
+
} else if (char === "{") depth += 1;
|
|
1128
|
+
else if (char === "}") {
|
|
1129
|
+
depth -= 1;
|
|
1130
|
+
if (depth === 0) return index + 1;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return text.length;
|
|
1134
|
+
}
|
|
783
1135
|
function readAliases(root, srcDir) {
|
|
784
1136
|
const aliases = [{ prefix: "@/", targets: [path.join(root, srcDir) + path.sep] }];
|
|
785
1137
|
try {
|
|
@@ -836,7 +1188,7 @@ function classifyPackage(fact, serverBoundary) {
|
|
|
836
1188
|
}
|
|
837
1189
|
if (specifier.startsWith("@farm.js/core")) {
|
|
838
1190
|
const portable = CORE_PORTABLE[specifier];
|
|
839
|
-
const unmapped = fact.names.filter((name2) => !_optionalChain([portable, 'optionalAccess',
|
|
1191
|
+
const unmapped = fact.names.filter((name2) => !_optionalChain([portable, 'optionalAccess', _66 => _66.has, 'call', _67 => _67(name2)]));
|
|
840
1192
|
if (unmapped.length > 0 || !portable) {
|
|
841
1193
|
return {
|
|
842
1194
|
...at,
|
|
@@ -922,11 +1274,14 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
922
1274
|
let pending = facts.get(file);
|
|
923
1275
|
if (!pending) {
|
|
924
1276
|
pending = _promises.readFile.call(void 0, file, "utf8").then((source) => {
|
|
925
|
-
const
|
|
1277
|
+
const component = _chunkWBTHHTBOcjs.farmComponentKind.call(void 0, file);
|
|
1278
|
+
const hash = _crypto.createHash.call(void 0, "sha1").update(
|
|
1279
|
+
component ? `${component}\0` : file.endsWith(".tsx") ? "tsx\0" : file.endsWith(".ts") ? "ts\0" : "jsx\0"
|
|
1280
|
+
).update(source).digest("hex");
|
|
926
1281
|
let result = cache.modules[hash];
|
|
927
1282
|
if (result) cached += 1;
|
|
928
1283
|
else {
|
|
929
|
-
result = analyzeSource(file, source, parseSync);
|
|
1284
|
+
result = component ? analyzeComponentSource(file, source, parseSync) : analyzeSource(file, source, parseSync);
|
|
930
1285
|
parsed += 1;
|
|
931
1286
|
}
|
|
932
1287
|
used[hash] = result;
|
|
@@ -990,7 +1345,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
990
1345
|
}
|
|
991
1346
|
};
|
|
992
1347
|
}
|
|
993
|
-
if (!
|
|
1348
|
+
if (!isModuleFile(file)) {
|
|
994
1349
|
return {
|
|
995
1350
|
fact,
|
|
996
1351
|
blocker: {
|
|
@@ -1027,8 +1382,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1027
1382
|
const scripts = /* @__PURE__ */ new Set();
|
|
1028
1383
|
for (const { page, layouts } of entries.values()) {
|
|
1029
1384
|
for (const file of [page, ...layouts]) {
|
|
1030
|
-
if (file &&
|
|
1031
|
-
scripts.add(file);
|
|
1385
|
+
if (file && isModuleFile(file)) scripts.add(file);
|
|
1032
1386
|
}
|
|
1033
1387
|
}
|
|
1034
1388
|
await Promise.all([...scripts].map(visitModule));
|
|
@@ -1048,7 +1402,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1048
1402
|
const allStylesheets = /* @__PURE__ */ new Set();
|
|
1049
1403
|
const unreadStylesheets = /* @__PURE__ */ new Set();
|
|
1050
1404
|
for (const [route, { page, layouts }] of entries) {
|
|
1051
|
-
if (!page && _optionalChain([options, 'access',
|
|
1405
|
+
if (!page && _optionalChain([options, 'access', _68 => _68.nativeOnlyRoutes, 'optionalAccess', _69 => _69.has, 'call', _70 => _70(route)])) continue;
|
|
1052
1406
|
const blockers = [];
|
|
1053
1407
|
const wins = /* @__PURE__ */ new Set();
|
|
1054
1408
|
const elements = { total: 0, mapped: 0, byKind: {} };
|
|
@@ -1059,6 +1413,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1059
1413
|
const tags = /* @__PURE__ */ new Set();
|
|
1060
1414
|
const graph = [];
|
|
1061
1415
|
const layoutClasses = /* @__PURE__ */ new Set();
|
|
1416
|
+
const componentSheets = [];
|
|
1062
1417
|
const walk = (file, entry, layout) => {
|
|
1063
1418
|
if (seen.has(file)) return;
|
|
1064
1419
|
seen.add(file);
|
|
@@ -1109,10 +1464,26 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1109
1464
|
}
|
|
1110
1465
|
if (moduleFacts.serverBoundary && !entry) return;
|
|
1111
1466
|
for (const blocker of moduleFacts.blockers) add({ file: label, ...blocker });
|
|
1467
|
+
for (const action of _nullishCoalesce(moduleFacts.formActions, () => ( []))) {
|
|
1468
|
+
const target = action.source === void 0 ? void 0 : _optionalChain([(_nullishCoalesce(resolved.get(file), () => ( []))), 'access', _71 => _71.find, 'call', _72 => _72((entry2) => entry2.fact.source === action.source), 'optionalAccess', _73 => _73.file]);
|
|
1469
|
+
const server = options.serverComponents === true && (action.source === void 0 || target !== void 0 && _optionalChain([settled, 'access', _74 => _74.get, 'call', _75 => _75(target), 'optionalAccess', _76 => _76.serverBoundary]) === true);
|
|
1470
|
+
if (!server) {
|
|
1471
|
+
add({
|
|
1472
|
+
file: label,
|
|
1473
|
+
line: action.line,
|
|
1474
|
+
column: action.column,
|
|
1475
|
+
rule: "form-action",
|
|
1476
|
+
message: action.message
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1112
1480
|
if (!layout) {
|
|
1113
1481
|
for (const appClass of moduleFacts.appClasses)
|
|
1114
1482
|
appClasses.push({ file: label, ...appClass });
|
|
1115
1483
|
for (const tag of moduleFacts.tags) tags.add(tag);
|
|
1484
|
+
for (const css of _nullishCoalesce(moduleFacts.styles, () => ( []))) {
|
|
1485
|
+
componentSheets.push(_chunkV727H3RIcjs.parseFarmNativeStylesheet.call(void 0, css));
|
|
1486
|
+
}
|
|
1116
1487
|
}
|
|
1117
1488
|
for (const win of moduleFacts.wins) wins.add(win);
|
|
1118
1489
|
elements.total += moduleFacts.elements.total;
|
|
@@ -1127,7 +1498,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1127
1498
|
if (entryImport.stylesheet) {
|
|
1128
1499
|
stylesheets.add(entryImport.stylesheet);
|
|
1129
1500
|
allStylesheets.add(entryImport.stylesheet);
|
|
1130
|
-
} else if (_optionalChain([entryImport, 'access',
|
|
1501
|
+
} else if (_optionalChain([entryImport, 'access', _77 => _77.blocker, 'optionalAccess', _78 => _78.rule]) === "css-import") {
|
|
1131
1502
|
unreadStylesheets.add(entryImport.fact.source);
|
|
1132
1503
|
}
|
|
1133
1504
|
if (entryImport.blocker) add({ file: label, ...entryImport.blocker });
|
|
@@ -1155,7 +1526,7 @@ async function analyzeFarmMobileRoutes(options) {
|
|
|
1155
1526
|
ir.root = `${relative2(root, page)}#default`;
|
|
1156
1527
|
}
|
|
1157
1528
|
for (const layout of layouts) walk(layout, true, true);
|
|
1158
|
-
const sheets = [...stylesheets].map(readStylesheet);
|
|
1529
|
+
const sheets = [...[...stylesheets].map(readStylesheet), ...componentSheets];
|
|
1159
1530
|
for (const appClass of appClasses) {
|
|
1160
1531
|
const { styled, problems } = _chunkV727H3RIcjs.inspectFarmNativeStylesheets.call(void 0, sheets, { class: appClass.name });
|
|
1161
1532
|
const at = { file: appClass.file, line: appClass.line, column: appClass.column };
|