qcobjects 2.5.107-beta → 2.5.109-beta
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/VERSION +1 -1
- package/build/_import_.js +26 -0
- package/build/findPackageNodePath.js +5 -2
- package/build/index.cjs +25 -2
- package/build/platform.js +8 -2
- package/build-esbuild.js +8 -1
- package/package.json +4 -3
- package/postbuild.js +10 -0
- package/public/browser/QCObjects.js +39 -6
- package/public/browser/QCObjects.js.map +4 -4
- package/public/cjs/QCObjects.cjs +39 -6
- package/public/cjs/QCObjects.cjs.map +4 -4
- package/public/esm/QCObjects.mjs +37 -4
- package/public/esm/QCObjects.mjs.map +4 -4
- package/public/types/index.d.ts +6 -0
- package/src/_import_.ts +27 -0
- package/src/findPackageNodePath.ts +2 -2
- package/src/platform.ts +9 -2
- package/src/index.cts +0 -2
- package/src/index.mts +0 -2
package/public/types/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ declare module "ClassFactory" {
|
|
|
12
12
|
import { TClassFactory } from "types";
|
|
13
13
|
export const ClassFactory: TClassFactory;
|
|
14
14
|
}
|
|
15
|
+
declare module "_import_" {
|
|
16
|
+
function _import_(name: string): Promise<any>;
|
|
17
|
+
export { _import_ };
|
|
18
|
+
}
|
|
15
19
|
declare module "platform" {
|
|
16
20
|
export const isDeno: boolean;
|
|
17
21
|
export const isBrowser: boolean;
|
|
@@ -1050,3 +1054,5 @@ declare module "localStorage" {
|
|
|
1050
1054
|
declare module "uniqueID" {
|
|
1051
1055
|
export const uniqueId: () => string;
|
|
1052
1056
|
}
|
|
1057
|
+
|
|
1058
|
+
export {};
|
package/src/_import_.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { logger } from "./Logger";
|
|
2
|
+
|
|
3
|
+
async function _import_(name:string):Promise<any> {
|
|
4
|
+
logger.debug(`Importing ${name}...`);
|
|
5
|
+
function isPackage(name:string) {
|
|
6
|
+
logger.debug(`Validating if ${name} is a package name...`);
|
|
7
|
+
// Simple check to determine if the name is a package
|
|
8
|
+
// This can be enhanced based on your specific needs
|
|
9
|
+
return !name.startsWith(".") && !name.startsWith("/") && !name.includes("/");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Ensure the name has a .js extension if it's not a package
|
|
14
|
+
const hasExtension = /\.[^/\\]+$/.test(name);
|
|
15
|
+
if (!hasExtension && !isPackage(name)) {
|
|
16
|
+
logger.debug(`${name} does not have an extension and is not a package. Adding js extension.`);
|
|
17
|
+
name += ".js";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const m:any = await import(name);
|
|
21
|
+
return m;
|
|
22
|
+
} catch (error:any) {
|
|
23
|
+
logger.warn(`Failed to load module: ${error}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {_import_};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CONFIG } from "./CONFIG";
|
|
2
2
|
import { Export } from "./Export";
|
|
3
3
|
import { logger } from "./Logger";
|
|
4
|
-
import {
|
|
4
|
+
import { isBrowser } from "./platform";
|
|
5
|
+
import fs from "node:fs";
|
|
5
6
|
|
|
6
7
|
export const findPackageNodePath = function (packagename:string):string|null {
|
|
7
8
|
let sdkPath = null;
|
|
8
9
|
if (!isBrowser) {
|
|
9
|
-
const fs = _require_("fs");
|
|
10
10
|
try {
|
|
11
11
|
let sdkPaths = [
|
|
12
12
|
`${CONFIG.get("projectPath")}${CONFIG.get("relativeImportPath")}`,
|
package/src/platform.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _import_ } from "./_import_";
|
|
1
2
|
import { logger } from "./Logger";
|
|
2
3
|
|
|
3
4
|
export const isDeno:boolean = (typeof window !== "undefined" && "Deno" in window);
|
|
@@ -11,8 +12,14 @@ export const _require_ = (name:string):any => {
|
|
|
11
12
|
( (name):any => {
|
|
12
13
|
let r;
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
_import_ (name)
|
|
16
|
+
.then ((m) => {
|
|
17
|
+
r = (m && m.default) || m;
|
|
18
|
+
})
|
|
19
|
+
.catch ((e:any) => {
|
|
20
|
+
logger.warn(`An error ocurred: ${e}`);
|
|
21
|
+
});
|
|
22
|
+
|
|
16
23
|
} catch (e:any) {
|
|
17
24
|
logger.debug(`An error ocurred importing module. ${e}`);
|
|
18
25
|
r = {export:{}};
|
package/src/index.cts
DELETED
package/src/index.mts
DELETED