mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
fix(build): eliminate CommonJS module warnings
Replace clipboard, file-saver, and query-string with native browser APIs. Add remaining CommonJS dependencies to allowedCommonJsDependencies.
This commit is contained in:
parent
c8fec79448
commit
e1a77380fc
5 changed files with 53 additions and 20 deletions
12
angular.json
12
angular.json
|
|
@ -42,7 +42,17 @@
|
|||
"browser": "src/main.ts",
|
||||
"stylePreprocessorOptions": {
|
||||
"includePaths": [".", "src", "src/styles"]
|
||||
}
|
||||
},
|
||||
"allowedCommonJsDependencies": [
|
||||
"typia",
|
||||
"electron-log",
|
||||
"stacktrace-js",
|
||||
"spark-md5",
|
||||
"chrono-node",
|
||||
"dayjs",
|
||||
"jira2md",
|
||||
"query-string"
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import { JiraIssue, JiraIssueReduced } from './jira-issue.model';
|
|||
import { BannerService } from '../../../../core/banner/banner.service';
|
||||
import { BannerId } from '../../../../core/banner/banner.model';
|
||||
import { T } from '../../../../t.const';
|
||||
import { stringify } from 'query-string';
|
||||
import { getErrorTxt } from '../../../../util/get-error-text';
|
||||
import { isOnline } from '../../../../util/is-online';
|
||||
import { GlobalProgressBarService } from '../../../../core-ui/global-progress-bar/global-progress-bar.service';
|
||||
|
|
@ -453,7 +452,7 @@ export class JiraApiService {
|
|||
const requestInit = this._makeRequestInit(jiraReqCfg, cfg);
|
||||
|
||||
const queryStr = jiraReqCfg.query
|
||||
? `?${stringify(jiraReqCfg.query, { arrayFormat: 'comma' })}`
|
||||
? `?${stringifyQueryParams(jiraReqCfg.query)}`
|
||||
: '';
|
||||
const base = `${stripTrailing(cfg.host || 'null', '/')}/rest/api/${API_VERSION}`;
|
||||
const url = `${base}/${jiraReqCfg.pathname}${queryStr}`.trim();
|
||||
|
|
@ -747,3 +746,19 @@ async function streamToJsonIfPossible(stream: ReadableStream): Promise<any> {
|
|||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
||||
function stringifyQueryParams(
|
||||
params: Record<string, string | boolean | number | string[]>,
|
||||
): string {
|
||||
const searchParams = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (Array.isArray(value)) {
|
||||
// arrayFormat: 'comma' - join array values with comma
|
||||
searchParams.set(key, value.join(','));
|
||||
} else if (value !== undefined && value !== null) {
|
||||
searchParams.set(key, String(value));
|
||||
}
|
||||
}
|
||||
return searchParams.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,10 +190,8 @@
|
|||
>
|
||||
@if (isShowAsText) {
|
||||
<button
|
||||
(click)="copyToClipboard()"
|
||||
color="primary"
|
||||
data-clipboard-action="copy"
|
||||
data-clipboard-target="#task-textarea"
|
||||
id="clipboard-btn"
|
||||
mat-button
|
||||
>
|
||||
<mat-icon>content_paste</mat-icon>
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import {
|
|||
} from '@angular/core';
|
||||
import { combineLatest, from, Subscription } from 'rxjs';
|
||||
import { getDbDateStr } from '../../../util/get-db-date-str';
|
||||
// @ts-ignore
|
||||
import Clipboard from 'clipboard';
|
||||
import { SnackService } from '../../../core/snack/snack.service';
|
||||
import { WorklogService } from '../worklog.service';
|
||||
import {
|
||||
|
|
@ -234,16 +232,6 @@ export class WorklogExportComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
}),
|
||||
);
|
||||
|
||||
// dirty but good enough for now
|
||||
const clipboard = new Clipboard('#clipboard-btn');
|
||||
clipboard.on('success', (e: any) => {
|
||||
this._snackService.open({
|
||||
msg: T.GLOBAL_SNACK.COPY_TO_CLIPPBOARD,
|
||||
type: 'SUCCESS',
|
||||
});
|
||||
e.clearSelection();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
|
@ -262,4 +250,20 @@ export class WorklogExportComponent implements OnInit, OnDestroy {
|
|||
addCol(colOpt: WorklogColTypes): void {
|
||||
this.options.cols.push(colOpt);
|
||||
}
|
||||
|
||||
async copyToClipboard(): Promise<void> {
|
||||
try {
|
||||
await navigator.clipboard.writeText(this.txt);
|
||||
this._snackService.open({
|
||||
msg: T.GLOBAL_SNACK.COPY_TO_CLIPPBOARD,
|
||||
type: 'SUCCESS',
|
||||
});
|
||||
} catch (err) {
|
||||
this._snackService.open({
|
||||
msg: 'Failed to copy to clipboard',
|
||||
type: 'ERROR',
|
||||
isSkipTranslate: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { saveAs } from 'file-saver';
|
||||
import { Directory, Encoding, Filesystem, WriteFileResult } from '@capacitor/filesystem';
|
||||
import { Share } from '@capacitor/share';
|
||||
import { IS_ANDROID_WEB_VIEW } from './is-android-web-view';
|
||||
|
|
@ -54,7 +53,14 @@ export const download = async (
|
|||
return { isSnap: true };
|
||||
} else {
|
||||
const blob = new Blob([stringData], { type: 'text/plain;charset=utf-8' });
|
||||
saveAs(blob, filename);
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue