@3dverse/livelink.core 1.0.4 → 1.0.6

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.
@@ -27,6 +27,11 @@ export type DebugLines = {
27
27
  * @defaultValue false
28
28
  */
29
29
  drawCenterOfMass?: boolean;
30
+ /**
31
+ * Whether to draw contacts between physics bodies
32
+ * @defaultValue false
33
+ */
34
+ drawContacts?: boolean;
30
35
  /**
31
36
  * Whether to draw joint-related debug lines
32
37
  * @defaultValue false
package/dist/library.cjs CHANGED
@@ -1,2 +1,2 @@
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(){}};
1
+ "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)s(o,r,{get:e[r],enumerable:!0})},m=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!l.call(o,i)&&i!==r&&s(o,i,{get:()=>e[i],enumerable:!(t=a(e,i))||t.enumerable});return o};var g=o=>m(s({},"__esModule",{value:!0}),o);var C={};u(C,{DynamicLoader:()=>d});module.exports=g(C);var x=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,d=class o{static#e=null;static#o=null;static get Core(){if(!o.#e)throw new Error("Livelink core not initialized");return o.#e}static load(e="prod"){return o.#o||(o.#o=o.#r(e)),o.#o}static async#r(e){let r=await o.#i(e),{LivelinkCore:t}=await r();o.#e=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${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: ${i[e]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`)}static async#i(e){let r="https://cdn.3dverse.com/livelink/core/1.0/"+(e!=="prod"?`core.${e}.mjs`:"core.mjs");if(!x)return new Function("return import('"+r+"')");let i=await(await fetch(r)).text(),p=await new Function("return import('node:vm')")();return p.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new p.SourceTextModule(i,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(i)+"')")}constructor(){}};
2
2
  //# sourceMappingURL=library.cjs.map
@@ -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 *\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"]
4
+ "sourcesContent": ["export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n", "import type { LivelinkCore } from \"./LivelinkCore\";\nimport type VM from \"node:vm\";\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 source = await response.text();\n\n // As a platform neutral build, we needs to load node:vm dynamically.\n // We can't use await import('node:vm') directly because it will be resolved at build time\n // and will not be available in the browser.\n const vm = (await new Function(\"return import('node:vm')\")()) as {\n SourceTextModule: typeof VM.SourceTextModule;\n };\n\n // VM Modules is an experimental feature, so it may not be available in all versions of Node.js.\n // This feature is only available with the --experimental-vm-modules command flag enabled.\n if (!vm.SourceTextModule) {\n return new Function(\"return import('data:text/javascript;base64,\" + btoa(source) + \"')\") as CoreImporter;\n }\n\n console.info(\"Using experimental VM SourceTextModule to load Livelink core\");\n return (async () => {\n const module = new vm.SourceTextModule(source, { identifier: moduleURL });\n // @ts-expect-error: Since core has no dependencies, the linker function will never be called.\n await module.link(() => {});\n await module.evaluate();\n\n return module.namespace;\n }) as CoreImporter;\n }\n\n /**\n *\n */\n private constructor() {}\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCMA,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,EAAS,MADE,MAAM,MAAMD,CAAS,GACR,KAAK,EAK7BE,EAAM,MAAM,IAAI,SAAS,0BAA0B,EAAE,EAM3D,OAAKA,EAAG,kBAIR,QAAQ,KAAK,8DAA8D,EACnE,SAAY,CAChB,IAAMC,EAAS,IAAID,EAAG,iBAAiBD,EAAQ,CAAE,WAAYD,CAAU,CAAC,EAExE,aAAMG,EAAO,KAAK,IAAM,CAAC,CAAC,EAC1B,MAAMA,EAAO,SAAS,EAEfA,EAAO,SAClB,GAXW,IAAI,SAAS,8CAAgD,KAAKF,CAAM,EAAI,IAAI,CAY/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", "source", "vm", "module"]
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 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};
1
+ var p=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,d=class e{static#e=null;static#o=null;static get Core(){if(!e.#e)throw new Error("Livelink core not initialized");return e.#e}static load(o="prod"){return e.#o||(e.#o=e.#r(o)),e.#o}static async#r(o){let r=await e.#i(o),{LivelinkCore:i}=await r();e.#e=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${o}`,"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[o]}; color: #000; font-weight: bold; padding: 6px 16px; border: 4px solid #080A12; border-radius: 16px; margin-left: 16px`)}static async#i(o){let r="https://cdn.3dverse.com/livelink/core/1.0/"+(o!=="prod"?`core.${o}.mjs`:"core.mjs");if(!p)return new Function("return import('"+r+"')");let t=await(await fetch(r)).text(),s=await new Function("return import('node:vm')")();return s.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new s.SourceTextModule(t,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(t)+"')")}constructor(){}};export{d as DynamicLoader};
2
2
  //# sourceMappingURL=library.mjs.map
@@ -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 *\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"]
4
+ "sourcesContent": ["import type { LivelinkCore } from \"./LivelinkCore\";\nimport type VM from \"node:vm\";\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 source = await response.text();\n\n // As a platform neutral build, we needs to load node:vm dynamically.\n // We can't use await import('node:vm') directly because it will be resolved at build time\n // and will not be available in the browser.\n const vm = (await new Function(\"return import('node:vm')\")()) as {\n SourceTextModule: typeof VM.SourceTextModule;\n };\n\n // VM Modules is an experimental feature, so it may not be available in all versions of Node.js.\n // This feature is only available with the --experimental-vm-modules command flag enabled.\n if (!vm.SourceTextModule) {\n return new Function(\"return import('data:text/javascript;base64,\" + btoa(source) + \"')\") as CoreImporter;\n }\n\n console.info(\"Using experimental VM SourceTextModule to load Livelink core\");\n return (async () => {\n const module = new vm.SourceTextModule(source, { identifier: moduleURL });\n // @ts-expect-error: Since core has no dependencies, the linker function will never be called.\n await module.link(() => {});\n await module.evaluate();\n\n return module.namespace;\n }) as CoreImporter;\n }\n\n /**\n *\n */\n private constructor() {}\n}\n"],
5
+ "mappings": "AAMA,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,EAAS,MADE,MAAM,MAAMD,CAAS,GACR,KAAK,EAK7BE,EAAM,MAAM,IAAI,SAAS,0BAA0B,EAAE,EAM3D,OAAKA,EAAG,kBAIR,QAAQ,KAAK,8DAA8D,EACnE,SAAY,CAChB,IAAMC,EAAS,IAAID,EAAG,iBAAiBD,EAAQ,CAAE,WAAYD,CAAU,CAAC,EAExE,aAAMG,EAAO,KAAK,IAAM,CAAC,CAAC,EAC1B,MAAMA,EAAO,SAAS,EAEfA,EAAO,SAClB,GAXW,IAAI,SAAS,8CAAgD,KAAKF,CAAM,EAAI,IAAI,CAY/F,CAKQ,aAAc,CAAC,CAC3B",
6
+ "names": ["isNode", "DynamicLoader", "_DynamicLoader", "#core", "#importPromise", "target", "#importCore", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "source", "vm", "module"]
7
7
  }
@@ -21,11 +21,17 @@ export declare class InactivityWarningEvent extends Event {
21
21
  */
22
22
  readonly resetTimer: () => void;
23
23
  }
24
+ /**
25
+ * Event emitted when activity is detected after a period of inactivity.
26
+ */
27
+ export declare class ActivityDetectedEvent extends Event {
28
+ }
24
29
  /**
25
30
  *
26
31
  */
27
32
  export type CoreEvents = {
28
33
  "on-inactivity-warning": InactivityWarningEvent;
34
+ "on-activity-detected": ActivityDetectedEvent;
29
35
  "on-disconnected": DisconnectedEvent;
30
36
  "on-frame-received": FrameReceivedEvent;
31
37
  "on-script-event-received": ScriptEventTriggeredEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3dverse/livelink.core",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "3dverse Livelink Core types.",
5
5
  "main": "./dist/library.cjs",
6
6
  "module": "./dist/library.mjs",