@kispace-io/core 0.7.0 → 0.8.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/dist/api/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, a, K, S, b, T, c, W, d, e, f, g, i, h, p, t, w } from "../k-standard-layout-CQ1VZoxa.js";
1
+ import { D, F, a, K, S, b, T, c, W, d, e, f, g, i, h, p, t, w } from "../k-standard-layout-5Gp_163g.js";
2
2
  import { C, E, H, K as K2, a as a2, b as b2, c as c2, M, P, S as S2, d as d2, e as e2, T as T2, f as f2, g as g2, h as h2, i as i2, j, k, l, m, n, o, p as p2, q, r, s, t as t2, u } from "../k-resizable-grid-Ch3iWZaL.js";
3
3
  import { C as C2, a as a3, E as E2, K as K3, T as T3, b as b3, c as c3, d as d3, e as e3, f as f3, g as g3, h as h3, i as i3, p as p3, j as j2, r as r2, k as k2, s as s2, t as t3, l as l2, m as m2, u as u2, w as w2 } from "../k-icon-BZC7dQV0.js";
4
4
  import { publish, subscribe, unsubscribe } from "../core/events.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, a, K, S, b, T, c, W, d, e, f, g, i, h, p, t, w } from "./k-standard-layout-CQ1VZoxa.js";
1
+ import { D, F, a, K, S, b, T, c, W, d, e, f, g, i, h, p, t, w } from "./k-standard-layout-5Gp_163g.js";
2
2
  import { C, E, H, K as K2, a as a2, b as b2, c as c2, M, P, S as S2, d as d2, e as e2, T as T2, f as f2, g as g2, h as h2, i as i2, j, k, l, m, n, o, p as p2, q, r, s, t as t2, u } from "./k-resizable-grid-Ch3iWZaL.js";
3
3
  import { C as C2, a as a3, E as E2, K as K3, T as T3, b as b3, c as c3, d as d3, e as e3, f as f3, g as g3, h as h3, i as i3, p as p3, j as j2, r as r2, k as k2, s as s2, t as t3, l as l2, m as m2, u as u2, w as w2 } from "./k-icon-BZC7dQV0.js";
4
4
  import { publish, subscribe, unsubscribe } from "./core/events.js";
@@ -3695,33 +3695,6 @@ async function getWorkspaceAndPath(params, requirePath = true) {
3695
3695
  function isEditorContentProvider(editor) {
3696
3696
  return editor && typeof editor.getContent === "function" && typeof editor.getSelection === "function" && typeof editor.getSnippet === "function" && typeof editor.getLanguage === "function" && typeof editor.getFilePath === "function";
3697
3697
  }
3698
- async function getResourceFromContext(context, params) {
3699
- let resource = void 0;
3700
- const path = context.params?.["path"];
3701
- if (path) {
3702
- const workspaceDir = await workspaceService.getWorkspace();
3703
- if (workspaceDir) {
3704
- resource = await workspaceDir.getResource(path);
3705
- }
3706
- }
3707
- if (!resource) {
3708
- resource = activeSelectionSignal.get();
3709
- }
3710
- return resource;
3711
- }
3712
- async function readTextFile(file) {
3713
- try {
3714
- const contents = await file.getContents();
3715
- if (typeof contents !== "string") {
3716
- toastError("File is not a text file");
3717
- return null;
3718
- }
3719
- return contents;
3720
- } catch (err) {
3721
- toastError(`Failed to read file: ${err.message}`);
3722
- return null;
3723
- }
3724
- }
3725
3698
  function createNullEditorResponse(includeCursorLine = false) {
3726
3699
  const base = {
3727
3700
  filePath: null,
@@ -3751,163 +3724,6 @@ async function getWorkspaceAndFile(params, requirePath = true) {
3751
3724
  return null;
3752
3725
  }
3753
3726
  }
3754
- registerAll({
3755
- command: {
3756
- "id": "create_file",
3757
- "name": "Create new file",
3758
- "description": "Creates a new file within the workspace. For .geospace map files, use create_map_file instead.",
3759
- "keyBinding": "CTRL+N",
3760
- "parameters": [
3761
- {
3762
- "name": "path",
3763
- "description": "the path including name of the file to be created, must be relative to the workspace",
3764
- "required": false
3765
- },
3766
- {
3767
- "name": "contents",
3768
- "description": "the textual contents of the file",
3769
- "required": false
3770
- },
3771
- {
3772
- "name": "ask",
3773
- "description": "whether to prompt the user for the file path",
3774
- "required": false
3775
- },
3776
- {
3777
- "name": "extension",
3778
- "description": "required file extension (e.g., '.geospace'), will be appended if missing",
3779
- "required": false
3780
- }
3781
- ],
3782
- "output": [
3783
- {
3784
- "name": "path",
3785
- "description": "the path of the created file"
3786
- }
3787
- ]
3788
- },
3789
- handler: {
3790
- execute: async ({ params }) => {
3791
- let path = params?.path;
3792
- const contents = params?.contents;
3793
- const ask = params?.ask;
3794
- const extension = params?.extension;
3795
- if (ask || !path) {
3796
- path = await promptDialog("Enter path to new file (directories will be created if not exist):", path || "");
3797
- if (!path) {
3798
- return;
3799
- }
3800
- }
3801
- if (extension && !path.endsWith(extension)) {
3802
- path += extension;
3803
- }
3804
- const result = await getWorkspaceAndPath({ path }, true);
3805
- if (!result) {
3806
- return;
3807
- }
3808
- const { workspace: workspaceDir } = result;
3809
- const existingResource = await workspaceDir.getResource(path);
3810
- if (existingResource) {
3811
- const overwrite = await confirmDialog(`File "${path}" already exists. Do you want to overwrite it?`);
3812
- if (!overwrite) {
3813
- return;
3814
- }
3815
- }
3816
- const createdResource = await workspaceDir.getResource(path, { create: true });
3817
- if (!createdResource) {
3818
- toastError("Could not create file: " + path);
3819
- } else {
3820
- if (contents) {
3821
- await createdResource.saveContents(contents);
3822
- }
3823
- defaultLogger.info("File created: " + path);
3824
- }
3825
- return path;
3826
- }
3827
- }
3828
- });
3829
- registerAll({
3830
- command: {
3831
- "id": "rename_resource",
3832
- "name": "Rename a resource (file or directory)",
3833
- "description": "Renames a resource (file or directory)",
3834
- "keyBinding": "F2",
3835
- "parameters": [
3836
- {
3837
- "name": "path",
3838
- "description": "the path of the resource within the workspace to rename or the currently active selection",
3839
- "required": false
3840
- },
3841
- {
3842
- "name": "newName",
3843
- "description": "the new name for the resource",
3844
- "required": false
3845
- }
3846
- ]
3847
- },
3848
- handler: {
3849
- execute: async (context) => {
3850
- const resource = await getResourceFromContext(context);
3851
- if (!resource) {
3852
- toastError("No resource to rename provided!");
3853
- return;
3854
- }
3855
- const currentName = resource.getName();
3856
- const newName = context.params?.newName || await promptDialog(`Enter new name for "${currentName}":`, currentName);
3857
- if (!newName || newName === currentName) {
3858
- return;
3859
- }
3860
- try {
3861
- await resource.rename(newName);
3862
- toastInfo(`Resource renamed to: ${newName}`);
3863
- } catch (err) {
3864
- toastError(`Failed to rename ${currentName}: ${err.message}`);
3865
- }
3866
- }
3867
- }
3868
- });
3869
- registerAll({
3870
- command: {
3871
- "id": "delete_resource",
3872
- "name": "Delete a resource (file or directory)",
3873
- "description": "Deletes a resource (file or directory)",
3874
- "parameters": [
3875
- {
3876
- "name": "path",
3877
- "description": "the path of the resource within the workspace to delete or the currently active selection",
3878
- "required": false
3879
- },
3880
- {
3881
- "name": "confirm",
3882
- "description": "whether to ask the user to confirm the deletion, true by default",
3883
- "required": false
3884
- }
3885
- ]
3886
- },
3887
- handler: {
3888
- execute: async (context) => {
3889
- const resource = await getResourceFromContext(context);
3890
- if (!resource) {
3891
- toastError("No resource to delete provided!");
3892
- return;
3893
- }
3894
- const path = resource.getWorkspacePath();
3895
- const confirmParam = context.params && context.params["confirm"];
3896
- let yes = true;
3897
- if (confirmParam === void 0 || confirmParam === true) {
3898
- yes = await confirmDialog(`Are you sure you want to delete ${path}?`);
3899
- }
3900
- if (yes) {
3901
- try {
3902
- await resource.delete();
3903
- toastInfo("Resource deleted: " + path);
3904
- } catch (err) {
3905
- toastError(`Resource ${path} could not be deleted: ${err.message || err}`);
3906
- }
3907
- }
3908
- }
3909
- }
3910
- });
3911
3727
  registerAll({
3912
3728
  command: {
3913
3729
  "id": "load_workspace",
@@ -3973,180 +3789,6 @@ registerAll({
3973
3789
  }
3974
3790
  }
3975
3791
  });
3976
- registerAll({
3977
- command: {
3978
- "id": "head_file",
3979
- "name": "Head - Show first lines",
3980
- "description": "Shows the first N lines of a file",
3981
- "parameters": [
3982
- {
3983
- "name": "path",
3984
- "description": "the path of the file to read",
3985
- "required": true
3986
- },
3987
- {
3988
- "name": "lines",
3989
- "description": "number of lines to show from the beginning (default: 10)",
3990
- "type": "number",
3991
- "required": false
3992
- }
3993
- ],
3994
- "output": [
3995
- {
3996
- "name": "content",
3997
- "description": "the first N lines of the file"
3998
- }
3999
- ]
4000
- },
4001
- handler: {
4002
- execute: async ({ params }) => {
4003
- const result = await getWorkspaceAndFile(params);
4004
- if (!result) {
4005
- return;
4006
- }
4007
- const { file } = result;
4008
- const numLines = params?.lines ? parseInt(params.lines, 10) : 10;
4009
- if (isNaN(numLines) || numLines < 1) {
4010
- toastError("Number of lines must be a positive integer");
4011
- return;
4012
- }
4013
- const contents = await readTextFile(file);
4014
- if (!contents) {
4015
- return;
4016
- }
4017
- const lines = contents.split("\n");
4018
- const headLines = lines.slice(0, numLines).join("\n");
4019
- return headLines;
4020
- }
4021
- }
4022
- });
4023
- registerAll({
4024
- command: {
4025
- "id": "tail_file",
4026
- "name": "Tail - Show last lines",
4027
- "description": "Shows the last N lines of a file",
4028
- "parameters": [
4029
- {
4030
- "name": "path",
4031
- "description": "the path of the file to read",
4032
- "required": true
4033
- },
4034
- {
4035
- "name": "lines",
4036
- "description": "number of lines to show from the end (default: 10)",
4037
- "type": "number",
4038
- "required": false
4039
- }
4040
- ],
4041
- "output": [
4042
- {
4043
- "name": "content",
4044
- "description": "the last N lines of the file"
4045
- }
4046
- ]
4047
- },
4048
- handler: {
4049
- execute: async ({ params }) => {
4050
- const result = await getWorkspaceAndFile(params);
4051
- if (!result) {
4052
- return;
4053
- }
4054
- const { file } = result;
4055
- const numLines = params?.lines ? parseInt(params.lines, 10) : 10;
4056
- if (isNaN(numLines) || numLines < 1) {
4057
- toastError("Number of lines must be a positive integer");
4058
- return;
4059
- }
4060
- const contents = await readTextFile(file);
4061
- if (!contents) {
4062
- return;
4063
- }
4064
- const lines = contents.split("\n");
4065
- const tailLines = lines.slice(-numLines).join("\n");
4066
- return tailLines;
4067
- }
4068
- }
4069
- });
4070
- registerAll({
4071
- command: {
4072
- "id": "cat_file",
4073
- "name": "Cat - Show file contents",
4074
- "description": "Shows the complete contents of a file",
4075
- "parameters": [
4076
- {
4077
- "name": "path",
4078
- "description": "the path of the file to read",
4079
- "required": true
4080
- }
4081
- ],
4082
- "output": [
4083
- {
4084
- "name": "content",
4085
- "description": "the complete contents of the file"
4086
- }
4087
- ]
4088
- },
4089
- handler: {
4090
- execute: async ({ params }) => {
4091
- const result = await getWorkspaceAndFile(params);
4092
- if (!result) {
4093
- return;
4094
- }
4095
- const { file } = result;
4096
- return await readTextFile(file);
4097
- }
4098
- }
4099
- });
4100
- registerAll({
4101
- command: {
4102
- "id": "wc_file",
4103
- "name": "Word count",
4104
- "description": "Counts lines, words, and characters in a file",
4105
- "parameters": [
4106
- {
4107
- "name": "path",
4108
- "description": "the path of the file to analyze",
4109
- "required": true
4110
- }
4111
- ],
4112
- "output": [
4113
- {
4114
- "name": "lines",
4115
- "description": "number of lines in the file"
4116
- },
4117
- {
4118
- "name": "words",
4119
- "description": "number of words in the file"
4120
- },
4121
- {
4122
- "name": "characters",
4123
- "description": "number of characters in the file"
4124
- }
4125
- ]
4126
- },
4127
- handler: {
4128
- execute: async ({ params }) => {
4129
- const result = await getWorkspaceAndFile(params);
4130
- if (!result) {
4131
- return;
4132
- }
4133
- const { file } = result;
4134
- const contents = await readTextFile(file);
4135
- if (!contents) {
4136
- return;
4137
- }
4138
- const lines = contents.split("\n");
4139
- const lineCount = lines.length;
4140
- const wordCount = contents.trim() === "" ? 0 : contents.trim().split(/\s+/).filter((w) => w.length > 0).length;
4141
- const charCount = contents.length;
4142
- return {
4143
- lines: lineCount,
4144
- words: wordCount,
4145
- characters: charCount
4146
- };
4147
- }
4148
- }
4149
- });
4150
3792
  registerAll({
4151
3793
  command: {
4152
3794
  "id": "file_exists",
@@ -4182,102 +3824,6 @@ registerAll({
4182
3824
  }
4183
3825
  }
4184
3826
  });
4185
- async function collectFilesRecursive(directory) {
4186
- const files = [];
4187
- const children = await directory.listChildren(true);
4188
- for (const child of children) {
4189
- if (child instanceof File) {
4190
- files.push(child.getWorkspacePath());
4191
- } else if (child instanceof Directory) {
4192
- const subFiles = await collectFilesRecursive(child);
4193
- files.push(...subFiles);
4194
- }
4195
- }
4196
- return files;
4197
- }
4198
- registerAll({
4199
- command: {
4200
- "id": "ls",
4201
- "name": "List files",
4202
- "description": "Lists files from a directory. If recursive is provided, it traverses from the provided directory down to all leaves. If no directory is provided, it will traverse from the workspace root.",
4203
- "parameters": [
4204
- {
4205
- "name": "path",
4206
- "description": "the path of the directory to list, relative to the workspace. If not provided, uses workspace root",
4207
- "required": false
4208
- },
4209
- {
4210
- "name": "recursive",
4211
- "description": "whether to recursively traverse all subdirectories",
4212
- "type": "boolean",
4213
- "required": false
4214
- }
4215
- ],
4216
- "output": [
4217
- {
4218
- "name": "files",
4219
- "description": "array of file objects with path and size information"
4220
- }
4221
- ]
4222
- },
4223
- handler: {
4224
- execute: async ({ params }) => {
4225
- const result = await getWorkspaceAndPath(params, false);
4226
- if (!result) {
4227
- toastError("No workspace available");
4228
- return [];
4229
- }
4230
- const { workspace, path } = result;
4231
- const recursive = params?.recursive === true || params?.recursive === "true";
4232
- try {
4233
- let targetDir = workspace;
4234
- if (path) {
4235
- const resource = await workspace.getResource(path);
4236
- if (!resource) {
4237
- toastError(`Path not found: ${path}`);
4238
- return [];
4239
- }
4240
- if (!(resource instanceof Directory)) {
4241
- toastError(`Path is not a directory: ${path}`);
4242
- return [];
4243
- }
4244
- targetDir = resource;
4245
- }
4246
- if (recursive) {
4247
- const files = await collectFilesRecursive(targetDir);
4248
- const result2 = [];
4249
- for (const filePath of files) {
4250
- const file = await workspace.getResource(filePath);
4251
- if (file instanceof File) {
4252
- const size = await file.size();
4253
- result2.push({
4254
- path: filePath,
4255
- size
4256
- });
4257
- }
4258
- }
4259
- return result2;
4260
- } else {
4261
- const children = await targetDir.listChildren(true);
4262
- const result2 = [];
4263
- for (const child of children) {
4264
- if (child instanceof File) {
4265
- const size = await child.size();
4266
- result2.push({
4267
- path: child.getWorkspacePath(),
4268
- size
4269
- });
4270
- }
4271
- }
4272
- return result2;
4273
- }
4274
- } catch (err) {
4275
- toastError(`Failed to list files: ${err.message}`);
4276
- return [];
4277
- }
4278
- }
4279
- }
4280
- });
4281
3827
  registerAll({
4282
3828
  command: {
4283
3829
  "id": "get_active_editor_content",
@@ -4609,20 +4155,6 @@ ${release.body}`;
4609
4155
  }
4610
4156
  }
4611
4157
  });
4612
- registerAll({
4613
- command: {
4614
- "id": "js",
4615
- "name": "Run JavaScript file",
4616
- "description": "Executes a JavaScript file given its path",
4617
- "parameters": [
4618
- {
4619
- "name": "script",
4620
- "description": "the path to a JavaScript file to run",
4621
- "required": false
4622
- }
4623
- ]
4624
- }
4625
- });
4626
4158
  registerAll({
4627
4159
  command: {
4628
4160
  "id": "save",
@@ -4650,15 +4182,6 @@ registerAll({
4650
4182
  }
4651
4183
  }
4652
4184
  });
4653
- registerAll({
4654
- command: {
4655
- "id": "run_python",
4656
- "name": "Run Python Cell",
4657
- "description": "Runs active Python code in a supporting context (e.g. notebook, terminal, etc.)",
4658
- "keyBinding": "CTRL+R",
4659
- "parameters": []
4660
- }
4661
- });
4662
4185
  const THEME_SETTINGS_KEY = "theme";
4663
4186
  async function applyTheme(themeClass) {
4664
4187
  const root = document.documentElement;
@@ -5008,4 +4531,4 @@ export {
5008
4531
  treeNodeComparator as t,
5009
4532
  workspaceService as w
5010
4533
  };
5011
- //# sourceMappingURL=k-standard-layout-CQ1VZoxa.js.map
4534
+ //# sourceMappingURL=k-standard-layout-5Gp_163g.js.map