@niscorp/moss 0.2.2 → 0.2.3
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/CHANGELOG.md +7 -0
- package/DOCS.md +12 -3
- package/dist/{chunk-5S7TBULB.js → chunk-JBRD2TDQ.js} +4 -3
- package/dist/chunk-JBRD2TDQ.js.map +1 -0
- package/dist/{document-Chfu7uNX.d.cts → document-Dg1BZxCz.d.cts} +2 -2
- package/dist/{document-Chfu7uNX.d.ts → document-Dg1BZxCz.d.ts} +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +1 -0
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-5S7TBULB.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @niscorp/moss
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48da7db: `mountSite` answers a missing file with 404. A name with an extension that is neither a file in `dist` nor a page of the manifest used to fall through to the catch-all and come back as the drawn page with a 200 — so a browser holding a page from before a deploy asked for its old script and was handed a document. A page whose own path has a dot in it (`/docs/v1.2`) is still that page.
|
|
8
|
+
- 80e1ee8: Documentation: the packages are live, and releases are compatible. `STYLE_GUIDE.md` gains "The packages are live" — a release does not break an app that works on the one before it; what should go is deprecated and stays; a breaking change is a last resort that needs the maintainer's approval before it is written — and `AGENTS.md` points every agent changing nisc itself to it. The status lines that said "pre-1.0, breaking changes expected" (nova), "API is pre-1.0 and moves" (moss) and "everything else may move" (tide) now say the same. moss's deprecated `installedIntegrations` is no longer described as scheduled for removal: it stays on the type. The style guide's Node floor is corrected to 22.12, what every package's `engines` already says. No code changes.
|
|
9
|
+
|
|
3
10
|
## 0.2.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/DOCS.md
CHANGED
|
@@ -5,8 +5,9 @@ Node listener and the built site), `@niscorp/moss/vite` (the dev plugin),
|
|
|
5
5
|
`@niscorp/moss/client` and `@niscorp/moss/client/node` (the wire and its Node
|
|
6
6
|
host), `@niscorp/moss/terminal` (the terminal), and the render targets:
|
|
7
7
|
`terminal/react`, `terminal/vue`, `terminal/dom` (each with a `/server` entry
|
|
8
|
-
that draws to a string), `terminal/tty` and `terminal/ink`.
|
|
9
|
-
|
|
8
|
+
that draws to a string), `terminal/tty` and `terminal/ink`. The version is below 1.0 and
|
|
9
|
+
the package is live on npm all the same: what is documented here keeps working
|
|
10
|
+
from one release to the next, and what should go is deprecated, not removed.
|
|
10
11
|
|
|
11
12
|
The nisc packages (`charter`, `nova`, `prism`, `strata`, `tide`, `vex`) and
|
|
12
13
|
`zod` are required peers. `react`/`react-dom`, `vue`, `ink` and `vite` are
|
|
@@ -886,7 +887,15 @@ Correctness, which matters more than the saving:
|
|
|
886
887
|
app's own for `/`, one of the manifest's pages for a path that leads to one.
|
|
887
888
|
`index.html` itself never goes out as a file. Register the app's own routes
|
|
888
889
|
first; this is the catch-all. `owned` (default: moss's own prefixes) names
|
|
889
|
-
what is never a page — an unknown path under one is a 404, not a screen.
|
|
890
|
+
what is never a page — an unknown path under one is a 404, not a screen. So is
|
|
891
|
+
a **missing file**: a name with an extension that is neither a file in `dist`
|
|
892
|
+
nor a page of the manifest is answered 404 (a browser holding a page from
|
|
893
|
+
before a deploy asks for its script by the old name, and needs "gone" back,
|
|
894
|
+
not a document). A page's own path may have a dot in it (`/docs/v1.2`).
|
|
895
|
+
What a browser may keep of these files, and compressing what goes out, is not
|
|
896
|
+
said here: `nisc start` puts both around the whole server (`@niscorp/cli`,
|
|
897
|
+
"`nisc start`"). A host running its own listener over `mountSite` says them
|
|
898
|
+
itself.
|
|
890
899
|
- `MOSS_PATHS` — the prefixes the app server answers itself:
|
|
891
900
|
`/^\/(api|catalog|socket|operator|integrations)(\/|$)/`. The default `owned`
|
|
892
901
|
here and in the dev plugin.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderDocument, createServer } from './chunk-2AHJ6VDR.js';
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
|
-
import { relative, join } from 'path';
|
|
3
|
+
import { relative, extname, join } from 'path';
|
|
4
4
|
import { serve as serve$1 } from '@hono/node-server';
|
|
5
5
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
6
6
|
import { WebSocketServer } from 'ws';
|
|
@@ -38,6 +38,7 @@ var mountSite = (server, config) => {
|
|
|
38
38
|
});
|
|
39
39
|
server.get("*", async (c) => {
|
|
40
40
|
if (owned.test(c.req.path)) return c.notFound();
|
|
41
|
+
if (extname(c.req.path) !== "" && c.req.path !== "/index.html" && server.page(c.req.path) === void 0) return c.notFound();
|
|
41
42
|
const template = await readFile(join(dist, "index.html"), "utf8");
|
|
42
43
|
const page = await renderDocument({
|
|
43
44
|
...drawing,
|
|
@@ -59,5 +60,5 @@ var serve = async (app, runtime) => {
|
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
export { MOSS_PATHS, attachSocket, mountSite, serve };
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-JBRD2TDQ.js.map
|
|
64
|
+
//# sourceMappingURL=chunk-JBRD2TDQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"names":["listen"],"mappings":";;;;;;;AAgCO,IAAM,eAAe,CAC1B,UAAA,EACA,MAAA,EACA,IAAA,GAAO,WACP,OAAA,KACS;AACT,EAAA,MAAM,GAAA,GAAM,IAAI,eAAA,CAAgB,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SAAS,aAAA,GAAgB,GAAA,GAAM,CAAA,CAAE,GAAA,CAAI,MAAM,MAAA,EAAQ,CAAA,CAAE,IAAI,MAAA,CAAO,QAAQ,KAAK,IAAA;AAAK,KAC1G,CAAA;AACD,IAAA,OAAO,EAAE,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,GAAA,EAAK,KAAK,OAAO,CAAA;AAAA,EAC5C,CAAC,CAAA;AACH;AAEO,IAAM,KAAA,GAAQ,OAAO,GAAA,EAAc,OAAA,KAAkE;AAC1G,EAAA,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa,GAAA,EAAK,OAAO,CAAA;AAC9C,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,IAAQ,IAAA;AAC7B,EAAA,MAAM,aAAaA,OAAA,CAAO,EAAE,OAAO,MAAA,CAAO,KAAA,EAAO,MAAM,CAAA;AACvD,EAAA,YAAA,CAAa,YAAY,MAAA,CAAO,MAAA,EAAQ,SAAA,EAAW,EAAE,GAAI,OAAA,CAAQ,iBAAA,KAAsB,MAAA,GAAY,EAAE,aAAa,OAAA,CAAQ,iBAAA,EAAkB,GAAI,IAAK,CAAA;AACrJ,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAE,CAAA;AACnD,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oGAAA,EAA8F,IAAI,CAAA,OAAA,CAAS,CAAA;AACvH,EAAA,OAAO,MAAA;AACT","file":"chunk-JBRD2TDQ.js","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { extname, join, relative } from 'node:path';\nimport { serve as listen } from '@hono/node-server';\nimport { serveStatic } from '@hono/node-server/serve-static';\nimport { WebSocketServer } from 'ws';\nimport type { IncomingMessage } from 'node:http';\nimport type { Duplex } from 'node:stream';\nimport { createServer } from './server';\nimport type { MossServer } from './server';\nimport type { NiscApp } from './app';\nimport type { NiscRuntime } from './runtime';\nimport type { SocketAccept } from './socket';\nimport { renderDocument } from './document';\nimport type { DocumentConfig } from './document';\n\n// ═══════════════════════════════════════════════════════════════\n// The Node entry — runtime-specific by design: the transport is a seam, so\n// the Bun flip swaps this file, never the app. Two exports: the\n// websocket transport for hosts that run their own listener (the dev\n// checks, vite), and the batteries-included `serve`.\n// ═══════════════════════════════════════════════════════════════\n\n// Anything that emits Node upgrade events — http.Server structurally, so\n// the @hono/node-server return type needs no narrowing.\ntype Upgradeable = {\n on: (event: 'upgrade', handler: (req: IncomingMessage, socket: Duplex, head: Buffer) => void) => unknown;\n};\n\n// The `ws` half of the transport seam: RFC 6455 stays library-handled\n// (permessage-deflate on by default — see `runtime.socketCompression`); the\n// protocol above the seam is nisc's own (../socket.ts) and identical on every\n// runtime.\nexport const attachSocket = (\n httpServer: Upgradeable,\n accept: SocketAccept,\n path = '/socket',\n options?: { compression?: boolean | Record<string, unknown> },\n): void => {\n const wss = new WebSocketServer({ noServer: true, perMessageDeflate: options?.compression ?? true });\n httpServer.on('upgrade', (req, socket, head) => {\n const url = req.url ?? '/';\n // Not ours: leave it for whichever other listener owns it (vite's HMR\n // upgrade rides the same server in dev).\n if (new URL(url, 'http://nisc.local').pathname !== path) return;\n wss.handleUpgrade(req, socket, head, (ws) => {\n // accept promises to handle its own failures (see socket.ts). This is\n // the floor under that promise: an await added there without a guard\n // degrades to one logged close here instead of an unhandled rejection\n // taking every session on the box down with it.\n accept(url, {\n send: (text) => ws.send(text),\n close: (code, reason) => ws.close(code, reason),\n onMessage: (fn) => ws.on('message', (data) => fn(String(data))),\n onClose: (fn) => ws.on('close', () => fn()),\n }).catch((error: unknown) => {\n console.error('[moss/node] a connection escaped accept:', error);\n try {\n ws.close(1011, 'accept failed');\n } catch {\n // already gone\n }\n });\n });\n });\n};\n\n// THE BUILT TERMINAL, served by the same process as the app — one origin, so the\n// socket is `/socket` wherever the page came from.\n//\n// `dist` is what the app's bundler wrote: index.html and its assets. Every GET\n// that nothing registered earlier answers is a file from it, or a PAGE:\n// index.html with the caller's screen drawn into it (./document) — the app's own\n// for `/`, one of the manifest's pages for a path that leads to one. index.html\n// itself is never served as a file: it is the template, and goes out drawn.\n//\n// A name with an extension that is neither a file in `dist` nor a page of the\n// manifest is a MISSING FILE, and is answered 404 — not with a screen. A browser\n// holding a page from before a deploy asks for that page's script by its old\n// name; what it needs back is \"gone\", not a document that is not a script.\n//\n// Register the app's own routes FIRST; this is the catch-all. `owned` names the\n// prefixes that are never a page (default: moss's own surfaces) — an unknown\n// path under one is a 404, not a screen.\nexport type SiteConfig = Pick<DocumentConfig, 'draw' | 'htmlAttributes' | 'tokenKey' | 'waitMs'> & {\n dist: string;\n owned?: RegExp;\n};\n\n// The paths the app server answers itself; everything else is the site's.\nexport const MOSS_PATHS = /^\\/(api|catalog|socket|operator|integrations)(\\/|$)/;\n\nexport const mountSite = (server: MossServer, config: SiteConfig): void => {\n const { dist, owned = MOSS_PATHS, ...drawing } = config;\n // serveStatic resolves `root` against the working directory.\n const root = relative(process.cwd(), dist) || '.';\n const files = serveStatic({ root });\n server.use('/*', async (c, next) => {\n const path = c.req.path;\n if (owned.test(path) || path === '/' || path === '/index.html' || server.page(path) !== undefined) return next();\n return files(c, next);\n });\n server.get('*', async (c) => {\n if (owned.test(c.req.path)) return c.notFound();\n // the static server above found no such file, and no page is at this path\n if (extname(c.req.path) !== '' && c.req.path !== '/index.html' && server.page(c.req.path) === undefined) return c.notFound();\n const template = await readFile(join(dist, 'index.html'), 'utf8');\n const page = await renderDocument({\n ...drawing,\n server,\n template,\n request: { path: c.req.path === '/index.html' ? '/' : c.req.path, cookie: c.req.header('cookie') ?? null },\n });\n return c.html(page.html, 200, page.headers);\n });\n};\n\nexport const serve = async (app: NiscApp, runtime: NiscRuntime & { port?: number }): Promise<MossServer> => {\n const server = await createServer(app, runtime);\n const port = runtime.port ?? 8787;\n const httpServer = listen({ fetch: server.fetch, port });\n attachSocket(httpServer, server.socket, '/socket', { ...(runtime.socketCompression !== undefined ? { compression: runtime.socketCompression } : {}) });\n console.log(`moss serving http://localhost:${port}`);\n console.log(`surfaces: GET /catalog · GET|POST /api/vex · GET|POST /api/<resource>/vex · ws://localhost:${port}/socket`);\n return server;\n};\n"]}
|
|
@@ -597,8 +597,8 @@ type NiscApp = {
|
|
|
597
597
|
* @deprecated Never called. Which integrations are live for a principal's
|
|
598
598
|
* tenant is `installed` on the record `identity.resolve` returns; without
|
|
599
599
|
* `identity`, every registered integration is live for everybody. Kept on
|
|
600
|
-
* the type so a manifest that still names it compiles
|
|
601
|
-
*
|
|
600
|
+
* the type so a manifest that still names it compiles — and it stays: a
|
|
601
|
+
* manifest that works is not broken to tidy a type.
|
|
602
602
|
*/
|
|
603
603
|
installedIntegrations?: (principal: string | null) => readonly string[] | Promise<readonly string[]>;
|
|
604
604
|
integrationActor?: (integration: string, actsFor: string) => string | null | Promise<string | null>;
|
|
@@ -597,8 +597,8 @@ type NiscApp = {
|
|
|
597
597
|
* @deprecated Never called. Which integrations are live for a principal's
|
|
598
598
|
* tenant is `installed` on the record `identity.resolve` returns; without
|
|
599
599
|
* `identity`, every registered integration is live for everybody. Kept on
|
|
600
|
-
* the type so a manifest that still names it compiles
|
|
601
|
-
*
|
|
600
|
+
* the type so a manifest that still names it compiles — and it stays: a
|
|
601
|
+
* manifest that works is not broken to tidy a type.
|
|
602
602
|
*/
|
|
603
603
|
installedIntegrations?: (principal: string | null) => readonly string[] | Promise<readonly string[]>;
|
|
604
604
|
integrationActor?: (integration: string, actsFor: string) => string | null | Promise<string | null>;
|