vite-plugin-zephyr 0.0.0-canary-20250513234234 → 0.0.0-canary-20250514220856
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/lib/internal/extract/extract_mf_plugin.d.ts +6 -0
- package/dist/lib/internal/extract/extract_mf_plugin.js +8 -0
- package/dist/lib/internal/extract/extract_mf_plugin.js.map +1 -0
- package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.d.ts +11 -1
- package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.js +8 -10
- package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.js.map +1 -1
- package/dist/lib/internal/mf-vite-etl/load_resolved_remotes.d.ts +1 -1
- package/dist/lib/internal/mf-vite-etl/load_resolved_remotes.js +32 -20
- package/dist/lib/internal/mf-vite-etl/load_resolved_remotes.js.map +1 -1
- package/dist/lib/internal/mf-vite-etl/runtime_plugin.d.ts +2 -0
- package/dist/lib/internal/mf-vite-etl/runtime_plugin.js +42 -0
- package/dist/lib/internal/mf-vite-etl/runtime_plugin.js.map +1 -0
- package/dist/lib/internal/mf-vite-etl/runtime_plugins_parser.d.ts +6 -0
- package/dist/lib/internal/mf-vite-etl/runtime_plugins_parser.js +48 -0
- package/dist/lib/internal/mf-vite-etl/runtime_plugins_parser.js.map +1 -0
- package/dist/lib/vite-plugin-zephyr-partial.js +6 -16
- package/dist/lib/vite-plugin-zephyr-partial.js.map +1 -1
- package/dist/lib/vite-plugin-zephyr.d.ts +1 -9
- package/dist/lib/vite-plugin-zephyr.js +11 -200
- package/dist/lib/vite-plugin-zephyr.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/dist/lib/internal/extract/extract_preload_import.d.ts +0 -0
- package/dist/lib/internal/extract/extract_preload_import.js +0 -18
- package/dist/lib/internal/extract/extract_preload_import.js.map +0 -1
- package/dist/lib/internal/extract/extract_vite_build_stats.d.ts +0 -16
- package/dist/lib/internal/extract/extract_vite_build_stats.js +0 -294
- package/dist/lib/internal/extract/extract_vite_build_stats.js.map +0 -1
- package/dist/lib/internal/mf-vite-etl/preload-imports.d.ts +0 -0
- package/dist/lib/internal/mf-vite-etl/preload-imports.js +0 -124
- package/dist/lib/internal/mf-vite-etl/preload-imports.js.map +0 -1
- package/dist/lib/internal/mf-vite-etl/remote_map_parser.d.ts +0 -20
- package/dist/lib/internal/mf-vite-etl/remote_map_parser.js +0 -120
- package/dist/lib/internal/mf-vite-etl/remote_map_parser.js.map +0 -1
@@ -1,120 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.parseRemoteMapAndImportedRemotes = parseRemoteMapAndImportedRemotes;
|
4
|
-
exports.replaceProtocolAndHost = replaceProtocolAndHost;
|
5
|
-
const tslib_1 = require("tslib");
|
6
|
-
const json5_1 = tslib_1.__importDefault(require("json5"));
|
7
|
-
const acorn_1 = tslib_1.__importDefault(require("acorn"));
|
8
|
-
const acorn_walk_1 = tslib_1.__importDefault(require("acorn-walk"));
|
9
|
-
const zephyr_agent_1 = require("zephyr-agent");
|
10
|
-
/**
|
11
|
-
* Parses the provided code to extract the remotes object.
|
12
|
-
*
|
13
|
-
* @param code - The code containing the remotes object declaration.
|
14
|
-
* @returns An object containing the remotes object and the start and end indices of the
|
15
|
-
* remotes object declaration in the code, or undefined if parsing fails.
|
16
|
-
*/
|
17
|
-
function parseRemoteMapAndImportedRemotes(code, id
|
18
|
-
//remotes?: string[]
|
19
|
-
) {
|
20
|
-
// let remoteNamesAndImports: acorn.Node | undefined;
|
21
|
-
function isImportedRemote(node) {
|
22
|
-
var _a, _b;
|
23
|
-
if (((_a = node.callee) === null || _a === void 0 ? void 0 : _a.type) === 'Identifier' &&
|
24
|
-
node.callee.name === '__vitePreload' &&
|
25
|
-
node.arguments.length >= 1) {
|
26
|
-
(0, zephyr_agent_1.ze_log)('vite.isImportedRemote.node: ', node);
|
27
|
-
for (const arg of node.arguments) {
|
28
|
-
(0, zephyr_agent_1.ze_log)('vite.isImportedRemote.arg Pos1: ', arg);
|
29
|
-
if (arg.type === 'ArrowFunctionExpression' &&
|
30
|
-
arg.body.type === 'CallExpression' &&
|
31
|
-
((_b = arg.body.callee) === null || _b === void 0 ? void 0 : _b.type) === 'Identifier' &&
|
32
|
-
arg.body.callee.name === 'import' &&
|
33
|
-
arg.body.arguments.length === 1) {
|
34
|
-
(0, zephyr_agent_1.ze_log)('vite.isImportedRemote.arg Pos2: ', arg);
|
35
|
-
// remoteNamesAndImports = arg.body.arguments[0];
|
36
|
-
return true;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
return false;
|
41
|
-
}
|
42
|
-
if (!id.includes('localSharedImportMap') || id.includes('node_modules')) {
|
43
|
-
return undefined;
|
44
|
-
}
|
45
|
-
let arrayNode;
|
46
|
-
const startTime = Date.now();
|
47
|
-
// Parse the code into an AST
|
48
|
-
const ast = acorn_1.default.parse(code, {
|
49
|
-
ecmaVersion: 'latest',
|
50
|
-
sourceType: 'module',
|
51
|
-
locations: true, // Include line and column numbers
|
52
|
-
ranges: true, // Include start and end indices
|
53
|
-
});
|
54
|
-
// Visitor function to find the variable declaration
|
55
|
-
function findUsedRemotes(node) {
|
56
|
-
if (node.type === 'VariableDeclaration' && node.kind === 'const') {
|
57
|
-
for (const declarator of node.declarations) {
|
58
|
-
if (declarator.id.type === 'Identifier' &&
|
59
|
-
declarator.id.name === 'usedRemotes' &&
|
60
|
-
declarator.init) {
|
61
|
-
// Found the 'usedRemotes' variable
|
62
|
-
arrayNode = declarator.init;
|
63
|
-
break;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
acorn_walk_1.default.simple(ast, {
|
69
|
-
VariableDeclaration: findUsedRemotes,
|
70
|
-
CallExpression: isImportedRemote,
|
71
|
-
// ImportDeclaration: isImportedRemote,
|
72
|
-
});
|
73
|
-
const endTime = Date.now();
|
74
|
-
(0, zephyr_agent_1.ze_log)(`parseRemoteMap took ${endTime - startTime}ms`);
|
75
|
-
if (!arrayNode) {
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
(0, zephyr_agent_1.ze_log)('vite.arrayNode found: ', arrayNode);
|
79
|
-
// Get start and end indices
|
80
|
-
const startIndex = arrayNode.start;
|
81
|
-
const endIndex = arrayNode.end;
|
82
|
-
// Extract the array text from the code
|
83
|
-
const arrayText = code.slice(startIndex, endIndex);
|
84
|
-
let remotesArray;
|
85
|
-
try {
|
86
|
-
// Use a faster JSON parser if possible
|
87
|
-
remotesArray = JSON.parse(arrayText);
|
88
|
-
(0, zephyr_agent_1.ze_log)('vite.parseRemoteMap.remotesArray: ', remotesArray);
|
89
|
-
}
|
90
|
-
catch (error) {
|
91
|
-
// Fallback to json5 only if necessary
|
92
|
-
(0, zephyr_agent_1.ze_log)(error);
|
93
|
-
try {
|
94
|
-
remotesArray = json5_1.default.parse(arrayText);
|
95
|
-
}
|
96
|
-
catch (innerError) {
|
97
|
-
(0, zephyr_agent_1.ze_log)(innerError);
|
98
|
-
return;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
return {
|
102
|
-
remotesMap: remotesArray,
|
103
|
-
startIndex,
|
104
|
-
endIndex,
|
105
|
-
// consumes: remoteNamesAndImports,
|
106
|
-
};
|
107
|
-
}
|
108
|
-
function replaceProtocolAndHost(originalUrl, newProtocolAndHost) {
|
109
|
-
(0, zephyr_agent_1.ze_log)('vite.replaceProtocalAndHost.originalUrl: ', originalUrl);
|
110
|
-
(0, zephyr_agent_1.ze_log)('vite.replaceProtocalAndHost: ', newProtocolAndHost);
|
111
|
-
const url = new URL(originalUrl);
|
112
|
-
const newUrl = new URL(newProtocolAndHost);
|
113
|
-
// Replace protocol and hostname
|
114
|
-
url.protocol = newUrl.protocol;
|
115
|
-
url.hostname = newUrl.hostname;
|
116
|
-
url.port = '';
|
117
|
-
(0, zephyr_agent_1.ze_log)('vite.transformedUrl: ', url.toString());
|
118
|
-
return url.toString();
|
119
|
-
}
|
120
|
-
//# sourceMappingURL=remote_map_parser.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"remote_map_parser.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/remote_map_parser.ts"],"names":[],"mappings":";;AAyBA,4EA0GC;AAED,wDAiBC;;AAtJD,0DAA0B;AAC1B,0DAA0B;AAC1B,oEAA8B;AAC9B,+CAAsC;AAetC;;;;;;GAMG;AACH,SAAgB,gCAAgC,CAC9C,IAAY,EACZ,EAAU;AACV,oBAAoB;;IAEpB,qDAAqD;IACrD,SAAS,gBAAgB,CAAC,IAA0B;;QAClD,IACE,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,YAAY;YAClC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe;YACpC,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,EAC1B,CAAC;YACD,IAAA,qBAAM,EAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;YAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjC,IAAA,qBAAM,EAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;gBAChD,IACE,GAAG,CAAC,IAAI,KAAK,yBAAyB;oBACtC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB;oBAClC,CAAA,MAAA,GAAG,CAAC,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,YAAY;oBACtC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;oBACjC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAC/B,CAAC;oBACD,IAAA,qBAAM,EAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;oBAChD,iDAAiD;oBACjD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IA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