Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"presets": [
"@babel/preset-react",
"@babel/preset-env"
"@babel/preset-env",
"@babel/preset-typescript"
],
"env": {
"production": {
Expand Down
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
"rules": {
"import/no-extraneous-dependencies": "off"
}
},
{
"files": ["*.ts", "*.tsx"],
// "parser": "@typescript-eslint/parser", // fix this later, this can't be added due to eslint version peer-dependency
// "plugins": ["@typescript-eslint"], // fix this later, this can't be added due to eslint version peer-dependency
"rules": {
"no-undef": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion client/modules/IDE/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import each from 'async/each';
import { isEqual } from 'lodash';
import browserHistory from '../../../browserHistory';
import apiClient from '../../../utils/apiClient';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';
import * as ActionTypes from '../../../constants';
import { showToast, setToastText } from './toast';
import {
Expand Down
8 changes: 4 additions & 4 deletions client/modules/IDE/actions/uploader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { TEXT_FILE_REGEX } from '../../../../server/utils/fileUtils';
import apiClient from '../../../utils/apiClient';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';
import { handleCreateFile } from './files';

export const s3BucketHttps =
getConfig('S3_BUCKET_URL_BASE') ||
`https://s3-${getConfig('AWS_REGION')}.amazonaws.com/${getConfig(
'S3_BUCKET'
)}/`;
`https://s3-${getConfig('AWS_REGION', {
nullishString: true
})}.amazonaws.com/${getConfig('S3_BUCKET', { nullishString: true })}/`;
const MAX_LOCAL_FILE_SIZE = 80000; // bytes, aka 80 KB

function isS3Upload(file) {
Expand Down
4 changes: 2 additions & 2 deletions client/modules/IDE/components/AssetSize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { useSelector } from 'react-redux';
import prettyBytes from 'pretty-bytes';

import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';

const limit = getConfig('UPLOAD_LIMIT') || 250000000;
const limit = getConfig('UPLOAD_LIMIT', { parseType: 'number' }) || 250000000;
const MAX_SIZE_B = limit;

const formatPercent = (percent) => {
Expand Down
19 changes: 12 additions & 7 deletions client/modules/IDE/components/Header/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
import MenubarSubmenu from '../../../../components/Menubar/MenubarSubmenu';
import MenubarItem from '../../../../components/Menubar/MenubarItem';
import { availableLanguages, languageKeyToLabel } from '../../../../i18n';
import getConfig from '../../../../utils/getConfig';
import getConfig from '../../../../utils/getConfig.ts';
import { showToast } from '../../actions/toast';
import { setLanguage } from '../../actions/preferences';
import Menubar from '../../../../components/Menubar/Menubar';
Expand Down Expand Up @@ -75,7 +75,7 @@ LeftLayout.defaultProps = {
};

const UserMenu = () => {
const isLoginEnabled = getConfig('LOGIN_ENABLED');
const isLoginEnabled = getConfig('LOGIN_ENABLED', { parseType: 'boolean' });
const isAuthenticated = useSelector(getAuthenticated);

if (isLoginEnabled && isAuthenticated) {
Expand Down Expand Up @@ -167,7 +167,8 @@ const ProjectMenu = () => {
<MenubarItem onClick={newSketch}>{t('Nav.File.New')}</MenubarItem>
<MenubarItem
hideIf={
!getConfig('LOGIN_ENABLED') || (project?.owner && !isUserOwner)
!getConfig('LOGIN_ENABLED', { parseType: 'boolean' }) ||
(project?.owner && !isUserOwner)
}
onClick={() => saveSketch(cmRef.current)}
>
Expand All @@ -194,7 +195,7 @@ const ProjectMenu = () => {
</MenubarItem>
<MenubarItem
hideIf={
!getConfig('UI_COLLECTIONS_ENABLED') ||
!getConfig('UI_COLLECTIONS_ENABLED', { parseType: 'boolean' }) ||
!user.authenticated ||
isUnsaved
}
Expand All @@ -203,7 +204,7 @@ const ProjectMenu = () => {
{t('Nav.File.AddToCollection')}
</MenubarItem>
<MenubarItem
hideIf={!getConfig('EXAMPLES_ENABLED')}
hideIf={!getConfig('EXAMPLES_ENABLED', { parseType: 'boolean' })}
href="/p5/sketches"
>
{t('Nav.File.Examples')}
Expand Down Expand Up @@ -251,7 +252,9 @@ const ProjectMenu = () => {
</MenubarItem>
<MenubarItem href="/about">{t('Nav.Help.About')}</MenubarItem>
</MenubarSubmenu>
{getConfig('TRANSLATIONS_ENABLED') && <LanguageMenu />}
{getConfig('TRANSLATIONS_ENABLED', { parseType: 'boolean' }) && (
<LanguageMenu />
)}
</ul>
);
};
Expand Down Expand Up @@ -334,7 +337,9 @@ const AuthenticatedUserMenu = () => {
</MenubarItem>
<MenubarItem
href={`/${username}/collections`}
hideIf={!getConfig('UI_COLLECTIONS_ENABLED')}
hideIf={
!getConfig('UI_COLLECTIONS_ENABLED', { parseType: 'boolean' })
}
>
{t('Nav.Auth.MyCollections')}
</MenubarItem>
Expand Down
2 changes: 1 addition & 1 deletion client/modules/IDE/components/PreviewFrame.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, useEffect } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';
import { registerFrame } from '../../../utils/dispatcher';

const Frame = styled.iframe`
Expand Down
2 changes: 1 addition & 1 deletion client/modules/IDE/components/ShareModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import CopyableInput from './CopyableInput';
// import getConfig from '../../../utils/getConfig';
// import getConfig from '../../../utils/getConfig.ts';

const ShareModal = () => {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion client/modules/IDE/components/SketchListRowBase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as IdeActions from '../actions/ide';
import TableDropdown from '../../../components/Dropdown/TableDropdown';
import MenuItem from '../../../components/Dropdown/MenuItem';
import dates from '../../../utils/formatDate';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';

const ROOT_URL = getConfig('API_URL');

Expand Down
4 changes: 2 additions & 2 deletions client/modules/IDE/components/UploadFileModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import prettyBytes from 'pretty-bytes';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';
import { closeUploadFileModal } from '../actions/ide';
import FileUploader from './FileUploader';
import { getreachedTotalSizeLimit } from '../selectors/users';
import Modal from './Modal';

const limit = getConfig('UPLOAD_LIMIT') || 250000000;
const limit = getConfig('UPLOAD_LIMIT', { parseType: 'number' }) || 250000000;
const limitText = prettyBytes(limit);

const UploadFileModal = () => {
Expand Down
4 changes: 2 additions & 2 deletions client/modules/IDE/selectors/users.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createSelector } from '@reduxjs/toolkit';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';

export const getAuthenticated = (state) => state.user.authenticated;
const getTotalSize = (state) => state.user.totalSize;
const getAssetsTotalSize = (state) => state.assets.totalSize;
export const getSketchOwner = (state) => state.project.owner;
const getUserId = (state) => state.user.id;
const limit = getConfig('UPLOAD_LIMIT') || 250000000;
const limit = getConfig('UPLOAD_LIMIT', { parseType: 'number' }) || 250000000;

export const getCanUploadMedia = createSelector(
getAuthenticated,
Expand Down
10 changes: 7 additions & 3 deletions client/modules/Preview/EmbedFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import loopProtect from 'loop-protect';
import { JSHINT } from 'jshint';
import decomment from 'decomment';
import { resolvePathToFile } from '../../../server/utils/filePath';
import getConfig from '../../utils/getConfig';
import getConfig from '../../utils/getConfig.ts';
import {
MEDIA_FILE_QUOTED_REGEX,
STRING_REGEX,
Expand Down Expand Up @@ -233,7 +233,11 @@ p5.prototype.registerMethod('afterSetup', p5.prototype.ensureAccessibleCanvas);`

const previewScripts = sketchDoc.createElement('script');
previewScripts.src = `${window.location.origin}${getConfig(
'PREVIEW_SCRIPTS_URL'
'PREVIEW_SCRIPTS_URL',
{
parseType: 'string',
nullishString: true
}
)}`;
previewScripts.setAttribute('crossorigin', '');
sketchDoc.head.appendChild(previewScripts);
Expand All @@ -245,7 +249,7 @@ p5.prototype.registerMethod('afterSetup', p5.prototype.ensureAccessibleCanvas);`
window.offs = ${JSON.stringify(scriptOffs)};
window.objectUrls = ${JSON.stringify(objectUrls)};
window.objectPaths = ${JSON.stringify(objectPaths)};
window.editorOrigin = '${getConfig('EDITOR_URL')}';
window.editorOrigin = '${getConfig('EDITOR_URL', { nullishString: true })}';
`;
addLoopProtect(sketchDoc);
sketchDoc.head.prepend(consoleErrorsScript);
Expand Down
2 changes: 1 addition & 1 deletion client/modules/Preview/previewIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../utils/dispatcher';
import { filesReducer, setFiles } from './filesReducer';
import EmbedFrame from './EmbedFrame';
import getConfig from '../../utils/getConfig';
import getConfig from '../../utils/getConfig.ts';
import { initialState } from '../IDE/reducers/files';

const GlobalStyle = createGlobalStyle`
Expand Down
2 changes: 1 addition & 1 deletion client/modules/User/components/CookieConsent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Transition } from 'react-transition-group';
import { Link } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
import getConfig from '../../../utils/getConfig';
import getConfig from '../../../utils/getConfig.ts';
import { setUserCookieConsent } from '../actions';
import { remSize, prop, device } from '../../../theme';
import Button from '../../../common/Button';
Expand Down
2 changes: 1 addition & 1 deletion client/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import listenerMiddleware from './middleware';
import DevTools from './modules/App/components/DevTools';
import rootReducer from './reducers';
import { clearState, loadState } from './persistState';
import getConfig from './utils/getConfig';
import getConfig from './utils/getConfig.ts';

// Enable DevTools only when rendering on client and during development.
// Display the dock monitor only if no browser extension is found.
Expand Down
33 changes: 33 additions & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ESNext",
"lib": ["DOM", "ESNext"],
"jsx": "react",

"strict": true,
"noEmit": true,

// "noImplicitAny": false,
// "strictNullChecks": false,
// "strictFunctionTypes": false,
// "strictBindCallApply": false,
// "noImplicitThis": false,
// "alwaysStrict": false,


"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
},
"include": ["**/*"],
"exclude": [
"../node_modules",
"../node_modules/@types",
"../dist",
"../build"
]
}
1 change: 1 addition & 0 deletions client/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./utils/getconfig.ts"],"version":"5.8.3"}
3 changes: 2 additions & 1 deletion client/utils/apiClient.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import axios from 'axios';

import getConfig from './getConfig';
import getConfig from './getConfig.ts';

const ROOT_URL = getConfig('API_URL');

/**
* Configures an Axios instance with the correct API URL
*/
function createClientInstance() {
// TODO: add fallback if no ROOT_URL is defined
return axios.create({
baseURL: ROOT_URL,
withCredentials: true
Expand Down
25 changes: 0 additions & 25 deletions client/utils/getConfig.js

This file was deleted.

Loading