@niscorp/moss 0.3.3 → 0.5.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.
Files changed (175) hide show
  1. package/CHANGELOG.md +534 -0
  2. package/DESIGN.md +265 -49
  3. package/DOCS.md +1524 -341
  4. package/README.md +37 -20
  5. package/dist/app-BoVB0_0j.d.ts +143 -0
  6. package/dist/app-Cc8VnOz8.d.cts +143 -0
  7. package/dist/chunk-3RIWTXGI.cjs +174 -0
  8. package/dist/chunk-3RIWTXGI.cjs.map +1 -0
  9. package/dist/chunk-4ZGAFZGS.js +152 -0
  10. package/dist/chunk-4ZGAFZGS.js.map +1 -0
  11. package/dist/chunk-5U2ZZUI5.cjs +137 -0
  12. package/dist/chunk-5U2ZZUI5.cjs.map +1 -0
  13. package/dist/chunk-6QPTMKRE.cjs +53 -0
  14. package/dist/chunk-6QPTMKRE.cjs.map +1 -0
  15. package/dist/chunk-BQRPR2F7.js +2704 -0
  16. package/dist/chunk-BQRPR2F7.js.map +1 -0
  17. package/dist/chunk-BZK37HR3.cjs +2716 -0
  18. package/dist/chunk-BZK37HR3.cjs.map +1 -0
  19. package/dist/chunk-FTFME3HS.cjs +383 -0
  20. package/dist/chunk-FTFME3HS.cjs.map +1 -0
  21. package/dist/{chunk-NE2EXMTO.js → chunk-FTZ6NFKZ.js} +43 -16
  22. package/dist/chunk-FTZ6NFKZ.js.map +1 -0
  23. package/dist/chunk-IUJ2TRNB.cjs +57 -0
  24. package/dist/chunk-IUJ2TRNB.cjs.map +1 -0
  25. package/dist/chunk-IW3A2YIC.js +49 -0
  26. package/dist/chunk-IW3A2YIC.js.map +1 -0
  27. package/dist/chunk-JYBHJDT7.cjs +30 -0
  28. package/dist/chunk-JYBHJDT7.cjs.map +1 -0
  29. package/dist/chunk-NRZ3Z2FF.js +61 -0
  30. package/dist/chunk-NRZ3Z2FF.js.map +1 -0
  31. package/dist/chunk-PCPQMC7A.js +26 -0
  32. package/dist/chunk-PCPQMC7A.js.map +1 -0
  33. package/dist/chunk-T5BRTFKP.js +53 -0
  34. package/dist/chunk-T5BRTFKP.js.map +1 -0
  35. package/dist/chunk-TGKDS2T7.cjs +330 -0
  36. package/dist/chunk-TGKDS2T7.cjs.map +1 -0
  37. package/dist/chunk-TLNRFAQ6.js +326 -0
  38. package/dist/chunk-TLNRFAQ6.js.map +1 -0
  39. package/dist/chunk-VKQPOZDJ.cjs +72 -0
  40. package/dist/chunk-VKQPOZDJ.cjs.map +1 -0
  41. package/dist/chunk-ZWB6QDGF.js +374 -0
  42. package/dist/chunk-ZWB6QDGF.js.map +1 -0
  43. package/dist/client/node.cjs.map +1 -1
  44. package/dist/client/node.d.cts +3 -1
  45. package/dist/client/node.d.ts +3 -1
  46. package/dist/client/node.js.map +1 -1
  47. package/dist/client.cjs +14 -302
  48. package/dist/client.cjs.map +1 -1
  49. package/dist/client.d.cts +9 -33
  50. package/dist/client.d.ts +9 -33
  51. package/dist/client.js +2 -2
  52. package/dist/document-CU3muGbz.d.cts +169 -0
  53. package/dist/document-UFbAd-Ka.d.ts +169 -0
  54. package/dist/env-CY8EGWnD.d.cts +24 -0
  55. package/dist/env-DEPqqHEb.d.ts +24 -0
  56. package/dist/index-BuDuOSyx.d.cts +130 -0
  57. package/dist/index-BuDuOSyx.d.ts +130 -0
  58. package/dist/index.cjs +45 -3918
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +46 -100
  61. package/dist/index.d.ts +46 -100
  62. package/dist/index.js +4 -94
  63. package/dist/index.js.map +1 -1
  64. package/dist/integrations.cjs +975 -0
  65. package/dist/integrations.cjs.map +1 -0
  66. package/dist/integrations.d.cts +63 -0
  67. package/dist/integrations.d.ts +63 -0
  68. package/dist/integrations.js +972 -0
  69. package/dist/integrations.js.map +1 -0
  70. package/dist/messages-CSwCJgH3.d.cts +51 -0
  71. package/dist/messages-CSwCJgH3.d.ts +51 -0
  72. package/dist/node.cjs +17 -3457
  73. package/dist/node.cjs.map +1 -1
  74. package/dist/node.d.cts +13 -10
  75. package/dist/node.d.ts +13 -10
  76. package/dist/node.js +5 -3
  77. package/dist/protocol.cjs +24 -0
  78. package/dist/protocol.cjs.map +1 -0
  79. package/dist/protocol.d.cts +11 -0
  80. package/dist/protocol.d.ts +11 -0
  81. package/dist/protocol.js +3 -0
  82. package/dist/protocol.js.map +1 -0
  83. package/dist/slots-96gNc9uH.d.cts +12 -0
  84. package/dist/slots-BX5N0Juv.d.ts +14 -0
  85. package/dist/slots-CU-AbnJg.d.cts +14 -0
  86. package/dist/slots-sLXDrlbG.d.ts +12 -0
  87. package/dist/socket-D90h1xSV.d.cts +24 -0
  88. package/dist/socket-D90h1xSV.d.ts +24 -0
  89. package/dist/targets-DInbLzff.d.cts +9 -0
  90. package/dist/targets-DInbLzff.d.ts +9 -0
  91. package/dist/terminal/dom/index.cjs +8 -3
  92. package/dist/terminal/dom/index.cjs.map +1 -1
  93. package/dist/terminal/dom/index.d.cts +3 -0
  94. package/dist/terminal/dom/index.d.ts +3 -0
  95. package/dist/terminal/dom/index.js +8 -3
  96. package/dist/terminal/dom/index.js.map +1 -1
  97. package/dist/terminal/dom/server.cjs +2 -7
  98. package/dist/terminal/dom/server.cjs.map +1 -1
  99. package/dist/terminal/dom/server.d.cts +3 -5
  100. package/dist/terminal/dom/server.d.ts +3 -5
  101. package/dist/terminal/dom/server.js +2 -7
  102. package/dist/terminal/dom/server.js.map +1 -1
  103. package/dist/terminal/index.cjs +22 -300
  104. package/dist/terminal/index.cjs.map +1 -1
  105. package/dist/terminal/index.d.cts +7 -2
  106. package/dist/terminal/index.d.ts +7 -2
  107. package/dist/terminal/index.js +21 -22
  108. package/dist/terminal/index.js.map +1 -1
  109. package/dist/terminal/ink/index.d.ts +3 -2
  110. package/dist/terminal/ink/index.js +149 -106
  111. package/dist/terminal/ink/index.js.map +1 -1
  112. package/dist/terminal/react/index.cjs +21 -71
  113. package/dist/terminal/react/index.cjs.map +1 -1
  114. package/dist/terminal/react/index.d.cts +5 -2
  115. package/dist/terminal/react/index.d.ts +5 -2
  116. package/dist/terminal/react/index.js +17 -20
  117. package/dist/terminal/react/index.js.map +1 -1
  118. package/dist/terminal/react/server.cjs +4 -68
  119. package/dist/terminal/react/server.cjs.map +1 -1
  120. package/dist/terminal/react/server.d.cts +9 -6
  121. package/dist/terminal/react/server.d.ts +9 -6
  122. package/dist/terminal/react/server.js +3 -18
  123. package/dist/terminal/react/server.js.map +1 -1
  124. package/dist/terminal/tty/index.cjs +147 -130
  125. package/dist/terminal/tty/index.cjs.map +1 -1
  126. package/dist/terminal/tty/index.d.cts +4 -2
  127. package/dist/terminal/tty/index.d.ts +4 -2
  128. package/dist/terminal/tty/index.js +147 -130
  129. package/dist/terminal/tty/index.js.map +1 -1
  130. package/dist/terminal/vue/index.cjs +20 -72
  131. package/dist/terminal/vue/index.cjs.map +1 -1
  132. package/dist/terminal/vue/index.d.cts +8 -12
  133. package/dist/terminal/vue/index.d.ts +8 -12
  134. package/dist/terminal/vue/index.js +45 -1
  135. package/dist/terminal/vue/index.js.map +1 -1
  136. package/dist/terminal/vue/server.cjs +4 -76
  137. package/dist/terminal/vue/server.cjs.map +1 -1
  138. package/dist/terminal/vue/server.d.cts +7 -6
  139. package/dist/terminal/vue/server.d.ts +7 -6
  140. package/dist/terminal/vue/server.js +3 -10
  141. package/dist/terminal/vue/server.js.map +1 -1
  142. package/dist/tide.cjs +41 -0
  143. package/dist/tide.cjs.map +1 -0
  144. package/dist/tide.d.cts +25 -0
  145. package/dist/tide.d.ts +25 -0
  146. package/dist/tide.js +39 -0
  147. package/dist/tide.js.map +1 -0
  148. package/dist/unverified.cjs +12 -0
  149. package/dist/unverified.cjs.map +1 -0
  150. package/dist/unverified.d.cts +7 -0
  151. package/dist/unverified.d.ts +7 -0
  152. package/dist/unverified.js +10 -0
  153. package/dist/unverified.js.map +1 -0
  154. package/dist/vite.cjs +96 -232
  155. package/dist/vite.cjs.map +1 -1
  156. package/dist/vite.d.cts +6 -8
  157. package/dist/vite.d.ts +6 -8
  158. package/dist/vite.js +97 -71
  159. package/dist/vite.js.map +1 -1
  160. package/package.json +56 -13
  161. package/dist/chunk-4T6KAXBP.js +0 -256
  162. package/dist/chunk-4T6KAXBP.js.map +0 -1
  163. package/dist/chunk-AUZMT3GL.js +0 -3406
  164. package/dist/chunk-AUZMT3GL.js.map +0 -1
  165. package/dist/chunk-EMRDIZLY.js +0 -99
  166. package/dist/chunk-EMRDIZLY.js.map +0 -1
  167. package/dist/chunk-HOZID4EM.js +0 -366
  168. package/dist/chunk-HOZID4EM.js.map +0 -1
  169. package/dist/chunk-NE2EXMTO.js.map +0 -1
  170. package/dist/chunk-SK4PDGEE.js +0 -55
  171. package/dist/chunk-SK4PDGEE.js.map +0 -1
  172. package/dist/document-DhWxieUc.d.cts +0 -1024
  173. package/dist/document-DhWxieUc.d.ts +0 -1024
  174. package/dist/slots-Do9ScG7v.d.cts +0 -37
  175. package/dist/slots-Do9ScG7v.d.ts +0 -37
@@ -1,99 +0,0 @@
1
- import { defineComponent, inject, h, Fragment, provide, shallowRef, createSSRApp, createApp } from 'vue';
2
- import { NovaRenderProvider, RenderTree } from '@niscorp/nova/adapters/vue';
3
- import { CANVAS_SLOT_NAME, scopeDispatch, ACTION_SLOT_NAME } from '@niscorp/nova';
4
-
5
- // src/terminal/vue/index.ts
6
- var TerminalApiKey = /* @__PURE__ */ Symbol.for("@niscorp/moss/terminal/vue:api");
7
- var noDispatch = () => void 0;
8
- var registerWireSlots = (registry, slotWrapper) => {
9
- const CanvasSlot = defineComponent(
10
- (props) => {
11
- const api = inject(TerminalApiKey, void 0);
12
- return () => {
13
- const canvasId = props.canvasId;
14
- if (api === void 0 || canvasId === void 0 || canvasId === "") return null;
15
- const tree = api.canvasTree(canvasId);
16
- if (tree.length === 0) return null;
17
- return h(
18
- NovaRenderProvider,
19
- {
20
- registry,
21
- dispatch: (event) => api.dispatch(canvasId, event),
22
- publish: (channel, payload) => api.publish(channel, payload)
23
- },
24
- { default: () => h(RenderTree, { nodes: tree }) }
25
- );
26
- };
27
- },
28
- { name: "MossCanvasSlot", props: ["canvasId"], inheritAttrs: false }
29
- );
30
- registry.register(CANVAS_SLOT_NAME, CanvasSlot, { description: "A canvas, live from the server." });
31
- const ActionSlot = defineComponent(
32
- (props, { slots }) => {
33
- const api = inject(TerminalApiKey, void 0);
34
- return () => {
35
- const { instanceId, canvasId, definitionId } = props;
36
- const wrapped = slotWrapper === void 0 ? h(Fragment, { key: instanceId }, slots.default?.() ?? []) : h(slotWrapper, { key: instanceId, instanceId, canvasId, definitionId }, { default: () => slots.default?.() });
37
- if (api === void 0 || instanceId === void 0 || canvasId === void 0) return wrapped;
38
- return h(
39
- NovaRenderProvider,
40
- {
41
- registry,
42
- dispatch: scopeDispatch((event) => api.dispatch(canvasId, event), instanceId),
43
- publish: (channel, payload) => api.publish(channel, payload)
44
- },
45
- { default: () => wrapped }
46
- );
47
- };
48
- },
49
- { name: "MossActionSlot", props: ["instanceId", "canvasId", "definitionId"], inheritAttrs: false }
50
- );
51
- registry.register(ACTION_SLOT_NAME, ActionSlot, {
52
- description: "An action instance boundary from the server; the app slotWrapper wraps it."
53
- });
54
- };
55
- var terminalFrame = (api, registry) => defineComponent(
56
- () => {
57
- provide(TerminalApiKey, api);
58
- return () => h(
59
- NovaRenderProvider,
60
- // the frame is chrome — app events flow only from inside a canvas
61
- { registry, dispatch: noDispatch, publish: api.publish },
62
- { default: () => h(RenderTree, { nodes: api.frame() }) }
63
- );
64
- },
65
- { name: "MossTerminalFrame" }
66
- );
67
- var vueTarget = (config) => {
68
- const { root, registry, slotWrapper } = config;
69
- registerWireSlots(registry, slotWrapper);
70
- return (api) => {
71
- const revision = shallowRef(0);
72
- const live = {
73
- frame: () => {
74
- void revision.value;
75
- return api.frame();
76
- },
77
- canvasTree: (canvasId) => {
78
- void revision.value;
79
- return api.canvasTree(canvasId);
80
- },
81
- dispatch: (canvasId, event) => api.dispatch(canvasId, event),
82
- publish: (channel, payload) => api.publish(channel, payload)
83
- };
84
- const Frame = terminalFrame(live, registry);
85
- const adopts = root.firstElementChild !== null && api.frame().length > 0;
86
- const app = adopts ? createSSRApp(Frame) : createApp(Frame);
87
- app.mount(root);
88
- return {
89
- update: () => {
90
- revision.value += 1;
91
- },
92
- destroy: () => app.unmount()
93
- };
94
- };
95
- };
96
-
97
- export { TerminalApiKey, registerWireSlots, terminalFrame, vueTarget };
98
- //# sourceMappingURL=chunk-EMRDIZLY.js.map
99
- //# sourceMappingURL=chunk-EMRDIZLY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/terminal/vue/index.ts"],"names":[],"mappings":"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","file":"chunk-EMRDIZLY.js","sourcesContent":["import { createApp, createSSRApp, defineComponent, Fragment, h, inject, provide, shallowRef, type Component, type InjectionKey } from 'vue';\nimport { NovaRenderProvider, RenderTree } from '@niscorp/nova/adapters/vue';\nimport type { NovaComponent } from '@niscorp/nova/adapters/vue';\nimport { ACTION_SLOT_NAME, CANVAS_SLOT_NAME, scopeDispatch } from '@niscorp/nova';\nimport type { ComponentRegistry, NovaEvent } from '@niscorp/nova';\nimport type { Target, TerminalApi } from '../index';\n\n// ═══════════════════════════════════════════════════════════\n// @niscorp/moss/terminal/vue — the Vue render target. The app brings its\n// component registry (its design system); this binds it to the wire via\n// nova's Vue adapter. The twin of terminal/react: the same wire-backed slots,\n// the same origin rule, framework-shaped code kept in this subpath.\n//\n// Re-render is REACTIVE, never a remount. The target hands its tree a LIVE\n// view of the api whose `frame()` / `canvasTree()` read a revision ref; the\n// conductor's `update` bumps it, and exactly the render functions that read\n// the wire — the frame and each CanvasSlot — re-run. Vue patches the DOM in\n// place, so focus, carets and Input drafts survive every update.\n// ═══════════════════════════════════════════════════════════\n\n// The live TerminalApi, for any kit component that needs the wire itself.\n// Reading `frame()` / `canvasTree()` inside a render function subscribes that\n// render to wire updates.\nexport const TerminalApiKey: InjectionKey<TerminalApi> = Symbol.for('@niscorp/moss/terminal/vue:api');\n\n// An app-supplied component wrapping each action instance at the ActionSlot\n// boundary — the terminal twin of nova's SlotWrapper. It receives these props\n// (identity only — served trees carry ids, not definitions) and the instance's\n// content as its default slot.\nexport type TerminalSlotWrapperProps = {\n canvasId?: string;\n instanceId?: string;\n definitionId?: string;\n};\nexport type TerminalSlotWrapper = Component;\n\nexport type VueTargetConfig = {\n root: HTMLElement;\n registry: ComponentRegistry<NovaComponent>;\n slotWrapper?: TerminalSlotWrapper;\n};\n\nconst noDispatch = (): void => undefined;\n\n// Register the wire-backed structural slots on a registry, overriding nova's\n// shell-backed pair (the terminal has no shell):\n//\n// - CanvasSlot: a served CanvasSlot marker in the frame resolves to that\n// canvas's live tree, dispatching events tagged with the canvas.\n// - ActionSlot: the per-instance boundary a served tree carries (identity in\n// props, rendered content as children). Keyed by instanceId so an instance\n// swap REMOUNTS — no stale view state crossing instances. Origin is decided\n// HERE, where instance identity lives: a list canvas renders several live\n// cards at once, and a click inside THIS boundary must reach THIS instance's\n// triggers. Events that already carry an origin keep it (core's\n// scopeDispatch).\nexport const registerWireSlots = (registry: ComponentRegistry<NovaComponent>, slotWrapper: TerminalSlotWrapper | undefined): void => {\n const CanvasSlot = defineComponent(\n (props: { canvasId?: string }) => {\n const api = inject(TerminalApiKey, undefined);\n return () => {\n const canvasId = props.canvasId;\n if (api === undefined || canvasId === undefined || canvasId === '') return null;\n const tree = api.canvasTree(canvasId);\n if (tree.length === 0) return null;\n return h(\n NovaRenderProvider,\n {\n registry,\n dispatch: (event: NovaEvent) => api.dispatch(canvasId, event),\n publish: (channel: string, payload?: unknown) => api.publish(channel, payload),\n },\n { default: () => h(RenderTree, { nodes: tree }) },\n );\n };\n },\n { name: 'MossCanvasSlot', props: ['canvasId'], inheritAttrs: false },\n );\n registry.register(CANVAS_SLOT_NAME, CanvasSlot, { description: 'A canvas, live from the server.' });\n\n const ActionSlot = defineComponent(\n (props: TerminalSlotWrapperProps, { slots }) => {\n const api = inject(TerminalApiKey, undefined);\n return () => {\n const { instanceId, canvasId, definitionId } = props;\n const wrapped =\n slotWrapper === undefined\n ? h(Fragment, { key: instanceId }, slots.default?.() ?? [])\n : h(slotWrapper, { key: instanceId, instanceId, canvasId, definitionId }, { default: () => slots.default?.() });\n if (api === undefined || instanceId === undefined || canvasId === undefined) return wrapped;\n return h(\n NovaRenderProvider,\n {\n registry,\n dispatch: scopeDispatch((event: NovaEvent) => api.dispatch(canvasId, event), instanceId),\n publish: (channel: string, payload?: unknown) => api.publish(channel, payload),\n },\n { default: () => wrapped },\n );\n };\n },\n { name: 'MossActionSlot', props: ['instanceId', 'canvasId', 'definitionId'], inheritAttrs: false },\n );\n registry.register(ACTION_SLOT_NAME, ActionSlot, {\n description: 'An action instance boundary from the server; the app slotWrapper wraps it.',\n });\n};\n\n// The frame, as a component: the api provided, the registry bound, the frame's\n// tree drawn. One definition for the browser's target and the server's\n// (./server), so what a server writes is what the browser then adopts.\nexport const terminalFrame = (api: TerminalApi, registry: ComponentRegistry<NovaComponent>): Component =>\n defineComponent(\n () => {\n provide(TerminalApiKey, api);\n return () =>\n h(\n NovaRenderProvider,\n // the frame is chrome — app events flow only from inside a canvas\n { registry, dispatch: noDispatch, publish: api.publish },\n { default: () => h(RenderTree, { nodes: api.frame() }) },\n );\n },\n { name: 'MossTerminalFrame' },\n );\n\nexport const vueTarget = (config: VueTargetConfig): Target => {\n const { root, registry, slotWrapper } = config;\n registerWireSlots(registry, slotWrapper);\n\n return (api) => {\n // The revision every wire read depends on. shallowRef: a counter, and the\n // trees behind it are the wire's own immutable snapshots.\n const revision = shallowRef(0);\n const live: TerminalApi = {\n frame: () => {\n void revision.value;\n return api.frame();\n },\n canvasTree: (canvasId) => {\n void revision.value;\n return api.canvasTree(canvasId);\n },\n dispatch: (canvasId, event) => api.dispatch(canvasId, event),\n publish: (channel, payload) => api.publish(channel, payload),\n };\n\n const Frame = terminalFrame(live, registry);\n\n // A root that already holds elements was drawn on the server from the\n // snapshot the wire starts from (./server): adopt them. Only when there is a\n // frame to adopt them WITH — a wire that did not start from the page's\n // snapshot has nothing that matches, and the elements are replaced.\n const adopts = root.firstElementChild !== null && api.frame().length > 0;\n const app = adopts ? createSSRApp(Frame) : createApp(Frame);\n app.mount(root);\n return {\n update: () => {\n revision.value += 1;\n },\n destroy: () => app.unmount(),\n };\n };\n};\n"]}
@@ -1,366 +0,0 @@
1
- import { DefinitionValidationError } from '@niscorp/nova';
2
-
3
- // src/telemetry.ts
4
- var emitterOf = (telemetry) => telemetry === void 0 ? void 0 : (span) => {
5
- try {
6
- telemetry.emit(span);
7
- } catch (err) {
8
- console.error("[moss:telemetry]", err);
9
- }
10
- };
11
- var elapsedClock = () => typeof performance !== "undefined" ? performance.now() : Date.now();
12
- var spanClock = () => {
13
- const startUnixNano = Date.now() * 1e6;
14
- const t0 = elapsedClock();
15
- return { startUnixNano, endUnixNano: () => startUnixNano + (elapsedClock() - t0) * 1e6 };
16
- };
17
-
18
- // src/session-cookie.ts
19
- var DEFAULT_TOKEN_KEY = "nisc.token";
20
- var tokenFromCookie = (header, name = DEFAULT_TOKEN_KEY) => {
21
- if (header === void 0 || header === null) return null;
22
- const wanted = encodeURIComponent(name);
23
- for (const part of header.split(";")) {
24
- const at = part.indexOf("=");
25
- if (at < 0 || part.slice(0, at).trim() !== wanted) continue;
26
- try {
27
- const value = decodeURIComponent(part.slice(at + 1).trim());
28
- return value === "" ? null : value;
29
- } catch {
30
- return null;
31
- }
32
- }
33
- return null;
34
- };
35
- var isOwnOrigin = (origin, host, listed = []) => {
36
- if (origin === void 0 || origin === null || !URL.canParse(origin)) return false;
37
- const asked = new URL(origin);
38
- return asked.host === host?.toLowerCase() || listed.some((entry) => URL.canParse(entry) && new URL(entry).origin === asked.origin);
39
- };
40
- var nameOf = (key, port) => `${key}${port === "" ? "" : `.${port}`}`;
41
- var heldCookieName = (key = DEFAULT_TOKEN_KEY, port = "") => encodeURIComponent(`${nameOf(key, port)}.held`);
42
- var cookiesAt = (where, key, token, lastsMs) => {
43
- const name = encodeURIComponent(nameOf(key, where.port));
44
- const life = token === null ? "; Max-Age=0" : typeof lastsMs === "number" ? `; Max-Age=${Math.max(0, Math.floor(lastsMs / 1e3))}` : "";
45
- const kept = `Path=/; SameSite=Lax${where.secure ? "; Secure" : ""}${life}`;
46
- return [`${where.secure ? "__Host-" : ""}${name}=${encodeURIComponent(token ?? "")}; HttpOnly; ${kept}`, `${name}.held=${token === null ? "" : "1"}; ${kept}`];
47
- };
48
- var originOf = (request) => {
49
- const said = request.headers.get("origin");
50
- if (said !== null && URL.canParse(said)) return said;
51
- const here = new URL(request.url);
52
- const scheme = request.headers.get("x-forwarded-proto")?.split(",")[0]?.trim() || here.protocol.slice(0, -1);
53
- return `${scheme}://${request.headers.get("host") ?? here.host}`;
54
- };
55
- var sessionCookies = (page, token, options = {}) => {
56
- const at = new URL(typeof page === "string" ? page : originOf(page));
57
- return cookiesAt({ port: at.port, secure: at.protocol === "https:" }, options.key ?? DEFAULT_TOKEN_KEY, token, options.lastsMs);
58
- };
59
- var sessionTokenOf = (cookies, where, key = DEFAULT_TOKEN_KEY) => {
60
- const name = nameOf(key, where.port);
61
- for (const secure of where.secure === void 0 ? [true, false] : [where.secure]) {
62
- const token = tokenFromCookie(cookies, `${secure ? "__Host-" : ""}${name}`);
63
- if (token !== null) return { token, clear: cookiesAt({ port: where.port, secure }, key, null) };
64
- }
65
- return null;
66
- };
67
- var SEALED_FOR_MS = 6e4;
68
- var sealName = (secure) => `${secure ? "__Http-" : ""}nisc.seal`;
69
- var toBase64Url = (bytes) => btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
70
- var fromBase64Url = (text) => Uint8Array.from(atob(text.replace(/-/g, "+").replace(/_/g, "/")), (char) => char.charCodeAt(0));
71
- var keyOf = async (seal) => crypto.subtle.importKey("raw", await crypto.subtle.digest("SHA-256", new TextEncoder().encode(seal)), "AES-GCM", false, ["encrypt", "decrypt"]);
72
- var newSeal = () => toBase64Url(crypto.getRandomValues(new Uint8Array(32)));
73
- var sealOf = (cookies, secure) => tokenFromCookie(cookies, sealName(secure));
74
- var sealCookie = (seal, where) => `${sealName(where.secure)}=${seal}; HttpOnly; Path=${where.path}; SameSite=Lax${where.secure ? "; Secure" : ""}`;
75
- var sealSession = async (seal, token, forMs = SEALED_FOR_MS) => {
76
- const iv = crypto.getRandomValues(new Uint8Array(12));
77
- const sealed = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, await keyOf(seal), new TextEncoder().encode(JSON.stringify({ token, until: Date.now() + forMs })));
78
- return toBase64Url(new Uint8Array([...iv, ...new Uint8Array(sealed)]));
79
- };
80
- var openSealed = async (seal, sealed) => {
81
- try {
82
- const bytes = fromBase64Url(sealed);
83
- const opened = await crypto.subtle.decrypt({ name: "AES-GCM", iv: bytes.slice(0, 12) }, await keyOf(seal), bytes.slice(12));
84
- const { token, until } = JSON.parse(new TextDecoder().decode(opened));
85
- return typeof token === "string" && typeof until === "number" && until > Date.now() ? token : null;
86
- } catch {
87
- return null;
88
- }
89
- };
90
- var PROTOCOL = 2;
91
- var PROTOCOL_MIN = 2;
92
- var SUBPROTOCOL = "nisc";
93
- var TOKEN_OFFER = "nisc.token.";
94
- var SEALED_OFFER = "nisc.sealed.";
95
- var offerToken = (token, sealed = null) => {
96
- const offer = sealed === null ? [SUBPROTOCOL] : [SUBPROTOCOL, `${SEALED_OFFER}${sealed}`];
97
- if (token === null) return offer;
98
- const bytes = String.fromCharCode(...new TextEncoder().encode(token));
99
- return [...offer, `${TOKEN_OFFER}${btoa(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`];
100
- };
101
- var offeredToken = (offered = []) => {
102
- const offer = offered.find((entry) => entry.startsWith(TOKEN_OFFER));
103
- if (offer === void 0) return null;
104
- try {
105
- const bytes = atob(offer.slice(TOKEN_OFFER.length).replace(/-/g, "+").replace(/_/g, "/"));
106
- return new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(bytes, (char) => char.charCodeAt(0))) || null;
107
- } catch {
108
- return null;
109
- }
110
- };
111
- var CLOSE_INVALID_TOKEN = 4401;
112
- var CLOSE_SIGNED_OUT = 4403;
113
- var CLOSE_SHELL_FAILED = 4500;
114
- var CLOSE_PROTOCOL_MISMATCH = 4426;
115
- var DEFAULT_REVALIDATE_MS = 60 * 1e3;
116
- var parse = (text) => {
117
- try {
118
- const value = JSON.parse(text);
119
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
120
- } catch {
121
- return null;
122
- }
123
- };
124
- var createSocket = (ctx) => {
125
- const emit = emitterOf(ctx.telemetry);
126
- let saidNotOwn = false;
127
- const live = /* @__PURE__ */ new Map();
128
- const expire = (connection) => {
129
- connection.send(JSON.stringify({ type: "error", code: "invalid_token", message: "The session token no longer resolves to this principal." }));
130
- connection.close(CLOSE_INVALID_TOKEN, "session expired");
131
- live.delete(connection);
132
- };
133
- const revalidate = async () => {
134
- for (const [connection, credential] of [...live]) {
135
- if (credential === null) continue;
136
- let resolved;
137
- try {
138
- resolved = await ctx.session(credential.token);
139
- } catch {
140
- continue;
141
- }
142
- if (resolved === credential.principal) continue;
143
- if (!live.has(connection)) continue;
144
- expire(connection);
145
- }
146
- };
147
- const revalidateMs = ctx.revalidateMs ?? DEFAULT_REVALIDATE_MS;
148
- let sweeper;
149
- if (revalidateMs > 0 && Number.isFinite(revalidateMs)) {
150
- sweeper = setInterval(() => void revalidate(), revalidateMs);
151
- sweeper.unref?.();
152
- }
153
- const accept = async (url, connection) => {
154
- const send = (message) => connection.send(JSON.stringify(message));
155
- try {
156
- await open(url, connection, send);
157
- } catch (error) {
158
- console.error("[moss/socket] refused a session:", error);
159
- live.delete(connection);
160
- const failures = error instanceof DefinitionValidationError ? (error.context?.failures ?? []).map((f) => f.id) : [];
161
- const detail = failures.length > 0 ? `${String(error instanceof Error ? error.message : error)}: ${failures.join(", ")}` : String(error);
162
- try {
163
- send({ type: "error", code: "session_failed", message: `This session could not be opened \u2014 ${detail}. The refusal is this terminal's alone; the server is up.` });
164
- connection.close(CLOSE_SHELL_FAILED, "session failed");
165
- } catch {
166
- }
167
- }
168
- };
169
- const open = async (url, connection, send) => {
170
- const upClock = emit === void 0 ? void 0 : spanClock();
171
- const params = new URL(url, "http://nisc.local").searchParams;
172
- const spoken = Number(params.get("protocol") ?? "1");
173
- if (!Number.isInteger(spoken) || spoken < PROTOCOL_MIN || spoken > PROTOCOL) {
174
- const behind = spoken > PROTOCOL ? "server" : "client";
175
- send({
176
- type: "error",
177
- code: `${behind}_too_old`,
178
- message: `This terminal speaks protocol ${params.get("protocol") ?? "1"}; this server speaks ${PROTOCOL_MIN}\u2013${PROTOCOL}. ${behind === "client" ? "Reload the terminal to get the current build." : "The server has not been updated yet."}`
179
- });
180
- connection.close(CLOSE_PROTOCOL_MISMATCH, "protocol mismatch");
181
- return;
182
- }
183
- const upgrade = connection.upgrade;
184
- const key = /^[\w.-]{1,64}$/.test(params.get("key") ?? "") ? params.get("key") : DEFAULT_TOKEN_KEY;
185
- const page = upgrade !== void 0 && isOwnOrigin(upgrade.origin, upgrade.host, ctx.origins) ? new URL(upgrade.origin) : void 0;
186
- const secure = page?.protocol === "https:";
187
- const held = page === void 0 ? null : sessionTokenOf(upgrade?.cookie, { port: page.port, secure }, key);
188
- const sealing = page !== void 0 && params.get("sealed") === "1";
189
- if (page === void 0 && params.get("sealed") === "1" && typeof upgrade?.origin === "string" && !saidNotOwn) {
190
- saidNotOwn = true;
191
- console.warn(`[moss] a terminal on ${upgrade.origin} holds its own session token: this server was addressed as ${upgrade.host ?? "nothing"}, so that is not the app\u2019s own page. If the app is served there, behind a proxy that rewrites Host, list it in runtime.origins.`);
192
- }
193
- const hadSeal = sealing ? sealOf(upgrade?.cookie, secure) : null;
194
- const sealedOffer = upgrade?.offered.find((entry) => entry.startsWith(SEALED_OFFER))?.slice(SEALED_OFFER.length) ?? null;
195
- const sealLost = sealing && sealedOffer !== null && hadSeal === null;
196
- const seal = !sealing || sealLost ? null : hadSeal ?? (upgrade?.answer === void 0 ? null : newSeal());
197
- const offered = offeredToken(upgrade?.offered) ?? (sealedOffer === null || hadSeal === null ? null : await openSealed(hadSeal, sealedOffer));
198
- let token = offered ?? (params.get("leave") === "1" ? null : held?.token ?? null);
199
- let principal = token === null ? null : await ctx.session(token);
200
- if (offered !== null && principal === null) {
201
- if (emit !== void 0 && upClock !== void 0) {
202
- emit({ name: "socket.upgrade", startUnixNano: upClock.startUnixNano, endUnixNano: upClock.endUnixNano(), status: "refused", attributes: { hasPrincipal: false } });
203
- }
204
- send({ type: "error", code: "invalid_token", message: "The session token did not resolve to a principal." });
205
- connection.close(CLOSE_INVALID_TOKEN, "invalid token");
206
- return;
207
- }
208
- if (principal === null) token = null;
209
- const answered = [
210
- ...page === void 0 || offered === null && (held?.token ?? null) === token ? [] : token === null ? held?.clear ?? [] : sessionCookies(page.origin, token, { key, lastsMs: await ctx.sessionLastsMs?.(token) ?? null }),
211
- ...seal !== null && hadSeal === null ? [sealCookie(seal, { secure, path: new URL(url, "http://nisc.local").pathname })] : []
212
- ];
213
- if (answered.length > 0) upgrade?.answer?.(answered);
214
- if (seal !== null) connection.seal = (granted) => sealSession(seal, granted);
215
- if (sealLost) {
216
- send({ type: "error", code: "seal_not_kept", message: "This browser did not keep the cookie a sealed sign-in is opened with. Sign in again: it will be handed over as a token." });
217
- }
218
- live.set(connection, token !== null && token !== "" && principal !== null ? { token, principal } : null);
219
- connection.onClose(() => live.delete(connection));
220
- if (emit !== void 0 && upClock !== void 0) {
221
- const hadPrincipal = principal !== null;
222
- connection.onClose(() => emit({ name: "socket.close", startUnixNano: upClock.startUnixNano, endUnixNano: upClock.endUnixNano(), status: "ok", attributes: { hasPrincipal: hadPrincipal } }));
223
- }
224
- const { ids, hash } = await ctx.catalog(principal);
225
- send({ type: "hello", protocol: PROTOCOL, principal, catalog: { actions: ids, hash } });
226
- const wantsDelta = params.get("delta") === "1";
227
- const named = params.get("seed");
228
- const seed = named !== null && /^[0-9a-f]{8,40}$/.test(named) ? named : void 0;
229
- const path = params.get("path");
230
- const route = path === null ? void 0 : ctx.page?.(path);
231
- const host = route?.host ?? ctx.shells;
232
- const session = await host?.session(token, principal, { ...seed === void 0 ? {} : { seed }, ...route === void 0 ? {} : { inputs: route.inputs } });
233
- if (session !== void 0) {
234
- session.attach(connection, { delta: wantsDelta });
235
- connection.onClose(() => session.detach(connection));
236
- }
237
- if (emit !== void 0 && upClock !== void 0) {
238
- emit({ name: "socket.upgrade", startUnixNano: upClock.startUnixNano, endUnixNano: upClock.endUnixNano(), status: "ok", attributes: { hasPrincipal: principal !== null } });
239
- }
240
- connection.onMessage((text) => {
241
- const message = parse(text);
242
- if (message !== null && message["type"] === "reset") {
243
- if (session === void 0) {
244
- send({ type: "error", code: "no_shell", message: "This app serves no shell." });
245
- return;
246
- }
247
- session.reset();
248
- return;
249
- }
250
- if (message !== null && message["type"] === "resync") {
251
- if (session === void 0) {
252
- send({ type: "error", code: "no_shell", message: "This app serves no shell." });
253
- return;
254
- }
255
- session.resync(connection);
256
- return;
257
- }
258
- if (message !== null && message["type"] === "back") {
259
- if (session === void 0) {
260
- send({ type: "error", code: "no_shell", message: "This app serves no shell." });
261
- return;
262
- }
263
- session.back();
264
- return;
265
- }
266
- if (message !== null && message["type"] === "popTo" && typeof message["canvas"] === "string" && typeof message["instance"] === "string") {
267
- if (session === void 0) {
268
- send({ type: "error", code: "no_shell", message: "This app serves no shell." });
269
- return;
270
- }
271
- session.popTo(message["canvas"], message["instance"]);
272
- return;
273
- }
274
- if (message !== null && message["type"] === "publish" && typeof message["channel"] === "string") {
275
- if (session === void 0) {
276
- send({ type: "error", code: "no_shell", message: "This app serves no shell." });
277
- return;
278
- }
279
- session.publish(message["channel"], message["payload"]);
280
- return;
281
- }
282
- if (message === null || message["type"] !== "event" || typeof message["canvas"] !== "string") {
283
- send({ type: "error", code: "invalid_message", message: 'Messages are JSON { type: "event", canvas, event }.' });
284
- return;
285
- }
286
- if (session === void 0) {
287
- send({ type: "error", code: "no_shell", message: "This app serves no shell.", canvas: message["canvas"] });
288
- return;
289
- }
290
- const event = message["event"];
291
- if (event === null || typeof event !== "object" || Array.isArray(event)) {
292
- send({ type: "error", code: "invalid_message", message: "The event field must be a NovaEvent object.", canvas: message["canvas"] });
293
- return;
294
- }
295
- session.dispatch(message["canvas"], event);
296
- });
297
- };
298
- return Object.assign(accept, {
299
- stop: () => {
300
- if (sweeper !== void 0) clearInterval(sweeper);
301
- sweeper = void 0;
302
- }
303
- });
304
- };
305
-
306
- // src/delta.ts
307
- var BLOCK = 16;
308
- var encodeDelta = (base, target) => {
309
- if (base.length < BLOCK) return [[1, target]];
310
- const index = /* @__PURE__ */ new Map();
311
- for (let i = 0; i + BLOCK <= base.length; i += 1) {
312
- const key = base.slice(i, i + BLOCK);
313
- if (!index.has(key)) index.set(key, i);
314
- }
315
- const ops = [];
316
- let literal = "";
317
- let at = 0;
318
- while (at < target.length) {
319
- const key = target.slice(at, at + BLOCK);
320
- const found = key.length === BLOCK ? index.get(key) : void 0;
321
- if (found === void 0) {
322
- literal += target[at];
323
- at += 1;
324
- continue;
325
- }
326
- let length = BLOCK;
327
- while (found + length < base.length && at + length < target.length && base[found + length] === target[at + length]) {
328
- length += 1;
329
- }
330
- if (literal !== "") {
331
- ops.push([1, literal]);
332
- literal = "";
333
- }
334
- ops.push([0, found, length]);
335
- at += length;
336
- }
337
- if (literal !== "") ops.push([1, literal]);
338
- return ops;
339
- };
340
- var applyDelta = (base, ops) => {
341
- let out = "";
342
- for (const op of ops) {
343
- if (op[0] === 1) {
344
- out += op[1];
345
- continue;
346
- }
347
- const [, offset, length] = op;
348
- if (offset < 0 || length < 0 || offset + length > base.length) {
349
- throw new Error(`moss/delta: copy ${offset}+${length} is outside a base of ${base.length}`);
350
- }
351
- out += base.slice(offset, offset + length);
352
- }
353
- return out;
354
- };
355
- var frameHash = (text) => {
356
- let hash = 2166136261;
357
- for (let i = 0; i < text.length; i += 1) {
358
- hash ^= text.charCodeAt(i);
359
- hash = Math.imul(hash, 16777619);
360
- }
361
- return hash >>> 0;
362
- };
363
-
364
- export { CLOSE_INVALID_TOKEN, CLOSE_PROTOCOL_MISMATCH, CLOSE_SHELL_FAILED, CLOSE_SIGNED_OUT, DEFAULT_REVALIDATE_MS, DEFAULT_TOKEN_KEY, PROTOCOL, PROTOCOL_MIN, SUBPROTOCOL, applyDelta, createSocket, emitterOf, encodeDelta, frameHash, heldCookieName, offerToken, sessionCookies, sessionTokenOf, spanClock, tokenFromCookie };
365
- //# sourceMappingURL=chunk-HOZID4EM.js.map
366
- //# sourceMappingURL=chunk-HOZID4EM.js.map