almostnode 0.2.1 → 0.2.2

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/index.cjs CHANGED
@@ -6,31 +6,8 @@ const pako = require('pako');
6
6
  const justBash = require('just-bash');
7
7
  const resolve_exports = require('resolve.exports');
8
8
  const comlink = require('comlink');
9
- const fs$1 = require('fs');
10
- const path$1 = require('path');
11
- const url$2 = require('url');
12
9
 
13
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
14
- function _interopNamespaceDefault(e) {
15
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
16
- if (e) {
17
- for (const k in e) {
18
- if (k !== 'default') {
19
- const d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: () => e[k]
23
- });
24
- }
25
- }
26
- }
27
- n.default = e;
28
- return Object.freeze(n);
29
- }
30
-
31
- const fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
32
- const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
33
-
34
11
  function createNodeError(code, syscall, path, message) {
35
12
  const errno = {
36
13
  ENOENT: -2,
@@ -9932,16 +9909,27 @@ async function createRuntime(vfs, options = {}) {
9932
9909
  return new AsyncRuntimeWrapper(vfs, runtimeOptions);
9933
9910
  }
9934
9911
 
9935
- const __dirname$1 = path__namespace.dirname(url$2.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
9936
9912
  function getServiceWorkerContent() {
9913
+ if (typeof require === "undefined") {
9914
+ return null;
9915
+ }
9937
9916
  try {
9938
- let swPath = path__namespace.join(__dirname$1, "__sw__.js");
9939
- if (fs__namespace.existsSync(swPath)) {
9940
- return fs__namespace.readFileSync(swPath, "utf-8");
9917
+ const fs = require("fs");
9918
+ const path = require("path");
9919
+ let dirname;
9920
+ try {
9921
+ const url = require("url");
9922
+ dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
9923
+ } catch {
9924
+ dirname = __dirname;
9925
+ }
9926
+ let swPath = path.join(dirname, "__sw__.js");
9927
+ if (fs.existsSync(swPath)) {
9928
+ return fs.readFileSync(swPath, "utf-8");
9941
9929
  }
9942
- swPath = path__namespace.join(__dirname$1, "../dist/__sw__.js");
9943
- if (fs__namespace.existsSync(swPath)) {
9944
- return fs__namespace.readFileSync(swPath, "utf-8");
9930
+ swPath = path.join(dirname, "../dist/__sw__.js");
9931
+ if (fs.existsSync(swPath)) {
9932
+ return fs.readFileSync(swPath, "utf-8");
9945
9933
  }
9946
9934
  return null;
9947
9935
  } catch {