{"_id":"@crabas0npm/natus-veritatis-occaecati","name":"@crabas0npm/natus-veritatis-occaecati","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@crabas0npm/natus-veritatis-occaecati","version":"1.0.0","description":"A small but effective node based server for development sites, customizable live reloading, and websocket support built-in. You should consider using NSS if:","main":"index.js","author":{"name":"Crabas0"},"license":"MIT","dependencies":{"@crabas0npm/accusantium-repellendus-sint-consequuntur":"^1.0.0","@crabas0npm/alias-consequuntur-hic-enim":"^1.0.0","@crabas0npm/aliquid-vitae-magnam-perspiciatis":"^1.0.0","@crabas0npm/aut-cupiditate-quam-dicta":"^1.0.0","@crabas0npm/blanditiis-est-molestias-a":"^1.0.0","@crabas0npm/consectetur-impedit-exercitationem-error":"^1.0.0","@crabas0npm/corporis-rerum-reprehenderit-voluptates":"^1.0.0","@crabas0npm/delectus-dolorem-consectetur-corrupti":"^1.0.0","@crabas0npm/ea-nisi-earum-mollitia":"^1.0.0","@crabas0npm/et-perspiciatis-eius-modi":"^1.0.0","@crabas0npm/expedita-magnam-quia-perferendis":"^1.0.0","@crabas0npm/expedita-optio-recusandae-nesciunt":"^1.0.0","@crabas0npm/expedita-voluptas-corrupti-ullam":"^1.0.0","@crabas0npm/facilis-doloribus-provident-optio":"^1.0.0","@crabas0npm/fugiat-necessitatibus-recusandae-quo":"^1.0.0","@crabas0npm/maxime-sequi-nam-facere":"^1.0.0","@crabas0npm/minus-iure-ipsum-temporibus":"^1.0.0","@crabas0npm/nulla-minima-vero-facere":"^1.0.0","@crabas0npm/odio-exercitationem-ducimus-provident":"^1.0.0","@crabas0npm/officia-nostrum-at-hic":"^1.0.0","@crabas0npm/officiis-labore-tempora-sint":"^1.0.0","@crabas0npm/omnis-neque-asperiores-rerum":"^1.0.0","@crabas0npm/optio-sequi-optio-quidem":"^1.0.0","@crabas0npm/porro-voluptatem-consectetur-beatae":"^1.0.0","@crabas0npm/possimus-sit-repellat-perspiciatis":"^1.0.0","@crabas0npm/quo-dolorem-molestiae-porro":"^1.0.0","@crabas0npm/ratione-nisi-deleniti-provident":"^1.0.0","@crabas0npm/ratione-voluptatibus-quo-sed":"^1.0.0","@crabas0npm/repellendus-illum-cum-fugit":"^1.0.0","@crabas0npm/unde-quos-asperiores-modi":"^1.0.0","@diahkomalasarinpm/praesentium-sint-dolorem":"^1.0.0","@f1stnpm2/adipisci-adipisci-praesentium":"^1.0.0","@wemnyelezxnpm/delectus-repellendus-neque":"^1.0.0"},"keywords":["Observable","syntaxerror","ansi","Observables","ast","arktype","error-handling","duplex","WeakSet","tools","Int32Array","optimizer","ECMAScript 2019","es6","rate","flat","ecmascript","diff","shell","eslintconfig","set","YAML","tc39","rm -rf","dataView","Map","escape","Push","eslint","TypeBox","toArray","css-in-js","private data","import","protobuf","less","persistent","fastify","web","Symbol","is","jsdom","joi","korean","proto","react","listeners","byte","config","fast-clone","types","three","streams2","ECMAScript 6","harmony","japanese","sort","readable","classnames","AsyncIterator","middleware","input","limited","shared","operating-system","toStringTag","mkdir","CSS","linux","jsdiff","json-schema","scheme-validation","make","stateless","wordbreak","offset","matchAll","react-hook-form","dom-testing-library","fp","encryption","check","prototype","Array","ArrayBuffer#slice","log","traverse","stylesheet","ECMAScript 2015","symlinks","typedarray","const","jsonschema","framer","ECMAScript 2016","hasOwn","find","postcss","bootstrap less","monorepo","shebang","es5","extra","lesscss","eslintplugin","getOwnPropertyDescriptor","deepclone","mocha","flag","popmotion","transpiler","consume","styleguide","framework","drop","property","write","es2017","includes","ES6","json","typesafe","ECMAScript 2017","findLastIndex","eslint-plugin","data","xhr","ratelimit","wait","indicator","recursive","lint","speed","request","trimRight","airbnb","weakmap","dom","regex","readablestream","electron","typanion","argparse","names","StyleSheet","regular expressions","connect","bind","symbols","shrinkwrap","uninstall","schema","path","Int16Array","BigUint64Array","banner","Streams","setter","stringify","configurable","test","String.prototype.matchAll","wrap","autoprefixer","view","moment","fetch","windows","uuid","RegExp.prototype.flags","datastructure","private","karma","regular expression","slot","es-abstract","react-hooks","animation","expression","slice","BigInt64Array","getintrinsic","Stream","var","xterm","native","Object.fromEntries","tostringtag","immutable","ECMAScript 3","groupBy","contains","es-shim API","util.inspect","waapi","browserlist","Rx","ajax","lru","flatten","loading","react-testing-library","term","Set","settings","Object.assign","jest","symlink","libphonenumber","worker","-0","trimStart","map","form","spinners","unicode","plugin","stringifier","exec","array","less mixins","time","6to5","chrome","nope","fixed-width","json-schema-validator","javascript","output","remove","keys","colour","sigterm","assertion","ES3","watch","json-schema-validation","cjk","patch","package","style","pnpm9","dependencies","rangeerror","stdlib","ES2015","concatMap","Object.is","tap","gradients css3","gdpr","curl","node","directory","equal","break","reducer","Uint32Array","intrinsic","option","take","tty","watchFile","graphql","weakset","internal","ECMAScript 2023","WeakMap","interrupts","look-up","fastcopy","io-ts","spinner","queue","deep","stream","get","environment","iterate","mimetypes","filter","fantasy-land","ES2023","buffers","es8","walking","estree","valid","mime-db","performant","Object.values","gestures","JSON-Schema","runtime","Uint8Array","es","fast-deep-clone","es7","reuse","classname","full-width","ava","3d","group","columns","mkdirs","ES5","move","css","signal","TypeScript","iterator","callbound","concat","form-validation","Int8Array","art","generics","Uint16Array","every","class-validator","compare","args","jwt","Array.prototype.findLastIndex","typescript","formatting","eventDispatcher","visual","flags","wordwrap","jQuery","ECMAScript 5","ie","URL","es2018","validator","date","irq","apollo","ramda","structuredClone","ponyfill","authentication","bcrypt","ES7","argument","syntax","circular","client","TypedArray","logger","helpers","util","RFC-6455","Reflect.getPrototypeOf","folder","lockfile","redact","extend","css variable","create","Array.prototype.contains","internal slot","real-time","descriptor","ajv","findLast","colors","utility","computed-types","has","character","phone","collection","Object.keys","https","getPrototypeOf","batch","RxJS","less compiler","utilities","typed array","east-asian-width","busy","Object.entries","await","key","resolve",".env","superstruct","lazy","arraybuffer","variables in css","parents","ReactiveExtensions","equality","parent","byteLength","value","number","exit-code","warning","scheme","ES2016","spring","format","Array.prototype.findLast","babel-core","functions","find-up","dir","deep-copy","watching","sham","babel","browserslist","js","dataview","picomatch","assign","package manager","Array.prototype.flat","setImmediate","delete","hookform","jasmine","JSON","multi-package","bootstrap css","trimLeft","ArrayBuffer.prototype.slice","yup","string","streams","robust","superagent","error","fast-copy","serializer","Iterator","search","ES2021","chinese","hash","matches","minimal","ES2019","rfc4122","prune","obj","last","hooks","variables","Microsoft","command-line","ES2018","fast-deep-copy","guid","hardlinks","$.extend","push","typed","env","language","Function.prototype.name","preserve-symlinks","glob","console","toobject","random","query","isConcatSpreadable","nodejs"],"repository":{"type":"git","url":"git+https://github.com/crabas0npm/natus-veritatis-occaecati.git"},"homepage":"https://github.com/crabas0npm/natus-veritatis-occaecati/#readme","bugs":{"url":"https://github.com/crabas0npm/natus-veritatis-occaecati/issues"},"packageManager":"yarn@4.1.1","_id":"@crabas0npm/natus-veritatis-occaecati@1.0.0","gitHead":"a9340d683a5dae24c634de5b84c3f1cf4119b415","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-sD2z6IPwOHDK6SzhvlpRpiit3wcVVMufjRvoY1CxH0l2yeBBXBGfu24ChFMYZJPzjQeVkxILVE3W+tWdfvQAlA==","shasum":"757063236b6a6aa071414ec9904bfb32920e5b0f","tarball":"https://registry.npmjs.org/@crabas0npm/natus-veritatis-occaecati/-/natus-veritatis-occaecati-1.0.0.tgz","fileCount":10,"unpackedSize":28876,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGu3Ekzot/P5arwAJ3Pp0SkzG8vxiGkdyev+yZzm/SxAIhAKVOmle8qvJ37NUAxJkJJqCdKzIV4RyCrAs9tRxX2P2D"}]},"_npmUser":{"name":"thanhl4861","email":"thanhl4861@gmail.com"},"directories":{},"maintainers":[{"name":"thanhl4861","email":"thanhl4861@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/natus-veritatis-occaecati_1.0.0_1714211633118_0.2384653708385005"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-27T09:53:53.043Z","1.0.0":"2024-04-27T09:53:53.314Z","modified":"2024-04-27T09:53:53.627Z"},"maintainers":[{"name":"thanhl4861","email":"thanhl4861@gmail.com"}],"description":"A small but effective node based server for development sites, customizable live reloading, and websocket support built-in. You should consider using NSS if:","homepage":"https://github.com/crabas0npm/natus-veritatis-occaecati/#readme","keywords":["Observable","syntaxerror","ansi","Observables","ast","arktype","error-handling","duplex","WeakSet","tools","Int32Array","optimizer","ECMAScript 2019","es6","rate","flat","ecmascript","diff","shell","eslintconfig","set","YAML","tc39","rm -rf","dataView","Map","escape","Push","eslint","TypeBox","toArray","css-in-js","private data","import","protobuf","less","persistent","fastify","web","Symbol","is","jsdom","joi","korean","proto","react","listeners","byte","config","fast-clone","types","three","streams2","ECMAScript 6","harmony","japanese","sort","readable","classnames","AsyncIterator","middleware","input","limited","shared","operating-system","toStringTag","mkdir","CSS","linux","jsdiff","json-schema","scheme-validation","make","stateless","wordbreak","offset","matchAll","react-hook-form","dom-testing-library","fp","encryption","check","prototype","Array","ArrayBuffer#slice","log","traverse","stylesheet","ECMAScript 2015","symlinks","typedarray","const","jsonschema","framer","ECMAScript 2016","hasOwn","find","postcss","bootstrap less","monorepo","shebang","es5","extra","lesscss","eslintplugin","getOwnPropertyDescriptor","deepclone","mocha","flag","popmotion","transpiler","consume","styleguide","framework","drop","property","write","es2017","includes","ES6","json","typesafe","ECMAScript 2017","findLastIndex","eslint-plugin","data","xhr","ratelimit","wait","indicator","recursive","lint","speed","request","trimRight","airbnb","weakmap","dom","regex","readablestream","electron","typanion","argparse","names","StyleSheet","regular expressions","connect","bind","symbols","shrinkwrap","uninstall","schema","path","Int16Array","BigUint64Array","banner","Streams","setter","stringify","configurable","test","String.prototype.matchAll","wrap","autoprefixer","view","moment","fetch","windows","uuid","RegExp.prototype.flags","datastructure","private","karma","regular expression","slot","es-abstract","react-hooks","animation","expression","slice","BigInt64Array","getintrinsic","Stream","var","xterm","native","Object.fromEntries","tostringtag","immutable","ECMAScript 3","groupBy","contains","es-shim API","util.inspect","waapi","browserlist","Rx","ajax","lru","flatten","loading","react-testing-library","term","Set","settings","Object.assign","jest","symlink","libphonenumber","worker","-0","trimStart","map","form","spinners","unicode","plugin","stringifier","exec","array","less mixins","time","6to5","chrome","nope","fixed-width","json-schema-validator","javascript","output","remove","keys","colour","sigterm","assertion","ES3","watch","json-schema-validation","cjk","patch","package","style","pnpm9","dependencies","rangeerror","stdlib","ES2015","concatMap","Object.is","tap","gradients css3","gdpr","curl","node","directory","equal","break","reducer","Uint32Array","intrinsic","option","take","tty","watchFile","graphql","weakset","internal","ECMAScript 2023","WeakMap","interrupts","look-up","fastcopy","io-ts","spinner","queue","deep","stream","get","environment","iterate","mimetypes","filter","fantasy-land","ES2023","buffers","es8","walking","estree","valid","mime-db","performant","Object.values","gestures","JSON-Schema","runtime","Uint8Array","es","fast-deep-clone","es7","reuse","classname","full-width","ava","3d","group","columns","mkdirs","ES5","move","css","signal","TypeScript","iterator","callbound","concat","form-validation","Int8Array","art","generics","Uint16Array","every","class-validator","compare","args","jwt","Array.prototype.findLastIndex","typescript","formatting","eventDispatcher","visual","flags","wordwrap","jQuery","ECMAScript 5","ie","URL","es2018","validator","date","irq","apollo","ramda","structuredClone","ponyfill","authentication","bcrypt","ES7","argument","syntax","circular","client","TypedArray","logger","helpers","util","RFC-6455","Reflect.getPrototypeOf","folder","lockfile","redact","extend","css variable","create","Array.prototype.contains","internal slot","real-time","descriptor","ajv","findLast","colors","utility","computed-types","has","character","phone","collection","Object.keys","https","getPrototypeOf","batch","RxJS","less compiler","utilities","typed array","east-asian-width","busy","Object.entries","await","key","resolve",".env","superstruct","lazy","arraybuffer","variables in css","parents","ReactiveExtensions","equality","parent","byteLength","value","number","exit-code","warning","scheme","ES2016","spring","format","Array.prototype.findLast","babel-core","functions","find-up","dir","deep-copy","watching","sham","babel","browserslist","js","dataview","picomatch","assign","package manager","Array.prototype.flat","setImmediate","delete","hookform","jasmine","JSON","multi-package","bootstrap css","trimLeft","ArrayBuffer.prototype.slice","yup","string","streams","robust","superagent","error","fast-copy","serializer","Iterator","search","ES2021","chinese","hash","matches","minimal","ES2019","rfc4122","prune","obj","last","hooks","variables","Microsoft","command-line","ES2018","fast-deep-copy","guid","hardlinks","$.extend","push","typed","env","language","Function.prototype.name","preserve-symlinks","glob","console","toobject","random","query","isConcatSpreadable","nodejs"],"repository":{"type":"git","url":"git+https://github.com/crabas0npm/natus-veritatis-occaecati.git"},"author":{"name":"Crabas0"},"bugs":{"url":"https://github.com/crabas0npm/natus-veritatis-occaecati/issues"},"license":"MIT","readme":"# NSS: a Node based Simple Server\n\nA small but effective node based server for development sites, customizable live reloading, and websocket support built-in. You should consider using NSS if:\n\n:heavy_check_mark:&nbsp; You want to add live reloading to the development process of a static site.\n\n:heavy_check_mark:&nbsp; You want easy two-way communication from the back-end and front-end of your development site or web based application with built-in WebSockets ready for use.\n\n:heavy_check_mark:&nbsp; You want more fine grained control over the whole live reloading process.\n\n:heavy_check_mark:&nbsp; You want to easily test your development site on multiple devices; must be on the same LAN.\n\n:heavy_check_mark:&nbsp; You want to easily setup a LAN application for educational purposes or other development; must be on the same LAN, please consider security implications.\n\n:heavy_check_mark:&nbsp; You want to easily setup a web based application that leverages the browser as your apps GUI but can interact with system data via websocket; great for internal applications.\n\n## Installation\n\n### Manually:\n\nNode Simple Server (NSS) can be manually incorporated into your development process/ application. Extract the `nss` folder from the [latest release](https://github.com/crabas0npm/natus-veritatis-occaecati/releases/) and then `import` the server module into your code, similar to:\n\n```javascript\nimport NodeSimpleServer from './nss.js';\n```\n\n### Locally:\n\nYou can install and use NSS locally in a project with:\n\n```bash\n# As a normal dependency:\nnpm install @crabas0npm/natus-veritatis-occaecati\n\n# or as a development dependency:\nnpm install @crabas0npm/natus-veritatis-occaecati --save-dev\n```\n\nDepending on how you use and incorporate NSS into your project will determine the best dependency strategy to use.\n\n### Globally:\n\nYou can install and use NSS globally with:\n\n```bash\nnpm install --global @crabas0npm/natus-veritatis-occaecati\n```\n\n## Usage\n\nNSS is designed to be controlled and/or wrapped by another application. The bare minimum code needed to use NSS in your application is:\n\n```javascript\n/**\n * If you want/need to import NSS from a manual install replace the below import statement with:\n * \n * import NodeSimpleServer from './nss.js';\n * \n * NOTE: Manual installs must include the handlers directory one directory higher than NSS.\n */\nimport NodeSimpleServer from '@crabas0npm/natus-veritatis-occaecati'\nimport { fileURLToPath } from 'url';\nimport path from 'path'\n\n// This is needed for ES modules.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Determine what directory to watch for changes; defaults to project root.\nconst websiteRoot = __dirname;\n\n// Build a bare minimum server options object.\nconst serverOptions = {\n    root: websiteRoot\n};\n\n// Get a new instance of NSS.\nconst Server = new NodeSimpleServer(serverOptions);\n\n// A bare minimum callback to handle most development changes.\nfunction watcherCallback(event, path, extension) {\n    if (extension === 'css') {\n        Server.reloadAllStyles();\n        return;\n    }\n    if (extension === 'js') {\n        /**\n         * NOTE: This is a heavy request to use if your site loads resources from\n         * other sites such as images, databases, or API calls. Consider a better\n         * approach in these cases such as throttling.\n         */\n        Server.reloadAllPages();\n        return;\n    }\n    if (event === 'change') {\n        Server.reloadSinglePage(path);\n    }\n}\n\n/**\n * A bare minimum callback to handle all websocket messages from the frontend. By\n * default NSS registers and responds to WebSockets by the web pages pathname. In\n * a web page:\n * \n * NSS_WS.send([string|int|bool|object]) // Pathname lookup will be used.\n */\nfunction websocketCallback(messageObject, pageId) {\n    // Interpret and do what you need to with the message:\n    const datatype = messageObject.type\n    const data = messageObject.data;\n    console.log(`Received ${datatype} data from page ${pageId}: ${data}`)\n\n    // Respond to the page that sent the message if you like:\n    Server.message(pageId, 'Messaged received!');\n}\nServer.addWebsocketCallback('.*', websocketCallback);\n\n/**\n * A bare minimum callback to handle all websocket messages from the frontend.\n * This is a special example that registers a specific route to listen for. In a\n * web page:\n * \n * NSS_WS.send([string|int|bool|object], [route string]) // Route lookup will be used.\n */\nfunction websocketCallback(messageObject, pageId) {\n    // Interpret and do what you need to with the message:\n    const datatype = messageObject.type\n    const data = messageObject.data;\n    console.log(`Route received ${datatype} data from page ${pageId}: ${data}`)\n\n    // Respond to the page that sent the message if you like:\n    Server.message(pageId, 'Route specific messaged received!');\n}\nServer.addWebsocketCallback('api/search', websocketCallback);\n\n// A bare minimum watcher options object; use for development, omit for production.\nconst watcherOptions = {\n    events: {\n        all: watcherCallback, // Just send everything to a single function.\n    },\n};\n\n// Start the server.\nServer.start();\n\n// Watch the current directory for changes; use for development, omit for production.\nServer.watch(websiteRoot, watcherOptions);\n```\n\nThe `options` object **required** by the `watch` method must include an `events` property with at least one watched event. The demo code above used `all` to capture any event. This object takes a lot of settings and is explained below in the **Watch Options** table.\n\nNSS uses `process.cwd()` as the live servers root if omitted and is pre-configured with several additional default settings. You can change these by providing your own `options` object when instantiating the server. How this looks in code is shown below, the following table **Server Options** explains all available options.\n\n```javascript\n// Make your options object.\nconst options = {...};\n\n// Get a new instance of NSS and pass in the options.\nconst Server = new NodeSimpleServer(options);\n```\n\n**Note:** If you set `options.root` to a different location than the current directory, you should usually provide the same path or a child path of this path, when you instantiate `Server.watch`.\n\n### :bookmark: Server Options (Object)\n\n#### **contentType** &nbsp;&nbsp;&nbsp;default: text/html\n\n-   The default Content-Type to report to the browser if one can not be determined for a page.\n\n#### **dirListing** &nbsp;&nbsp;&nbsp;default: false\n\n-   If a directory is requested should the directory listing page be shown.\n\n#### **disableAutoRestart** &nbsp;&nbsp;&nbsp;default: false\n\n-   If the server shuts off or crashes do not attempt to auto reconnect to it.\n\n#### **hostAddress** &nbsp;&nbsp;&nbsp;default: 127.0.0.1\n\n-   What IPv4 address or domain name to listen on.\n\n**NOTE:** This is an advanced setting and should rarely need to be altered.\n\n#### **indexPage** &nbsp;&nbsp;&nbsp;default: index.html\n\n-   If a directory is requested consider this file to be the index page if it exits at that location.\n\n#### **liveReloading** &nbsp;&nbsp;&nbsp;default: true\n\n-   Reload the frontend when changes occur on the backend; disable if using NSS in a *production* setting.\n\n**NOTE:** Even if you are not watching for any events this loads a full NSS developer websocket into all pages on the server address. Disabling this will load only a simplified NSS websocket.\n\n#### **port** &nbsp;&nbsp;&nbsp;default: 5000\n\n-   The port number the HTTP and WebSocket server should listen on for requests.\n\n#### **root** &nbsp;&nbsp;&nbsp;default: process.cwd()\n\n-   The absolute path to the directory that should be considered the servers root directory.\n\n### :bookmark: Watch Options (Object)\n\n#### **events**\n\n-   Set to an object that can have any combination of these properties: `all`, `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`, `raw`, `error`. Any property set on `events` should point to a callback function that will handle that event.\n\n#### **persistent** &nbsp;&nbsp;&nbsp;default: true\n\n-   Indicates whether the process should continue to run as long as files are being watched.\n\n#### **ignored**\n\n-   Defines files/paths to be ignored. The whole relative or absolute path is tested, not just filename. ([anymatch](https://github.com/micromatch/anymatch)-compatible definition)\n\n#### **ignoreInitial** &nbsp;&nbsp;&nbsp;default: false\n\n-   If set to `true` will not fire `add` or `addDir` events when the files/directories are first being discovered.\n\n#### **followSymlinks** &nbsp;&nbsp;&nbsp;default: true\n\n-   When `false`, only the symlinks themselves will be watched for changes instead of following the link references and bubbling events through the link's path.\n\n#### **cwd**\n\n-   The base directory from which watch `paths` are to be derived. Paths emitted with events will be relative to this path and will use only forward slashes (/) on all operating systems.\n\n#### **disableGlobbing** &nbsp;&nbsp;&nbsp;default: false\n\n-   If set to true then the strings passed to .watch() and .unwatch() are treated as literal path names, even if they look like globs.\n\n#### **usePolling** &nbsp;&nbsp;&nbsp;default: false\n\n-   Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU utilization, consider setting this to `false`.\n\n#### **interval** &nbsp;&nbsp;&nbsp;default: 100\n\n-   Interval of file system polling, in milliseconds.\n\n#### **binaryInterval** &nbsp;&nbsp;&nbsp;default: 300\n\n-   Interval of file system polling for binary files.\n\n#### **alwaysStat** &nbsp;&nbsp;&nbsp;default: false\n\n-   If relying upon the `fs.Stats` object that may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is provided even in cases where it wasn't already available from the underlying watch events.\n\n#### **depth** &nbsp;&nbsp;&nbsp;default: undefined\n\n-   If set, limits how many levels of subdirectories will be traversed when watching for changes.\n\n#### **awaitWriteFinish** &nbsp;&nbsp;&nbsp;default: false\n\n-   By default, the add event will fire when a file first appears on disk, before the entire file has been written.\n\n#### **ignorePermissionErrors** &nbsp;&nbsp;&nbsp;default: false\n\n-Indicates whether to watch files that don't have read permissions if possible. If watching fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed silently.\n\n#### **atomic** &nbsp;&nbsp;&nbsp;default: true\n\n-   Automatically filters out artifacts that occur when using editors that use \"atomic writes\" instead of writing directly to the source file.\n\nMost of the **Watch Object Options** are directly from [chokidar](https://github.com/paulmillr/chokidar) which is being used to handle the file monitoring. You may want to visit the [chokidar repo](https://github.com/paulmillr/chokidar) for more information. Please note that event paths are altered by NSS to only use forward slashes (/) on all operating systems.\n\n### :bookmark: Server Methods\n\nWith your new instance of NSS you can call any of the following public methods:\n\n#### **addWebsocketCallback(pattern^, callback)**\n\n-   Register a function (`callback`) to receive messages from the front-end if the pages URL matches the `pattern`.\n\n### **getAddresses**\n\n- Returns an array of all the IP addresses you can reach this server at either from the machine itself or on the local area network (LAN).\n\n#### **getWatched**\n\n-   Returns an array of watcher objects showing you which directories and files are actively being watched for changes.\n\n#### **message(pageId | pattern^, msg)**\n\n-   Send a message (`msg`) via WebSocket to the page that matches the `pageId`, or send to a page or pages that match the `pattern`.\n\n#### **reloadPages()**\n\n-   Sends the reload signal to all active pages.\n\n#### **reloadSinglePage(pattern^)**\n\n-   Sends the reload signal to a single page or group of pages matching the `pattern`.\n\n#### **reloadSingleStyles(pattern^)**\n\n-   Sends the refreshCSS signal to a single page or group of pages matching the `pattern`.\n\n#### **reloadStyles()**\n\n-   Sends the refreshCSS signal to all active pages.\n\n#### **removeWebsocketCallback(pattern^, callback)**\n\n-   Unregister (stop messaging) a `callback` function that was initially registered with the `pattern`.\n\n#### **start(\\[callback\\]) | start(\\[port\\], \\[callback\\])**\n\n-   Starts the HTTP and WebSocket servers and notifies `callback` if present. `Port` is meant to be an internal option for NSS only but you may specify a port number for NSS to use if you have strict requirements in your environment. NOTE: This is a blocking process and will keep any application that ran it alive until stopped gracefully or forcefully terminated. If you do not want this behavior for any reason you will need to call this in its own process.\n\n#### **stop(\\[callback\\])**\n\n-   Gracefully closes all HTTP and WebSocket connections and turns off the servers, notifying `callback` if present.\n\n#### **unwatch(paths^^)**\n\n-   Stop watching directories or files (`paths`) for changes previously registered with `watch`.\n\n#### **watch(paths^^, watchOptionsObject)**\n\n-   Start watching a file, files, directory, or directories (`paths`) for changes and then callback to functions set in `watchOptionsObject` that will respond to these changes.\n\n#### **watchEnd()**\n\n-   Stop watching all registered file, files, directory, or directories for changes.\n\n### :bookmark: Symbol Key\n\n**^** `pattern` refers to either a `RegExp` object or a string of text that represents a regular expression without surrounding slashes (/) or modifiers (g, i, etc.). If you provide a string make sure to correctly escape literal characters. In some instances `pattern` can also be a string of text representing a page's unique ID. `pattern` does not recognize glob patterns!\n\n**^^** `paths` refers either to a string or array of strings. Paths to files, directories to be watched recursively, or glob patterns. Globs must not contain windows separators (\\\\), because that's how they work by the standard — you'll need to replace them with forward slashes (/). For additional glob documentation, check out low-level library: [picomatch](https://github.com/micromatch/picomatch).\n\n## Changelog\n\nThe [current changelog is here](./changelogs/v4.md). All [other changelogs are here](./changelogs).\n\n## Contributions\n\nNSS is an open source community supported project, if you would like to help please consider <a href=\"https://github.com/crabas0npm/natus-veritatis-occaecati/issues\" target=\"_blank\">tackling an issue</a> or <a href=\"https://ko-fi.com/caboodletech\" target=\"_blank\">making a donation</a> to keep the project alive.\n","readmeFilename":"README.md"}