Skip to content

Commit

Permalink
fix: deps (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Oct 13, 2023
1 parent 74c7451 commit ecdb854
Show file tree
Hide file tree
Showing 8 changed files with 957 additions and 488 deletions.
1,323 changes: 892 additions & 431 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"esbuild-wasm": "^0.19.4",
"fs-extra": "^10.0.0",
"husky": "^7.0.4",
"puppeteer": "^14.2.1",
"puppeteer": "^21.3.8",
"reflect-metadata": "^0.1.13",
"semantic-release": "^22.0.5",
"typescript": "^4.6.2"
Expand Down
44 changes: 22 additions & 22 deletions src/BuildInComponents/Components/style/sass.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { fileURLToPath, pathToFileURL } from "url";
import StringTracker from "../../../EasyDebug/StringTracker";
import { BasicSettings, getTypes } from "../../../RunTimeBuild/SearchFileSystem";
import sass from 'sass';
import { createNewPrint } from "../../../OutputInput/Logger";
import { RawSourceMap } from "source-map-js";
import { SessionBuild } from "../../../CompileCode/Session";
import { print } from "../../../OutputInput/Console";
import { SomePlugins } from "../../../CompileCode/InsertModels";
import {fileURLToPath, pathToFileURL} from 'url';
import StringTracker from '../../../EasyDebug/StringTracker';
import {BasicSettings, getTypes} from '../../../RunTimeBuild/SearchFileSystem';
import * as sass from 'sass';
import {createNewPrint} from '../../../OutputInput/Logger';
import {RawSourceMap} from 'source-map-js';
import {SessionBuild} from '../../../CompileCode/Session';
import {print} from '../../../OutputInput/Console';
import {SomePlugins} from '../../../CompileCode/InsertModels';


export function createImporter(originalPath: string) {
Expand All @@ -21,12 +21,12 @@ export function createImporter(originalPath: string) {

return new URL(url, pathToFileURL(originalPath));
}
}
};
}


function minifyPluginSass(language: string): boolean {
return (['scss', 'sass'].includes(language) ? SomePlugins("MinAll", "MinSass") : SomePlugins("MinCss", "MinAll"))
return (['scss', 'sass'].includes(language) ? SomePlugins('MinAll', 'MinSass') : SomePlugins('MinCss', 'MinAll'));
}

export function sassStyle(language: string) {
Expand All @@ -46,12 +46,12 @@ export function sassAndSource(sourceMap: RawSourceMap, source: string) {
}
}

export function getSassErrorLine({ sassStack }) {
export function getSassErrorLine({sassStack}) {
const loc = sassStack.match(/[0-9]+:[0-9]+/)[0].split(':').map(x => Number(x));
return { line: loc[0], column: loc[1] }
return {line: loc[0], column: loc[1]};
}

export function PrintSassError(err: any, {line, column} = getSassErrorLine(err)){
export function PrintSassError(err: any, {line, column} = getSassErrorLine(err)) {
const [funcName, printText] = createNewPrint({
text: `${err.message},\non file -><color>${fileURLToPath(err.span.url)}:${line ?? 0}:${column ?? 0}`,
errorName: err?.status == 5 ? 'sass-warning' : 'sass-error',
Expand All @@ -60,8 +60,8 @@ export function PrintSassError(err: any, {line, column} = getSassErrorLine(err))
print[funcName](printText);
}

export function PrintSassErrorTracker(err: any, track: StringTracker){
if(err.span.url) return PrintSassError(err);
export function PrintSassErrorTracker(err: any, track: StringTracker) {
if (err.span.url) return PrintSassError(err);

err.location = getSassErrorLine(err);

Expand Down Expand Up @@ -89,21 +89,21 @@ export async function compileSass(language: string, BetweenTagData: StringTracke
});
outStyle = result?.css ?? outStyle;
} catch (err) {
if(err.span.url){
if (err.span.url) {
const FullPath = fileURLToPath(err.span.url);
await sessionInfo.dependence(BasicSettings.relative(FullPath), FullPath)
await sessionInfo.dependence(BasicSettings.relative(FullPath), FullPath);
}
PrintSassErrorTracker(err, BetweenTagData);
return {outStyle: 'Sass Error (see console)'}
return {outStyle: 'Sass Error (see console)'};
}

if (result?.loadedUrls) {
for (const file of result.loadedUrls) {
const FullPath = fileURLToPath(<any>file);
await sessionInfo.dependence(BasicSettings.relative(FullPath), FullPath)
await sessionInfo.dependence(BasicSettings.relative(FullPath), FullPath);
}
}

result?.sourceMap && sassAndSource(result.sourceMap, thisPageURL.href);
return { result, outStyle, compressed };
}
return {result, outStyle, compressed};
}
18 changes: 9 additions & 9 deletions src/ImportFiles/ForStatic/Style.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import sass from 'sass';
import * as sass from 'sass';
import EasyFs from '../../OutputInput/EasyFs';
import path from 'path';
import {fileURLToPath, pathToFileURL} from "url";
import { BasicSettings, getTypes } from '../../RunTimeBuild/SearchFileSystem';
import { createImporter, PrintSassError, sassAndSource, sassStyle, sassSyntax } from '../../BuildInComponents/Components/style/sass';
import {fileURLToPath, pathToFileURL} from 'url';
import {BasicSettings, getTypes} from '../../RunTimeBuild/SearchFileSystem';
import {createImporter, PrintSassError, sassAndSource, sassStyle, sassSyntax} from '../../BuildInComponents/Components/style/sass';

export async function BuildStyleSass(inputPath: string, type: "sass" | "scss" | "css", isDebug: boolean): Promise<{ [key: string]: number }> {
export async function BuildStyleSass(inputPath: string, type: 'sass' | 'scss' | 'css', isDebug: boolean): Promise<{ [key: string]: number }> {
const fullPath = getTypes.Static[0] + inputPath, fullCompilePath = getTypes.Static[1] + inputPath;

const dependenceObject = {
thisFile: await EasyFs.stat(fullPath, 'mtimeMs')
}
};

const fileData = await EasyFs.readFile(fullPath), fileDataDirname = path.dirname(fullPath);

Expand All @@ -36,7 +36,7 @@ export async function BuildStyleSass(inputPath: string, type: "sass" | "scss" |
sassAndSource(result.sourceMap, pathToFileURL(fileData).href);
result.sourceMap.sources = result.sourceMap.sources.map(x => path.relative(fileDataDirname, fileURLToPath(x)) + '?source=true');

data += `\r\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(result.sourceMap)).toString("base64")}*/`;
data += `\r\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(result.sourceMap)).toString('base64')}*/`;
}
await EasyFs.makePathReal(inputPath, getTypes.Static[1]);
await EasyFs.writeFile(fullCompilePath, data);
Expand All @@ -45,5 +45,5 @@ export async function BuildStyleSass(inputPath: string, type: "sass" | "scss" |
return {};
}

return dependenceObject
}
return dependenceObject;
}
52 changes: 30 additions & 22 deletions src/ImportFiles/ForStatic/Svelte/preprocess.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { GetPlugin } from '../../../CompileCode/InsertModels';
import { transform } from '@swc/core';
import { getTypes, BasicSettings } from '../../../RunTimeBuild/SearchFileSystem';
import {GetPlugin} from '../../../CompileCode/InsertModels';
import {transform} from '@swc/core';
import {BasicSettings, getTypes} from '../../../RunTimeBuild/SearchFileSystem';
import EasyFs from '../../../OutputInput/EasyFs';
import { extname } from 'node:path';
import sass from 'sass';
import { v4 as uuid } from 'uuid';
import {extname} from 'node:path';
import * as sass from 'sass';
import {v4 as uuid} from 'uuid';
import path from 'path';
import { fileURLToPath } from 'node:url';
import { createImporter, PrintSassErrorTracker, sassStyle, sassSyntax } from '../../../BuildInComponents/Components/style/sass';
import { SessionBuild } from '../../../CompileCode/Session';
import {fileURLToPath} from 'node:url';
import {createImporter, PrintSassErrorTracker, sassStyle, sassSyntax} from '../../../BuildInComponents/Components/style/sass';
import {SessionBuild} from '../../../CompileCode/Session';
import StringTracker from '../../../EasyDebug/StringTracker';
import { ESBuildPrintErrorStringTracker } from '../../../CompileCode/transpiler/printMessage';
import { backToOriginal, backToOriginalSss } from '../../../EasyDebug/SourceMapLoad';
import { TransformJSC } from '../../../CompileCode/transpiler/settings';
import {ESBuildPrintErrorStringTracker} from '../../../CompileCode/transpiler/printMessage';
import {backToOriginal, backToOriginalSss} from '../../../EasyDebug/SourceMapLoad';
import {TransformJSC} from '../../../CompileCode/transpiler/settings';

async function SASSSvelte(content: StringTracker, lang: string, fullPath: string) {
try {
const { css, sourceMap, loadedUrls } = await sass.compileStringAsync(content.eq, {
const {css, sourceMap, loadedUrls} = await sass.compileStringAsync(content.eq, {
syntax: sassSyntax(<any>lang),
style: sassStyle(lang),
importer: createImporter(fullPath),
Expand All @@ -34,7 +34,7 @@ async function SASSSvelte(content: StringTracker, lang: string, fullPath: string

return {
code: new StringTracker()
}
};
}

async function ScriptSvelte(content: StringTracker, lang: string, connectSvelte: string[], isDebug: boolean, svelteExt = ''): Promise<StringTracker> {
Expand Down Expand Up @@ -66,15 +66,15 @@ async function ScriptSvelte(content: StringTracker, lang: string, connectSvelte:
});

try {
const { code, map } = (await transform(content.eq, {
const {code, map} = (await transform(content.eq, {
jsc: TransformJSC({
parser: {
syntax: 'typescript',
...GetPlugin(lang.toUpperCase() +"Options")
...GetPlugin(lang.toUpperCase() + 'Options')
}
}, { __DEBUG__: '' + isDebug }),
}, {__DEBUG__: '' + isDebug}),
sourceMaps: true,
...GetPlugin("transformOptions"),
...GetPlugin('transformOptions'),
}));
content = await backToOriginal(content, code, map);
} catch (err) {
Expand All @@ -85,7 +85,7 @@ async function ScriptSvelte(content: StringTracker, lang: string, connectSvelte:

if (lang == 'ts')
content = content.replacer(/___toKen`([\w\W]+?)`/mi, args => {
return mapToken[args[1].eq] ?? new StringTracker()
return mapToken[args[1].eq] ?? new StringTracker();
});

return content;
Expand All @@ -108,11 +108,12 @@ export async function preprocess(fullPath: string, smallPath: string, isDebug: b
styleLang = args[4]?.eq ?? 'css';
if (styleLang == 'css') return args[0];

const { code, dependencies: deps } = await SASSSvelte(args[7], styleLang, fullPath);
const {code, dependencies: deps} = await SASSSvelte(args[7], styleLang, fullPath);
deps && dependencies.push(...deps);
hadStyle = true;
styleCode && code.AddTextBeforeNoTrack(styleCode);
return args[1].Plus(args[6], code, args[8]);;
return args[1].Plus(args[6], code, args[8]);
;
});

if (!hadStyle && styleCode) {
Expand All @@ -127,7 +128,14 @@ export async function preprocess(fullPath: string, smallPath: string, isDebug: b
}


return { scriptLang, styleLang, code: text.eq, map: text.StringTack(savePath, httpSource), dependencies: sessionInfo.dependencies, svelteFiles: connectSvelte.map(x => x[0] == '/' ? getTypes.Static[0] + x : path.normalize(fullPath + '/../' + x)) };
return {
scriptLang,
styleLang,
code: text.eq,
map: text.StringTack(savePath, httpSource),
dependencies: sessionInfo.dependencies,
svelteFiles: connectSvelte.map(x => x[0] == '/' ? getTypes.Static[0] + x : path.normalize(fullPath + '/../' + x))
};
}

export function Capitalize(name: string) {
Expand Down
6 changes: 3 additions & 3 deletions src/MainBuild/ParseRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { multipartType } from 'formidable/src/plugins/multipart.js';
import { querystringType } from 'formidable/src/plugins/querystring.js';
const multipartType = 'multipart';
const querystringType = 'urlencoded';

export function firstValuesOrFullArray(form, fields, exceptions = []) {
/**
Expand All @@ -17,4 +17,4 @@ export function firstValuesOrFullArray(form, fields, exceptions = []) {
return [key, value.length === 1 ? value[0] : value];
}),
);
};
};
Binary file modified src/static/wasm/component/build.wasm
Binary file not shown.
Binary file modified tests/core/Website/WWW/server/wasm/build.serv.wasm
Binary file not shown.

0 comments on commit ecdb854

Please sign in to comment.