@3dverse/livelink.core 1.0.10 → 1.1.0

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 CHANGED
@@ -1,2 +1,2 @@
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(){}};
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.1/"+(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.0");
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\";\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",
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"],
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 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};
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.1/"+(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.0");export{s as DynamicLoader};
2
2
  //# sourceMappingURL=library.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../sources/DynamicLoader.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"],
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",
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"],
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
  }
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Internally the activity watcher uses two timeouts:
7
7
  * - Inactivity warning: the time in seconds after which the {@link InactivityWarningEvent} event is dispatched.
8
- * - Inactivity timeout: the time in seconds after which the {@link DisconnectedEvent} event is dispatched.
8
+ * - Inactivity timeout: the time in seconds after which the {@link Events.DisconnectedEvent} event is dispatched.
9
9
  *
10
10
  * Whenever an internal activity is detected like a message being sent to the gateway, the activity watcher is reset
11
11
  * and a {@link ActivityDetectedEvent} event is dispatched.
@@ -22,7 +22,7 @@
22
22
  * The application should also listen to the {@link ActivityDetectedEvent} event and update the UI accordingly.
23
23
  *
24
24
  * Once the inactivity timeout is reached it automatically triggers the disconnection from the gateway, and a
25
- * {@link DisconnectedEvent} is dispatched with `inactivity` as the reason.
25
+ * {@link Events.DisconnectedEvent} is dispatched with `inactivity` as the reason.
26
26
  * In this case, there is no way to recover the connection. The application should let the user know that the connection
27
27
  * has been lost.
28
28
  *
@@ -1,7 +1,7 @@
1
- export * from "./controllers/GatewayEvents";
2
- export * from "./controllers/EditorEvents";
3
- import { AssetLoadingStatusEvent, FrameReceivedEvent, ScriptEventTriggeredEvent } from "./controllers/GatewayEvents";
4
- import { EntitiesUpdatedEvent, EntityVisibilityChangedEvent } from "./controllers/EditorEvents";
1
+ export * from "./internal/GatewayEvents";
2
+ export * from "./internal/EditorEvents";
3
+ import { AssetLoadingStatusEvent, FrameReceivedEvent, ScriptEventTriggeredEvent } from "./internal/GatewayEvents";
4
+ import { EntitiesUpdatedEvent, EntityVisibilityChangedEvent } from "./internal/EditorEvents";
5
5
  /**
6
6
  *
7
7
  */
@@ -40,11 +40,9 @@ export declare class LivelinkCore extends TypedEventTarget<CoreEvents> {
40
40
  *
41
41
  * @param params
42
42
  * @param params.session - The session to connect to. MUST be joinable.
43
- * @param params.editor_url - The URL of the editor.
44
43
  */
45
- connect({ session, editor_url }: {
44
+ connect({ session }: {
46
45
  session: SessionInterface;
47
- editor_url: string;
48
46
  }): Promise<void>;
49
47
  /**
50
48
  * Closes the connections to the 3dverse server.
@@ -2,6 +2,7 @@ export declare const FTL_HEADER_SIZE: 4;
2
2
  export declare const FTL_VIEWER_CONTROL_ROP_HEADER_SIZE: 1;
3
3
  export declare const FTL_CLIENT_ROP_HEADER_SIZE: 25;
4
4
  export declare const FTL_EDITOR_ROP_HEADER_SIZE: 25;
5
+ export declare const FTL_CLIENT_EDITOR_MSG_SIZE: 24;
5
6
  export declare const LITTLE_ENDIAN: true;
6
7
  export declare const BIG_ENDIAN: false;
7
8
  export declare const HEARTBEAT_PERIOD_IN_MS: 2000;
@@ -1,2 +1,7 @@
1
1
  export * from "./DynamicLoader";
2
2
  export type * from "./core";
3
+ declare global {
4
+ interface Window {
5
+ __LIVELINK__: Record<string, string>;
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3dverse/livelink.core",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "description": "3dverse Livelink Core types.",
5
5
  "main": "./dist/library.cjs",
6
6
  "module": "./dist/library.mjs",
@@ -1,6 +0,0 @@
1
- /**
2
- * DO NOT EDIT THIS FILE MANUALLY.
3
- * This file has been generated automatically from its AsyncAPI spec file.
4
- * See : https://gitlab.com/3dverse/platform/libs/js/asyncapi-server-generator
5
- */
6
- export {};
@@ -1 +0,0 @@
1
- export {};