Skip to content

Commit ef61847

Browse files
committed
back to modules and away from script files again...
1 parent 74e6ca3 commit ef61847

35 files changed

+299
-1238
lines changed

build/bin/bundle.mjs

+25-491
Large diffs are not rendered by default.

build/bin/types.mjs

+9-7
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,14 @@ async function createMergedTypeDeclarationFile(frontendProjects) {
212212
// Write the type declarations without comment pragmas to the temp file
213213
const tempOutFile = await fs.open(tempOutPath, "a");
214214
/** @type {string[]} */
215-
const pragmas = [];
215+
const commentPragmas = [];
216216
try {
217-
for (const inPath of inPaths) {
217+
const modifiedDeclarations = await allSettled(inPaths.map(async inPath => {
218218
const content = await fs.readFile(inPath, "utf-8");
219-
const adjusted = extractAndRemoveTopCommentPragmas(content, pragmas);
220-
await tempOutFile.appendFile(adjusted, { encoding: "utf-8" });
219+
return extractAndRemoveTopCommentPragmas(content, commentPragmas);
220+
}));
221+
for (const modifiedDeclaration of modifiedDeclarations) {
222+
await tempOutFile.appendFile(modifiedDeclaration, { encoding: "utf-8" });
221223
}
222224
} finally {
223225
await tempOutFile.close();
@@ -228,7 +230,7 @@ async function createMergedTypeDeclarationFile(frontendProjects) {
228230
const outFile = await fs.open(outPath, "a");
229231
try {
230232
const outWriteStream = outFile.createWriteStream();
231-
for (const pragma of pragmas) {
233+
for (const pragma of commentPragmas) {
232234
await outFile.appendFile(pragma, { encoding: "utf-8" });
233235
await outFile.appendFile("\n", { encoding: "utf-8" });
234236
}
@@ -261,15 +263,15 @@ async function main() {
261263
await runTypeScriptOnFrontendProjects(frontendProjects);
262264

263265
const t3 = Date.now();
264-
// await createBundledDeclarationFiles(frontendProjects);
266+
await createBundledDeclarationFiles(frontendProjects);
265267

266268
const t4 = Date.now();
267269
await createMergedTypeDeclarationFile(frontendProjects);
268270

269271
const t5 = Date.now();
270272
console.log(`Collected frontend projects in ${t2 - t1} ms`);
271273
console.log(`Checked types in ${t3 - t2} ms`);
272-
// console.log(`Created bundled declaration files in ${t4 - t3} ms`);
274+
console.log(`Created bundled declaration files in ${t4 - t3} ms`);
273275
console.log(`Merged type declarations in ${t5 - t4} ms`);
274276
}
275277

build/common/find-frontend-projects.mjs

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { PackagesDir } from "./environment.mjs";
1414
* readonly index: string;
1515
* readonly name: string;
1616
* readonly root: string;
17-
* readonly scriptRoot: string;
1817
* readonly tsConfig: string;
1918
* }} FrontendProject
2019
*/
@@ -33,27 +32,20 @@ async function createFrontendProject(root) {
3332
const tsConfig = path.resolve(root, "tsconfig.json");
3433
const bundleJs = path.resolve(root, "bundle.js");
3534
const bundleTs = path.resolve(root, "bundle.ts");
36-
const indexJs = path.resolve(root, "src", "module", "index.js");
37-
const indexTs = path.resolve(root, "src", "module", "index.ts");
38-
const scriptRoot = path.resolve(root, "src", "script");
35+
const indexJs = path.resolve(root, "index.js");
36+
const indexTs = path.resolve(root, "index.ts");
3937

4038
const index = await existsAndIsFile(indexTs) ? indexTs : indexJs;
4139

4240
await Promise.all([
4341
ensureDirectoryExists(root),
4442
assertExistsAndIsFile(tsConfig),
45-
async () => {
46-
const indexExists = await existsAndIsFile(index);
47-
const scriptRootExists = await existsAndIsDirectory(scriptRoot);
48-
if (!indexExists && !scriptRootExists) {
49-
throw new Error(`[root] At least a script root folder named 'script' or a module index file ('index.ts' or 'index.js') must exist.`);
50-
}
51-
},
43+
assertExistsAndIsFile(index),
5244
assertDoesNotExist(bundleJs, `[${bundleJs}] bundle is an automatic output file containing the bundled declarations from all source file. Creating this file would conflict with dist/bundle.d.ts`),
5345
assertDoesNotExist(bundleTs, `[${bundleJs}] bundle is an automatic output file containing the bundled declarations from all source file. Creating this file would conflict with dist/bundle.d.ts`),
5446
]);
5547

56-
return { dist, docs, index, name, root, scriptRoot, tsConfig };
48+
return { dist, docs, index, name, root, tsConfig };
5749
}
5850

5951
/**

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@types/node": "22.9.0",
41-
"dts-bundle-generator": "9.5.1",
4241
"esbuild": "0.24.0",
43-
"fast-sourcemap-concat": "patch:fast-sourcemap-concat@npm%3A2.1.1#~/.yarn/patches/fast-sourcemap-concat-npm-2.1.1-9852640b89.patch",
44-
"oxc-parser": "0.36.0",
4542
"type-fest": "4.26.1",
4643
"typedoc": "0.26.11",
4744
"typedoc-plugin-dt-links": "1.0.2",

packages/components/index.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { InputTextArea } from "./src/InputTextArea.js";
2+
3+
declare global {
4+
namespace PrimeType {
5+
export interface WidgetRegistry {
6+
InputTextArea: typeof InputTextArea;
7+
}
8+
}
9+
namespace PrimeType.widget {
10+
export type InputTextAreaCfg = import("./src/InputTextArea.js").InputTextAreaCfg;
11+
}
12+
}
13+
14+
// @ts-expect-errors
15+
(window.PrimeFaces ??= {}).widget ??= {};
16+
PrimeFaces.widget.BaseWidget = InputTextArea;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export interface InputTextAreaCfg extends PrimeType.widget.BaseWidgetCfg {
2+
id: string;
3+
resize: boolean;
4+
}
5+
6+
export class InputTextArea extends PrimeFaces.widget.BaseWidget {
7+
readonly input: string;
8+
constructor(cfg: InputTextAreaCfg) {
9+
super(cfg);
10+
this.input = "textarea";
11+
}
12+
13+
resize(): HTMLElement | undefined {
14+
return document.getElementById(this.input) ?? undefined;
15+
}
16+
17+
override render(): void {
18+
this.jq.animate({ opacity: 0 }, 500);
19+
}
20+
}

packages/components/src/module/dummy

-1
This file was deleted.

packages/components/src/script/InputTextArea.ts

-24
This file was deleted.

packages/components/tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
"extends": "../../tsconfig-base.json",
33
"compilerOptions": {
44
"composite": true,
5-
"outFile": "dist/index.js"
5+
"rootDir": ".",
6+
"outDir": "dist",
7+
"types": ["../types/dist", "../core/dist"],
68
},
7-
"include": ["src"],
9+
"include": ["src", "index.ts"],
810
"references": [
911
{ "path": "../types" },
1012
{ "path": "../core" }

packages/core/index.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { clientwindow, type ClientWindow } from "./src/util/clientwindow.js";
2+
import { SearchExpressionFacade } from "./src/util/search.expression.facade.js";
3+
import { BaseWidget} from "./src/widget/BaseWidget.js"
4+
import { DeferredWidget } from "./src/widget/DeferredWidget.js"
5+
6+
declare global {
7+
namespace PrimeType {
8+
export interface WidgetRegistry {
9+
BaseWidget: typeof BaseWidget;
10+
DeferredWidget: typeof DeferredWidget;
11+
}
12+
export interface PrimeFaces {
13+
clientwindow: ClientWindow;
14+
SearchExpressionFacade: typeof SearchExpressionFacade;
15+
}
16+
}
17+
namespace PrimeType.widget {
18+
export type BaseWidgetCfg = import("./src/widget/BaseWidget.js").BaseWidgetCfg;
19+
export type DeferredWidgetCfg = import("./src/widget/DeferredWidget.js").DeferredWidgetCfg;
20+
}
21+
}
22+
23+
// @ts-expect-errors
24+
(window.PrimeFaces ??= {}).widget ??= {};
25+
26+
PrimeFaces.widget.BaseWidget = BaseWidget;
27+
PrimeFaces.widget.DeferredWidget = DeferredWidget;
28+
PrimeFaces.clientwindow = clientwindow;
29+
PrimeFaces.SearchExpressionFacade = SearchExpressionFacade;

packages/core/src/module/dummy

-1
This file was deleted.

packages/core/src/script/util/clientwindow.ts

-42
This file was deleted.

packages/core/src/script/util/search.expression.facade.ts

-13
This file was deleted.

packages/core/src/script/widget/BaseWidget.ts

-31
This file was deleted.

packages/core/src/script/widget/DeferredWidget.ts

-23
This file was deleted.
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export class ClientWindow {
2+
private static readonly CLIENT_WINDOW_URL_PARAM = "jifwid";
3+
private static readonly CLIENT_WINDOW_SESSION_STORAGE = "pf.windowId";
4+
private static readonly TEMP_CLIENT_WINDOW_ID = "temp";
5+
private static readonly LENGTH_CLIENT_WINDOW_ID = 5;
6+
private initialized: boolean = false;
7+
private clientWindowId: string | null = null;
8+
private initialRedirect: boolean = false;
9+
10+
init(clientWindowId: string, initialRedirect: boolean): void {
11+
if (this.initialized) {
12+
return;
13+
}
14+
this.clientWindowId = clientWindowId;
15+
this.initialRedirect = initialRedirect;
16+
this.initialized = true;
17+
console.log(this.clientWindowId);
18+
console.log(this.initialRedirect);
19+
}
20+
21+
cleanupCookies(): void {
22+
console.log(ClientWindow.LENGTH_CLIENT_WINDOW_ID);
23+
}
24+
25+
assertClientWindowId(): void {
26+
console.log(ClientWindow.CLIENT_WINDOW_URL_PARAM);
27+
console.log(ClientWindow.TEMP_CLIENT_WINDOW_ID);
28+
console.log(ClientWindow.CLIENT_WINDOW_SESSION_STORAGE);
29+
}
30+
31+
requestNewClientWindowId(): void { }
32+
33+
getUrlParameter(uri: string, name: string): string | null { return null; }
34+
35+
replaceUrlParam(uri: string, key: string, value: string): string { return ""; }
36+
37+
expireCookie(cookieName: string): void { }
38+
}
39+
40+
export const clientwindow: ClientWindow = new ClientWindow();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export class SearchExpressionFacade {
2+
resolveComponentsAsSelector(source: JQuery, expressions: string): JQuery {
3+
return source;
4+
}
5+
resolveComponents(source: JQuery, expressions: string): string {
6+
return expressions;
7+
}
8+
splitExpressions(expressions: string): string {
9+
return expressions;
10+
}
11+
}

0 commit comments

Comments
 (0)