@agoric/xsnap-lockdown 0.14.1-upgrade-18a-dev-61134db.0 → 0.14.1-upgrade-19-dev-c605745.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.
@@ -1 +1 @@
1
- b9c432d6a773aea4042a88d7b70ca0576601e61df3e881d047933e5e0fa8bb27
1
+ 0f3d516ecca63a3139a17bf98a7db6660e1b1b57f3ba8ba2bce0e92461175c9b
@@ -0,0 +1 @@
1
+ export default {"moduleFormat":"getExport","source":"function getExport() { 'use strict'; let exports = {}; const module = { exports }; 'use strict';\n\nObject.defineProperty(exports,'__esModule',{value:true});\n\n/* @ts-nocheck*/\n/* eslint-disable no-nested-ternary */\n\n/* global globalThis */\n/* Adapted from object-inspect@1.12.0 https://github.com/inspect-js/object-inspect*/\n/* MIT License\n Copyright (c) 2013 James Halliday\n Permission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n The above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n\n\n\n\nconst mapSize=Object.getOwnPropertyDescriptor(Map.prototype,'size').get;\nconst mapForEach=Map.prototype.forEach;\nconst setSize=Object.getOwnPropertyDescriptor(Set.prototype,'size').get;\nconst setForEach=Set.prototype.forEach;\nconst WeakRefPrototype=\ntypeof globalThis.WeakRef==='function'?globalThis.WeakRef.prototype:{};\nconst booleanValueOf=Boolean.prototype.valueOf;\nconst objectToString=Object.prototype.toString;\nconst functionToString=Function.prototype.toString;\nconst $match=String.prototype.match;\nconst $slice=String.prototype.slice;\nconst $replace=String.prototype.replace;\nconst $toUpperCase=String.prototype.toUpperCase;\nconst $test=RegExp.prototype.test;\nconst $concat=Array.prototype.concat;\nconst $join=Array.prototype.join;\nconst bigIntValueOf=BigInt.prototype.valueOf;\nconst getOwnPropertyNames=Object.getOwnPropertyNames;\nconst getOwnPropertySymbols=Object.getOwnPropertySymbols;\nconst symToString=Symbol.prototype.toString;\nconst symKeyFor=Symbol.keyFor;\n/* ie, `has-tostringtag/shams*/\nconst toStringTag=Symbol.toStringTag;\nconst isEnumerable=Object.prototype.propertyIsEnumerable;\nconst dateToISOString=Date.prototype.toISOString;\n\nconst gPO=Reflect.getPrototypeOf;\nconst hasOwn=Object.prototype.hasOwnProperty;\n\n/* Separate every three rightmost digits.*/\nconst separateDigits=(\ndigits,\nseparator='_',\nseparationRegExp=/^-?\\d+(\\d{3})$/)=>\n{\nconst separations=[];\nlet match;\n/* eslint-disable-next-line no-cond-assign*/\nwhile(match=digits.match(separationRegExp)){\nseparations.unshift(match[1]);\ndigits=digits.slice(0,-match[1].length);\n}\nseparations.unshift(digits);\nreturn $join.call(separations,separator);\n};\n\nfunction inspect0(obj,opts={},depth=0,circular=new Set()){\n/* Handle enumerable primitives.*/\nif(obj==null){\nreturn obj===null?'null':'undefined';\n}\nif(obj===true){\nreturn'true';\n}\nif(obj===false){\nreturn'false';\n}\n\nconst typeofObj=typeof obj;\nif(typeofObj==='string'){\nreturn inspectString(obj,opts);\n}\nif(typeofObj==='number'){\nif(obj===0){\nreturn Infinity/obj>0?'0':'-0';\n}\nreturn String(obj);\n}\nif(typeofObj==='bigint'){\n/* Separate the digits to help visualise, terminate with `n`.*/\nreturn`${separateDigits(String(obj))}n`;\n}\n\nconst maxDepth=typeof opts.depth==='undefined'?5:opts.depth;\nif(depth>=maxDepth&&maxDepth>0&&typeofObj==='object'){\nreturn isArray(obj)?'[Array]':'[Object]';\n}\n\nconst indent=getIndent(opts,depth);\n\nif(circular.has(obj)){\nreturn'[Circular]';\n}\n\nfunction inspect(value,from,noIndent){\nif(from){\ncircular.add(from);\n}\nlet ret;\nif(noIndent){\nconst newOpts={\ndepth:opts.depth};\n\nif(has(opts,'quoteStyle')){\nnewOpts.quoteStyle=opts.quoteStyle;\n}\nret=inspect0(value,newOpts,depth+1,circular);\n}else{\nret=inspect0(value,opts,depth+1,circular);\n}\nif(from){\ncircular.delete(from);\n}\nreturn ret;\n}\n\nif(typeofObj==='function'){\nconst name=nameOf(obj);\nconst keys=arrObjKeys(obj,inspect);\nreturn`[Function${name?`: ${name}`:' (anonymous)'}]${\nkeys.length>0?` { ${$join.call(keys,', ')} }`:''\n}`;\n}\nif(isSymbol(obj)){\nconst registered=symKeyFor(obj);\nif(registered!==undefined){\n/* Registered symbol.*/\nreturn`Symbol.for(${registered})`;\n}\nreturn symToString.call(obj);\n}\nif(typeof obj!=='object'){\n/* Some new unknown type*/\nreturn typeof obj;\n}\n\nif(isArray(obj)){\nif(obj.length===0){\nreturn'[]';\n}\nconst elems=arrObjKeys(obj,inspect);\nif(indent&&!singleLineValues(elems)){\nreturn`[${indentedJoin(elems,indent)}]`;\n}\nreturn`[ ${$join.call(elems,', ')} ]`;\n}\nif(isError(obj)){\nconst parts=arrObjKeys(obj,inspect);\nif('cause'in obj&&!isEnumerable.call(obj,'cause')){\nparts.unshift(`[cause]: ${inspect(obj.cause)}`);\n}\nif(parts.length===0){\nreturn`[${String(obj)}]`;\n}\nreturn`{ [${String(obj)}] ${$join.call(parts,', ')} }`;\n}\n\nconst objProto=gPO(obj);\nswitch(objProto){\ncase Map.prototype:{\nconst mapParts=[];\nmapForEach.call(obj,(value,key)=>{\nmapParts.push(`${inspect(key,obj,true)} => ${inspect(value,obj)}`);\n});\nreturn collectionOf('Map',mapSize.call(obj),mapParts,indent);\n}\ncase Set.prototype:{\nconst setParts=[];\nsetForEach.call(obj,(value)=>{\nsetParts.push(inspect(value,obj));\n});\nreturn collectionOf('Set',setSize.call(obj),setParts,indent);\n}\ncase WeakMap.prototype:{\nreturn weakContainerOf('WeakMap');\n}\ncase WeakSet.prototype:{\nreturn weakContainerOf('WeakSet');\n}\ncase WeakRefPrototype:{\nreturn weakContainerOf('WeakRef');\n}\ncase BigInt.prototype:{\nreturn markBoxed(inspect(bigIntValueOf.call(obj)));\n}\ndefault:\n/* Fall-through*/}\n\n\nif(!(toStringTag in obj)){\nswitch(objProto){\ncase Number.prototype:{\nreturn markBoxed(inspect(Number(obj)));\n}\ncase Boolean.prototype:{\nreturn markBoxed(booleanValueOf.call(obj));\n}\ncase String.prototype:{\nreturn markBoxed(inspect(String(obj)));\n}\ncase Date.prototype:{\nreturn dateToISOString.call(obj);\n}\ncase RegExp.prototype:{\nreturn String(obj);\n}\ndefault:\n/* Fall-through*/}\n\n}\n\nconst elems=arrObjKeys(obj,inspect);\nconst isPlainObject=objProto===Object.prototype;\nconst protoTag=\nisPlainObject||obj instanceof Object?'':'null prototype';\nconst stringTag=\n!isPlainObject&&toStringTag&&Object(obj)===obj&&toStringTag in obj?\n$slice.call(toStr(obj),8,-1):\nprotoTag?\n'Object':\n'';\nconst protoConstructor=objProto&&objProto.constructor;\nconst constructorTag=\nisPlainObject||typeof protoConstructor!=='function'?\n'':\nprotoConstructor.name?\n`${protoConstructor.name} `:\n'';\nconst tag=\nconstructorTag+(\nstringTag||protoTag?\n`[${$join.call(\n$concat.call([],stringTag||[],protoTag||[]),\n': ')\n}] `:\n'');\nif(elems.length===0){\nreturn`${tag}{}`;\n}\nif(indent){\nreturn`${tag}{${indentedJoin(elems,indent)}}`;\n}\nreturn`${tag}{ ${$join.call(elems,', ')} }`;\n}\n\nfunction wrapQuotes(s,defaultStyle,opts){\nconst quoteChar=(opts.quoteStyle||defaultStyle)==='double'?'\"':\"'\";\nreturn quoteChar+s+quoteChar;\n}\n\nfunction isArray(obj){\nreturn(\nArray.isArray(obj)&&(\n!toStringTag||!(typeof obj==='object'&&toStringTag in obj)));\n\n}\nfunction isError(obj){\nreturn(\nobj instanceof Error&&!(typeof obj==='object'&&toStringTag in obj));\n\n}\n\n/* Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives*/\nfunction isSymbol(obj){\nreturn typeof obj==='symbol';\n}\n\nfunction has(obj,key){\nreturn hasOwn.call(obj,key);\n}\n\nfunction toStr(obj){\nreturn objectToString.call(obj);\n}\n\nfunction nameOf(f){\nif(f.name){\nreturn f.name;\n}\nconst m=$match.call(functionToString.call(f),/^function\\s*([\\w$]+)/);\nif(m){\nreturn m[1];\n}\nreturn null;\n}\n\nfunction indexOf(xs,x){\nif(xs.indexOf){\nreturn xs.indexOf(x);\n}\nfor(let i=0,l=xs.length;i<l;i+=1){\nif(xs[i]===x){\nreturn i;\n}\n}\nreturn-1;\n}\n\nfunction inspectString(str,opts){\nif(str.length>opts.maxStringLength){\nconst remaining=str.length-opts.maxStringLength;\nconst trailer=`... ${remaining} more character${\nremaining>1?'s':''\n}`;\nreturn(\ninspectString($slice.call(str,0,opts.maxStringLength),opts)+trailer);\n\n}\nconst s=$replace.call(\n/* Replace ' with \\' and \\ with \\\\.*/\n$replace.call(str,/(['\\\\])/g,'\\\\$1'),\n/* eslint-disable-next-line no-control-regex*/\n/[\\x00-\\x1f]/g,\nlowbyte);\n\nreturn wrapQuotes(s,'single',opts);\n}\n\n/* Replace control characters with `\\b`, `\\t`, `\\n`, `\\f`, `\\r`, `\\x0B` or*/\n/* `\\xAB` escaped versions.*/\nfunction lowbyte(c){\nconst n=c.charCodeAt(0);\nconst x={\n8:'b',\n9:'t',\n10:'n',\n12:'f',\n13:'r'}[\nn];\nif(x){\nreturn`\\\\${x}`;\n}\nreturn`\\\\x${n<0x10?'0':''}${$toUpperCase.call(n.toString(16))}`;\n}\n\nfunction markBoxed(str){\nreturn`Object(${str})`;\n}\n\nfunction weakContainerOf(type){\nreturn`${type} { ? }`;\n}\n\nfunction collectionOf(type,size,entries,indent){\nconst joinedEntries=indent?\nindentedJoin(entries,indent):\n$join.call(entries,', ');\nreturn`${type} (${size}) {${joinedEntries}}`;\n}\n\nfunction singleLineValues(xs){\nfor(let i=0;i<xs.length;i+=1){\nif(indexOf(xs[i],'\\n')>=0){\nreturn false;\n}\n}\nreturn true;\n}\n\nfunction getIndent(opts,depth){\nlet baseIndent;\nif(opts.indent==='\\t'){\nbaseIndent='\\t';\n}else if(typeof opts.indent==='number'&&opts.indent>0){\nbaseIndent=$join.call(Array(opts.indent+1),' ');\n}else{\nreturn null;\n}\nreturn{\nbase:baseIndent,\nprev:$join.call(Array(depth+1),baseIndent)};\n\n}\n\nfunction indentedJoin(xs,indent){\nif(xs.length===0){\nreturn'';\n}\nconst lineJoiner=`\\n${indent.prev}${indent.base}`;\nreturn`${lineJoiner+$join.call(xs,`,${lineJoiner}`)}\\n${indent.prev}`;\n}\n\nfunction arrObjKeys(obj,inspect){\nconst isArr=isArray(obj);\nconst elems=[];\nif(isArr){\nelems.length=obj.length;\nfor(let i=0;i<obj.length;i+=1){\nelems[i]=has(obj,i)?inspect(obj[i],obj):'';\n}\n}\nconst syms=getOwnPropertySymbols(obj);\nfor(const key of getOwnPropertyNames(obj)){\nif(!isEnumerable.call(obj,key)){\ncontinue;\n}\nif(isArr&&String(Number(key))===key&&key<obj.length){\ncontinue;\n}\nif($test.call(/[^\\w$]/,key)){\nelems.push(`${inspect(key,obj)}: ${inspect(obj[key],obj)}`);\n}else{\nelems.push(`${key}: ${inspect(obj[key],obj)}`);\n}\n}\nfor(let j=0;j<syms.length;j+=1){\nif(isEnumerable.call(obj,syms[j])){\nelems.push(`[${inspect(syms[j])}]: ${inspect(obj[syms[j]],obj)}`);\n}\n}\nreturn elems;\n}\n\nconst outerInspect=(obj,...args)=>{\ntry{\nreturn inspect0(obj,...args);\n}catch(err){\nlet errStr;\ntry{\nerrStr=inspect0(err);\n}catch(_){\nerrStr='throw';\n}\nreturn`[cannot inspect (${typeof obj}) due to ${errStr}]`;\n}\n};\n\n/* This must be the only import/export statement, and occur last in the file, so*/\n/* that confined-object-inspect.js can comment out the `export default`*/\n/* and evaluate this entire file's source code to obtain the inspector as the*/\n/* completion value.*/\nvar objectInspect=harden(outerInspect);\n\nexports[\"default\"]=objectInspect;\n\nreturn module.exports;\n}\n//# sourceURL=/bundled-source/.../object-inspect.js\n","sourceMap":"//# sourceURL=/bundled-source/.../object-inspect.js\n"};
@@ -1,24 +1,9 @@
1
- import objectInspectSources from '../dist/src-object-inspect.js';
1
+ import objectInspectSources from '../dist/object-inspect.js';
2
2
 
3
3
  // Ensure the object inspector is confined.
4
4
  const c = new Compartment();
5
5
  harden(c.globalThis);
6
6
 
7
- // Transform the imported inspector module source string into an evaluable
8
- // string. We could have played more games with bundlers to do something less
9
- // fragile, but even so, SES should fail-safe if this replacement doesn't match.
10
- //
11
- // The goal (presuming the file ends with a single export default statement):
12
- // `...\n export default harden(inspect0);`
13
- // becomes:
14
- // `...\n /* export default */ harden(inspect0);`
15
- // and we can evaluate it to obtain the completion value as the object inspector.
16
- const src = objectInspectSources.replace(
17
- /(^|\s)(export\s+default)(\s+)/g,
18
- '$1/* $2 */$3',
19
- );
20
- const objectInspect = c.evaluate(
21
- `${src}\n//# sourceURL=xsnap-lockdown/lib/object-inspect.js\n`,
22
- );
7
+ const objectInspect = c.evaluate(`(${objectInspectSources.source})`)().default;
23
8
 
24
9
  export default objectInspect;
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@agoric/xsnap-lockdown",
3
- "version": "0.14.1-upgrade-18a-dev-61134db.0+61134db",
3
+ "version": "0.14.1-upgrade-19-dev-c605745.0+c605745",
4
4
  "description": "Endo/lockdown initialization bundle for xsnap workers",
5
5
  "author": "Agoric",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.js",
9
9
  "scripts": {
10
- "build:bundle-rollup": "rollup --config rollup.config.js",
11
- "build:bundle-source": "node scripts/build-bundle.js",
12
- "build": "yarn build:bundle-rollup && yarn build:bundle-source",
10
+ "build": "node scripts/build-bundle.js",
13
11
  "clean": "rm -rf dist",
14
12
  "lint": "run-s --continue-on-error lint:*",
15
13
  "lint:js": "eslint 'src/**/*.js' 'lib/**/*.js' 'scripts/**/*.js' 'test/**/*.js'",
@@ -20,12 +18,10 @@
20
18
  "test:xs": "exit 0"
21
19
  },
22
20
  "devDependencies": {
23
- "@endo/bundle-source": "^3.5.0",
24
- "@endo/init": "^1.1.7",
21
+ "@endo/bundle-source": "^3.5.1",
22
+ "@endo/init": "^1.1.8",
25
23
  "ava": "^5.3.0",
26
24
  "c8": "^10.1.2",
27
- "rollup": "^4.24.0",
28
- "rollup-plugin-string": "^3.0.0",
29
25
  "source-map": "^0.7.4"
30
26
  },
31
27
  "files": [
@@ -48,7 +44,7 @@
48
44
  "workerThreads": false
49
45
  },
50
46
  "typeCoverage": {
51
- "atLeast": 73.6
47
+ "atLeast": 73.54
52
48
  },
53
- "gitHead": "61134dbe832b81ad609b1218fb0859f2222fa1ef"
49
+ "gitHead": "c605745ee6619292b51cec5fc0db0a25ff1b203c"
54
50
  }
package/src/paths.js CHANGED
@@ -1,21 +1,24 @@
1
1
  // define these here, in one place, so both the builder and the
2
2
  // client-facing API can see the same paths
3
3
 
4
+ import { fileURLToPath } from 'url';
5
+
6
+ /** @param {string} path */
7
+ const resolve = path => fileURLToPath(new URL(path, import.meta.url));
8
+
4
9
  export const bundlePaths = {
5
- lockdown: new URL('../dist/lockdown.bundle', import.meta.url).pathname,
6
- lockdownDebug: new URL('../dist/lockdown-debug.bundle', import.meta.url)
7
- .pathname,
10
+ lockdown: resolve('../dist/lockdown.bundle'),
11
+ lockdownDebug: resolve('../dist/lockdown-debug.bundle'),
12
+ objectInspect: resolve('../dist/object-inspect.js'),
8
13
  };
9
14
 
10
15
  export const hashPaths = {
11
- lockdown: new URL('../dist/lockdown.bundle.sha256', import.meta.url).pathname,
12
- lockdownDebug: new URL(
13
- '../dist/lockdown-debug.bundle.sha256',
14
- import.meta.url,
15
- ).pathname,
16
+ lockdown: resolve('../dist/lockdown.bundle.sha256'),
17
+ lockdownDebug: resolve('../dist/lockdown-debug.bundle.sha256'),
16
18
  };
17
19
 
18
20
  export const entryPaths = {
19
- lockdown: new URL('../lib/ses-boot.js', import.meta.url).pathname,
20
- lockdownDebug: new URL('../lib/ses-boot-debug.js', import.meta.url).pathname,
21
+ lockdown: resolve('../lib/ses-boot.js'),
22
+ lockdownDebug: resolve('../lib/ses-boot-debug.js'),
23
+ objectInspect: resolve('../lib/object-inspect.js'),
21
24
  };
@@ -1,3 +0,0 @@
1
- var objectInspect = "// @ts-nocheck\n/* eslint-disable no-nested-ternary */\n\n/* global globalThis */\n// Adapted from object-inspect@1.12.0 https://github.com/inspect-js/object-inspect\n/*\nMIT License\n\nCopyright (c) 2013 James Halliday\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\nconst mapSize = Object.getOwnPropertyDescriptor(Map.prototype, 'size').get;\nconst mapForEach = Map.prototype.forEach;\nconst setSize = Object.getOwnPropertyDescriptor(Set.prototype, 'size').get;\nconst setForEach = Set.prototype.forEach;\nconst WeakRefPrototype =\n typeof globalThis.WeakRef === 'function' ? globalThis.WeakRef.prototype : {};\nconst booleanValueOf = Boolean.prototype.valueOf;\nconst objectToString = Object.prototype.toString;\nconst functionToString = Function.prototype.toString;\nconst $match = String.prototype.match;\nconst $slice = String.prototype.slice;\nconst $replace = String.prototype.replace;\nconst $toUpperCase = String.prototype.toUpperCase;\nconst $test = RegExp.prototype.test;\nconst $concat = Array.prototype.concat;\nconst $join = Array.prototype.join;\nconst bigIntValueOf = BigInt.prototype.valueOf;\nconst getOwnPropertyNames = Object.getOwnPropertyNames;\nconst getOwnPropertySymbols = Object.getOwnPropertySymbols;\nconst symToString = Symbol.prototype.toString;\nconst symKeyFor = Symbol.keyFor;\n// ie, `has-tostringtag/shams\nconst toStringTag = Symbol.toStringTag;\nconst isEnumerable = Object.prototype.propertyIsEnumerable;\nconst dateToISOString = Date.prototype.toISOString;\n\nconst gPO = Reflect.getPrototypeOf;\nconst hasOwn = Object.prototype.hasOwnProperty;\n\n// Separate every three rightmost digits.\nconst separateDigits = (\n digits,\n separator = '_',\n separationRegExp = /^-?\\d+(\\d{3})$/,\n) => {\n const separations = [];\n let match;\n // eslint-disable-next-line no-cond-assign\n while ((match = digits.match(separationRegExp))) {\n separations.unshift(match[1]);\n digits = digits.slice(0, -match[1].length);\n }\n separations.unshift(digits);\n return $join.call(separations, separator);\n};\n\nfunction inspect0(obj, opts = {}, depth = 0, circular = new Set()) {\n // Handle enumerable primitives.\n if (obj == null) {\n return obj === null ? 'null' : 'undefined';\n }\n if (obj === true) {\n return 'true';\n }\n if (obj === false) {\n return 'false';\n }\n\n const typeofObj = typeof obj;\n if (typeofObj === 'string') {\n return inspectString(obj, opts);\n }\n if (typeofObj === 'number') {\n if (obj === 0) {\n return Infinity / obj > 0 ? '0' : '-0';\n }\n return String(obj);\n }\n if (typeofObj === 'bigint') {\n // Separate the digits to help visualise, terminate with `n`.\n return `${separateDigits(String(obj))}n`;\n }\n\n const maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;\n if (depth >= maxDepth && maxDepth > 0 && typeofObj === 'object') {\n return isArray(obj) ? '[Array]' : '[Object]';\n }\n\n const indent = getIndent(opts, depth);\n\n if (circular.has(obj)) {\n return '[Circular]';\n }\n\n function inspect(value, from, noIndent) {\n if (from) {\n circular.add(from);\n }\n let ret;\n if (noIndent) {\n const newOpts = {\n depth: opts.depth,\n };\n if (has(opts, 'quoteStyle')) {\n newOpts.quoteStyle = opts.quoteStyle;\n }\n ret = inspect0(value, newOpts, depth + 1, circular);\n } else {\n ret = inspect0(value, opts, depth + 1, circular);\n }\n if (from) {\n circular.delete(from);\n }\n return ret;\n }\n\n if (typeofObj === 'function') {\n const name = nameOf(obj);\n const keys = arrObjKeys(obj, inspect);\n return `[Function${name ? `: ${name}` : ' (anonymous)'}]${\n keys.length > 0 ? ` { ${$join.call(keys, ', ')} }` : ''\n }`;\n }\n if (isSymbol(obj)) {\n const registered = symKeyFor(obj);\n if (registered !== undefined) {\n // Registered symbol.\n return `Symbol.for(${registered})`;\n }\n return symToString.call(obj);\n }\n if (typeof obj !== 'object') {\n // Some new unknown type\n return typeof obj;\n }\n\n if (isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const elems = arrObjKeys(obj, inspect);\n if (indent && !singleLineValues(elems)) {\n return `[${indentedJoin(elems, indent)}]`;\n }\n return `[ ${$join.call(elems, ', ')} ]`;\n }\n if (isError(obj)) {\n const parts = arrObjKeys(obj, inspect);\n if ('cause' in obj && !isEnumerable.call(obj, 'cause')) {\n parts.unshift(`[cause]: ${inspect(obj.cause)}`);\n }\n if (parts.length === 0) {\n return `[${String(obj)}]`;\n }\n return `{ [${String(obj)}] ${$join.call(parts, ', ')} }`;\n }\n\n const objProto = gPO(obj);\n switch (objProto) {\n case Map.prototype: {\n const mapParts = [];\n mapForEach.call(obj, (value, key) => {\n mapParts.push(`${inspect(key, obj, true)} => ${inspect(value, obj)}`);\n });\n return collectionOf('Map', mapSize.call(obj), mapParts, indent);\n }\n case Set.prototype: {\n const setParts = [];\n setForEach.call(obj, value => {\n setParts.push(inspect(value, obj));\n });\n return collectionOf('Set', setSize.call(obj), setParts, indent);\n }\n case WeakMap.prototype: {\n return weakContainerOf('WeakMap');\n }\n case WeakSet.prototype: {\n return weakContainerOf('WeakSet');\n }\n case WeakRefPrototype: {\n return weakContainerOf('WeakRef');\n }\n case BigInt.prototype: {\n return markBoxed(inspect(bigIntValueOf.call(obj)));\n }\n default:\n // Fall-through\n }\n\n if (!(toStringTag in obj)) {\n switch (objProto) {\n case Number.prototype: {\n return markBoxed(inspect(Number(obj)));\n }\n case Boolean.prototype: {\n return markBoxed(booleanValueOf.call(obj));\n }\n case String.prototype: {\n return markBoxed(inspect(String(obj)));\n }\n case Date.prototype: {\n return dateToISOString.call(obj);\n }\n case RegExp.prototype: {\n return String(obj);\n }\n default:\n // Fall-through\n }\n }\n\n const elems = arrObjKeys(obj, inspect);\n const isPlainObject = objProto === Object.prototype;\n const protoTag =\n isPlainObject || obj instanceof Object ? '' : 'null prototype';\n const stringTag =\n !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj\n ? $slice.call(toStr(obj), 8, -1)\n : protoTag\n ? 'Object'\n : '';\n const protoConstructor = objProto && objProto.constructor;\n const constructorTag =\n isPlainObject || typeof protoConstructor !== 'function'\n ? ''\n : protoConstructor.name\n ? `${protoConstructor.name} `\n : '';\n const tag =\n constructorTag +\n (stringTag || protoTag\n ? `[${$join.call(\n $concat.call([], stringTag || [], protoTag || []),\n ': ',\n )}] `\n : '');\n if (elems.length === 0) {\n return `${tag}{}`;\n }\n if (indent) {\n return `${tag}{${indentedJoin(elems, indent)}}`;\n }\n return `${tag}{ ${$join.call(elems, ', ')} }`;\n}\n\nfunction wrapQuotes(s, defaultStyle, opts) {\n const quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '\"' : \"'\";\n return quoteChar + s + quoteChar;\n}\n\nfunction isArray(obj) {\n return (\n Array.isArray(obj) &&\n (!toStringTag || !(typeof obj === 'object' && toStringTag in obj))\n );\n}\nfunction isError(obj) {\n return (\n obj instanceof Error && !(typeof obj === 'object' && toStringTag in obj)\n );\n}\n\n// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives\nfunction isSymbol(obj) {\n return typeof obj === 'symbol';\n}\n\nfunction has(obj, key) {\n return hasOwn.call(obj, key);\n}\n\nfunction toStr(obj) {\n return objectToString.call(obj);\n}\n\nfunction nameOf(f) {\n if (f.name) {\n return f.name;\n }\n const m = $match.call(functionToString.call(f), /^function\\s*([\\w$]+)/);\n if (m) {\n return m[1];\n }\n return null;\n}\n\nfunction indexOf(xs, x) {\n if (xs.indexOf) {\n return xs.indexOf(x);\n }\n for (let i = 0, l = xs.length; i < l; i += 1) {\n if (xs[i] === x) {\n return i;\n }\n }\n return -1;\n}\n\nfunction inspectString(str, opts) {\n if (str.length > opts.maxStringLength) {\n const remaining = str.length - opts.maxStringLength;\n const trailer = `... ${remaining} more character${\n remaining > 1 ? 's' : ''\n }`;\n return (\n inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer\n );\n }\n const s = $replace.call(\n // Replace ' with \\' and \\ with \\\\.\n $replace.call(str, /(['\\\\])/g, '\\\\$1'),\n // eslint-disable-next-line no-control-regex\n /[\\x00-\\x1f]/g,\n lowbyte,\n );\n return wrapQuotes(s, 'single', opts);\n}\n\n// Replace control characters with `\\b`, `\\t`, `\\n`, `\\f`, `\\r`, `\\x0B` or\n// `\\xAB` escaped versions.\nfunction lowbyte(c) {\n const n = c.charCodeAt(0);\n const x = {\n 8: 'b',\n 9: 't',\n 10: 'n',\n 12: 'f',\n 13: 'r',\n }[n];\n if (x) {\n return `\\\\${x}`;\n }\n return `\\\\x${n < 0x10 ? '0' : ''}${$toUpperCase.call(n.toString(16))}`;\n}\n\nfunction markBoxed(str) {\n return `Object(${str})`;\n}\n\nfunction weakContainerOf(type) {\n return `${type} { ? }`;\n}\n\nfunction collectionOf(type, size, entries, indent) {\n const joinedEntries = indent\n ? indentedJoin(entries, indent)\n : $join.call(entries, ', ');\n return `${type} (${size}) {${joinedEntries}}`;\n}\n\nfunction singleLineValues(xs) {\n for (let i = 0; i < xs.length; i += 1) {\n if (indexOf(xs[i], '\\n') >= 0) {\n return false;\n }\n }\n return true;\n}\n\nfunction getIndent(opts, depth) {\n let baseIndent;\n if (opts.indent === '\\t') {\n baseIndent = '\\t';\n } else if (typeof opts.indent === 'number' && opts.indent > 0) {\n baseIndent = $join.call(Array(opts.indent + 1), ' ');\n } else {\n return null;\n }\n return {\n base: baseIndent,\n prev: $join.call(Array(depth + 1), baseIndent),\n };\n}\n\nfunction indentedJoin(xs, indent) {\n if (xs.length === 0) {\n return '';\n }\n const lineJoiner = `\\n${indent.prev}${indent.base}`;\n return `${lineJoiner + $join.call(xs, `,${lineJoiner}`)}\\n${indent.prev}`;\n}\n\nfunction arrObjKeys(obj, inspect) {\n const isArr = isArray(obj);\n const elems = [];\n if (isArr) {\n elems.length = obj.length;\n for (let i = 0; i < obj.length; i += 1) {\n elems[i] = has(obj, i) ? inspect(obj[i], obj) : '';\n }\n }\n const syms = getOwnPropertySymbols(obj);\n for (const key of getOwnPropertyNames(obj)) {\n if (!isEnumerable.call(obj, key)) {\n continue;\n }\n if (isArr && String(Number(key)) === key && key < obj.length) {\n continue;\n }\n if ($test.call(/[^\\w$]/, key)) {\n elems.push(`${inspect(key, obj)}: ${inspect(obj[key], obj)}`);\n } else {\n elems.push(`${key}: ${inspect(obj[key], obj)}`);\n }\n }\n for (let j = 0; j < syms.length; j += 1) {\n if (isEnumerable.call(obj, syms[j])) {\n elems.push(`[${inspect(syms[j])}]: ${inspect(obj[syms[j]], obj)}`);\n }\n }\n return elems;\n}\n\nconst outerInspect = (obj, ...args) => {\n try {\n return inspect0(obj, ...args);\n } catch (err) {\n let errStr;\n try {\n errStr = inspect0(err);\n } catch (_) {\n errStr = 'throw';\n }\n return `[cannot inspect (${typeof obj}) due to ${errStr}]`;\n }\n};\n\n// This must be the only import/export statement, and occur last in the file, so\n// that confined-object-inspect.js can comment out the `export default`\n// and evaluate this entire file's source code to obtain the inspector as the\n// completion value.\nexport default harden(outerInspect);\n";
2
-
3
- export { objectInspect as default };