jopi-toolkit 3.0.5 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/jk_crypto/jBundler_ifServer.d.ts +2 -2
- package/dist/jk_crypto/jBundler_ifServer.js +8 -8
- package/dist/jk_crypto/jBundler_ifServer.js.map +1 -1
- package/dist/jk_events/index.d.ts +5 -5
- package/dist/jk_events/index.js +20 -10
- package/dist/jk_events/index.js.map +1 -1
- package/dist/jk_fs/jBundler_ifBrowser.d.ts +2 -2
- package/dist/jk_fs/jBundler_ifBrowser.js +2 -2
- package/dist/jk_fs/jBundler_ifServer.d.ts +39 -3
- package/dist/jk_fs/jBundler_ifServer.js +152 -3
- package/dist/jk_fs/jBundler_ifServer.js.map +1 -1
- package/dist/jk_logs/index.d.ts +54 -0
- package/dist/jk_logs/index.js +316 -0
- package/dist/jk_logs/index.js.map +1 -0
- package/dist/jk_logs/jBundler_ifBrowser.js.map +1 -0
- package/dist/jk_logs/jBundler_ifServer.d.ts +2 -0
- package/dist/jk_logs/jBundler_ifServer.js +25 -0
- package/dist/jk_logs/jBundler_ifServer.js.map +1 -0
- package/dist/jk_schemas/index.js +2 -0
- package/dist/jk_schemas/index.js.map +1 -1
- package/dist/jk_timer/index.js +9 -4
- package/dist/jk_timer/index.js.map +1 -1
- package/dist/jk_tools/common.d.ts +29 -0
- package/dist/jk_tools/common.js +89 -0
- package/dist/jk_tools/common.js.map +1 -0
- package/dist/jk_tools/index.d.ts +1 -20
- package/dist/jk_tools/index.js +1 -71
- package/dist/jk_tools/index.js.map +1 -1
- package/dist/jk_tools/jBundler_ifBrowser.d.ts +1 -0
- package/dist/jk_tools/jBundler_ifBrowser.js +2 -0
- package/dist/jk_tools/jBundler_ifBrowser.js.map +1 -0
- package/dist/jk_tools/jBundler_ifServer.d.ts +22 -0
- package/dist/jk_tools/jBundler_ifServer.js +75 -0
- package/dist/jk_tools/jBundler_ifServer.js.map +1 -0
- package/package.json +11 -4
- package/src/jk_crypto/jBundler_ifServer.ts +8 -8
- package/src/jk_events/index.js +17 -7
- package/src/jk_events/index.ts +24 -3
- package/src/jk_fs/jBundler_ifBrowser.ts +2 -2
- package/src/jk_fs/jBundler_ifServer.js +552 -0
- package/src/jk_fs/jBundler_ifServer.ts +171 -4
- package/src/jk_logs/index.ts +444 -0
- package/src/jk_logs/jBundler_ifBrowser.ts +2 -0
- package/src/jk_logs/jBundler_ifServer.ts +27 -0
- package/src/jk_thread/common.js +7 -0
- package/src/jk_tools/common.js +101 -0
- package/src/jk_tools/common.ts +99 -0
- package/src/jk_tools/index.js +1 -82
- package/src/jk_tools/index.ts +1 -82
- package/src/jk_tools/jBundler_ifBrowser.ts +1 -0
- package/src/jk_tools/jBundler_ifServer.js +167 -0
- package/src/jk_tools/jBundler_ifServer.ts +109 -0
- package/src/jk_what/jBundler_ifServer.js +5 -0
- package/dist/jk_appResolver/common.d.ts +0 -40
- package/dist/jk_appResolver/common.js +0 -306
- package/dist/jk_appResolver/common.js.map +0 -1
- package/dist/jk_appResolver/index.d.ts +0 -30
- package/dist/jk_appResolver/index.js +0 -276
- package/dist/jk_appResolver/index.js.map +0 -1
- package/dist/jk_appResolver/jBundler_ifBrowser.js.map +0 -1
- package/dist/jk_appResolver/jBundler_ifServer.d.ts +0 -1
- package/dist/jk_appResolver/jBundler_ifServer.js +0 -9
- package/dist/jk_appResolver/jBundler_ifServer.js.map +0 -1
- package/dist/jk_linker/TypeComposite.d.ts +0 -12
- package/dist/jk_linker/TypeComposite.js +0 -112
- package/dist/jk_linker/TypeComposite.js.map +0 -1
- package/dist/jk_linker/arobaseType_List.d.ts +0 -44
- package/dist/jk_linker/arobaseType_List.js +0 -183
- package/dist/jk_linker/arobaseType_List.js.map +0 -1
- package/dist/jk_linker/arobaseTypes.d.ts +0 -45
- package/dist/jk_linker/arobaseTypes.js +0 -181
- package/dist/jk_linker/arobaseTypes.js.map +0 -1
- package/dist/jk_linker/binding.d.ts +0 -1
- package/dist/jk_linker/binding.js +0 -13
- package/dist/jk_linker/binding.js.map +0 -1
- package/dist/jk_linker/engine.d.ts +0 -119
- package/dist/jk_linker/engine.js +0 -553
- package/dist/jk_linker/engine.js.map +0 -1
- package/dist/jk_linker/index.d.ts +0 -1
- package/dist/jk_linker/index.js +0 -2
- package/dist/jk_linker/index.js.map +0 -1
- package/dist/jk_linker/install.d.ts +0 -4
- package/dist/jk_linker/install.js +0 -44
- package/dist/jk_linker/install.js.map +0 -1
- package/dist/jk_linker/jBundler_ifServer.d.ts +0 -3
- package/dist/jk_linker/jBundler_ifServer.js +0 -4
- package/dist/jk_linker/jBundler_ifServer.js.map +0 -1
- package/dist/jk_linker/modulesInitProcessor.d.ts +0 -7
- package/dist/jk_linker/modulesInitProcessor.js +0 -36
- package/dist/jk_linker/modulesInitProcessor.js.map +0 -1
- package/dist/jk_linker/typeChunks.d.ts +0 -15
- package/dist/jk_linker/typeChunks.js +0 -42
- package/dist/jk_linker/typeChunks.js.map +0 -1
- package/dist/jk_linker/typeComposites.d.ts +0 -13
- package/dist/jk_linker/typeComposites.js +0 -121
- package/dist/jk_linker/typeComposites.js.map +0 -1
- package/dist/jk_linker/typeEvents.d.ts +0 -5
- package/dist/jk_linker/typeEvents.js +0 -29
- package/dist/jk_linker/typeEvents.js.map +0 -1
- package/dist/jk_linker/typeList.d.ts +0 -30
- package/dist/jk_linker/typeList.js +0 -144
- package/dist/jk_linker/typeList.js.map +0 -1
- package/dist/jk_linker/typeListeners.d.ts +0 -21
- package/dist/jk_linker/typeListeners.js +0 -188
- package/dist/jk_linker/typeListeners.js.map +0 -1
- package/dist/jk_linker/typeReplaces.d.ts +0 -8
- package/dist/jk_linker/typeReplaces.js +0 -41
- package/dist/jk_linker/typeReplaces.js.map +0 -1
- package/dist/jk_registry/index.d.ts +0 -11
- package/dist/jk_registry/index.js +0 -36
- package/dist/jk_registry/index.js.map +0 -1
- /package/dist/{jk_appResolver → jk_logs}/jBundler_ifBrowser.d.ts +0 -0
- /package/dist/{jk_appResolver → jk_logs}/jBundler_ifBrowser.js +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type Listener = () => void | Promise<void>;
|
|
2
|
-
declare global {
|
|
3
|
-
var jopiHotReload: HotReloadType;
|
|
4
|
-
}
|
|
5
|
-
export interface HotReloadType {
|
|
6
|
-
onHotReload: Listener[];
|
|
7
|
-
memory: {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export declare function onServerSideReady(listener: Listener): void;
|
|
12
|
-
export declare function waitServerSideReady(): Promise<void>;
|
|
13
|
-
export declare function declareServerSideReady(): Promise<void>;
|
|
14
|
-
export declare function onAppStart(listener: Listener): void;
|
|
15
|
-
export declare function onAppExiting(listener: Listener): void;
|
|
16
|
-
export declare function onAppExited(listener: Listener): void;
|
|
17
|
-
export declare function declareAppStarted(): Promise<void>;
|
|
18
|
-
export declare function declareAppExiting(): Promise<void>;
|
|
19
|
-
export declare function executeApp(app: Listener): Promise<void>;
|
|
20
|
-
export declare function onHotReload(listener: Listener): void;
|
|
21
|
-
export declare function keepOnHotReload<T>(key: string, provider: () => T): T;
|
|
22
|
-
export declare function clearHotReloadKey(key: string): void;
|
|
23
|
-
export declare function getTempDir(): string;
|
|
24
|
-
export declare function findNodePackageDir(packageName: string, useLinuxPathFormat?: boolean): string | undefined;
|
|
25
|
-
export declare function requireNodePackageDir(packageName: string, useLinuxPathFormat?: boolean): string;
|
|
26
|
-
export declare function findPackageJsonDir(searchFromDir?: string): string;
|
|
27
|
-
export declare function findPackageJson(searchFromDir?: string): string;
|
|
28
|
-
export declare function setApplicationMainFile(applicationMainFile: string): void;
|
|
29
|
-
export declare function getApplicationMainFile(): string | undefined;
|
|
30
|
-
export declare function getCodeSourceDirHint(): string;
|
|
31
|
-
export declare function getSourceCodeDir(): string;
|
|
32
|
-
export declare function getCompiledCodeDir(): string;
|
|
33
|
-
export declare function getCompiledFilePathFor(sourceFilePath: string): string;
|
|
34
|
-
export declare function getSourcesCodePathFor(compiledFilePath: string): string;
|
|
35
|
-
export declare function requireSourceOf(scriptPath: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Search the source of the component if it's a JavaScript and not a TypeScript.
|
|
38
|
-
* Why? Because EsBuild doesn't work well on already transpiled code.
|
|
39
|
-
*/
|
|
40
|
-
export declare function searchSourceOf(scriptPath: string): string | undefined;
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
// noinspection JSUnusedGlobalSymbols
|
|
2
|
-
import * as jk_thread from "jopi-toolkit/jk_thread";
|
|
3
|
-
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
4
|
-
import * as jk_timer from "jopi-toolkit/jk_timer";
|
|
5
|
-
import { isBunJS, isNodeJS } from "jopi-toolkit/jk_what";
|
|
6
|
-
import { isUsingWorker } from "jopi-toolkit/jk_thread";
|
|
7
|
-
async function execListeners(listeners) {
|
|
8
|
-
const list = [...listeners];
|
|
9
|
-
listeners.splice(0);
|
|
10
|
-
for (const listener of list) {
|
|
11
|
-
try {
|
|
12
|
-
const res = listener();
|
|
13
|
-
if (res instanceof Promise)
|
|
14
|
-
await res;
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const gOnServerSideReady = [];
|
|
22
|
-
const gOnAppExiting = [];
|
|
23
|
-
const gOnAppExited = [];
|
|
24
|
-
const gOnAppStart = [];
|
|
25
|
-
let gIsServerSideReady = !(isNodeJS || isBunJS);
|
|
26
|
-
let gIsHotReload = globalThis.jopiHotReload !== undefined;
|
|
27
|
-
let gIsAppStarted = false;
|
|
28
|
-
if (gIsHotReload) {
|
|
29
|
-
execListeners(globalThis.jopiHotReload.onHotReload).then();
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
globalThis.jopiHotReload = {
|
|
33
|
-
onHotReload: [],
|
|
34
|
-
memory: {}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const gOnHotReload = globalThis.jopiHotReload.onHotReload;
|
|
38
|
-
const gMemory = globalThis.jopiHotReload.memory;
|
|
39
|
-
export function onServerSideReady(listener) {
|
|
40
|
-
if (gIsServerSideReady)
|
|
41
|
-
listener();
|
|
42
|
-
else
|
|
43
|
-
gOnServerSideReady.push(listener);
|
|
44
|
-
}
|
|
45
|
-
export function waitServerSideReady() {
|
|
46
|
-
if (gIsServerSideReady) {
|
|
47
|
-
return Promise.resolve();
|
|
48
|
-
}
|
|
49
|
-
return new Promise(r => {
|
|
50
|
-
onServerSideReady(r);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
export async function declareServerSideReady() {
|
|
54
|
-
gIsServerSideReady = true;
|
|
55
|
-
await execListeners(gOnServerSideReady);
|
|
56
|
-
}
|
|
57
|
-
export function onAppStart(listener) {
|
|
58
|
-
if (gIsAppStarted)
|
|
59
|
-
listener();
|
|
60
|
-
else
|
|
61
|
-
gOnAppStart.push(listener);
|
|
62
|
-
}
|
|
63
|
-
export function onAppExiting(listener) {
|
|
64
|
-
if (gIsExited)
|
|
65
|
-
listener();
|
|
66
|
-
else
|
|
67
|
-
gOnAppExiting.push(listener);
|
|
68
|
-
}
|
|
69
|
-
export function onAppExited(listener) {
|
|
70
|
-
if (gIsExited)
|
|
71
|
-
listener();
|
|
72
|
-
else
|
|
73
|
-
gOnAppExited.push(listener);
|
|
74
|
-
}
|
|
75
|
-
export async function declareAppStarted() {
|
|
76
|
-
gIsAppStarted = true;
|
|
77
|
-
await execListeners(gOnAppStart);
|
|
78
|
-
}
|
|
79
|
-
export async function declareAppExiting() {
|
|
80
|
-
if (gIsExited)
|
|
81
|
-
return;
|
|
82
|
-
gIsExited = true;
|
|
83
|
-
if (isUsingWorker()) {
|
|
84
|
-
// Wait 1 sec, which allows the worker to correctly initialize.
|
|
85
|
-
await jk_timer.tick(1000);
|
|
86
|
-
}
|
|
87
|
-
gIsAppStarted = false;
|
|
88
|
-
await execListeners(gOnAppExiting);
|
|
89
|
-
if (isUsingWorker()) {
|
|
90
|
-
// Allows to worker to correctly stop their activity.
|
|
91
|
-
await jk_timer.tick(100);
|
|
92
|
-
}
|
|
93
|
-
if (!jk_thread.isMainThread) {
|
|
94
|
-
// Allows to worker to correctly stop their activity.
|
|
95
|
-
await jk_timer.tick(50);
|
|
96
|
-
}
|
|
97
|
-
await execListeners(gOnAppExited);
|
|
98
|
-
}
|
|
99
|
-
export async function executeApp(app) {
|
|
100
|
-
await waitServerSideReady();
|
|
101
|
-
declareAppStarted();
|
|
102
|
-
try {
|
|
103
|
-
const res = app();
|
|
104
|
-
if (res instanceof Promise)
|
|
105
|
-
await res;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
declareAppExiting();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
export function onHotReload(listener) {
|
|
112
|
-
gOnHotReload.push(listener);
|
|
113
|
-
}
|
|
114
|
-
export function keepOnHotReload(key, provider) {
|
|
115
|
-
let current = gMemory[key];
|
|
116
|
-
if (current !== undefined)
|
|
117
|
-
return current;
|
|
118
|
-
return gMemory[key] = provider();
|
|
119
|
-
}
|
|
120
|
-
export function clearHotReloadKey(key) {
|
|
121
|
-
delete (gMemory[key]);
|
|
122
|
-
}
|
|
123
|
-
export function getTempDir() {
|
|
124
|
-
if (!gTempDir) {
|
|
125
|
-
gTempDir = jk_fs.resolve(process.cwd(), "temp");
|
|
126
|
-
}
|
|
127
|
-
return gTempDir;
|
|
128
|
-
}
|
|
129
|
-
let gIsExited = false;
|
|
130
|
-
let gTempDir;
|
|
131
|
-
export function findNodePackageDir(packageName, useLinuxPathFormat = true) {
|
|
132
|
-
let currentDir = jk_fs.dirname(findPackageJson());
|
|
133
|
-
while (true) {
|
|
134
|
-
const packagePath = jk_fs.join(currentDir, 'node_modules', packageName);
|
|
135
|
-
if (jk_fs.isDirectorySync(packagePath)) {
|
|
136
|
-
if (useLinuxPathFormat)
|
|
137
|
-
return jk_fs.win32ToLinuxPath(packagePath);
|
|
138
|
-
return packagePath;
|
|
139
|
-
}
|
|
140
|
-
const parentDir = jk_fs.dirname(currentDir);
|
|
141
|
-
// Reached root directory
|
|
142
|
-
if (parentDir === currentDir) {
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
currentDir = parentDir;
|
|
146
|
-
}
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
export function requireNodePackageDir(packageName, useLinuxPathFormat = true) {
|
|
150
|
-
let pkgDir = findNodePackageDir(packageName, useLinuxPathFormat);
|
|
151
|
-
if (!pkgDir)
|
|
152
|
-
throw new Error("Package '" + packageName + "' not found");
|
|
153
|
-
return pkgDir;
|
|
154
|
-
}
|
|
155
|
-
export function findPackageJsonDir(searchFromDir = getCodeSourceDirHint()) {
|
|
156
|
-
let pkgJsonPath = findPackageJson(searchFromDir);
|
|
157
|
-
return jk_fs.dirname(pkgJsonPath);
|
|
158
|
-
}
|
|
159
|
-
export function findPackageJson(searchFromDir = getCodeSourceDirHint()) {
|
|
160
|
-
if (!searchFromDir && (gPackageJsonPath !== undefined))
|
|
161
|
-
return gPackageJsonPath;
|
|
162
|
-
let currentDir = searchFromDir;
|
|
163
|
-
while (true) {
|
|
164
|
-
const packagePath = jk_fs.join(currentDir, 'package.json');
|
|
165
|
-
if (jk_fs.isFileSync(packagePath))
|
|
166
|
-
return gPackageJsonPath = packagePath;
|
|
167
|
-
const parentDir = jk_fs.dirname(currentDir);
|
|
168
|
-
// Reached root directory
|
|
169
|
-
if (parentDir === currentDir)
|
|
170
|
-
break;
|
|
171
|
-
currentDir = parentDir;
|
|
172
|
-
}
|
|
173
|
-
throw "No package.json found.";
|
|
174
|
-
}
|
|
175
|
-
//
|
|
176
|
-
let gPackageJsonPath;
|
|
177
|
-
export function setApplicationMainFile(applicationMainFile) {
|
|
178
|
-
gApplicationMainFile = applicationMainFile;
|
|
179
|
-
gCodeSourceDirHint = jk_fs.dirname(applicationMainFile);
|
|
180
|
-
}
|
|
181
|
-
export function getApplicationMainFile() {
|
|
182
|
-
return gApplicationMainFile;
|
|
183
|
-
}
|
|
184
|
-
export function getCodeSourceDirHint() {
|
|
185
|
-
if (!gCodeSourceDirHint)
|
|
186
|
-
return process.cwd();
|
|
187
|
-
return gCodeSourceDirHint;
|
|
188
|
-
}
|
|
189
|
-
export function getSourceCodeDir() {
|
|
190
|
-
if (gSourceCodeDir)
|
|
191
|
-
return gSourceCodeDir;
|
|
192
|
-
let pkgJsonPath = findPackageJson();
|
|
193
|
-
let dirName = jk_fs.join(jk_fs.dirname(pkgJsonPath), "src");
|
|
194
|
-
if (jk_fs.isDirectorySync(dirName)) {
|
|
195
|
-
return gSourceCodeDir = dirName;
|
|
196
|
-
}
|
|
197
|
-
return gSourceCodeDir = jk_fs.dirname(pkgJsonPath);
|
|
198
|
-
}
|
|
199
|
-
export function getCompiledCodeDir() {
|
|
200
|
-
if (gCompiledSourcesDir)
|
|
201
|
-
return gCompiledSourcesDir;
|
|
202
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
203
|
-
if (!sourceCodeDir.endsWith("src")) {
|
|
204
|
-
return gCompiledSourcesDir = sourceCodeDir;
|
|
205
|
-
}
|
|
206
|
-
// This means that it's Bun.js, and it directly uses the TypeScript version.
|
|
207
|
-
if (gApplicationMainFile && isBunJS && gApplicationMainFile.startsWith(sourceCodeDir)) {
|
|
208
|
-
return gCompiledSourcesDir = sourceCodeDir;
|
|
209
|
-
}
|
|
210
|
-
let pkgJsonPath = findPackageJson();
|
|
211
|
-
let rootDir = jk_fs.dirname(pkgJsonPath);
|
|
212
|
-
for (let toTest of ["dist", "build", "out"]) {
|
|
213
|
-
if (jk_fs.isDirectorySync(jk_fs.join(rootDir, toTest))) {
|
|
214
|
-
return gCompiledSourcesDir = jk_fs.join(rootDir, toTest);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
// No output dir? Assume we compiled on the same dir.
|
|
218
|
-
return rootDir;
|
|
219
|
-
}
|
|
220
|
-
export function getCompiledFilePathFor(sourceFilePath) {
|
|
221
|
-
const compiledCodeDir = getCompiledCodeDir();
|
|
222
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
223
|
-
if (!sourceFilePath.startsWith(sourceCodeDir)) {
|
|
224
|
-
throw new Error("jopi-loader - The source file must be in the source code directory: " + sourceFilePath);
|
|
225
|
-
}
|
|
226
|
-
let filePath = sourceFilePath.substring(sourceCodeDir.length);
|
|
227
|
-
if (isNodeJS && !filePath.endsWith(".js")) {
|
|
228
|
-
let idx = filePath.lastIndexOf(".");
|
|
229
|
-
if (idx !== -1)
|
|
230
|
-
filePath = filePath.substring(0, idx) + ".js";
|
|
231
|
-
}
|
|
232
|
-
return jk_fs.join(compiledCodeDir, filePath);
|
|
233
|
-
}
|
|
234
|
-
export function getSourcesCodePathFor(compiledFilePath) {
|
|
235
|
-
const compiledCodeDir = getCompiledCodeDir();
|
|
236
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
237
|
-
if (!compiledFilePath.startsWith(compiledCodeDir)) {
|
|
238
|
-
throw new Error("jopi-loader - The compiled file must be in the compiled code directory: " + compiledFilePath);
|
|
239
|
-
}
|
|
240
|
-
let filePath = jk_fs.join(sourceCodeDir, compiledFilePath.substring(compiledCodeDir.length));
|
|
241
|
-
let idx = filePath.lastIndexOf(".");
|
|
242
|
-
if (idx !== -1)
|
|
243
|
-
filePath = filePath.substring(0, idx);
|
|
244
|
-
if (jk_fs.isFileSync(filePath + ".tsx")) {
|
|
245
|
-
return filePath + ".tsx";
|
|
246
|
-
}
|
|
247
|
-
if (jk_fs.isFileSync(filePath + ".ts")) {
|
|
248
|
-
return filePath + ".ts";
|
|
249
|
-
}
|
|
250
|
-
return filePath + ".js";
|
|
251
|
-
}
|
|
252
|
-
export function requireSourceOf(scriptPath) {
|
|
253
|
-
let src = searchSourceOf(scriptPath);
|
|
254
|
-
if (!src)
|
|
255
|
-
throw new Error("Cannot find source of " + scriptPath);
|
|
256
|
-
return src;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Search the source of the component if it's a JavaScript and not a TypeScript.
|
|
260
|
-
* Why? Because EsBuild doesn't work well on already transpiled code.
|
|
261
|
-
*/
|
|
262
|
-
export function searchSourceOf(scriptPath) {
|
|
263
|
-
function tryResolve(filePath, outDir) {
|
|
264
|
-
let out = jk_fs.sep + outDir + jk_fs.sep;
|
|
265
|
-
let idx = filePath.lastIndexOf(out);
|
|
266
|
-
if (idx !== -1) {
|
|
267
|
-
filePath = filePath.slice(0, idx) + jk_fs.sep + "src" + jk_fs.sep + filePath.slice(idx + out.length);
|
|
268
|
-
if (jk_fs.isFileSync(filePath))
|
|
269
|
-
return filePath;
|
|
270
|
-
}
|
|
271
|
-
return undefined;
|
|
272
|
-
}
|
|
273
|
-
let scriptExt = jk_fs.extname(scriptPath);
|
|
274
|
-
if ((scriptExt === ".ts") || (scriptExt === ".tsx")) {
|
|
275
|
-
// Is already the source.
|
|
276
|
-
return scriptPath;
|
|
277
|
-
}
|
|
278
|
-
const originalScriptPath = scriptPath;
|
|
279
|
-
let isJavascript = (scriptPath.endsWith(".js") || (scriptPath.endsWith(".jsx")));
|
|
280
|
-
if (isJavascript) {
|
|
281
|
-
// Remove his extension.
|
|
282
|
-
scriptPath = scriptPath.slice(0, -scriptExt.length);
|
|
283
|
-
}
|
|
284
|
-
let tryDirs = ["dist", "build"];
|
|
285
|
-
for (let toTry of tryDirs) {
|
|
286
|
-
if (isJavascript) {
|
|
287
|
-
let found = tryResolve(scriptPath + ".tsx", toTry);
|
|
288
|
-
if (found)
|
|
289
|
-
return found;
|
|
290
|
-
found = tryResolve(scriptPath + ".ts", toTry);
|
|
291
|
-
if (found)
|
|
292
|
-
return found;
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
let found = tryResolve(scriptPath, toTry);
|
|
296
|
-
if (found)
|
|
297
|
-
return found;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return originalScriptPath;
|
|
301
|
-
}
|
|
302
|
-
let gSourceCodeDir;
|
|
303
|
-
let gCodeSourceDirHint;
|
|
304
|
-
let gApplicationMainFile;
|
|
305
|
-
let gCompiledSourcesDir;
|
|
306
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/jk_appResolver/common.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAIrD,KAAK,UAAU,aAAa,CAAC,SAAqB;IAC9C,MAAM,IAAI,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEpB,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;YACvB,IAAI,GAAG,YAAY,OAAO;gBAAE,MAAM,GAAG,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,kBAAkB,GAAe,EAAE,CAAC;AAC1C,MAAM,aAAa,GAAe,EAAE,CAAC;AACrC,MAAM,YAAY,GAAe,EAAE,CAAC;AACpC,MAAM,WAAW,GAAe,EAAE,CAAC;AACnC,IAAI,kBAAkB,GAAG,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;AAEhD,IAAI,YAAY,GAAG,UAAU,CAAC,aAAa,KAAK,SAAS,CAAC;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kBAAkB,CAAC;AAC9B,CAAC;AAED,IAAI,cAAgC,CAAC;AACrC,IAAI,kBAAoC,CAAC;AACzC,IAAI,oBAAsC,CAAC;AAC3C,IAAI,mBAAqC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare function onServerSideReady(listener: Listener): void;
|
|
2
|
-
export declare function waitServerSideReady(): Promise<void>;
|
|
3
|
-
export declare function declareServerSideReady(): Promise<void>;
|
|
4
|
-
export declare function onAppStart(listener: Listener): void;
|
|
5
|
-
export declare function onAppExiting(listener: Listener): void;
|
|
6
|
-
export declare function onAppExited(listener: Listener): void;
|
|
7
|
-
export declare function declareAppStarted(): Promise<void>;
|
|
8
|
-
export declare function declareAppExiting(): Promise<void>;
|
|
9
|
-
export declare function executeApp(app: Listener): Promise<void>;
|
|
10
|
-
export declare function onHotReload(listener: Listener): void;
|
|
11
|
-
export declare function keepOnHotReload<T>(key: string, provider: () => T): T;
|
|
12
|
-
export declare function clearHotReloadKey(key: string): void;
|
|
13
|
-
export declare function getTempDir(): string;
|
|
14
|
-
export declare function findNodePackageDir(packageName: string, useLinuxPathFormat?: boolean): string | undefined;
|
|
15
|
-
export declare function requireNodePackageDir(packageName: string, useLinuxPathFormat?: boolean): string;
|
|
16
|
-
export declare function findPackageJsonDir(searchFromDir?: string): string;
|
|
17
|
-
export declare function findPackageJson(searchFromDir?: string): string;
|
|
18
|
-
export declare function setApplicationMainFile(applicationMainFile: string): void;
|
|
19
|
-
export declare function getApplicationMainFile(): string | undefined;
|
|
20
|
-
export declare function getCodeSourceDirHint(): string;
|
|
21
|
-
export declare function getSourceCodeDir(): string;
|
|
22
|
-
export declare function getCompiledCodeDir(): string;
|
|
23
|
-
export declare function getCompiledFilePathFor(sourceFilePath: string): string;
|
|
24
|
-
export declare function getSourcesCodePathFor(compiledFilePath: string): string;
|
|
25
|
-
export declare function requireSourceOf(scriptPath: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Search the source of the component if it's a JavaScript and not a TypeScript.
|
|
28
|
-
* Why? Because EsBuild doesn't work well on already transpiled code.
|
|
29
|
-
*/
|
|
30
|
-
export declare function searchSourceOf(scriptPath: string): string | undefined;
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
// noinspection JSUnusedGlobalSymbols
|
|
2
|
-
import * as jk_thread from "jopi-toolkit/jk_thread";
|
|
3
|
-
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
4
|
-
import * as jk_timer from "jopi-toolkit/jk_timer";
|
|
5
|
-
import { isBunJS, isNodeJS } from "jopi-toolkit/jk_what";
|
|
6
|
-
import { isUsingWorker } from "jopi-toolkit/jk_thread";
|
|
7
|
-
const gOnHotReload = globalThis.jopiHotReload.onHotReload;
|
|
8
|
-
const gMemory = globalThis.jopiHotReload.memory;
|
|
9
|
-
export function onServerSideReady(listener) {
|
|
10
|
-
if (gIsServerSideReady)
|
|
11
|
-
listener();
|
|
12
|
-
else
|
|
13
|
-
gOnServerSideReady.push(listener);
|
|
14
|
-
}
|
|
15
|
-
export function waitServerSideReady() {
|
|
16
|
-
if (gIsServerSideReady) {
|
|
17
|
-
return Promise.resolve();
|
|
18
|
-
}
|
|
19
|
-
return new Promise(r => {
|
|
20
|
-
onServerSideReady(r);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export async function declareServerSideReady() {
|
|
24
|
-
gIsServerSideReady = true;
|
|
25
|
-
await execListeners(gOnServerSideReady);
|
|
26
|
-
}
|
|
27
|
-
export function onAppStart(listener) {
|
|
28
|
-
if (gIsAppStarted)
|
|
29
|
-
listener();
|
|
30
|
-
else
|
|
31
|
-
gOnAppStart.push(listener);
|
|
32
|
-
}
|
|
33
|
-
export function onAppExiting(listener) {
|
|
34
|
-
if (gIsExited)
|
|
35
|
-
listener();
|
|
36
|
-
else
|
|
37
|
-
gOnAppExiting.push(listener);
|
|
38
|
-
}
|
|
39
|
-
export function onAppExited(listener) {
|
|
40
|
-
if (gIsExited)
|
|
41
|
-
listener();
|
|
42
|
-
else
|
|
43
|
-
gOnAppExited.push(listener);
|
|
44
|
-
}
|
|
45
|
-
export async function declareAppStarted() {
|
|
46
|
-
gIsAppStarted = true;
|
|
47
|
-
await execListeners(gOnAppStart);
|
|
48
|
-
}
|
|
49
|
-
export async function declareAppExiting() {
|
|
50
|
-
if (gIsExited)
|
|
51
|
-
return;
|
|
52
|
-
gIsExited = true;
|
|
53
|
-
if (isUsingWorker()) {
|
|
54
|
-
// Wait 1 sec, which allows the worker to correctly initialize.
|
|
55
|
-
await jk_timer.tick(1000);
|
|
56
|
-
}
|
|
57
|
-
gIsAppStarted = false;
|
|
58
|
-
await execListeners(gOnAppExiting);
|
|
59
|
-
if (isUsingWorker()) {
|
|
60
|
-
// Allows to worker to correctly stop their activity.
|
|
61
|
-
await jk_timer.tick(100);
|
|
62
|
-
}
|
|
63
|
-
if (!jk_thread.isMainThread) {
|
|
64
|
-
// Allows to worker to correctly stop their activity.
|
|
65
|
-
await jk_timer.tick(50);
|
|
66
|
-
}
|
|
67
|
-
await execListeners(gOnAppExited);
|
|
68
|
-
}
|
|
69
|
-
export async function executeApp(app) {
|
|
70
|
-
await waitServerSideReady();
|
|
71
|
-
declareAppStarted();
|
|
72
|
-
try {
|
|
73
|
-
const res = app();
|
|
74
|
-
if (res instanceof Promise)
|
|
75
|
-
await res;
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
declareAppExiting();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
export function onHotReload(listener) {
|
|
82
|
-
gOnHotReload.push(listener);
|
|
83
|
-
}
|
|
84
|
-
export function keepOnHotReload(key, provider) {
|
|
85
|
-
let current = gMemory[key];
|
|
86
|
-
if (current !== undefined)
|
|
87
|
-
return current;
|
|
88
|
-
return gMemory[key] = provider();
|
|
89
|
-
}
|
|
90
|
-
export function clearHotReloadKey(key) {
|
|
91
|
-
delete (gMemory[key]);
|
|
92
|
-
}
|
|
93
|
-
export function getTempDir() {
|
|
94
|
-
if (!gTempDir) {
|
|
95
|
-
gTempDir = jk_fs.resolve(process.cwd(), "temp");
|
|
96
|
-
}
|
|
97
|
-
return gTempDir;
|
|
98
|
-
}
|
|
99
|
-
let gIsExited = false;
|
|
100
|
-
let gTempDir;
|
|
101
|
-
export function findNodePackageDir(packageName, useLinuxPathFormat = true) {
|
|
102
|
-
let currentDir = jk_fs.dirname(findPackageJson());
|
|
103
|
-
while (true) {
|
|
104
|
-
const packagePath = jk_fs.join(currentDir, 'node_modules', packageName);
|
|
105
|
-
if (jk_fs.isDirectorySync(packagePath)) {
|
|
106
|
-
if (useLinuxPathFormat)
|
|
107
|
-
return jk_fs.win32ToLinuxPath(packagePath);
|
|
108
|
-
return packagePath;
|
|
109
|
-
}
|
|
110
|
-
const parentDir = jk_fs.dirname(currentDir);
|
|
111
|
-
// Reached root directory
|
|
112
|
-
if (parentDir === currentDir) {
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
currentDir = parentDir;
|
|
116
|
-
}
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
export function requireNodePackageDir(packageName, useLinuxPathFormat = true) {
|
|
120
|
-
let pkgDir = findNodePackageDir(packageName, useLinuxPathFormat);
|
|
121
|
-
if (!pkgDir)
|
|
122
|
-
throw new Error("Package '" + packageName + "' not found");
|
|
123
|
-
return pkgDir;
|
|
124
|
-
}
|
|
125
|
-
export function findPackageJsonDir(searchFromDir = getCodeSourceDirHint()) {
|
|
126
|
-
let pkgJsonPath = findPackageJson(searchFromDir);
|
|
127
|
-
return jk_fs.dirname(pkgJsonPath);
|
|
128
|
-
}
|
|
129
|
-
export function findPackageJson(searchFromDir = getCodeSourceDirHint()) {
|
|
130
|
-
if (!searchFromDir && (gPackageJsonPath !== undefined))
|
|
131
|
-
return gPackageJsonPath;
|
|
132
|
-
let currentDir = searchFromDir;
|
|
133
|
-
while (true) {
|
|
134
|
-
const packagePath = jk_fs.join(currentDir, 'package.json');
|
|
135
|
-
if (jk_fs.isFileSync(packagePath))
|
|
136
|
-
return gPackageJsonPath = packagePath;
|
|
137
|
-
const parentDir = jk_fs.dirname(currentDir);
|
|
138
|
-
// Reached root directory
|
|
139
|
-
if (parentDir === currentDir)
|
|
140
|
-
break;
|
|
141
|
-
currentDir = parentDir;
|
|
142
|
-
}
|
|
143
|
-
throw "No package.json found.";
|
|
144
|
-
}
|
|
145
|
-
//
|
|
146
|
-
let gPackageJsonPath;
|
|
147
|
-
export function setApplicationMainFile(applicationMainFile) {
|
|
148
|
-
gApplicationMainFile = applicationMainFile;
|
|
149
|
-
gCodeSourceDirHint = jk_fs.dirname(applicationMainFile);
|
|
150
|
-
}
|
|
151
|
-
export function getApplicationMainFile() {
|
|
152
|
-
return gApplicationMainFile;
|
|
153
|
-
}
|
|
154
|
-
export function getCodeSourceDirHint() {
|
|
155
|
-
if (!gCodeSourceDirHint)
|
|
156
|
-
return process.cwd();
|
|
157
|
-
return gCodeSourceDirHint;
|
|
158
|
-
}
|
|
159
|
-
export function getSourceCodeDir() {
|
|
160
|
-
if (gSourceCodeDir)
|
|
161
|
-
return gSourceCodeDir;
|
|
162
|
-
let pkgJsonPath = findPackageJson();
|
|
163
|
-
let dirName = jk_fs.join(jk_fs.dirname(pkgJsonPath), "src");
|
|
164
|
-
if (jk_fs.isDirectorySync(dirName)) {
|
|
165
|
-
return gSourceCodeDir = dirName;
|
|
166
|
-
}
|
|
167
|
-
return gSourceCodeDir = jk_fs.dirname(pkgJsonPath);
|
|
168
|
-
}
|
|
169
|
-
export function getCompiledCodeDir() {
|
|
170
|
-
if (gCompiledSourcesDir)
|
|
171
|
-
return gCompiledSourcesDir;
|
|
172
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
173
|
-
if (!sourceCodeDir.endsWith("src")) {
|
|
174
|
-
return gCompiledSourcesDir = sourceCodeDir;
|
|
175
|
-
}
|
|
176
|
-
// This means that it's Bun.js, and it directly uses the TypeScript version.
|
|
177
|
-
if (gApplicationMainFile && isBunJS && gApplicationMainFile.startsWith(sourceCodeDir)) {
|
|
178
|
-
return gCompiledSourcesDir = sourceCodeDir;
|
|
179
|
-
}
|
|
180
|
-
let pkgJsonPath = findPackageJson();
|
|
181
|
-
let rootDir = jk_fs.dirname(pkgJsonPath);
|
|
182
|
-
for (let toTest of ["dist", "build", "out"]) {
|
|
183
|
-
if (jk_fs.isDirectorySync(jk_fs.join(rootDir, toTest))) {
|
|
184
|
-
return gCompiledSourcesDir = jk_fs.join(rootDir, toTest);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// No output dir? Assume we compiled on the same dir.
|
|
188
|
-
return rootDir;
|
|
189
|
-
}
|
|
190
|
-
export function getCompiledFilePathFor(sourceFilePath) {
|
|
191
|
-
const compiledCodeDir = getCompiledCodeDir();
|
|
192
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
193
|
-
if (!sourceFilePath.startsWith(sourceCodeDir)) {
|
|
194
|
-
throw new Error("jopi-loader - The source file must be in the source code directory: " + sourceFilePath);
|
|
195
|
-
}
|
|
196
|
-
let filePath = sourceFilePath.substring(sourceCodeDir.length);
|
|
197
|
-
if (isNodeJS && !filePath.endsWith(".js")) {
|
|
198
|
-
let idx = filePath.lastIndexOf(".");
|
|
199
|
-
if (idx !== -1)
|
|
200
|
-
filePath = filePath.substring(0, idx) + ".js";
|
|
201
|
-
}
|
|
202
|
-
return jk_fs.join(compiledCodeDir, filePath);
|
|
203
|
-
}
|
|
204
|
-
export function getSourcesCodePathFor(compiledFilePath) {
|
|
205
|
-
const compiledCodeDir = getCompiledCodeDir();
|
|
206
|
-
const sourceCodeDir = getSourceCodeDir();
|
|
207
|
-
if (!compiledFilePath.startsWith(compiledCodeDir)) {
|
|
208
|
-
throw new Error("jopi-loader - The compiled file must be in the compiled code directory: " + compiledFilePath);
|
|
209
|
-
}
|
|
210
|
-
let filePath = jk_fs.join(sourceCodeDir, compiledFilePath.substring(compiledCodeDir.length));
|
|
211
|
-
let idx = filePath.lastIndexOf(".");
|
|
212
|
-
if (idx !== -1)
|
|
213
|
-
filePath = filePath.substring(0, idx);
|
|
214
|
-
if (jk_fs.isFileSync(filePath + ".tsx")) {
|
|
215
|
-
return filePath + ".tsx";
|
|
216
|
-
}
|
|
217
|
-
if (jk_fs.isFileSync(filePath + ".ts")) {
|
|
218
|
-
return filePath + ".ts";
|
|
219
|
-
}
|
|
220
|
-
return filePath + ".js";
|
|
221
|
-
}
|
|
222
|
-
export function requireSourceOf(scriptPath) {
|
|
223
|
-
let src = searchSourceOf(scriptPath);
|
|
224
|
-
if (!src)
|
|
225
|
-
throw new Error("Cannot find source of " + scriptPath);
|
|
226
|
-
return src;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Search the source of the component if it's a JavaScript and not a TypeScript.
|
|
230
|
-
* Why? Because EsBuild doesn't work well on already transpiled code.
|
|
231
|
-
*/
|
|
232
|
-
export function searchSourceOf(scriptPath) {
|
|
233
|
-
function tryResolve(filePath, outDir) {
|
|
234
|
-
let out = jk_fs.sep + outDir + jk_fs.sep;
|
|
235
|
-
let idx = filePath.lastIndexOf(out);
|
|
236
|
-
if (idx !== -1) {
|
|
237
|
-
filePath = filePath.slice(0, idx) + jk_fs.sep + "src" + jk_fs.sep + filePath.slice(idx + out.length);
|
|
238
|
-
if (jk_fs.isFileSync(filePath))
|
|
239
|
-
return filePath;
|
|
240
|
-
}
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
let scriptExt = jk_fs.extname(scriptPath);
|
|
244
|
-
if ((scriptExt === ".ts") || (scriptExt === ".tsx")) {
|
|
245
|
-
// Is already the source.
|
|
246
|
-
return scriptPath;
|
|
247
|
-
}
|
|
248
|
-
const originalScriptPath = scriptPath;
|
|
249
|
-
let isJavascript = (scriptPath.endsWith(".js") || (scriptPath.endsWith(".jsx")));
|
|
250
|
-
if (isJavascript) {
|
|
251
|
-
// Remove his extension.
|
|
252
|
-
scriptPath = scriptPath.slice(0, -scriptExt.length);
|
|
253
|
-
}
|
|
254
|
-
let tryDirs = ["dist", "build"];
|
|
255
|
-
for (let toTry of tryDirs) {
|
|
256
|
-
if (isJavascript) {
|
|
257
|
-
let found = tryResolve(scriptPath + ".tsx", toTry);
|
|
258
|
-
if (found)
|
|
259
|
-
return found;
|
|
260
|
-
found = tryResolve(scriptPath + ".ts", toTry);
|
|
261
|
-
if (found)
|
|
262
|
-
return found;
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
let found = tryResolve(scriptPath, toTry);
|
|
266
|
-
if (found)
|
|
267
|
-
return found;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return originalScriptPath;
|
|
271
|
-
}
|
|
272
|
-
let gSourceCodeDir;
|
|
273
|
-
let gCodeSourceDirHint;
|
|
274
|
-
let gApplicationMainFile;
|
|
275
|
-
let gCompiledSourcesDir;
|
|
276
|
-
//# sourceMappingURL=index.js.map
|