@3dverse/livelink.core 1.0.3 → 1.0.4
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/dist/library.cjs +1 -1
- package/dist/library.cjs.map +3 -3
- package/dist/library.mjs +1 -1
- package/dist/library.mjs.map +3 -3
- package/dist/sources/DynamicLoader.d.ts +11 -3
- package/package.json +1 -1
package/dist/library.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},l=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of d(r))!a.call(e,i)&&i!==o&&n(e,i,{get:()=>r[i],enumerable:!(t=s(r,i))||t.enumerable});return e};var u=e=>l(n({},"__esModule",{value:!0}),e);var m={};c(m,{DynamicLoader:()=>p});module.exports=u(m);var g=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,p=class e{static#r=null;static#e=null;static get Core(){if(!e.#r)throw new Error("Livelink core not initialized");return e.#r}static load(r="prod"){return e.#e||(e.#e=e.#o(r)),e.#e}static async#o(r){let o=await e.#i(r),{LivelinkCore:t}=await o();e.#r=t;let i={prod:"#FFC700",dev:"#36D399",debug:"#FB4949"};console.info(`%c Livelink Core initialized \u{1F680} %c ${t.VERSION} %c ${t.COMMIT_SHA} %c${r}`,"background: #080A12; color: #FFC700; font-weight: bold; padding: 8px; padding-right: 164px; border-radius: 16px; margin: 16px 0 16px 0","background: #9EA6D6; color: #0A1018; font-weight: bold; padding: 1px; padding-right: 0px; margin-left: -160px; border-radius: 16px 0 0 16px;","background: #6973A8; color: #0A1018; font-weight: bold; padding: 1px; padding-left: 0; border-radius: 0 16px 16px 0;",`background: ${i[r]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`)}static async#i(r){let o="https://cdn.3dverse.com/livelink/core/1.0/"+(r!=="prod"?`core.${r}.mjs`:"core.mjs");if(!g)return new Function("return import('"+o+"')");let i=await(await fetch(o)).text();return new Function("return import('data:text/javascript;base64,"+btoa(i)+"')")}constructor(){}};
|
|
2
2
|
//# sourceMappingURL=library.cjs.map
|
package/dist/library.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../sources/library.ts", "../sources/DynamicLoader.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n", "import type { LivelinkCore } from \"./LivelinkCore\";\n\n/**\n *\n */\nconst isNode = typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n\n/**\n * The URL of the Livelink core library. Injected by the build system.\n */\ndeclare const LIVELINK_CORE_URL: string;\n\n/**\n *\n */\ntype LivelinkCoreType = typeof LivelinkCore;\n\n/**\n *\n */\ntype CoreImporter = () => Promise<{\n LivelinkCore: LivelinkCoreType;\n LIVELINK_CORE_VERSION: string;\n LIVELINK_CORE_COMMIT_SHA: string;\n}>;\n\n/**\n * Dynamically loads the Livelink core library.\n *\n * {@link DynamicLoader.load} must be called before accessing {@link DynamicLoader.Core}.\n *\n * ### Usage\n * ```typescript\n * await DynamicLoader.load();\n * const core = new DynamicLoader.Core();\n * ```\n *\n * @category Core\n */\nexport class DynamicLoader {\n /**\n *\n */\n static #core: LivelinkCoreType | null = null;\n\n /**\n * Returns the core
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCKA,IAAMI,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,MAAQ,QAAQ,SAAS,MAAQ,
|
|
6
|
-
"names": ["library_exports", "__export", "DynamicLoader", "__toCommonJS", "isNode", "DynamicLoader", "_DynamicLoader", "#core", "target", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "moduleData"]
|
|
4
|
+
"sourcesContent": ["export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n", "import type { LivelinkCore } from \"./LivelinkCore\";\n\n/**\n *\n */\nconst isNode = typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n\n/**\n * The URL of the Livelink core library. Injected by the build system.\n */\ndeclare const LIVELINK_CORE_URL: string;\n\n/**\n *\n */\ntype LivelinkCoreType = typeof LivelinkCore;\n\n/**\n *\n */\ntype CoreImporter = () => Promise<{\n LivelinkCore: LivelinkCoreType;\n LIVELINK_CORE_VERSION: string;\n LIVELINK_CORE_COMMIT_SHA: string;\n}>;\n\n/**\n *\n */\ntype BuildTarget = \"prod\" | \"dev\" | \"debug\";\n\n/**\n * Dynamically loads the Livelink core library.\n *\n * {@link DynamicLoader.load} must be called before accessing {@link DynamicLoader.Core}.\n *\n * ### Usage\n * ```typescript\n * await DynamicLoader.load();\n * const core = new DynamicLoader.Core();\n * ```\n *\n * @category Core\n */\nexport class DynamicLoader {\n /**\n *\n */\n static #core: LivelinkCoreType | null = null;\n\n /**\n *\n */\n static #importPromise: Promise<void> | null = null;\n\n /**\n * Returns the core.\n */\n static get Core(): LivelinkCoreType {\n if (!DynamicLoader.#core) {\n throw new Error(\"Livelink core not initialized\");\n }\n return DynamicLoader.#core;\n }\n\n /**\n * Dynamically loads the Livelink core library.\n *\n * Must be called before accessing {@link DynamicLoader.Core}.\n * Only one target can be loaded at a time.\n *\n * @param target - The target build to load.\n * - `\"prod\"`: Contains no debug information.\n * - `\"dev\"`: Contains some debug information.\n * - `\"debug\"`: Contains extra debug information.\n */\n static load(target: BuildTarget = \"prod\"): Promise<void> {\n if (!DynamicLoader.#importPromise) {\n DynamicLoader.#importPromise = DynamicLoader.#importCore(target);\n }\n\n return DynamicLoader.#importPromise;\n }\n\n /**\n *\n */\n static async #importCore(target: BuildTarget): Promise<void> {\n const dynamicImport = await DynamicLoader.#createImporter(target);\n const { LivelinkCore } = await dynamicImport();\n\n DynamicLoader.#core = LivelinkCore;\n\n const TARGET_COLOR = {\n prod: \"#FFC700\",\n dev: \"#36D399\",\n debug: \"#FB4949\",\n } satisfies Record<BuildTarget, string>;\n\n console.info(\n `%c Livelink Core initialized \uD83D\uDE80 %c ${LivelinkCore.VERSION} %c ${LivelinkCore.COMMIT_SHA} %c${target}`,\n \"background: #080A12; color: #FFC700; font-weight: bold; padding: 8px; padding-right: 164px; border-radius: 16px; margin: 16px 0 16px 0\",\n \"background: #9EA6D6; color: #0A1018; font-weight: bold; padding: 1px; padding-right: 0px; margin-left: -160px; border-radius: 16px 0 0 16px;\",\n \"background: #6973A8; color: #0A1018; font-weight: bold; padding: 1px; padding-left: 0; border-radius: 0 16px 16px 0;\",\n `background: ${TARGET_COLOR[target]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`,\n );\n }\n\n /**\n *\n */\n static async #createImporter(target: string): Promise<CoreImporter> {\n const moduleURL = LIVELINK_CORE_URL + \"/\" + (target !== \"prod\" ? `core.${target}.mjs` : \"core.mjs\");\n\n if (!isNode) {\n return new Function(\"return import('\" + moduleURL + \"')\") as CoreImporter;\n }\n\n const response = await fetch(moduleURL);\n const moduleData = await response.text();\n return new Function(\"return import('data:text/javascript;base64,\" + btoa(moduleData) + \"')\") as CoreImporter;\n }\n\n /**\n *\n */\n private constructor() {}\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCKA,IAAMI,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,MAAQ,QAAQ,SAAS,MAAQ,KAuCzFC,EAAN,MAAMC,CAAc,CAIvB,MAAOC,GAAiC,KAKxC,MAAOC,GAAuC,KAK9C,WAAW,MAAyB,CAChC,GAAI,CAACF,EAAcC,GACf,MAAM,IAAI,MAAM,+BAA+B,EAEnD,OAAOD,EAAcC,EACzB,CAaA,OAAO,KAAKE,EAAsB,OAAuB,CACrD,OAAKH,EAAcE,KACfF,EAAcE,GAAiBF,EAAcI,GAAYD,CAAM,GAG5DH,EAAcE,EACzB,CAKA,YAAaE,GAAYD,EAAoC,CACzD,IAAME,EAAgB,MAAML,EAAcM,GAAgBH,CAAM,EAC1D,CAAE,aAAAI,CAAa,EAAI,MAAMF,EAAc,EAE7CL,EAAcC,GAAQM,EAEtB,IAAMC,EAAe,CACjB,KAAM,UACN,IAAK,UACL,MAAO,SACX,EAEA,QAAQ,KACJ,6CAAsCD,EAAa,OAAO,OAAOA,EAAa,UAAU,MAAMJ,CAAM,GACpG,yIACA,+IACA,uHACA,eAAeK,EAAaL,CAAM,CAAC,wHACvC,CACJ,CAKA,YAAaG,GAAgBH,EAAuC,CAChE,IAAMM,EAAY,8CAA2BN,IAAW,OAAS,QAAQA,CAAM,OAAS,YAExF,GAAI,CAACL,EACD,OAAO,IAAI,SAAS,kBAAoBW,EAAY,IAAI,EAI5D,IAAMC,EAAa,MADF,MAAM,MAAMD,CAAS,GACJ,KAAK,EACvC,OAAO,IAAI,SAAS,8CAAgD,KAAKC,CAAU,EAAI,IAAI,CAC/F,CAKQ,aAAc,CAAC,CAC3B",
|
|
6
|
+
"names": ["library_exports", "__export", "DynamicLoader", "__toCommonJS", "isNode", "DynamicLoader", "_DynamicLoader", "#core", "#importPromise", "target", "#importCore", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "moduleData"]
|
|
7
7
|
}
|
package/dist/library.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,n=class
|
|
1
|
+
var p=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,n=class r{static#r=null;static#e=null;static get Core(){if(!r.#r)throw new Error("Livelink core not initialized");return r.#r}static load(e="prod"){return r.#e||(r.#e=r.#o(e)),r.#e}static async#o(e){let o=await r.#i(e),{LivelinkCore:i}=await o();r.#r=i;let t={prod:"#FFC700",dev:"#36D399",debug:"#FB4949"};console.info(`%c Livelink Core initialized \u{1F680} %c ${i.VERSION} %c ${i.COMMIT_SHA} %c${e}`,"background: #080A12; color: #FFC700; font-weight: bold; padding: 8px; padding-right: 164px; border-radius: 16px; margin: 16px 0 16px 0","background: #9EA6D6; color: #0A1018; font-weight: bold; padding: 1px; padding-right: 0px; margin-left: -160px; border-radius: 16px 0 0 16px;","background: #6973A8; color: #0A1018; font-weight: bold; padding: 1px; padding-left: 0; border-radius: 0 16px 16px 0;",`background: ${t[e]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`)}static async#i(e){let o="https://cdn.3dverse.com/livelink/core/1.0/"+(e!=="prod"?`core.${e}.mjs`:"core.mjs");if(!p)return new Function("return import('"+o+"')");let t=await(await fetch(o)).text();return new Function("return import('data:text/javascript;base64,"+btoa(t)+"')")}constructor(){}};export{n as DynamicLoader};
|
|
2
2
|
//# sourceMappingURL=library.mjs.map
|
package/dist/library.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../sources/DynamicLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import type { LivelinkCore } from \"./LivelinkCore\";\n\n/**\n *\n */\nconst isNode = typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n\n/**\n * The URL of the Livelink core library. Injected by the build system.\n */\ndeclare const LIVELINK_CORE_URL: string;\n\n/**\n *\n */\ntype LivelinkCoreType = typeof LivelinkCore;\n\n/**\n *\n */\ntype CoreImporter = () => Promise<{\n LivelinkCore: LivelinkCoreType;\n LIVELINK_CORE_VERSION: string;\n LIVELINK_CORE_COMMIT_SHA: string;\n}>;\n\n/**\n * Dynamically loads the Livelink core library.\n *\n * {@link DynamicLoader.load} must be called before accessing {@link DynamicLoader.Core}.\n *\n * ### Usage\n * ```typescript\n * await DynamicLoader.load();\n * const core = new DynamicLoader.Core();\n * ```\n *\n * @category Core\n */\nexport class DynamicLoader {\n /**\n *\n */\n static #core: LivelinkCoreType | null = null;\n\n /**\n * Returns the core
|
|
5
|
-
"mappings": "AAKA,IAAMA,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,MAAQ,QAAQ,SAAS,MAAQ,
|
|
6
|
-
"names": ["isNode", "DynamicLoader", "_DynamicLoader", "#core", "target", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "moduleData"]
|
|
4
|
+
"sourcesContent": ["import type { LivelinkCore } from \"./LivelinkCore\";\n\n/**\n *\n */\nconst isNode = typeof process !== \"undefined\" && process.versions != null && process.versions.node != null;\n\n/**\n * The URL of the Livelink core library. Injected by the build system.\n */\ndeclare const LIVELINK_CORE_URL: string;\n\n/**\n *\n */\ntype LivelinkCoreType = typeof LivelinkCore;\n\n/**\n *\n */\ntype CoreImporter = () => Promise<{\n LivelinkCore: LivelinkCoreType;\n LIVELINK_CORE_VERSION: string;\n LIVELINK_CORE_COMMIT_SHA: string;\n}>;\n\n/**\n *\n */\ntype BuildTarget = \"prod\" | \"dev\" | \"debug\";\n\n/**\n * Dynamically loads the Livelink core library.\n *\n * {@link DynamicLoader.load} must be called before accessing {@link DynamicLoader.Core}.\n *\n * ### Usage\n * ```typescript\n * await DynamicLoader.load();\n * const core = new DynamicLoader.Core();\n * ```\n *\n * @category Core\n */\nexport class DynamicLoader {\n /**\n *\n */\n static #core: LivelinkCoreType | null = null;\n\n /**\n *\n */\n static #importPromise: Promise<void> | null = null;\n\n /**\n * Returns the core.\n */\n static get Core(): LivelinkCoreType {\n if (!DynamicLoader.#core) {\n throw new Error(\"Livelink core not initialized\");\n }\n return DynamicLoader.#core;\n }\n\n /**\n * Dynamically loads the Livelink core library.\n *\n * Must be called before accessing {@link DynamicLoader.Core}.\n * Only one target can be loaded at a time.\n *\n * @param target - The target build to load.\n * - `\"prod\"`: Contains no debug information.\n * - `\"dev\"`: Contains some debug information.\n * - `\"debug\"`: Contains extra debug information.\n */\n static load(target: BuildTarget = \"prod\"): Promise<void> {\n if (!DynamicLoader.#importPromise) {\n DynamicLoader.#importPromise = DynamicLoader.#importCore(target);\n }\n\n return DynamicLoader.#importPromise;\n }\n\n /**\n *\n */\n static async #importCore(target: BuildTarget): Promise<void> {\n const dynamicImport = await DynamicLoader.#createImporter(target);\n const { LivelinkCore } = await dynamicImport();\n\n DynamicLoader.#core = LivelinkCore;\n\n const TARGET_COLOR = {\n prod: \"#FFC700\",\n dev: \"#36D399\",\n debug: \"#FB4949\",\n } satisfies Record<BuildTarget, string>;\n\n console.info(\n `%c Livelink Core initialized \uD83D\uDE80 %c ${LivelinkCore.VERSION} %c ${LivelinkCore.COMMIT_SHA} %c${target}`,\n \"background: #080A12; color: #FFC700; font-weight: bold; padding: 8px; padding-right: 164px; border-radius: 16px; margin: 16px 0 16px 0\",\n \"background: #9EA6D6; color: #0A1018; font-weight: bold; padding: 1px; padding-right: 0px; margin-left: -160px; border-radius: 16px 0 0 16px;\",\n \"background: #6973A8; color: #0A1018; font-weight: bold; padding: 1px; padding-left: 0; border-radius: 0 16px 16px 0;\",\n `background: ${TARGET_COLOR[target]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`,\n );\n }\n\n /**\n *\n */\n static async #createImporter(target: string): Promise<CoreImporter> {\n const moduleURL = LIVELINK_CORE_URL + \"/\" + (target !== \"prod\" ? `core.${target}.mjs` : \"core.mjs\");\n\n if (!isNode) {\n return new Function(\"return import('\" + moduleURL + \"')\") as CoreImporter;\n }\n\n const response = await fetch(moduleURL);\n const moduleData = await response.text();\n return new Function(\"return import('data:text/javascript;base64,\" + btoa(moduleData) + \"')\") as CoreImporter;\n }\n\n /**\n *\n */\n private constructor() {}\n}\n"],
|
|
5
|
+
"mappings": "AAKA,IAAMA,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,MAAQ,QAAQ,SAAS,MAAQ,KAuCzFC,EAAN,MAAMC,CAAc,CAIvB,MAAOC,GAAiC,KAKxC,MAAOC,GAAuC,KAK9C,WAAW,MAAyB,CAChC,GAAI,CAACF,EAAcC,GACf,MAAM,IAAI,MAAM,+BAA+B,EAEnD,OAAOD,EAAcC,EACzB,CAaA,OAAO,KAAKE,EAAsB,OAAuB,CACrD,OAAKH,EAAcE,KACfF,EAAcE,GAAiBF,EAAcI,GAAYD,CAAM,GAG5DH,EAAcE,EACzB,CAKA,YAAaE,GAAYD,EAAoC,CACzD,IAAME,EAAgB,MAAML,EAAcM,GAAgBH,CAAM,EAC1D,CAAE,aAAAI,CAAa,EAAI,MAAMF,EAAc,EAE7CL,EAAcC,GAAQM,EAEtB,IAAMC,EAAe,CACjB,KAAM,UACN,IAAK,UACL,MAAO,SACX,EAEA,QAAQ,KACJ,6CAAsCD,EAAa,OAAO,OAAOA,EAAa,UAAU,MAAMJ,CAAM,GACpG,yIACA,+IACA,uHACA,eAAeK,EAAaL,CAAM,CAAC,wHACvC,CACJ,CAKA,YAAaG,GAAgBH,EAAuC,CAChE,IAAMM,EAAY,8CAA2BN,IAAW,OAAS,QAAQA,CAAM,OAAS,YAExF,GAAI,CAACL,EACD,OAAO,IAAI,SAAS,kBAAoBW,EAAY,IAAI,EAI5D,IAAMC,EAAa,MADF,MAAM,MAAMD,CAAS,GACJ,KAAK,EACvC,OAAO,IAAI,SAAS,8CAAgD,KAAKC,CAAU,EAAI,IAAI,CAC/F,CAKQ,aAAc,CAAC,CAC3B",
|
|
6
|
+
"names": ["isNode", "DynamicLoader", "_DynamicLoader", "#core", "#importPromise", "target", "#importCore", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "moduleData"]
|
|
7
7
|
}
|
|
@@ -3,6 +3,10 @@ import type { LivelinkCore } from "./LivelinkCore";
|
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
5
|
type LivelinkCoreType = typeof LivelinkCore;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
type BuildTarget = "prod" | "dev" | "debug";
|
|
6
10
|
/**
|
|
7
11
|
* Dynamically loads the Livelink core library.
|
|
8
12
|
*
|
|
@@ -19,17 +23,21 @@ type LivelinkCoreType = typeof LivelinkCore;
|
|
|
19
23
|
export declare class DynamicLoader {
|
|
20
24
|
#private;
|
|
21
25
|
/**
|
|
22
|
-
* Returns the core
|
|
26
|
+
* Returns the core.
|
|
23
27
|
*/
|
|
24
28
|
static get Core(): LivelinkCoreType;
|
|
25
29
|
/**
|
|
26
30
|
* Dynamically loads the Livelink core library.
|
|
27
31
|
*
|
|
28
32
|
* Must be called before accessing {@link DynamicLoader.Core}.
|
|
33
|
+
* Only one target can be loaded at a time.
|
|
29
34
|
*
|
|
30
|
-
* @param
|
|
35
|
+
* @param target - The target build to load.
|
|
36
|
+
* - `"prod"`: Contains no debug information.
|
|
37
|
+
* - `"dev"`: Contains some debug information.
|
|
38
|
+
* - `"debug"`: Contains extra debug information.
|
|
31
39
|
*/
|
|
32
|
-
static load(target?:
|
|
40
|
+
static load(target?: BuildTarget): Promise<void>;
|
|
33
41
|
/**
|
|
34
42
|
*
|
|
35
43
|
*/
|