refactor: build system

This commit is contained in:
2023-03-22 11:45:30 +01:00
parent 4df19e8c20
commit 8cb9285462
427 changed files with 3978 additions and 9810 deletions

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {ValidationError} from '@openstapps/core-tools/lib/types/validator.js';
import {ValidationError} from '@openstapps/core-tools';
import {StatusCodes} from 'http-status-codes';
import {SCError} from '../error.js';

View File

@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import equal = require('fast-deep-equal/es6');
import clone = require('rfdc');
import equal from 'fast-deep-equal/es6';
import clone from 'rfdc';
import {SCLanguageCode} from './general/i18n.js';
import {isThing} from './guards.js';
import {SCClasses} from './meta.js';
@@ -92,12 +92,11 @@ export class SCThingTranslator {
* @returns a T object allowing for access to translations or a translated value(s)
*/
private deeptranslate<T>(data: T): T {
return typeof data === 'object' ? new Proxy(
data as never,
{
get: (target, key) => this.deeptranslate(target[key as never]),
},
) as unknown as T : data;
return typeof data === 'object'
? (new Proxy(data as never, {
get: (target, key) => this.deeptranslate(target[key as never]),
}) as unknown as T)
: data;
}
/**
@@ -254,25 +253,22 @@ export class SCThingTranslator {
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
*/
public translatedAccess<T extends SCThing>(thing: T): T {
return new Proxy(
thing,
{
get: (target, key) => {
const object: any = target;
if (equal(this.sourceCache.get(thing), thing)) {
const objectTranslatedFromCache = this.cache.get(thing);
if (objectTranslatedFromCache !== undefined) {
return this.deeptranslate((objectTranslatedFromCache as any)[key]);
}
return new Proxy(thing, {
get: (target, key) => {
const object: any = target;
if (equal(this.sourceCache.get(thing), thing)) {
const objectTranslatedFromCache = this.cache.get(thing);
if (objectTranslatedFromCache !== undefined) {
return this.deeptranslate((objectTranslatedFromCache as any)[key]);
}
const objectTranslated = this.translateThingInPlaceDestructively(clone()(object));
this.cache.putObject(objectTranslated);
this.sourceCache.putObject(thing);
}
const objectTranslated = this.translateThingInPlaceDestructively(clone()(object));
this.cache.putObject(objectTranslated);
this.sourceCache.putObject(thing);
return this.deeptranslate(objectTranslated[key]);
},
return this.deeptranslate(objectTranslated[key]);
},
);
});
}
/**