@3dverse/livelink.core 1.1.6 → 1.1.8

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.
@@ -0,0 +1,11 @@
1
+ import { UUID } from "../../../../sources/types";
2
+ /**
3
+ *
4
+ */
5
+ export type ConnectedClient = {
6
+ username: string;
7
+ user_id: UUID;
8
+ client_id: UUID;
9
+ is_headless: boolean;
10
+ client_type: "guest" | "user";
11
+ };
@@ -0,0 +1,11 @@
1
+ import { UUID } from "../../../../sources/types";
2
+ /**
3
+ *
4
+ */
5
+ export type ConnectedClients = {
6
+ username: string;
7
+ user_id: UUID;
8
+ client_id: UUID;
9
+ is_headless: boolean;
10
+ client_type: "guest" | "user";
11
+ }[];
@@ -0,0 +1,5 @@
1
+ import { UUID } from "../../../../sources/types";
2
+ /**
3
+ *
4
+ */
5
+ export type DisconnectedClients = Array<UUID>;
@@ -1,4 +1,7 @@
1
1
  export * from "./AssetLoadingEvent";
2
2
  export * from "./AudioPacketEvent";
3
+ export * from "./ConnectedClientEvent";
4
+ export * from "./DisconnectedClientsEvent";
5
+ export * from "./ConnectedClientsEvent";
3
6
  export * from "./FrameDataEvent";
4
7
  export * from "./ScriptEvent";
package/dist/library.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)d(o,r,{get:e[r],enumerable:!0})},L=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!l.call(o,i)&&i!==r&&d(o,i,{get:()=>e[i],enumerable:!(t=p(e,i))||t.enumerable});return o};var m=o=>L(d({},"__esModule",{value:!0}),o);var I={};u(I,{DynamicLoader:()=>s});module.exports=m(I);var g=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,s=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(!g)return new Function("return import('"+r+"')");let i=await(await fetch(r)).text(),a=await new Function("return import('node:vm')")();return a.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new a.SourceTextModule(i,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(i)+"')")}constructor(){}};typeof window<"u"&&(window.__LIVELINK__||(window.__LIVELINK__={}),Object.prototype.hasOwnProperty.call(window.__LIVELINK__,"@3dverse/livelink.core")?console.warn("\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported."):window.__LIVELINK__["@3dverse/livelink.core"]="1.1.6");
1
+ "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)d(o,r,{get:e[r],enumerable:!0})},L=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of c(e))!l.call(o,i)&&i!==r&&d(o,i,{get:()=>e[i],enumerable:!(t=p(e,i))||t.enumerable});return o};var m=o=>L(d({},"__esModule",{value:!0}),o);var I={};u(I,{DynamicLoader:()=>s});module.exports=m(I);var g=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,s=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(!g)return new Function("return import('"+r+"')");let i=await(await fetch(r)).text(),a=await new Function("return import('node:vm')")();return a.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new a.SourceTextModule(i,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(i)+"')")}constructor(){}};typeof window<"u"&&(window.__LIVELINK__||(window.__LIVELINK__={}),Object.prototype.hasOwnProperty.call(window.__LIVELINK__,"@3dverse/livelink.core")?console.warn("\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported."):window.__LIVELINK__["@3dverse/livelink.core"]="1.1.8");
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\n//------------------------------------------------------------------------------\n/**\n * Version of the Livelink Core library, injected by the build system.\n * @internal\n */\ndeclare const LIVELINK_CORE_VERSION: string;\n\n/**\n * Name of the package, injected by the build system.\n * @internal\n */\ndeclare const PACKAGE_NAME: string;\n\n//------------------------------------------------------------------------------\ndeclare global {\n interface Window {\n __LIVELINK__: Record<string, string>;\n }\n}\n\n//------------------------------------------------------------------------------\nif (typeof window !== \"undefined\") {\n if (!window.__LIVELINK__) {\n window.__LIVELINK__ = {};\n }\n\n if (Object.prototype.hasOwnProperty.call(window.__LIVELINK__, PACKAGE_NAME)) {\n console.warn(\"\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported.\");\n } else {\n window.__LIVELINK__[PACKAGE_NAME] = LIVELINK_CORE_VERSION;\n }\n}\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"],
4
+ "sourcesContent": ["export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n\n//------------------------------------------------------------------------------\n/**\n * Version of the Livelink Core library, injected by the build system.\n * @internal\n */\ndeclare const LIVELINK_CORE_VERSION: string;\n\n/**\n * Name of the package, injected by the build system.\n * @internal\n */\ndeclare const PACKAGE_NAME: string;\n\n//------------------------------------------------------------------------------\ndeclare global {\n interface Window {\n __LIVELINK__: Record<string, string>;\n }\n}\n\n//------------------------------------------------------------------------------\nif (typeof window !== \"undefined\") {\n if (!window.__LIVELINK__) {\n window.__LIVELINK__ = {};\n }\n\n if (Object.prototype.hasOwnProperty.call(window.__LIVELINK__, PACKAGE_NAME)) {\n console.warn(\"\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported.\");\n } else {\n window.__LIVELINK__[PACKAGE_NAME] = LIVELINK_CORE_VERSION;\n }\n}\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 * @inline\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
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,ED9HI,OAAO,OAAW,MACb,OAAO,eACR,OAAO,aAAe,CAAC,GAGvB,OAAO,UAAU,eAAe,KAAK,OAAO,aAAc,wBAAY,EACtE,QAAQ,KAAK,uFAAmE,EAEhF,OAAO,aAAa,wBAAY,EAAI",
6
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 a=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,s=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(!a)return new Function("return import('"+r+"')");let t=await(await fetch(r)).text(),d=await new Function("return import('node:vm')")();return d.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new d.SourceTextModule(t,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(t)+"')")}constructor(){}};typeof window<"u"&&(window.__LIVELINK__||(window.__LIVELINK__={}),Object.prototype.hasOwnProperty.call(window.__LIVELINK__,"@3dverse/livelink.core")?console.warn("\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported."):window.__LIVELINK__["@3dverse/livelink.core"]="1.1.6");export{s as DynamicLoader};
1
+ var a=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,s=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(!a)return new Function("return import('"+r+"')");let t=await(await fetch(r)).text(),d=await new Function("return import('node:vm')")();return d.SourceTextModule?(console.info("Using experimental VM SourceTextModule to load Livelink core"),async()=>{let n=new d.SourceTextModule(t,{identifier:r});return await n.link(()=>{}),await n.evaluate(),n.namespace}):new Function("return import('data:text/javascript;base64,"+btoa(t)+"')")}constructor(){}};typeof window<"u"&&(window.__LIVELINK__||(window.__LIVELINK__={}),Object.prototype.hasOwnProperty.call(window.__LIVELINK__,"@3dverse/livelink.core")?console.warn("\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported."):window.__LIVELINK__["@3dverse/livelink.core"]="1.1.8");export{s as DynamicLoader};
2
2
  //# sourceMappingURL=library.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../sources/DynamicLoader.ts", "../sources/library.ts"],
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", "export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n\n//------------------------------------------------------------------------------\n/**\n * Version of the Livelink Core library, injected by the build system.\n * @internal\n */\ndeclare const LIVELINK_CORE_VERSION: string;\n\n/**\n * Name of the package, injected by the build system.\n * @internal\n */\ndeclare const PACKAGE_NAME: string;\n\n//------------------------------------------------------------------------------\ndeclare global {\n interface Window {\n __LIVELINK__: Record<string, string>;\n }\n}\n\n//------------------------------------------------------------------------------\nif (typeof window !== \"undefined\") {\n if (!window.__LIVELINK__) {\n window.__LIVELINK__ = {};\n }\n\n if (Object.prototype.hasOwnProperty.call(window.__LIVELINK__, PACKAGE_NAME)) {\n console.warn(\"\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported.\");\n } else {\n window.__LIVELINK__[PACKAGE_NAME] = LIVELINK_CORE_VERSION;\n }\n}\n"],
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 * @inline\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", "export * from \"./DynamicLoader\";\nexport type * from \"./core\";\n\n//------------------------------------------------------------------------------\n/**\n * Version of the Livelink Core library, injected by the build system.\n * @internal\n */\ndeclare const LIVELINK_CORE_VERSION: string;\n\n/**\n * Name of the package, injected by the build system.\n * @internal\n */\ndeclare const PACKAGE_NAME: string;\n\n//------------------------------------------------------------------------------\ndeclare global {\n interface Window {\n __LIVELINK__: Record<string, string>;\n }\n}\n\n//------------------------------------------------------------------------------\nif (typeof window !== \"undefined\") {\n if (!window.__LIVELINK__) {\n window.__LIVELINK__ = {};\n }\n\n if (Object.prototype.hasOwnProperty.call(window.__LIVELINK__, PACKAGE_NAME)) {\n console.warn(\"\u26A0\uFE0F WARNING \u26A0\uFE0F Multiple instances of Livelink Core being imported.\");\n } else {\n window.__LIVELINK__[PACKAGE_NAME] = LIVELINK_CORE_VERSION;\n }\n}\n"],
5
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,EC9HI,OAAO,OAAW,MACb,OAAO,eACR,OAAO,aAAe,CAAC,GAGvB,OAAO,UAAU,eAAe,KAAK,OAAO,aAAc,wBAAY,EACtE,QAAQ,KAAK,uFAAmE,EAEhF,OAAO,aAAa,wBAAY,EAAI",
6
6
  "names": ["isNode", "DynamicLoader", "_DynamicLoader", "#core", "#importPromise", "target", "#importCore", "dynamicImport", "#createImporter", "LivelinkCore", "TARGET_COLOR", "moduleURL", "source", "vm", "module"]
7
7
  }
@@ -17,7 +17,7 @@
17
17
  * It is up to the application to decide what can be qualified as activity.
18
18
  * For example, the application could consider the user moving the mouse as activity. In this case, the application
19
19
  * would listen to the "mousemove" event and reset the activity watcher whenever the mouse is moved calling
20
- * the {@link ActivityWatcher.reset} method.
20
+ * the reset method.
21
21
  *
22
22
  * The application should also listen to the {@link ActivityDetectedEvent} event and update the UI accordingly.
23
23
  *
@@ -63,7 +63,6 @@ export declare class ActivityWatcher {
63
63
  timeout_after_seconds: number;
64
64
  }): void;
65
65
  /**
66
- * @method
67
66
  * Reset the timeouts.
68
67
  */
69
68
  reset: () => void;
@@ -1,6 +1,6 @@
1
1
  export * from "./internal/GatewayEvents";
2
2
  export * from "./internal/EditorEvents";
3
- import { AssetLoadingStatusEvent, AudioReceivedEvent, FrameReceivedEvent, ScriptEventTriggeredEvent } from "./internal/GatewayEvents";
3
+ import { AssetLoadingStatusEvent, AudioReceivedEvent, ClientConnectedEvent, ClientsDisconnectedEvent, FrameReceivedEvent, ScriptEventTriggeredEvent } from "./internal/GatewayEvents";
4
4
  import { EntitiesUpdatedEvent, EntityVisibilityChangedEvent, LoadingCompletedEvent } from "./internal/EditorEvents";
5
5
  /**
6
6
  *
@@ -33,6 +33,8 @@ export type CoreEvents = {
33
33
  "on-inactivity-warning": InactivityWarningEvent;
34
34
  "on-activity-detected": ActivityDetectedEvent;
35
35
  "on-disconnected": DisconnectedEvent;
36
+ "on-client-connected": ClientConnectedEvent;
37
+ "on-clients-disconnected": ClientsDisconnectedEvent;
36
38
  "on-frame-received": FrameReceivedEvent;
37
39
  "on-audio-received": AudioReceivedEvent;
38
40
  "on-script-event-received": ScriptEventTriggeredEvent;
@@ -4,7 +4,7 @@ import type { LivelinkCore } from "./LivelinkCore";
4
4
  */
5
5
  type LivelinkCoreType = typeof LivelinkCore;
6
6
  /**
7
- *
7
+ * @inline
8
8
  */
9
9
  type BuildTarget = "prod" | "dev" | "debug";
10
10
  /**
@@ -1,6 +1,24 @@
1
1
  export * from "../../_prebuild/messages/gateway/events";
2
- import { RawFrameMetaData } from "../../_prebuild/messages/gateway/events";
2
+ import { ConnectedClient, DisconnectedClients, RawFrameMetaData } from "../../_prebuild/messages/gateway/events";
3
3
  import { RTID, ScriptDataObject } from "../types";
4
+ /**
5
+ *
6
+ */
7
+ export declare class ClientConnectedEvent extends Event {
8
+ /**
9
+ *
10
+ */
11
+ readonly client_info: ConnectedClient;
12
+ }
13
+ /**
14
+ *
15
+ */
16
+ export declare class ClientsDisconnectedEvent extends Event {
17
+ /**
18
+ *
19
+ */
20
+ readonly client_ids: DisconnectedClients;
21
+ }
4
22
  /**
5
23
  *
6
24
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3dverse/livelink.core",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "3dverse Livelink Core types.",
5
5
  "main": "./dist/library.cjs",
6
6
  "module": "./dist/library.mjs",