web-llm-runner 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -13625,7 +13625,7 @@ class WebLLM {
13625
13625
  download_model(model_id_1, progressCallback_1) {
13626
13626
  return __awaiter(this, arguments, void 0, function* (model_id, progressCallback,
13627
13627
  // @ts-ignore: TS1343 complains about es6 target instead of es2020
13628
- workerUrl = new URL("./llm-worker.js", import.meta.url)) {
13628
+ workerUrl = import.meta.url) {
13629
13629
  if (!this.worker) {
13630
13630
  this.worker = new Worker(workerUrl, { type: "module" });
13631
13631
  }
@@ -13765,5 +13765,14 @@ class WebLLM {
13765
13765
  }
13766
13766
  }
13767
13767
 
13768
+ // Monolithic Web Worker Configuration
13769
+ // This enables the compiled library to act as its own Web Worker seamlessly.
13770
+ if (typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope) {
13771
+ const handler = new WebWorkerMLCEngineHandler();
13772
+ self.onmessage = (msg) => {
13773
+ handler.onmessage(msg);
13774
+ };
13775
+ }
13776
+
13768
13777
  export { Chat, ChatCompletionRequestUnsupportedFields, Completions, CreateServiceWorkerMLCEngine as CreateExtensionServiceWorkerMLCEngine, CreateMLCEngine, CreateServiceWorkerMLCEngine$1 as CreateServiceWorkerMLCEngine, CreateWebWorkerMLCEngine, Embeddings, ServiceWorkerMLCEngine as ExtensionServiceWorkerMLCEngine, ServiceWorkerMLCEngineHandler as ExtensionServiceWorkerMLCEngineHandler, IntegrityError, MLCEngine, ModelType, ServiceWorkerMLCEngine$1 as ServiceWorkerMLCEngine, ServiceWorkerMLCEngineHandler$1 as ServiceWorkerMLCEngineHandler, WebLLM, WebWorkerMLCEngine, WebWorkerMLCEngineHandler, deleteChatConfigInCache, deleteModelAllInfoInCache, deleteModelInCache, deleteModelWasmInCache, functionCallingModelIds, hasModelInCache, isValidSRI, modelLibURLPrefix, modelVersion, postInitAndCheckFields$2 as postInitAndCheckFieldsChatCompletion, postInitAndCheckFields$1 as postInitAndCheckFieldsCompletion, postInitAndCheckFields as postInitAndCheckFieldsEmbedding, prebuiltAppConfig, verifyIntegrity };
13769
13778
  //# sourceMappingURL=index.js.map