Skip to content

Commit

Permalink
Merge pull request #1192 from jetstreamapp/chore/firefox-submission-fix
Browse files Browse the repository at this point in the history
Web-extension: Avoid loading xlsx cptable
  • Loading branch information
paustint authored Feb 20, 2025
2 parents f959a12 + 7897804 commit cad3681
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/jetstream-web-extension/src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Jetstream",
"description": "Jetstream is a set of tools that supercharge your administration of Salesforce.com.",
"version": "1.5.0",
"version": "1.5.1",
"manifest_version": 3,
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmPjyzVG3Kpm0wyjDECyDLnwPlyEhlNmfzcPVybZz9gFKiHTm0qEuUYqGqOSAOWE6KnOR8RbiNkyrROGeEbGmhZIXxS02yKPTpJsA4qflKtTUGoeT7XcOm9cHWw3+BrVuqABCdXEwv/Do1/UX2vu9WeOMHQAr911nVl77JrhhaMQvpu0ruJjD+sZ9QbfjdLNeVeU1+hzgpuvpDnMihDIfZv47GaqvTTwxT67P09loBySjXMmx2mrtOpyLzsATLwQr6kmQQAX5X23ykw3PxY4NWBDldqXxKqTomMkwa3x6mh/4jmI5h6p6Wt6Gaf9FcG1pBOXTrUHNfdFzuK6ahYBsRQIDAQAB",
"icons": {
Expand Down
10 changes: 10 additions & 0 deletions apps/jetstream-web-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ module.exports = composePlugins(withNx(), withReact(), (config, { configuration
// if runtime chunk is enabled, then the service worker will not work
config.optimization = {
...config.optimization,
minimizer: [
(compiler) => {
const TerserPlugin = require('terser-webpack-plugin');
new TerserPlugin({
parallel: true,
minify: TerserPlugin.esbuildMinify,
// @ts-expect-error this is correct, not sure why it is complaining
}).apply(compiler);
},
],
runtimeChunk: false,
splitChunks: {
chunks(chunk) {
Expand Down
33 changes: 30 additions & 3 deletions libs/shared/ui-db/src/lib/client-data-sync.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,51 @@ async function handleServerSyncResponse({ records, updatedAt }: PullResponse, ap
}

function enrichDataTypes(entity: SyncRecord['entity'], data: Record<string, unknown>) {
enrichDataTypesForAll(data);
switch (entity) {
case 'query_history':
enrichDataTypesForQueryHistory(data);
break;
case 'load_saved_mapping':
enrichDataTypesForLoadMapping(data);
break;
case 'recent_history_item':
enrichDataTypesForRecentHistory(data);
break;
default:
break;
}
}

function enrichDataTypesForQueryHistory(data: Record<string, unknown>) {
function enrichDataTypesForAll(data: Record<string, unknown>) {
if (!data) {
return;
}
if (isString(data.created)) {
data.createdAt = parseISO(data.created);
}
if (isString(data.updatedAt)) {
data.updatedAt = parseISO(data.updatedAt);
}
}

function enrichDataTypesForQueryHistory(data: Record<string, unknown>) {
if (isString(data.lastRun)) {
data.lastRun = parseISO(data.lastRun);
}
if (isString(data.updatedAt)) {
data.updatedAt = parseISO(data.updatedAt);
}

function enrichDataTypesForLoadMapping(data: Record<string, unknown>) {
// nothing to do here
}

function enrichDataTypesForRecentHistory(data: Record<string, unknown>) {
if (Array.isArray(data.items)) {
data.items.forEach((item) => {
if (isString(item.lastUsed)) {
item.lastUsedAt = parseISO(item.lastUsed);
}
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/shared/ui-db/src/lib/recent-history-items.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function saveRecentHistoryItem(
recentHistoryItem: Pick<RecentHistoryItem, 'key' | 'items' | 'org'> & Partial<Pick<RecentHistoryItem, 'hashedKey' | 'createdAt'>>
) {
const items = uniqBy(recentHistoryItem.items, 'name')
.sort((a, b) => b.lastUsed.getTime() - a.lastUsed.getTime())
.sort((a, b) => new Date(b.lastUsed).getTime() - new Date(a.lastUsed).getTime())
.slice(0, MAX_ITEM_SIZE);

const newItem: RecentHistoryItem = {
Expand Down
16 changes: 9 additions & 7 deletions libs/shared/ui-utils/src/lib/shared-ui-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ initXlsx(XLSX);
* https://git.sheetjs.com/sheetjs/sheetjs/issues/2900
*/
export function initXlsx(_xlsx: typeof import('xlsx')) {
import('xlsx/dist/cpexcel.full.mjs')
.then((module) => {
_xlsx.set_cptable(module);
})
.catch((ex) => {
// ignore error
});
if (!globalThis.__IS_BROWSER_EXTENSION__) {
import('xlsx/dist/cpexcel.full.mjs')
.then((module) => {
XLSX.set_cptable(module);
})
.catch((ex) => {
// ignore error
});
}
}

export function formatNumber(number?: number) {
Expand Down

0 comments on commit cad3681

Please sign in to comment.