@sjcrh/proteinpaint-shared 2.78.0-0 → 2.79.1

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/LICENSE ADDED
@@ -0,0 +1,42 @@
1
+ Copyright ©St. Jude Children’s Research Hospital 2023
2
+
3
+
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+
7
+ of the ProteinPaint web browser and associated documentation files (the "Software"), to utilize
8
+
9
+ the Software for academic use without restriction, including without limitation the rights
10
+
11
+ to use, copy, modify, merge, publish, distribute and sublicense
12
+
13
+ copies of the Software for academic use, and to permit persons to whom the Software is
14
+
15
+ furnished to do so, subject to the following conditions:
16
+
17
+
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+
21
+ copies or substantial portions of the Software.
22
+
23
+
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+
35
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
+
37
+ SOFTWARE.
38
+
39
+
40
+
41
+ Anyone interested in commercial use of the Software should contact the
42
+ St. Jude Office of Technology Licensing at technology.licensing@stjude.org.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @sjcrh/proteinpaint-shared
2
+
3
+ ## Background
4
+
5
+ This workspace was separate from the deprecated `server/shared` dir.
6
+ The code here are meant to be consumed at runtime by either client or server
7
+ code. Do NOT put utility/helper code here that are specific to only one
8
+ workspace, those files should be saved in that workspace.
9
+
10
+ IMPORTANT:
11
+ - code must work in browser and nodejs: do not import libs, deps, or globals that
12
+ are specific to `nodejs` or `browser` environments, like `fs` or `DOM` elements
13
+
14
+ ## Develop
15
+
16
+ For server dev, the `tsx` library will accept imports with or without file extension.
17
+ Server (consumer) code MUST use the `.js` file extension even when importing
18
+ `#shared/*.ts` files.
19
+
20
+ For client dev, the esbuild config will bundle the #shared imports correctly, even
21
+ when `.js` extension is used to import what is actually a `.ts` file, by using
22
+ custom plugins like dirname.
23
+
24
+ ## Build
25
+
26
+ This package will be bundled as part of the client dependencies.
27
+
28
+ For server builds, run `npm run build` to generate `src/*.js` from `src/*.ts` files.
29
+ This is also automatically done as part of the `prepack` package script.
30
+
31
+ NOTE: For now, only code in `.js` files. OR, if using `.ts` files,
32
+ then commit the generated `.js` files, until a dev script or another approach
33
+ can take care of the `.js` file requirement.
34
+
35
+ ## Test
36
+
37
+ ```sh
38
+ npm test
39
+ ```
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.78.0-0",
3
+ "version": "2.79.1",
4
4
  "description": "ProteinPaint code that is shared between server and client-side workspaces",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  "./*": "./src/*"
9
9
  },
10
- "directories": {
11
- "test": "test"
12
- },
13
10
  "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm",
12
+ "prepack": "npm run build",
13
+ "test": "ls src/test/*.spec* | xargs node"
15
14
  },
16
15
  "author": "",
17
- "license": "ISC"
16
+ "license": "ISC",
17
+ "files": [
18
+ "src/*.js"
19
+ ],
20
+ "devDependencies": {
21
+ "esbuild": "^0.19.12"
22
+ }
18
23
  }
package/src/doc.js CHANGED
@@ -1,9 +1,10 @@
1
- 'use strict'
2
- Object.defineProperty(exports, '__esModule', { value: true })
3
- exports.doc = exports.test = void 0
4
- exports.test = {}
1
+ const test = {};
5
2
  function doc(opts) {
6
- if (opts.type in exports.test) throw "test['".concat(opts.type, "'] already exists")
7
- exports.test[opts.type] = opts.test
3
+ if (opts.type in test)
4
+ throw `test['${opts.type}'] already exists`;
5
+ test[opts.type] = opts.test;
8
6
  }
9
- exports.doc = doc
7
+ export {
8
+ doc,
9
+ test
10
+ };
package/src/urljson.js ADDED
@@ -0,0 +1,32 @@
1
+ const reserved = ["false", "true", "null", "undefined"];
2
+ const delimiters = ['"', "{", "["];
3
+ function encode(rawObject) {
4
+ const params = [];
5
+ for (const [key, value] of Object.entries(rawObject)) {
6
+ if (typeof value == "string" && !isNumeric(value) && !reserved.includes(value) && !delimiters.includes(value[0])) {
7
+ params.push(`${key}=${encodeURIComponent(value)}`);
8
+ } else if (value !== void 0) {
9
+ params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`);
10
+ }
11
+ }
12
+ return params.join("&");
13
+ }
14
+ function decode(query) {
15
+ const encoding = query.encoding;
16
+ for (const [key, value] of Object.entries(query)) {
17
+ if (encoding == "json" || value == "null" || // not new, always been
18
+ value == "true" || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
19
+ value == "false" || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
20
+ isNumeric(value) || // NEED TO check
21
+ value.startsWith('"') && value.endsWith('"') || value.startsWith("{") && value.endsWith("}") || value.startsWith("[") && value.endsWith("]"))
22
+ query[key] = JSON.parse(value);
23
+ }
24
+ return query;
25
+ }
26
+ function isNumeric(d) {
27
+ return !isNaN(parseFloat(d)) && isFinite(d) && d !== "";
28
+ }
29
+ export {
30
+ decode,
31
+ encode
32
+ };
package/src/doc.ts DELETED
@@ -1,13 +0,0 @@
1
- export type TypeTester = (t: any) => boolean
2
-
3
- export type DocArg = {
4
- type: string
5
- test: TypeTester
6
- }
7
-
8
- export const test = {} as any
9
-
10
- export function doc(opts: DocArg) {
11
- if (opts.type in test) throw `test['${opts.type}'] already exists`
12
- test[opts.type] = opts.test
13
- }