@nextop-os/browser-node 0.0.8

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.
@@ -0,0 +1,132 @@
1
+ import {
2
+ BrowserNode,
3
+ BrowserNodeWorkbenchHeader
4
+ } from "../chunk-VQTJWLWO.js";
5
+ import "../chunk-OTK5YBCK.js";
6
+
7
+ // src/workbench/index.ts
8
+ import { createElement } from "react";
9
+ var defaultBrowserNodeFrame = {
10
+ height: 560,
11
+ width: 920,
12
+ x: 220,
13
+ y: 120
14
+ };
15
+ var defaultBrowserNodeTypeId = "browser";
16
+ var defaultBrowserNodeDockIconUrl = new URL(
17
+ "../assets/workspace-dock-website.png",
18
+ import.meta.url
19
+ ).href;
20
+ function createBrowserNodeDefinition({
21
+ defaultUrl,
22
+ feature,
23
+ frame = defaultBrowserNodeFrame,
24
+ typeId = defaultBrowserNodeTypeId
25
+ }) {
26
+ return {
27
+ frame,
28
+ instance: {
29
+ mode: "multi"
30
+ },
31
+ renderBody: (context) => createElement(BrowserNode, {
32
+ defaultUrl: resolveBrowserNodeInitialUrl({
33
+ activation: context.activation,
34
+ defaultUrl,
35
+ externalNodeState: context.externalNodeState
36
+ }),
37
+ feature,
38
+ nodeId: context.node.id,
39
+ onFocusRequest: context.isFocused ? void 0 : () => context.focus(),
40
+ showHeader: false
41
+ }),
42
+ renderHeader: ({
43
+ defaultActions,
44
+ activation,
45
+ dragHandleProps,
46
+ externalNodeState,
47
+ isFocused,
48
+ node,
49
+ windowActions
50
+ }) => createElement(BrowserNodeWorkbenchHeader, {
51
+ className: "bg-transparent",
52
+ defaultActions,
53
+ defaultUrl: resolveBrowserNodeInitialUrl({
54
+ activation,
55
+ defaultUrl,
56
+ externalNodeState
57
+ }),
58
+ dragHandleProps,
59
+ feature,
60
+ nodeId: node.id,
61
+ onCloseRequest: () => {
62
+ void feature.hostApi.close({ nodeId: node.id }).catch(() => void 0);
63
+ },
64
+ onFocusRequest: isFocused ? void 0 : () => windowActions.focus()
65
+ }),
66
+ title: feature.i18n.t("title"),
67
+ typeId,
68
+ window: {
69
+ closable: true,
70
+ defaultOpen: false,
71
+ minimizable: true,
72
+ restoreOnLoad: true
73
+ }
74
+ };
75
+ }
76
+ function createBrowserDockEntry(input) {
77
+ return {
78
+ capturePopupItemPreview: ({ node }) => input.feature.hostApi.capturePreview?.({ nodeId: node.id }) ?? null,
79
+ icon: input.dockIcon ?? createElement(BrowserNodeDockIcon),
80
+ id: input.id ?? defaultBrowserNodeTypeId,
81
+ label: input.feature.i18n.t("dockLabel"),
82
+ launchBehavior: "enabled",
83
+ matchNode: (node) => node.data.typeId === (input.typeId ?? defaultBrowserNodeTypeId),
84
+ order: input.order,
85
+ resolvePopupItem: ({ node }) => {
86
+ const runtime = input.feature.runtimeStore.getNodeState(node.id);
87
+ return {
88
+ subtitle: runtime.url?.trim() || node.data.instanceId,
89
+ title: runtime.title?.trim() || node.title
90
+ };
91
+ },
92
+ sectionId: input.sectionId,
93
+ typeId: input.typeId ?? defaultBrowserNodeTypeId,
94
+ visibility: "always"
95
+ };
96
+ }
97
+ function resolveBrowserNodeInitialUrl({
98
+ activation,
99
+ defaultUrl,
100
+ externalNodeState
101
+ }) {
102
+ return readBrowserOpenUrlActivationPayload(activation)?.url ?? normalizeBrowserNodeInitialUrl(externalNodeState?.url) ?? defaultUrl;
103
+ }
104
+ function normalizeBrowserNodeInitialUrl(value) {
105
+ const trimmed = value?.trim() ?? "";
106
+ return trimmed.length > 0 ? trimmed : null;
107
+ }
108
+ function BrowserNodeDockIcon() {
109
+ return createElement("img", {
110
+ alt: "",
111
+ "aria-hidden": "true",
112
+ "data-browser-node-dock-icon": "true",
113
+ draggable: false,
114
+ src: defaultBrowserNodeDockIconUrl
115
+ });
116
+ }
117
+ function readBrowserOpenUrlActivationPayload(activation) {
118
+ if (activation?.type !== "open-url" || !activation.payload || typeof activation.payload !== "object") {
119
+ return null;
120
+ }
121
+ const typed = activation.payload;
122
+ return typeof typed.url === "string" ? {
123
+ title: typeof typed.title === "string" ? typed.title : void 0,
124
+ url: typed.url
125
+ } : null;
126
+ }
127
+ export {
128
+ createBrowserDockEntry,
129
+ createBrowserNodeDefinition,
130
+ defaultBrowserNodeTypeId
131
+ };
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/workbench/index.ts"],"sourcesContent":["import { createElement, type ReactNode } from \"react\";\nimport type {\n WorkbenchHostActivation,\n WorkbenchHostDockEntry,\n WorkbenchFrame,\n WorkbenchHostNodeDefinition\n} from \"@nextop-os/workbench-surface\";\nimport type { BrowserNodeFeature } from \"../core/feature.ts\";\nimport {\n BrowserNode,\n BrowserNodeWorkbenchHeader\n} from \"../react/BrowserNode.tsx\";\n\nexport interface BrowserNodeOpenUrlActivationPayload {\n title?: string;\n url: string;\n}\n\nexport interface BrowserNodeExternalState {\n title?: string | null;\n url?: string | null;\n}\n\nexport interface CreateBrowserNodeDefinitionInput {\n defaultUrl: string;\n dockIcon?: ReactNode;\n feature: BrowserNodeFeature;\n frame?: WorkbenchFrame;\n typeId?: string;\n}\n\nconst defaultBrowserNodeFrame: WorkbenchFrame = {\n height: 560,\n width: 920,\n x: 220,\n y: 120\n};\n\nexport const defaultBrowserNodeTypeId = \"browser\";\nconst defaultBrowserNodeDockIconUrl = new URL(\n \"../assets/workspace-dock-website.png\",\n import.meta.url\n).href;\n\nexport function createBrowserNodeDefinition({\n defaultUrl,\n feature,\n frame = defaultBrowserNodeFrame,\n typeId = defaultBrowserNodeTypeId\n}: CreateBrowserNodeDefinitionInput): WorkbenchHostNodeDefinition<BrowserNodeExternalState> {\n return {\n frame,\n instance: {\n mode: \"multi\"\n },\n renderBody: (context) =>\n createElement(BrowserNode, {\n defaultUrl: resolveBrowserNodeInitialUrl({\n activation: context.activation,\n defaultUrl,\n externalNodeState: context.externalNodeState\n }),\n feature,\n nodeId: context.node.id,\n onFocusRequest: context.isFocused ? undefined : () => context.focus(),\n showHeader: false\n }),\n renderHeader: ({\n defaultActions,\n activation,\n dragHandleProps,\n externalNodeState,\n isFocused,\n node,\n windowActions\n }) =>\n createElement(BrowserNodeWorkbenchHeader, {\n className: \"bg-transparent\",\n defaultActions,\n defaultUrl: resolveBrowserNodeInitialUrl({\n activation,\n defaultUrl,\n externalNodeState\n }),\n dragHandleProps,\n feature,\n nodeId: node.id,\n onCloseRequest: () => {\n void feature.hostApi\n .close({ nodeId: node.id })\n .catch(() => undefined);\n },\n onFocusRequest: isFocused ? undefined : () => windowActions.focus()\n }),\n title: feature.i18n.t(\"title\"),\n typeId,\n window: {\n closable: true,\n defaultOpen: false,\n minimizable: true,\n restoreOnLoad: true\n }\n };\n}\n\nexport function createBrowserDockEntry(input: {\n dockIcon?: ReactNode;\n feature: BrowserNodeFeature;\n id?: string;\n order?: number;\n sectionId?: string;\n typeId?: string;\n}): WorkbenchHostDockEntry {\n return {\n capturePopupItemPreview: ({ node }) =>\n input.feature.hostApi.capturePreview?.({ nodeId: node.id }) ?? null,\n icon: input.dockIcon ?? createElement(BrowserNodeDockIcon),\n id: input.id ?? defaultBrowserNodeTypeId,\n label: input.feature.i18n.t(\"dockLabel\"),\n launchBehavior: \"enabled\",\n matchNode: (node) =>\n node.data.typeId === (input.typeId ?? defaultBrowserNodeTypeId),\n order: input.order,\n resolvePopupItem: ({ node }) => {\n const runtime = input.feature.runtimeStore.getNodeState(node.id);\n return {\n subtitle: runtime.url?.trim() || node.data.instanceId,\n title: runtime.title?.trim() || node.title\n };\n },\n sectionId: input.sectionId,\n typeId: input.typeId ?? defaultBrowserNodeTypeId,\n visibility: \"always\"\n };\n}\n\nfunction resolveBrowserNodeInitialUrl({\n activation,\n defaultUrl,\n externalNodeState\n}: {\n activation: WorkbenchHostActivation | null;\n defaultUrl: string;\n externalNodeState?: BrowserNodeExternalState | null;\n}): string {\n return (\n readBrowserOpenUrlActivationPayload(activation)?.url ??\n normalizeBrowserNodeInitialUrl(externalNodeState?.url) ??\n defaultUrl\n );\n}\n\nfunction normalizeBrowserNodeInitialUrl(\n value: string | null | undefined\n): string | null {\n const trimmed = value?.trim() ?? \"\";\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction BrowserNodeDockIcon() {\n return createElement(\"img\", {\n alt: \"\",\n \"aria-hidden\": \"true\",\n \"data-browser-node-dock-icon\": \"true\",\n draggable: false,\n src: defaultBrowserNodeDockIconUrl\n });\n}\n\nfunction readBrowserOpenUrlActivationPayload(\n activation: WorkbenchHostActivation | null\n): BrowserNodeOpenUrlActivationPayload | null {\n if (\n activation?.type !== \"open-url\" ||\n !activation.payload ||\n typeof activation.payload !== \"object\"\n ) {\n return null;\n }\n\n const typed =\n activation.payload as Partial<BrowserNodeOpenUrlActivationPayload>;\n return typeof typed.url === \"string\"\n ? {\n title: typeof typed.title === \"string\" ? typed.title : undefined,\n url: typed.url\n }\n : null;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,qBAAqC;AA+B9C,IAAM,0BAA0C;AAAA,EAC9C,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,2BAA2B;AACxC,IAAM,gCAAgC,IAAI;AAAA,EACxC;AAAA,EACA,YAAY;AACd,EAAE;AAEK,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AACX,GAA4F;AAC1F,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,IACR;AAAA,IACA,YAAY,CAAC,YACX,cAAc,aAAa;AAAA,MACzB,YAAY,6BAA6B;AAAA,QACvC,YAAY,QAAQ;AAAA,QACpB;AAAA,QACA,mBAAmB,QAAQ;AAAA,MAC7B,CAAC;AAAA,MACD;AAAA,MACA,QAAQ,QAAQ,KAAK;AAAA,MACrB,gBAAgB,QAAQ,YAAY,SAAY,MAAM,QAAQ,MAAM;AAAA,MACpE,YAAY;AAAA,IACd,CAAC;AAAA,IACH,cAAc,CAAC;AAAA,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A,IACA,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM,UAAU;AAAA,IACxB,YAAY;AAAA,EACd;AACF;AAEA,SAAS,6BAA6B;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,SACE,oCAAoC,UAAU,GAAG,OACjD,+BAA+B,mBAAmB,GAAG,KACrD;AAEJ;AAEA,SAAS,+BACP,OACe;AACf,QAAM,UAAU,OAAO,KAAK,KAAK;AACjC,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,sBAAsB;AAC7B,SAAO,cAAc,OAAO;AAAA,IAC1B,KAAK;AAAA,IACL,eAAe;AAAA,IACf,+BAA+B;AAAA,IAC/B,WAAW;AAAA,IACX,KAAK;AAAA,EACP,CAAC;AACH;AAEA,SAAS,oCACP,YAC4C;AAC5C,MACE,YAAY,SAAS,cACrB,CAAC,WAAW,WACZ,OAAO,WAAW,YAAY,UAC9B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,QACJ,WAAW;AACb,SAAO,OAAO,MAAM,QAAQ,WACxB;AAAA,IACE,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ;AAAA,IACvD,KAAK,MAAM;AAAA,EACb,IACA;AACN;","names":[]}
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@nextop-os/browser-node",
3
+ "version": "0.0.8",
4
+ "private": false,
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./bridge": {
13
+ "types": "./dist/bridge/index.d.ts",
14
+ "import": "./dist/bridge/index.js"
15
+ },
16
+ "./electron-main": {
17
+ "types": "./dist/electron-main/index.d.ts",
18
+ "import": "./dist/electron-main/index.js"
19
+ },
20
+ "./electron-preload": {
21
+ "types": "./dist/electron-preload/index.d.ts",
22
+ "import": "./dist/electron-preload/index.js"
23
+ },
24
+ "./i18n": {
25
+ "types": "./dist/i18n/index.d.ts",
26
+ "import": "./dist/i18n/index.js"
27
+ },
28
+ "./react": {
29
+ "types": "./dist/react/index.d.ts",
30
+ "import": "./dist/react/index.js"
31
+ },
32
+ "./workbench": {
33
+ "types": "./dist/workbench/index.d.ts",
34
+ "import": "./dist/workbench/index.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/nextop-os/nextop.git",
44
+ "directory": "packages/browser/workbench-node"
45
+ },
46
+ "dependencies": {
47
+ "@nextop-os/ui-i18n-runtime": "0.0.8",
48
+ "@nextop-os/ui-system": "0.0.8",
49
+ "@nextop-os/workbench-surface": "0.0.8"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^24.0.1",
53
+ "@types/react": "^19.1.6",
54
+ "@types/react-dom": "^19.1.5",
55
+ "electron": "^35.7.5",
56
+ "react": "^19.1.0",
57
+ "react-dom": "^19.1.0",
58
+ "typescript": "^5.8.3",
59
+ "@nextop-os/config-tsconfig": "0.0.0"
60
+ },
61
+ "peerDependencies": {
62
+ "electron": "^35.7.5",
63
+ "react": "^19.1.0",
64
+ "react-dom": "^19.1.0"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "electron": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "nextop": {
72
+ "tailwindSourceRoot": "src"
73
+ },
74
+ "publishConfig": {
75
+ "access": "public"
76
+ },
77
+ "scripts": {
78
+ "build": "tsup --config tsup.config.ts",
79
+ "test": "node --test --experimental-strip-types ./src/**/*.test.ts",
80
+ "typecheck": "tsc --noEmit -p tsconfig.json"
81
+ }
82
+ }