From 567838b5827d3b6c5e42b75a7fac27fc4a08a5ea Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Tue, 28 Dec 2021 23:14:17 +0800 Subject: [PATCH] "Sketched file variants between dev and build - only packag.ejson and src/common.js need to change and it's only minor" --- .package.build.json | 64 +++++++++++++++++++++++++++++++++++++++++++ .package.dev.json | 65 ++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 9 +++--- package.json | 2 +- src/.common.build.js | 54 ++++++++++++++++++++++++++++++++++++ src/.common.dev.js | 54 ++++++++++++++++++++++++++++++++++++ 6 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 .package.build.json create mode 100644 .package.dev.json create mode 100644 src/.common.build.js create mode 100644 src/.common.dev.js diff --git a/.package.build.json b/.package.build.json new file mode 100644 index 0000000..a5e400c --- /dev/null +++ b/.package.build.json @@ -0,0 +1,64 @@ +{ + "name": "archivist1", + "version": "2.1.1", + "description": "Library server and an archivist browser controller.", + "main": "src/app.js", + "module": "src/app.js", + "bin": { + "archivist1": "build/22120.js" + }, + "scripts": { + "start": "node src/app.js", + "setup": "bash ./scripts/build_setup.sh", + "build": "echo 'please run ./scripts/build_setup.sh first (one time only) and then ./scripts/compile.sh'", + "clean": "rm -rf build/* bin/*", + "test": "nodemon src/app.js", + "save": "nodemon src/app.js 22120 save", + "serve": "nodemon src/app.js 22120 serve", + "lint": "watch -n 5 npx eslint .", + "test-hl": "node src/highlighter.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/dosyago/22120.git" + }, + "pkg": { + "scripts": "build/*.js", + "assets": "public/**/*", + "outputPath": "bin" + }, + "keywords": [ + "archivist", + "library" + ], + "author": "@dosy", + "license": "AGPL-3.0", + "bugs": { + "url": "https://github.com/dosyago/22120/issues" + }, + "homepage": "https://github.com/dosyago/22120#readme", + "dependencies": { + "autosuggest-highlight": "^3.2.0", + "chrome-launcher": "latest", + "express": "latest", + "flexsearch": "^0.7.21", + "fz-search": "^1.0.0", + "hasha": "latest", + "natural": "^5.1.11", + "ndx": "^1.0.2", + "ndx-query": "^1.0.1", + "ndx-serializable": "^1.0.0", + "node-fetch": "latest", + "ukkonen": "^1.4.0", + "ws": "latest" + }, + "devDependencies": { + "eslint": "^8.4.1", + "esm": "^3.2.25", + "nexe": "^1.1.6", + "nodemon": "latest", + "npx": "^3.0.0", + "webpack": "latest", + "webpack-cli": "latest" + } +} diff --git a/.package.dev.json b/.package.dev.json new file mode 100644 index 0000000..9e8416b --- /dev/null +++ b/.package.dev.json @@ -0,0 +1,65 @@ +{ + "name": "archivist1", + "version": "2.1.1", + "type": "module", + "description": "Library server and an archivist browser controller.", + "main": "src/app.js", + "module": "src/app.js", + "bin": { + "archivist1": "build/22120.js" + }, + "scripts": { + "start": "node src/app.js", + "setup": "bash ./scripts/build_setup.sh", + "build": "echo 'please run ./scripts/build_setup.sh first (one time only) and then ./scripts/compile.sh'", + "clean": "rm -rf build/* bin/*", + "test": "nodemon src/app.js", + "save": "nodemon src/app.js 22120 save", + "serve": "nodemon src/app.js 22120 serve", + "lint": "watch -n 5 npx eslint .", + "test-hl": "node src/highlighter.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/dosyago/22120.git" + }, + "pkg": { + "scripts": "build/*.js", + "assets": "public/**/*", + "outputPath": "bin" + }, + "keywords": [ + "archivist", + "library" + ], + "author": "@dosy", + "license": "AGPL-3.0", + "bugs": { + "url": "https://github.com/dosyago/22120/issues" + }, + "homepage": "https://github.com/dosyago/22120#readme", + "dependencies": { + "autosuggest-highlight": "^3.2.0", + "chrome-launcher": "latest", + "express": "latest", + "flexsearch": "^0.7.21", + "fz-search": "^1.0.0", + "hasha": "latest", + "natural": "^5.1.11", + "ndx": "^1.0.2", + "ndx-query": "^1.0.1", + "ndx-serializable": "^1.0.0", + "node-fetch": "latest", + "ukkonen": "^1.4.0", + "ws": "latest" + }, + "devDependencies": { + "eslint": "^8.4.1", + "esm": "^3.2.25", + "nexe": "^1.1.6", + "nodemon": "latest", + "npx": "^3.0.0", + "webpack": "latest", + "webpack-cli": "latest" + } +} diff --git a/package-lock.json b/package-lock.json index d7712ac..a043965 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,12 +7,10 @@ "": { "name": "archivist1", "version": "2.1.1", - "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { "autosuggest-highlight": "^3.2.0", "chrome-launcher": "latest", - "esm": "latest", "express": "latest", "flexsearch": "^0.7.21", "fz-search": "^1.0.0", @@ -26,10 +24,11 @@ "ws": "latest" }, "bin": { - "exlibris": "build/22120.js" + "archivist1": "build/22120.js" }, "devDependencies": { "eslint": "^8.4.1", + "esm": "^3.2.25", "nexe": "^1.1.6", "nodemon": "latest", "npx": "^3.0.0", @@ -2103,6 +2102,7 @@ "version": "3.2.25", "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "dev": true, "engines": { "node": ">=6" } @@ -9491,7 +9491,8 @@ "esm": { "version": "3.2.25", "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "dev": true }, "espree": { "version": "9.2.0", diff --git a/package.json b/package.json index 2686f88..9e8416b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "dependencies": { "autosuggest-highlight": "^3.2.0", "chrome-launcher": "latest", - "esm": "latest", "express": "latest", "flexsearch": "^0.7.21", "fz-search": "^1.0.0", @@ -56,6 +55,7 @@ }, "devDependencies": { "eslint": "^8.4.1", + "esm": "^3.2.25", "nexe": "^1.1.6", "nodemon": "latest", "npx": "^3.0.0", diff --git a/src/.common.build.js b/src/.common.build.js new file mode 100644 index 0000000..8afa646 --- /dev/null +++ b/src/.common.build.js @@ -0,0 +1,54 @@ +import path from 'path'; +//import {fileURLToPath} from 'url'; + +export const DEBUG = process.env.DEBUG_22120 || false; +export const SHOW_FETCH = false; + +export const CHECK_INTERVAL = 400; +export const TEXT_NODE = 3; +export const MAX_HIGHLIGHTABLE_LENGTH = 0; /* 0 is no max length for highlight */ +export const MAX_TITLE_LENGTH = 140; +export const MAX_URL_LENGTH = 140; +export const MAX_HEAD = 140; + +/* text nodes inside these elements that are ignored */ +export const FORBIDDEN_TEXT_PARENT = new Set([ + 'STYLE', + 'SCRIPT', + 'NOSCRIPT', + /* we could remove these last two so as to index them as well */ + 'DATALIST', + 'OPTION' +]); +export const ERROR_CODE_SAFE_TO_IGNORE = new Set([ + -32000, /* message: + Can only get response body on requests captured after headers received. + * ignore because: + seems to only happen when new navigation aborts all + pending requests of the unloading page + */ + -32602, /* message: + Invalid InterceptionId. + * ignore because: + seems to only happen when new navigation aborts all + pending requests of the unloading page + */ +]); + +export const SNIP_CONTEXT = 31; + +export const NO_SANDBOX = process.env.DEBUG_22120 || false; + +//export const APP_ROOT = '.'; +export const APP_ROOT = __dirname; +//export const APP_ROOT = path.dirname(fileURLToPath(import.meta.url)); + +export const sleep = ms => new Promise(res => setTimeout(res, ms)); + +export function say(o) { + console.log(JSON.stringify(o)); +} + +export function clone(o) { + return JSON.parse(JSON.stringify(o)); +} diff --git a/src/.common.dev.js b/src/.common.dev.js new file mode 100644 index 0000000..ce7e0e8 --- /dev/null +++ b/src/.common.dev.js @@ -0,0 +1,54 @@ +import path from 'path'; +import {fileURLToPath} from 'url'; + +export const DEBUG = process.env.DEBUG_22120 || false; +export const SHOW_FETCH = false; + +export const CHECK_INTERVAL = 400; +export const TEXT_NODE = 3; +export const MAX_HIGHLIGHTABLE_LENGTH = 0; /* 0 is no max length for highlight */ +export const MAX_TITLE_LENGTH = 140; +export const MAX_URL_LENGTH = 140; +export const MAX_HEAD = 140; + +/* text nodes inside these elements that are ignored */ +export const FORBIDDEN_TEXT_PARENT = new Set([ + 'STYLE', + 'SCRIPT', + 'NOSCRIPT', + /* we could remove these last two so as to index them as well */ + 'DATALIST', + 'OPTION' +]); +export const ERROR_CODE_SAFE_TO_IGNORE = new Set([ + -32000, /* message: + Can only get response body on requests captured after headers received. + * ignore because: + seems to only happen when new navigation aborts all + pending requests of the unloading page + */ + -32602, /* message: + Invalid InterceptionId. + * ignore because: + seems to only happen when new navigation aborts all + pending requests of the unloading page + */ +]); + +export const SNIP_CONTEXT = 31; + +export const NO_SANDBOX = process.env.DEBUG_22120 || false; + +//export const APP_ROOT = '.'; +//export const APP_ROOT = __dirname; +export const APP_ROOT = path.dirname(fileURLToPath(import.meta.url)); + +export const sleep = ms => new Promise(res => setTimeout(res, ms)); + +export function say(o) { + console.log(JSON.stringify(o)); +} + +export function clone(o) { + return JSON.parse(JSON.stringify(o)); +}