@plumeria/utils 19.2.12 → 19.2.13
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/transform.js +73 -73
- package/package.json +1 -1
package/dist/transform.js
CHANGED
|
@@ -317,81 +317,82 @@ const transformSource = async (env) => {
|
|
|
317
317
|
const createStaticImportMap = {};
|
|
318
318
|
const plumeriaAliases = {};
|
|
319
319
|
const localImports = {};
|
|
320
|
-
(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
320
|
+
for (const statement of ast.body) {
|
|
321
|
+
if (statement.type !== 'ImportDeclaration')
|
|
322
|
+
continue;
|
|
323
|
+
const node = statement;
|
|
324
|
+
const sourcePath = node.source.value;
|
|
325
|
+
if (sourcePath === '@plumeria/core') {
|
|
326
|
+
node.specifiers.forEach((specifier) => {
|
|
327
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
328
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
329
|
+
}
|
|
330
|
+
else if (specifier.type === 'ImportDefaultSpecifier') {
|
|
331
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
332
|
+
}
|
|
333
|
+
else if (specifier.type === 'ImportSpecifier') {
|
|
334
|
+
const importedName = specifier.imported
|
|
335
|
+
? specifier.imported.value
|
|
336
|
+
: specifier.local.value;
|
|
337
|
+
plumeriaAliases[specifier.local.value] = importedName;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
const actualPath = (0, resolver_1.resolveImportPath)(sourcePath, resourcePath);
|
|
342
|
+
if (actualPath) {
|
|
343
|
+
node.specifiers.forEach((specifier) => {
|
|
344
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
345
|
+
localImports[specifier.local.value] = {
|
|
346
|
+
actualPath,
|
|
347
|
+
importedName: '*',
|
|
348
|
+
};
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (specifier.type === 'ImportSpecifier' ||
|
|
352
|
+
specifier.type === 'ImportDefaultSpecifier') {
|
|
353
|
+
const importedName = specifier.type === 'ImportDefaultSpecifier'
|
|
354
|
+
? 'default'
|
|
355
|
+
: specifier.imported
|
|
333
356
|
? specifier.imported.value
|
|
334
357
|
: specifier.local.value;
|
|
335
|
-
|
|
358
|
+
const localName = specifier.local.value;
|
|
359
|
+
let resolvedKey = `${actualPath}-${importedName}`;
|
|
360
|
+
const resolved = (0, parser_1.resolveExport)(actualPath, importedName);
|
|
361
|
+
if (resolved) {
|
|
362
|
+
resolvedKey = `${resolved.filePath}-${resolved.localName}`;
|
|
336
363
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
node.specifiers.forEach((specifier) => {
|
|
342
|
-
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
343
|
-
localImports[specifier.local.value] = {
|
|
344
|
-
actualPath,
|
|
345
|
-
importedName: '*',
|
|
346
|
-
};
|
|
347
|
-
return;
|
|
364
|
+
const uniqueKey = resolvedKey;
|
|
365
|
+
localImports[localName] = { actualPath, importedName };
|
|
366
|
+
if (scannedTables.staticTable[uniqueKey]) {
|
|
367
|
+
importMap[localName] = scannedTables.staticTable[uniqueKey];
|
|
348
368
|
}
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
? 'default'
|
|
353
|
-
: specifier.imported
|
|
354
|
-
? specifier.imported.value
|
|
355
|
-
: specifier.local.value;
|
|
356
|
-
const localName = specifier.local.value;
|
|
357
|
-
let resolvedKey = `${actualPath}-${importedName}`;
|
|
358
|
-
const resolved = (0, parser_1.resolveExport)(actualPath, importedName);
|
|
359
|
-
if (resolved) {
|
|
360
|
-
resolvedKey = `${resolved.filePath}-${resolved.localName}`;
|
|
361
|
-
}
|
|
362
|
-
const uniqueKey = resolvedKey;
|
|
363
|
-
localImports[localName] = { actualPath, importedName };
|
|
364
|
-
if (scannedTables.staticTable[uniqueKey]) {
|
|
365
|
-
importMap[localName] = scannedTables.staticTable[uniqueKey];
|
|
366
|
-
}
|
|
367
|
-
if (scannedTables.keyframesHashTable[uniqueKey]) {
|
|
368
|
-
keyframesImportMap[localName] =
|
|
369
|
-
scannedTables.keyframesHashTable[uniqueKey];
|
|
370
|
-
}
|
|
371
|
-
if (scannedTables.viewTransitionHashTable[uniqueKey]) {
|
|
372
|
-
viewTransitionImportMap[localName] =
|
|
373
|
-
scannedTables.viewTransitionHashTable[uniqueKey];
|
|
374
|
-
}
|
|
375
|
-
if (scannedTables.createHashTable[uniqueKey]) {
|
|
376
|
-
createImportMap[localName] =
|
|
377
|
-
scannedTables.createHashTable[uniqueKey];
|
|
378
|
-
}
|
|
379
|
-
if (scannedTables.createFunctionTable[uniqueKey]) {
|
|
380
|
-
createFunctionImportMap[localName] = (0, dynamicKey_1.styleFunctionsOf)(scannedTables.createFunctionTable[uniqueKey]);
|
|
381
|
-
}
|
|
382
|
-
if (scannedTables.createThemeHashTable[uniqueKey]) {
|
|
383
|
-
createThemeImportMap[localName] =
|
|
384
|
-
scannedTables.createThemeHashTable[uniqueKey];
|
|
385
|
-
}
|
|
386
|
-
if (scannedTables.createStaticHashTable[uniqueKey]) {
|
|
387
|
-
createStaticImportMap[localName] =
|
|
388
|
-
scannedTables.createStaticHashTable[uniqueKey];
|
|
389
|
-
}
|
|
369
|
+
if (scannedTables.keyframesHashTable[uniqueKey]) {
|
|
370
|
+
keyframesImportMap[localName] =
|
|
371
|
+
scannedTables.keyframesHashTable[uniqueKey];
|
|
390
372
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
373
|
+
if (scannedTables.viewTransitionHashTable[uniqueKey]) {
|
|
374
|
+
viewTransitionImportMap[localName] =
|
|
375
|
+
scannedTables.viewTransitionHashTable[uniqueKey];
|
|
376
|
+
}
|
|
377
|
+
if (scannedTables.createHashTable[uniqueKey]) {
|
|
378
|
+
createImportMap[localName] =
|
|
379
|
+
scannedTables.createHashTable[uniqueKey];
|
|
380
|
+
}
|
|
381
|
+
if (scannedTables.createFunctionTable[uniqueKey]) {
|
|
382
|
+
createFunctionImportMap[localName] = (0, dynamicKey_1.styleFunctionsOf)(scannedTables.createFunctionTable[uniqueKey]);
|
|
383
|
+
}
|
|
384
|
+
if (scannedTables.createThemeHashTable[uniqueKey]) {
|
|
385
|
+
createThemeImportMap[localName] =
|
|
386
|
+
scannedTables.createThemeHashTable[uniqueKey];
|
|
387
|
+
}
|
|
388
|
+
if (scannedTables.createStaticHashTable[uniqueKey]) {
|
|
389
|
+
createStaticImportMap[localName] =
|
|
390
|
+
scannedTables.createStaticHashTable[uniqueKey];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
395
396
|
const mergedStaticTable = Object.create(scannedTables.staticTable);
|
|
396
397
|
for (const key of Object.keys(localConsts)) {
|
|
397
398
|
mergedStaticTable[key] = localConsts[key];
|
|
@@ -2321,17 +2322,16 @@ const transformSource = async (env) => {
|
|
|
2321
2322
|
for (const replacement of replacements)
|
|
2322
2323
|
replacement.content = replacement.content.replaceAll(deferred.token, content);
|
|
2323
2324
|
}
|
|
2324
|
-
const buffer = Buffer.from(source);
|
|
2325
2325
|
let offset = 0;
|
|
2326
2326
|
const parts = [];
|
|
2327
2327
|
replacements.forEach((r) => {
|
|
2328
2328
|
if (r.start < offset)
|
|
2329
2329
|
return;
|
|
2330
|
-
parts.push(
|
|
2330
|
+
parts.push(sourceBuffer.subarray(offset, r.start));
|
|
2331
2331
|
parts.push(Buffer.from(r.content));
|
|
2332
2332
|
offset = r.end;
|
|
2333
2333
|
});
|
|
2334
|
-
parts.push(
|
|
2334
|
+
parts.push(sourceBuffer.subarray(offset));
|
|
2335
2335
|
const transformedSource = Buffer.concat(parts).toString();
|
|
2336
2336
|
return { code: transformedSource, sheets: [...extractedSheets] };
|
|
2337
2337
|
};
|