1/*
2  2022-07-22
3
4  The author disclaims copyright to this source code.  In place of a
5  legal notice, here is a blessing:
6
7  *   May you do good and not evil.
8  *   May you find forgiveness for yourself and forgive others.
9  *   May you share freely, never taking more than you give.
10
11  ***********************************************************************
12
13  This file is the tail end of the sqlite3-api.js constellation,
14  intended to be appended after all other files so that it can clean
15  up any global systems temporarily used for setting up the API's
16  various subsystems.
17*/
18'use strict';
19self.sqlite3.postInit.forEach(
20  self.importScripts/*global is a Worker*/
21    ? function(f){
22      /** We try/catch/report for the sake of failures which happen in
23          a Worker, as those exceptions can otherwise get completely
24          swallowed, leading to confusing downstream errors which have
25          nothing to do with this failure. */
26      try{ f(self, self.sqlite3) }
27      catch(e){
28        console.error("Error in postInit() function:",e);
29        throw e;
30      }
31    }
32  : (f)=>f(self, self.sqlite3)
33);
34delete self.sqlite3.postInit;
35if(self.location && +self.location.port > 1024){
36  console.warn("Installing sqlite3 bits as global S for dev-testing purposes.");
37  self.S = self.sqlite3;
38}
39/* Clean up temporary global-scope references to our APIs... */
40self.sqlite3.config.Module.sqlite3 = self.sqlite3
41/* ^^^^ Currently needed by test code and Worker API setup */;
42delete self.sqlite3.capi.util /* arguable, but these are (currently) internal-use APIs */;
43delete self.sqlite3 /* clean up our global-scope reference */;
44//console.warn("Module.sqlite3 =",Module.sqlite3);
45