@systems-modeling/jupyterlab-sysml 0.52.1 → 0.54.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/build/fold.js +107 -0
- package/build/mode.js +61 -100
- package/build/plugin.js +66 -10
- package/package.json +7 -13
package/build/fold.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SysML 2 Pilot Implementation
|
|
4
|
+
* Copyright (c) 2020-2025 Mgnite Inc.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU Lesser General Public License for more details.
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*
|
|
18
|
+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.sysmlFoldServiceSelection = sysmlFoldServiceSelection;
|
|
22
|
+
var language_1 = require("@codemirror/language");
|
|
23
|
+
function isInStringCommentOrVariable(state, pos) {
|
|
24
|
+
var tree = (0, language_1.syntaxTree)(state);
|
|
25
|
+
var node = tree.resolveInner(pos, 1);
|
|
26
|
+
while (node) {
|
|
27
|
+
var nodeType = node.type.name;
|
|
28
|
+
// Check if we're in a string, comment, or other non-code context
|
|
29
|
+
// Note that 'variableName' correesponds to a quoted name
|
|
30
|
+
if (nodeType === 'String' ||
|
|
31
|
+
nodeType === 'Comment' ||
|
|
32
|
+
nodeType === 'BlockComment' ||
|
|
33
|
+
nodeType === 'LineComment' ||
|
|
34
|
+
nodeType === 'variableName' ||
|
|
35
|
+
nodeType.toLowerCase().includes('string') ||
|
|
36
|
+
nodeType.toLowerCase().includes('comment')) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
node = node.parent;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function findMatchingCloseBrace(state, openPos) {
|
|
44
|
+
var docLength = state.doc.length;
|
|
45
|
+
var nest = 1;
|
|
46
|
+
var pos = openPos + 1;
|
|
47
|
+
while (pos < docLength && nest > 0) {
|
|
48
|
+
var char = state.sliceDoc(pos, pos + 1);
|
|
49
|
+
// Skip if we're in a string, comment, or variable
|
|
50
|
+
if (!isInStringCommentOrVariable(state, pos)) {
|
|
51
|
+
if (char === '{') {
|
|
52
|
+
nest++;
|
|
53
|
+
}
|
|
54
|
+
else if (char === '}') {
|
|
55
|
+
nest--;
|
|
56
|
+
if (nest === 0) {
|
|
57
|
+
return pos;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
pos++;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function computeFoldRange(state, lineStart, lineEnd) {
|
|
66
|
+
// Check the language first
|
|
67
|
+
var lang = state.facet(language_1.language);
|
|
68
|
+
if (!lang || lang.name !== 'sysml')
|
|
69
|
+
return null;
|
|
70
|
+
var lineText = state.sliceDoc(lineStart, lineEnd);
|
|
71
|
+
for (var i = 0; i < lineText.length; i++) {
|
|
72
|
+
var char = lineText[i];
|
|
73
|
+
if (char === '{') {
|
|
74
|
+
var absolutePos = lineStart + i;
|
|
75
|
+
// Check if this brace is in a string, comment, or variable
|
|
76
|
+
if (isInStringCommentOrVariable(state, absolutePos)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Find the matching closing brace
|
|
80
|
+
var closePos = findMatchingCloseBrace(state, absolutePos);
|
|
81
|
+
if (closePos === null) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
// Check if the fold spans multiple lines
|
|
85
|
+
var openLine = state.doc.lineAt(absolutePos);
|
|
86
|
+
var closeLine = state.doc.lineAt(closePos);
|
|
87
|
+
if (openLine.number === closeLine.number) {
|
|
88
|
+
/* Do not fold the same line */
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return { from: absolutePos, to: closePos };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function sysmlFoldServiceSelection(options) {
|
|
97
|
+
var mimeType = options.model.mimeType;
|
|
98
|
+
if (mimeType === 'text/x-sysml'
|
|
99
|
+
// In the newly created notebook, the first cell is initialized as 'text/plain'
|
|
100
|
+
// We check the language in the foldService as well to avoid misapplication.
|
|
101
|
+
|| mimeType === 'text/plain') {
|
|
102
|
+
return [language_1.foldService.of(computeFoldRange)];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
}
|
package/build/mode.js
CHANGED
|
@@ -34,114 +34,75 @@ var __assign = (this && this.__assign) || function () {
|
|
|
34
34
|
};
|
|
35
35
|
return __assign.apply(this, arguments);
|
|
36
36
|
};
|
|
37
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
38
|
-
if (k2 === undefined) k2 = k;
|
|
39
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
40
|
-
}) : (function(o, m, k, k2) {
|
|
41
|
-
if (k2 === undefined) k2 = k;
|
|
42
|
-
o[k2] = m[k];
|
|
43
|
-
}));
|
|
44
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
45
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
46
|
-
}) : function(o, v) {
|
|
47
|
-
o["default"] = v;
|
|
48
|
-
});
|
|
49
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
50
|
-
if (mod && mod.__esModule) return mod;
|
|
51
|
-
var result = {};
|
|
52
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
53
|
-
__setModuleDefault(result, mod);
|
|
54
|
-
return result;
|
|
55
|
-
};
|
|
56
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.
|
|
58
|
-
|
|
59
|
-
require("codemirror/addon/mode/simple");
|
|
60
|
-
var CodeMirror = __importStar(require("codemirror"));
|
|
61
|
-
var SI_MODE = 'sysml';
|
|
62
|
-
var P_MIME = 'text/x-sysml';
|
|
38
|
+
exports.sysmlparser = void 0;
|
|
39
|
+
var clike_1 = require("@codemirror/legacy-modes/mode/clike");
|
|
63
40
|
var f_wordify = function (h, s) {
|
|
64
41
|
var _a;
|
|
65
42
|
return (__assign(__assign({}, h), (_a = {}, _a[s] = true, _a)));
|
|
66
43
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
44
|
+
exports.sysmlparser = (0, clike_1.clike)({
|
|
45
|
+
name: 'sysml',
|
|
46
|
+
keywords: [
|
|
47
|
+
"about", "abstract", "accept", "action", "actor", "after", "alias", "all", "allocate", "allocation",
|
|
48
|
+
"analysis", "and", "as", "assert", "assign", "assume", "at", "attribute", "bind", "binding", "by",
|
|
49
|
+
"calc", "case", "comment", "concern", "connect", "connection", "constant", "constraint", "crosses",
|
|
50
|
+
"decide", "def", "default", "defined", "dependency", "derived", "do", "doc", "else", "end", "entry",
|
|
51
|
+
"enum", "event", "exhibit", "exit", "expose", "filter", "first", "flow", "for", "fork", "frame", "from",
|
|
52
|
+
"hastype", "if", "implies", "import", "in", "include", "individual", "inout", "interface", "istype",
|
|
53
|
+
"item", "join", "language", "library", "locale", "loop", "merge", "message", "meta", "metadata", "new",
|
|
54
|
+
"nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package", "parallel",
|
|
55
|
+
"part", "perform", "port", "private", "protected", "public", "redefines", "ref", "references", "render",
|
|
56
|
+
"rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot", "specializes",
|
|
57
|
+
"stakeholder", "standard", "state", "subject", "subsets", "succession", "terminate", "then",
|
|
58
|
+
"timeslice", "to", "transition", "until", "use", "variant", "variation", "verification", "verify",
|
|
59
|
+
"via", "view", "viewpoint", "when", "while", "xor"
|
|
60
|
+
].reduce(f_wordify, {}),
|
|
61
|
+
types: [
|
|
62
|
+
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",
|
|
63
|
+
"connection", "constraint", "def", "doc", "enum", "flow", "interface", "item", "metadata", "objective",
|
|
64
|
+
"occurrence", "package", "part", "port", "ref", "rendering", "rep", "requirement", "snapshot", "state",
|
|
65
|
+
"subject", "succession", "timeslice", "transition", "verification", "view", "viewpoint"
|
|
66
|
+
].reduce(f_wordify, {}),
|
|
67
|
+
atoms: ['true', 'false', 'null'].reduce(f_wordify, {}),
|
|
68
|
+
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
|
69
|
+
hooks: {
|
|
70
|
+
"'": function (stream) {
|
|
71
|
+
var b_escaped = false;
|
|
72
|
+
var s_next;
|
|
73
|
+
while (s_next = stream.next()) {
|
|
74
|
+
if (s_next === "'" && !b_escaped)
|
|
75
|
+
break;
|
|
76
|
+
b_escaped = !b_escaped && s_next === '\\';
|
|
77
|
+
}
|
|
78
|
+
return 'variable';
|
|
79
|
+
},
|
|
80
|
+
'/': function (stream) {
|
|
81
|
+
if (stream.match('/*', false))
|
|
82
|
+
stream.next();
|
|
83
|
+
return false;
|
|
84
|
+
},
|
|
85
|
+
"#": function (stream) {
|
|
86
|
+
var b_first = true;
|
|
87
|
+
do {
|
|
88
|
+
if (stream.match("'", true)) {
|
|
100
89
|
var b_escaped = false;
|
|
101
|
-
var s_next;
|
|
90
|
+
var s_next = void 0;
|
|
102
91
|
while (s_next = stream.next()) {
|
|
103
92
|
if (s_next === "'" && !b_escaped)
|
|
104
93
|
break;
|
|
105
94
|
b_escaped = !b_escaped && s_next === '\\';
|
|
106
95
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
while (s_next = stream.next()) {
|
|
121
|
-
if (s_next === "'" && !b_escaped)
|
|
122
|
-
break;
|
|
123
|
-
b_escaped = !b_escaped && s_next === '\\';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else if (stream.match(/\w/, true)) {
|
|
127
|
-
stream.eatWhile(/\w/);
|
|
128
|
-
}
|
|
129
|
-
else if (b_first) {
|
|
130
|
-
return 'operator';
|
|
131
|
-
}
|
|
132
|
-
b_first = false;
|
|
133
|
-
} while (stream.match('::', true));
|
|
134
|
-
return 'keyword';
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
CodeMirror.defineMIME(P_MIME, SI_MODE);
|
|
140
|
-
CodeMirror.modeInfo.push({
|
|
141
|
-
ext: ['sysml'],
|
|
142
|
-
mime: P_MIME,
|
|
143
|
-
mode: SI_MODE,
|
|
144
|
-
name: 'sysml',
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
exports.defineSysMLv2Mode = defineSysMLv2Mode;
|
|
96
|
+
}
|
|
97
|
+
else if (stream.match(/\w/, true)) {
|
|
98
|
+
stream.eatWhile(/\w/);
|
|
99
|
+
}
|
|
100
|
+
else if (b_first) {
|
|
101
|
+
return 'operator';
|
|
102
|
+
}
|
|
103
|
+
b_first = false;
|
|
104
|
+
} while (stream.match('::', true));
|
|
105
|
+
return 'keyword';
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
package/build/plugin.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* SysML 2 Pilot Implementation
|
|
4
4
|
* Copyright (C) 2020 California Institute of Technology ("Caltech")
|
|
5
|
+
* Copyright (C) 2025 Model Driven Solutions, Inc.
|
|
6
|
+
* Copyright (C) 2025 Mgnite Inc.
|
|
5
7
|
*
|
|
6
8
|
* This program is free software: you can redistribute it and/or modify
|
|
7
9
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
@@ -17,17 +19,71 @@
|
|
|
17
19
|
*
|
|
18
20
|
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
|
|
19
21
|
*/
|
|
22
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
23
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
27
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
28
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
32
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
33
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
34
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
35
|
+
function step(op) {
|
|
36
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
37
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
38
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
39
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
40
|
+
switch (op[0]) {
|
|
41
|
+
case 0: case 1: t = op; break;
|
|
42
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
43
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
44
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
45
|
+
default:
|
|
46
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
47
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
48
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
49
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
50
|
+
if (t[2]) _.ops.pop();
|
|
51
|
+
_.trys.pop(); continue;
|
|
52
|
+
}
|
|
53
|
+
op = body.call(thisArg, _);
|
|
54
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
55
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
20
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var codemirror_1 = require("@jupyterlab/codemirror");
|
|
21
60
|
var mode_1 = require("./mode");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Initialization data for extension
|
|
27
|
-
*/
|
|
28
|
-
var extension = {
|
|
29
|
-
activate: activate,
|
|
30
|
-
autoStart: true,
|
|
61
|
+
var fold_1 = require("./fold");
|
|
62
|
+
var plugin = {
|
|
31
63
|
id: 'jupyterlab-sysml:plugin',
|
|
64
|
+
description: 'A JupyterLab extension adding a syntax highlight for SysMLv2 language.',
|
|
65
|
+
autoStart: true,
|
|
66
|
+
requires: [codemirror_1.IEditorLanguageRegistry, codemirror_1.IEditorExtensionRegistry],
|
|
67
|
+
activate: function (app, languages, ext) {
|
|
68
|
+
languages.addLanguage({
|
|
69
|
+
name: 'sysml',
|
|
70
|
+
displayName: 'sysml',
|
|
71
|
+
mime: 'text/x-sysml',
|
|
72
|
+
extensions: ['sysml'],
|
|
73
|
+
load: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
return [2 /*return*/, codemirror_1.EditorLanguageRegistry.legacy(mode_1.sysmlparser)];
|
|
76
|
+
});
|
|
77
|
+
}); }
|
|
78
|
+
});
|
|
79
|
+
var sysmlFoldExtension = Object.freeze({
|
|
80
|
+
name: 'sysml-fold-extension',
|
|
81
|
+
default: true,
|
|
82
|
+
factory: function (options) {
|
|
83
|
+
return codemirror_1.EditorExtensionRegistry.createConditionalExtension((0, fold_1.sysmlFoldServiceSelection)(options));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
ext.addExtension(sysmlFoldExtension);
|
|
87
|
+
}
|
|
32
88
|
};
|
|
33
|
-
exports.default =
|
|
89
|
+
exports.default = plugin;
|
package/package.json
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systems-modeling/jupyterlab-sysml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "A JupyterLab extension for system modeling using SysML",
|
|
5
5
|
"repository": "github:Systems-Modeling/SysML-v2-Pilot-Implementation",
|
|
6
6
|
"author": "SysML v2 Submission Team",
|
|
7
7
|
"license": "LGPL-3.0-or-later",
|
|
8
|
+
"main": "build/plugin.js",
|
|
8
9
|
"keywords": [
|
|
9
10
|
"jupyter",
|
|
10
11
|
"jupyterlab",
|
|
11
12
|
"jupyterlab-extension"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
|
-
"@jupyterlab/application": "
|
|
15
|
+
"@jupyterlab/application": "4.x"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@
|
|
18
|
+
"@codemirror/legacy-modes": "^6.3.2",
|
|
19
|
+
"@jupyterlab/codemirror": ">=4.0",
|
|
18
20
|
"@types/json-schema": "*",
|
|
19
|
-
"typescript": "
|
|
20
|
-
},
|
|
21
|
-
"resolutions": {
|
|
22
|
-
"@lumino/coreutils": "^1.11.0",
|
|
23
|
-
"@lumino/widgets": "^1.37.2",
|
|
24
|
-
"lib0": "0.2.108"
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"codemirror": "^5.58.1"
|
|
21
|
+
"typescript": "~5.8.3"
|
|
28
22
|
},
|
|
29
23
|
"files": [
|
|
30
24
|
"build/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}"
|
|
31
25
|
],
|
|
32
26
|
"jupyterlab": {
|
|
33
|
-
"extension":
|
|
27
|
+
"extension": true
|
|
34
28
|
},
|
|
35
29
|
"scripts": {
|
|
36
30
|
"build": "tsc",
|