@get-bb/plugin-sdk 0.4.9 → 0.4.11

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/dist/app.js CHANGED
@@ -3,6 +3,8 @@ var runtime = globalThis.__bbPluginRuntime?.pluginSdkApp ?? {};
3
3
  var definePluginApp = runtime.definePluginApp;
4
4
  var ThreadChat = runtime.ThreadChat;
5
5
  var Markdown = runtime.Markdown;
6
+ var experimental_FileLink = runtime.experimental_FileLink;
7
+ var experimental_UrlLink = runtime.experimental_UrlLink;
6
8
  var experimental_NewThreadComposer = runtime.experimental_NewThreadComposer;
7
9
  var experimental_SourceCode = runtime.experimental_SourceCode;
8
10
  var experimental_Diff = runtime.experimental_Diff;
@@ -12,19 +14,27 @@ var useRealtimeConnectionState = runtime.useRealtimeConnectionState;
12
14
  var useSettings = runtime.useSettings;
13
15
  var useBbContext = runtime.useBbContext;
14
16
  var useBbNavigate = runtime.useBbNavigate;
17
+ var experimental_useAppPanel = runtime.experimental_useAppPanel;
18
+ var experimental_useFixedTabTarget = runtime.experimental_useFixedTabTarget;
15
19
  var useComposer = runtime.useComposer;
16
20
  var useComposerView = runtime.useComposerView;
17
21
  var experimental_useSidebarThreads = runtime.experimental_useSidebarThreads;
18
22
  var experimental_useSidebarThreadActions = runtime.experimental_useSidebarThreadActions;
19
23
  var experimental_useSidebarThreadPullRequest = runtime.experimental_useSidebarThreadPullRequest;
20
24
  var experimental_useSidebarThreadSplit = runtime.experimental_useSidebarThreadSplit;
25
+ var experimental_useProviders = runtime.experimental_useProviders;
21
26
  export {
22
27
  Markdown,
23
28
  ThreadChat,
24
29
  definePluginApp,
25
30
  experimental_Diff,
31
+ experimental_FileLink,
26
32
  experimental_NewThreadComposer,
27
33
  experimental_SourceCode,
34
+ experimental_UrlLink,
35
+ experimental_useAppPanel,
36
+ experimental_useFixedTabTarget,
37
+ experimental_useProviders,
28
38
  experimental_useSidebarThreadActions,
29
39
  experimental_useSidebarThreadPullRequest,
30
40
  experimental_useSidebarThreadSplit,
@@ -0,0 +1,135 @@
1
+ // src/internal/file-navigation-validation.ts
2
+ var FILE_PATH_MAX_LENGTH = 32768;
3
+ var WINDOWS_DRIVE_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/u;
4
+ var WINDOWS_UNC_ABSOLUTE_PATH = /^\\\\/u;
5
+ function isJsonObject(value) {
6
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
7
+ return false;
8
+ }
9
+ const prototype = Object.getPrototypeOf(value);
10
+ return prototype === Object.prototype || prototype === null;
11
+ }
12
+ function hasExactKeys(value, keys) {
13
+ const actualKeys = Object.keys(value);
14
+ return actualKeys.length === keys.length && keys.every((key) => Object.prototype.hasOwnProperty.call(value, key));
15
+ }
16
+ function isNonEmptyIdentity(value) {
17
+ return typeof value === "string" && value.length > 0 && value.length <= FILE_PATH_MAX_LENGTH && value.trim() === value;
18
+ }
19
+ function hasControlCharacter(value) {
20
+ for (const character of value) {
21
+ const codePoint = character.codePointAt(0);
22
+ if (codePoint !== void 0 && codePoint < 32) return true;
23
+ }
24
+ return false;
25
+ }
26
+ function hasUnpairedSurrogate(value) {
27
+ for (let index = 0; index < value.length; index += 1) {
28
+ const codeUnit = value.charCodeAt(index);
29
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
30
+ if (index + 1 >= value.length) return true;
31
+ const nextCodeUnit = value.charCodeAt(index + 1);
32
+ if (nextCodeUnit < 56320 || nextCodeUnit > 57343) return true;
33
+ index += 1;
34
+ } else if (codeUnit >= 56320 && codeUnit <= 57343) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+ function isValidPathSegment(segment) {
41
+ return segment.length > 0 && segment !== "." && segment !== "..";
42
+ }
43
+ function isPositiveSafeInteger(value) {
44
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
45
+ }
46
+ function isValidRelativeFilePath(value) {
47
+ if (typeof value !== "string" || value.length === 0 || value.length > FILE_PATH_MAX_LENGTH || value.trim() !== value || value.includes("\\") || hasControlCharacter(value) || hasUnpairedSurrogate(value)) {
48
+ return false;
49
+ }
50
+ return value.split("/").every(isValidPathSegment);
51
+ }
52
+ function isValidAbsoluteHostFilePath(value) {
53
+ if (typeof value !== "string" || value.length === 0 || value.length > FILE_PATH_MAX_LENGTH || value.trim() !== value || hasControlCharacter(value) || hasUnpairedSurrogate(value)) {
54
+ return false;
55
+ }
56
+ if (value.startsWith("/") && !value.startsWith("//")) {
57
+ const segments = value.slice(1).split("/");
58
+ return segments.length > 0 && segments.every(isValidPathSegment);
59
+ }
60
+ if (WINDOWS_DRIVE_ABSOLUTE_PATH.test(value)) {
61
+ const segments = value.slice(3).split(/[\\/]/u);
62
+ return segments.length > 0 && segments.every(isValidPathSegment);
63
+ }
64
+ if (WINDOWS_UNC_ABSOLUTE_PATH.test(value)) {
65
+ const segments = value.slice(2).split(/[\\/]/u);
66
+ return segments.length >= 3 && segments.every(isValidPathSegment);
67
+ }
68
+ return false;
69
+ }
70
+ function normalizeExperimentalLiveFileTarget(value) {
71
+ if (!isJsonObject(value) || typeof value.kind !== "string") return null;
72
+ switch (value.kind) {
73
+ case "workspace":
74
+ if (!hasExactKeys(value, ["kind", "environmentId", "path"]) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
75
+ return null;
76
+ }
77
+ return {
78
+ kind: value.kind,
79
+ environmentId: value.environmentId,
80
+ path: value.path
81
+ };
82
+ case "host":
83
+ if (!hasExactKeys(value, ["kind", "hostId", "path"]) || !isNonEmptyIdentity(value.hostId) || !isValidAbsoluteHostFilePath(value.path)) {
84
+ return null;
85
+ }
86
+ return { kind: value.kind, hostId: value.hostId, path: value.path };
87
+ case "thread-storage":
88
+ if (!hasExactKeys(value, ["kind", "threadId", "path"]) || !isNonEmptyIdentity(value.threadId) || !isValidRelativeFilePath(value.path)) {
89
+ return null;
90
+ }
91
+ return { kind: value.kind, threadId: value.threadId, path: value.path };
92
+ default:
93
+ return null;
94
+ }
95
+ }
96
+ function normalizeExperimentalFileLocation(value) {
97
+ if (value === null) return null;
98
+ if (!isJsonObject(value) || typeof value.kind !== "string") return void 0;
99
+ switch (value.kind) {
100
+ case "line":
101
+ if (!hasExactKeys(value, ["kind", "line", "column"]) || !isPositiveSafeInteger(value.line) || value.column !== null && !isPositiveSafeInteger(value.column)) {
102
+ return void 0;
103
+ }
104
+ return {
105
+ kind: value.kind,
106
+ line: value.line,
107
+ column: value.column
108
+ };
109
+ case "range":
110
+ if (!hasExactKeys(value, ["kind", "startLine", "endLine"]) || !isPositiveSafeInteger(value.startLine) || !isPositiveSafeInteger(value.endLine) || value.endLine < value.startLine) {
111
+ return void 0;
112
+ }
113
+ return {
114
+ kind: value.kind,
115
+ startLine: value.startLine,
116
+ endLine: value.endLine
117
+ };
118
+ default:
119
+ return void 0;
120
+ }
121
+ }
122
+ function normalizeExperimentalFileOpenOptions(value) {
123
+ if (!isJsonObject(value) || !hasExactKeys(value, ["target", "location"])) {
124
+ return null;
125
+ }
126
+ const target = normalizeExperimentalLiveFileTarget(value.target);
127
+ const location = normalizeExperimentalFileLocation(value.location);
128
+ if (target === null || location === void 0) return null;
129
+ return { target, location };
130
+ }
131
+ export {
132
+ normalizeExperimentalFileLocation,
133
+ normalizeExperimentalFileOpenOptions,
134
+ normalizeExperimentalLiveFileTarget
135
+ };