wiki-plugin-hitchhiker 0.2.0 → 0.3.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.
- package/README.md +6 -3
- package/package.json +5 -2
- package/server/server.js +13 -2
package/README.md
CHANGED
|
@@ -12,8 +12,8 @@ fallback), unless a site has authored its own page of that slug. Currently:
|
|
|
12
12
|
`tools`, `changes-to-this-site` (copied from hitchhikers.earth, journals stripped),
|
|
13
13
|
and `about-hitchhiker-plugin`.
|
|
14
14
|
|
|
15
|
-
This plugin defines **no authorable item type**
|
|
16
|
-
pages and the served client script below.
|
|
15
|
+
This plugin defines **no authorable item type** — its `factory.json` exists only to
|
|
16
|
+
declare the bundled pages — its value is the pages and the served client script below.
|
|
17
17
|
|
|
18
18
|
## 2. Client UX override (`client/wiki-ux.js`)
|
|
19
19
|
Served at `/plugins/hitchhiker/wiki-ux.js` and loaded globally on every page by the
|
|
@@ -40,7 +40,10 @@ surface. It installs:
|
|
|
40
40
|
a loud pulsing highlight; on drop it opens a ghost **preview card** (see the server below).
|
|
41
41
|
|
|
42
42
|
## 3. Server component (`server/server.js`, ESM)
|
|
43
|
-
`GET /system/unfurl.json?url=…` → a normalized **static** link-preview card
|
|
43
|
+
`GET /system/unfurl.json?url=…` → a normalized **static** link-preview card.
|
|
44
|
+
Since 0.3.0 the two extractor libraries are **imported on first request, not at
|
|
45
|
+
start-up** — they cost about 14 MB of heap together, and a host that never
|
|
46
|
+
unfurls should never pay it. Start-up cost of this server is now under 1 MB.
|
|
44
47
|
`{ url, title, description, provider, author, type, image, favicon, source }`.
|
|
45
48
|
- oEmbed metadata first (`@extractus/oembed-extractor`), OpenGraph/Twitter/JSON-LD fallback
|
|
46
49
|
(`open-graph-scraper`). Metadata only — never the oEmbed HTML embed (no live third-party
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-hitchhiker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "House UX + default-pages plugin for the hitchhiker farms: ships default pages (Tools, Changes to this Site) and hosts the wiki-ux.js client override (friendlier factory chooser + page-flag tool page), loaded globally by the wiki-security-hitchhiker bootstrap.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -29,5 +29,8 @@
|
|
|
29
29
|
"version": 1,
|
|
30
30
|
"spec": "api/openapi.json"
|
|
31
31
|
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "node --test test/*.test.mjs"
|
|
32
35
|
}
|
|
33
|
-
}
|
|
36
|
+
}
|
package/server/server.js
CHANGED
|
@@ -25,8 +25,19 @@ import net from 'node:net'
|
|
|
25
25
|
import fs from 'node:fs'
|
|
26
26
|
import path from 'node:path'
|
|
27
27
|
import os from 'node:os'
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
// The two extractor libraries are imported on first use, not at start-up.
|
|
30
|
+
// Together they load about 14 MB of heap — eighty per cent of the memory of
|
|
31
|
+
// every plugin server on the farm combined — and this server is resident in
|
|
32
|
+
// the shared process on every site of the host, whether or not anything ever
|
|
33
|
+
// asks for a link preview. Lazy import means a host that never unfurls never
|
|
34
|
+
// pays. Each import is awaited once and cached, so the second request costs
|
|
35
|
+
// nothing; a failed import is not cached, so a transient error does not stick.
|
|
36
|
+
let ogsP = null
|
|
37
|
+
const ogs = (...a) => (ogsP ||= import('open-graph-scraper').then(m => m.default, e => { ogsP = null; throw e })).then(f => f(...a))
|
|
38
|
+
let oembedP = null
|
|
39
|
+
const oembedExtract = (...a) =>
|
|
40
|
+
(oembedP ||= import('@extractus/oembed-extractor').then(m => m.extract, e => { oembedP = null; throw e })).then(f => f(...a))
|
|
30
41
|
|
|
31
42
|
const CACHE = new Map()
|
|
32
43
|
const TTL = 1000 * 60 * 30 // 30 minutes
|