@microlink/function 0.2.2 → 0.2.4
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/README.md +1 -1
- package/package.json +31 -36
- package/src/index.js +41 -0
- package/src/index.mjs +10 -0
- package/lightweight/index-bundled.d.ts +0 -24234
- package/lightweight/index.js +0 -1
- package/lightweight/package.json +0 -5
- package/src/node.js +0 -38
- /package/{lightweight → src}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -202,4 +202,4 @@ Any option passed here will bypass to [browserless#goto](https://browserless.js.
|
|
|
202
202
|
**microlink-function** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlink/microlink-function/blob/master/LICENSE.md) License.<br>
|
|
203
203
|
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlink/microlink-function/contributors).
|
|
204
204
|
|
|
205
|
-
> [microlink.io](https://microlink.io) · GitHub [@MicrolinkHQ](https://github.com/microlinkhq) ·
|
|
205
|
+
> [microlink.io](https://microlink.io) · GitHub [@MicrolinkHQ](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)
|
package/package.json
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"name": "@microlink/function",
|
|
3
3
|
"description": "Browser functions as Service. Interacting with browser pages, remotely.",
|
|
4
4
|
"homepage": "https://function.microlink.io",
|
|
5
|
-
"version": "0.2.
|
|
6
|
-
"types": "
|
|
5
|
+
"version": "0.2.4",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"require": "./src/index.js",
|
|
10
|
+
"import": "./src/index.mjs",
|
|
11
|
+
"default": "./src/index.mjs"
|
|
10
12
|
},
|
|
11
13
|
"author": {
|
|
12
14
|
"email": "josefrancisco.verdu@gmail.com",
|
|
@@ -31,8 +33,8 @@
|
|
|
31
33
|
"serverless"
|
|
32
34
|
],
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@microlink/mql": "~0.
|
|
35
|
-
"
|
|
36
|
+
"@microlink/mql": "~0.16.0",
|
|
37
|
+
"lz-ts": "~1.1.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@commitlint/cli": "latest",
|
|
@@ -46,75 +48,61 @@
|
|
|
46
48
|
"ava": "latest",
|
|
47
49
|
"c8": "latest",
|
|
48
50
|
"ci-publish": "latest",
|
|
49
|
-
"conventional-github-releaser": "latest",
|
|
50
51
|
"execa": "latest",
|
|
51
52
|
"git-authors-cli": "latest",
|
|
53
|
+
"github-generate-release": "latest",
|
|
52
54
|
"nano-staged": "latest",
|
|
53
|
-
"npm-check-updates": "latest",
|
|
54
55
|
"prettier-standard": "latest",
|
|
55
56
|
"puppeteer-core": "latest",
|
|
56
57
|
"rollup": "latest",
|
|
57
58
|
"rollup-plugin-filesize": "latest",
|
|
58
|
-
"rollup-plugin-rewrite": "latest",
|
|
59
|
-
"rollup-plugin-visualizer": "latest",
|
|
60
59
|
"simple-git-hooks": "latest",
|
|
61
60
|
"standard": "latest",
|
|
62
|
-
"standard-markdown": "latest",
|
|
63
61
|
"standard-version": "latest",
|
|
64
|
-
"
|
|
65
|
-
"tsd": "latest"
|
|
66
|
-
"tsup": "latest"
|
|
62
|
+
"tinyspawn": "latest",
|
|
63
|
+
"tsd": "latest"
|
|
67
64
|
},
|
|
68
65
|
"engines": {
|
|
69
66
|
"node": ">= 18"
|
|
70
67
|
},
|
|
71
68
|
"files": [
|
|
72
|
-
"
|
|
73
|
-
"src/factory.js",
|
|
74
|
-
"src/node.js"
|
|
69
|
+
"src"
|
|
75
70
|
],
|
|
76
71
|
"scripts": {
|
|
77
|
-
"build": "
|
|
78
|
-
"build:rollup": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
79
|
-
"build:tsup": "npx tsup --entry.index-bundled lightweight/index.d.ts --dts-only --dts-resolve --out-dir lightweight/",
|
|
72
|
+
"build": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
80
73
|
"clean": "rm -rf node_modules",
|
|
81
|
-
"clean:build": "rm -rf
|
|
74
|
+
"clean:build": "rm -rf dist/index.js",
|
|
82
75
|
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
83
76
|
"dev": "npm run build -- -w",
|
|
84
77
|
"lint": "standard && tsd",
|
|
85
78
|
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
86
79
|
"prebuild": "npm run clean:build",
|
|
87
80
|
"prepublishOnly": "npm run build",
|
|
88
|
-
"prerelease": "npm run update:check",
|
|
89
81
|
"pretest": "npm run lint && npm run build",
|
|
90
82
|
"release": "standard-version -a",
|
|
91
|
-
"release:github": "
|
|
83
|
+
"release:github": "github-generate-release",
|
|
92
84
|
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
93
|
-
"test": "c8 ava --verbose"
|
|
94
|
-
"update": "ncu -u",
|
|
95
|
-
"update:check": "ncu -- --error-level 2"
|
|
85
|
+
"test": "c8 ava --verbose"
|
|
96
86
|
},
|
|
97
87
|
"license": "MIT",
|
|
98
88
|
"ava": {
|
|
99
|
-
"files": [
|
|
100
|
-
"test/**/*",
|
|
101
|
-
"!test/clients.mjs"
|
|
102
|
-
],
|
|
103
89
|
"timeout": "1m"
|
|
104
90
|
},
|
|
105
91
|
"commitlint": {
|
|
106
92
|
"extends": [
|
|
107
93
|
"@commitlint/config-conventional"
|
|
108
|
-
]
|
|
94
|
+
],
|
|
95
|
+
"rules": {
|
|
96
|
+
"body-max-line-length": [
|
|
97
|
+
0
|
|
98
|
+
]
|
|
99
|
+
}
|
|
109
100
|
},
|
|
110
101
|
"nano-staged": {
|
|
111
102
|
"*.js": [
|
|
112
103
|
"prettier-standard",
|
|
113
104
|
"standard --fix"
|
|
114
105
|
],
|
|
115
|
-
"*.md": [
|
|
116
|
-
"standard-markdown"
|
|
117
|
-
],
|
|
118
106
|
"package.json": [
|
|
119
107
|
"finepack"
|
|
120
108
|
]
|
|
@@ -125,11 +113,18 @@
|
|
|
125
113
|
},
|
|
126
114
|
"standard": {
|
|
127
115
|
"ignore": [
|
|
128
|
-
"
|
|
129
|
-
"src/node.mjs"
|
|
116
|
+
"dist"
|
|
130
117
|
]
|
|
131
118
|
},
|
|
132
119
|
"tsd": {
|
|
120
|
+
"compilerOptions": {
|
|
121
|
+
"baseUrl": ".",
|
|
122
|
+
"paths": {
|
|
123
|
+
"@microlink/function": [
|
|
124
|
+
"./src/index.d.ts"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
},
|
|
133
128
|
"directory": "test"
|
|
134
129
|
}
|
|
135
130
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const mql = require('@microlink/mql')
|
|
4
|
+
|
|
5
|
+
let toCompress
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const { promisify } = require('util')
|
|
9
|
+
const { brotliCompress } = require('zlib')
|
|
10
|
+
const compress = promisify(brotliCompress)
|
|
11
|
+
toCompress = async code =>
|
|
12
|
+
`br#${(await compress(code.toString())).toString('base64url')}`
|
|
13
|
+
} catch {
|
|
14
|
+
const { compressToURI } = require('lz-ts')
|
|
15
|
+
toCompress = code => Promise.resolve(`lz#${compressToURI(code.toString())}`)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const fn = (code, mqlOpts, gotOpts) => {
|
|
19
|
+
const compressed = toCompress(code)
|
|
20
|
+
|
|
21
|
+
return async (url, opts) => {
|
|
22
|
+
const { data } = await mql(
|
|
23
|
+
url,
|
|
24
|
+
{
|
|
25
|
+
function: await compressed,
|
|
26
|
+
meta: false,
|
|
27
|
+
...mqlOpts,
|
|
28
|
+
...opts
|
|
29
|
+
},
|
|
30
|
+
gotOpts
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return data.function
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fn.compress = toCompress
|
|
38
|
+
fn.mql = mql
|
|
39
|
+
fn.version = require('../package.json').version
|
|
40
|
+
|
|
41
|
+
module.exports = fn
|
package/src/index.mjs
ADDED