xmlui 0.8.6 → 0.9.1

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 (106) hide show
  1. package/dist/{apiInterceptorWorker-fLBfPj2T.mjs → apiInterceptorWorker-230V_-Ds.mjs} +1 -1
  2. package/dist/{index-wd8FRzuM.mjs → index-DUwwx3L4.mjs} +5864 -6108
  3. package/dist/index.css +274 -301
  4. package/dist/language-server.mjs +25 -1
  5. package/dist/{lint-B18Ko6Sy.mjs → lint-gX2osbkz.mjs} +920 -1120
  6. package/dist/scripts/bin/build.js +2 -2
  7. package/dist/scripts/bin/start.js +3 -9
  8. package/dist/scripts/bin/vite-xmlui-plugin.js +2 -2
  9. package/dist/scripts/bin/viteConfig.js +89 -63
  10. package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +1 -2
  11. package/dist/scripts/src/components/Accordion/Accordion.js +6 -16
  12. package/dist/scripts/src/components/App/AppNative.js +8 -0
  13. package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -5
  14. package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +10 -4
  15. package/dist/scripts/src/components/AutoComplete/AutoComplete.js +13 -19
  16. package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
  17. package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +7 -3
  18. package/dist/scripts/src/components/Avatar/Avatar.js +2 -9
  19. package/dist/scripts/src/components/Badge/Badge.js +2 -8
  20. package/dist/scripts/src/components/Button/Button.js +28 -60
  21. package/dist/scripts/src/components/Card/Card.js +1 -6
  22. package/dist/scripts/src/components/Checkbox/Checkbox.js +4 -12
  23. package/dist/scripts/src/components/ComponentProvider.js +4 -0
  24. package/dist/scripts/src/components/DatePicker/DatePicker.js +3 -10
  25. package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
  26. package/dist/scripts/src/components/Form/Form.js +12 -28
  27. package/dist/scripts/src/components/Form/FormNative.js +9 -0
  28. package/dist/scripts/src/components/FormItem/HelperText.js +1 -1
  29. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +2 -2
  30. package/dist/scripts/src/components/Heading/HeadingNative.js +0 -1
  31. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +4 -19
  32. package/dist/scripts/src/components/IconProvider.js +2 -2
  33. package/dist/scripts/src/components/Link/Link.js +2 -8
  34. package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
  35. package/dist/scripts/src/components/ModalDialog/ModalDialog.js +1 -3
  36. package/dist/scripts/src/components/NavGroup/NavGroup.js +34 -3
  37. package/dist/scripts/src/components/NavGroup/NavGroupNative.js +24 -12
  38. package/dist/scripts/src/components/NavLink/NavLink.js +4 -11
  39. package/dist/scripts/src/components/NavPanel/NavPanel.js +1 -6
  40. package/dist/scripts/src/components/ProgressBar/ProgressBar.js +2 -8
  41. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -12
  42. package/dist/scripts/src/components/Select/Select.js +5 -13
  43. package/dist/scripts/src/components/Select/SelectNative.js +7 -3
  44. package/dist/scripts/src/components/Slider/Slider.js +2 -8
  45. package/dist/scripts/src/components/Spinner/Spinner.js +1 -6
  46. package/dist/scripts/src/components/SubNavPanel/SubNavPanel.js +22 -0
  47. package/dist/scripts/src/components/SubNavPanel/SubNavPanelNative.js +9 -0
  48. package/dist/scripts/src/components/Switch/Switch.js +6 -16
  49. package/dist/scripts/src/components/Table/Table.js +8 -17
  50. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +4 -12
  51. package/dist/scripts/src/components/Tabs/Tabs.js +3 -10
  52. package/dist/scripts/src/components/Text/Text.js +10 -24
  53. package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
  54. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
  55. package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +3 -3
  56. package/dist/scripts/src/components-core/DevTools.js +5 -4
  57. package/dist/scripts/src/components-core/RestApiProxy.js +7 -3
  58. package/dist/scripts/src/components-core/action/APICall.js +2 -1
  59. package/dist/scripts/src/components-core/rendering/Container.js +15 -11
  60. package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -2
  61. package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +0 -2
  62. package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
  63. package/dist/scripts/src/components-core/script-runner/asyncProxy.js +11 -64
  64. package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +196 -175
  65. package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +173 -231
  66. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +129 -100
  67. package/dist/scripts/src/components-core/script-runner/process-statement-async.js +170 -175
  68. package/dist/scripts/src/components-core/script-runner/process-statement-common.js +48 -33
  69. package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +164 -170
  70. package/dist/scripts/src/components-core/script-runner/statement-queue.js +5 -4
  71. package/dist/scripts/src/components-core/script-runner/visitors.js +124 -116
  72. package/dist/scripts/src/components-core/theming/themes/palette.js +1 -0
  73. package/dist/scripts/src/components-core/theming/themes/root.js +300 -154
  74. package/dist/scripts/src/components-core/theming/themes/theme-colors.js +510 -510
  75. package/dist/scripts/src/components-core/theming/themes/xmlui.js +0 -1
  76. package/dist/scripts/src/components-core/theming/transformThemeVars.js +11 -11
  77. package/dist/scripts/src/components-core/utils/misc.js +13 -0
  78. package/dist/scripts/src/components-core/utils/statementUtils.js +56 -53
  79. package/dist/scripts/src/components-core/xmlui-parser.js +1 -1
  80. package/dist/scripts/src/parsers/scripting-exp/Lexer.js +1092 -0
  81. package/dist/scripts/src/parsers/scripting-exp/Parser.js +2635 -0
  82. package/dist/scripts/src/parsers/scripting-exp/ParserError.js +47 -0
  83. package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +109 -0
  84. package/dist/scripts/src/parsers/scripting-exp/TokenType.js +2 -4
  85. package/dist/scripts/src/parsers/scripting-exp/code-behind-collect.js +101 -0
  86. package/dist/scripts/src/parsers/scripting-exp/modules.js +107 -0
  87. package/dist/scripts/src/parsers/{scripting → scripting-exp}/tree-visitor.js +103 -107
  88. package/dist/scripts/src/parsers/xmlui-parser/transform.js +12 -12
  89. package/dist/style.css +245 -286
  90. package/dist/xmlui-metadata.mjs +2741 -2211
  91. package/dist/xmlui-metadata.umd.js +2740 -2212
  92. package/dist/xmlui-parser.d.ts +320 -232
  93. package/dist/xmlui-parser.mjs +19 -19
  94. package/dist/xmlui-standalone.umd.js +6770 -7220
  95. package/dist/xmlui.d.ts +322 -230
  96. package/dist/xmlui.mjs +1 -1
  97. package/package.json +10 -6
  98. package/dist/_commonjsHelpers-CcAunmGO.mjs +0 -33
  99. package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +0 -34
  100. package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +0 -40
  101. package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +0 -40
  102. package/dist/scripts/src/components-core/script-runner/syncProxy.js +0 -31
  103. package/dist/scripts/src/parsers/scripting/code-behind-collect.js +0 -153
  104. package/dist/scripts/src/parsers/scripting/modules.js +0 -284
  105. /package/dist/scripts/src/abstractions/scripting/{LogicalThread.js → LogicalThreadExp.js} +0 -0
  106. /package/dist/scripts/src/abstractions/scripting/{TryScope.js → TryScopeExp.js} +0 -0
package/dist/xmlui.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A, B, E, I, i, h, S, b, c, e, f, j, p, s, t, k, u } from "./index-wd8FRzuM.mjs";
1
+ import { A, B, E, I, i, h, S, b, c, e, f, j, p, s, t, k, u } from "./index-DUwwx3L4.mjs";
2
2
  export {
3
3
  A as AppRoot,
4
4
  B as Button,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.8.6",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
7
- "build:test-bed": "cd src/testing/infrastructure && xmlui build --build-mode=INLINE_ALL --withHostingMetaFiles",
7
+ "build:test-bed": "cd src/testing/infrastructure && xmlui build --build-mode=INLINE_ALL --withHostingMetaFiles --withMock",
8
8
  "build:bin": "tsc -p tsconfig.bin.json",
9
9
  "build:xmlui": "vite build --mode lib",
10
10
  "build:xmlui-standalone": "vite build --mode standalone",
@@ -18,10 +18,12 @@
18
18
  "test:e2e-smoke": "playwright test --project smoke",
19
19
  "test:e2e-ui": "npm run test:e2e -- --ui",
20
20
  "prepublishOnly": "clean-package && npm run build",
21
+ "cleanPackage": "clean-package",
21
22
  "postpublish": "clean-package restore",
22
23
  "generate-docs": "node scripts/generate-docs/get-docs.mjs",
23
24
  "prepare-docs-data": "npm run build:xmlui-metadata",
24
- "generate-all-docs": "npm run build:xmlui-metadata && npm run build:ext-meta && npm run generate-docs"
25
+ "generate-all-docs": "npm run build:xmlui-metadata && npm run build:ext-meta && npm run generate-docs",
26
+ "export-themes": "npm run prepare-docs-data && node scripts/generate-docs/create-theme-files.mjs"
25
27
  },
26
28
  "dependencies": {
27
29
  "@eslint-community/regexpp": "4.10.0",
@@ -51,6 +53,7 @@
51
53
  "adm-zip": "0.5.10",
52
54
  "axios": "1.7.7",
53
55
  "chroma-js": "^3.1.2",
56
+ "classnames": "2.5.1",
54
57
  "cmdk": "^1.0.4",
55
58
  "color": "4.2.3",
56
59
  "date-fns": "2.30.0",
@@ -127,11 +130,12 @@
127
130
  "eslint-import-resolver-typescript": "3.6.1",
128
131
  "eslint-plugin-import": "2.28.1",
129
132
  "eslint-plugin-jsx-a11y": "6.7.1",
130
- "eslint-plugin-react": "7.33.2",
131
- "eslint-plugin-react-hooks": "4.6.0",
133
+ "eslint-plugin-react": "^7.37.4",
134
+ "eslint-plugin-react-hooks": "^5.2.0",
132
135
  "prettier": "^3.3.3",
133
136
  "rimraf": "6.0.1",
134
137
  "rollup-plugin-visualizer": "5.8.3",
138
+ "@rollup/pluginutils": "5.1.0",
135
139
  "serve": "14.2.0",
136
140
  "typescript": "5.7.3",
137
141
  "vite": "5.4.9",
@@ -228,7 +232,7 @@
228
232
  "url": "https://github.com/xmlui-com/xmlui.git"
229
233
  },
230
234
  "msw": {
231
- "workerDirectory": "src/testing/infrastructure"
235
+ "workerDirectory": "src/testing/infrastructure/public"
232
236
  },
233
237
  "module": "./dist/xmlui.mjs",
234
238
  "types": "./dist/xmlui.d.ts"
@@ -1,33 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2
- function getDefaultExportFromCjs(x) {
3
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
- }
5
- function getAugmentedNamespace(n) {
6
- if (n.__esModule) return n;
7
- var f = n.default;
8
- if (typeof f == "function") {
9
- var a = function a2() {
10
- if (this instanceof a2) {
11
- return Reflect.construct(f, arguments, this.constructor);
12
- }
13
- return f.apply(this, arguments);
14
- };
15
- a.prototype = f.prototype;
16
- } else a = {};
17
- Object.defineProperty(a, "__esModule", { value: true });
18
- Object.keys(n).forEach(function(k) {
19
- var d = Object.getOwnPropertyDescriptor(n, k);
20
- Object.defineProperty(a, k, d.get ? d : {
21
- enumerable: true,
22
- get: function() {
23
- return n[k];
24
- }
25
- });
26
- });
27
- return a;
28
- }
29
- export {
30
- getAugmentedNamespace as a,
31
- commonjsGlobal as c,
32
- getDefaultExportFromCjs as g
33
- };
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomOperationType = void 0;
4
- var CustomOperationType;
5
- (function (CustomOperationType) {
6
- CustomOperationType[CustomOperationType["MemberAccess"] = 0] = "MemberAccess";
7
- CustomOperationType[CustomOperationType["CalculatedMemberAccess"] = 1] = "CalculatedMemberAccess";
8
- CustomOperationType[CustomOperationType["UnaryPlus"] = 2] = "UnaryPlus";
9
- CustomOperationType[CustomOperationType["UnaryMinus"] = 3] = "UnaryMinus";
10
- CustomOperationType[CustomOperationType["LogicalNot"] = 4] = "LogicalNot";
11
- CustomOperationType[CustomOperationType["BitwiseNot"] = 5] = "BitwiseNot";
12
- CustomOperationType[CustomOperationType["Multiply"] = 6] = "Multiply";
13
- CustomOperationType[CustomOperationType["Divide"] = 7] = "Divide";
14
- CustomOperationType[CustomOperationType["Remainder"] = 8] = "Remainder";
15
- CustomOperationType[CustomOperationType["Add"] = 9] = "Add";
16
- CustomOperationType[CustomOperationType["Subtract"] = 10] = "Subtract";
17
- CustomOperationType[CustomOperationType["SignedRightShift"] = 11] = "SignedRightShift";
18
- CustomOperationType[CustomOperationType["UnsignedRightShift"] = 12] = "UnsignedRightShift";
19
- CustomOperationType[CustomOperationType["LeftShift"] = 13] = "LeftShift";
20
- CustomOperationType[CustomOperationType["LessThan"] = 14] = "LessThan";
21
- CustomOperationType[CustomOperationType["LessThanOrEqual"] = 15] = "LessThanOrEqual";
22
- CustomOperationType[CustomOperationType["GreaterThan"] = 16] = "GreaterThan";
23
- CustomOperationType[CustomOperationType["GreaterThanOrEqual"] = 17] = "GreaterThanOrEqual";
24
- CustomOperationType[CustomOperationType["Equal"] = 18] = "Equal";
25
- CustomOperationType[CustomOperationType["StrictEqual"] = 19] = "StrictEqual";
26
- CustomOperationType[CustomOperationType["NotEqual"] = 20] = "NotEqual";
27
- CustomOperationType[CustomOperationType["StrictNotEqual"] = 21] = "StrictNotEqual";
28
- CustomOperationType[CustomOperationType["BitwiseAnd"] = 22] = "BitwiseAnd";
29
- CustomOperationType[CustomOperationType["BitwiseXor"] = 23] = "BitwiseXor";
30
- CustomOperationType[CustomOperationType["BitwiseOr"] = 24] = "BitwiseOr";
31
- CustomOperationType[CustomOperationType["LogicalAnd"] = 25] = "LogicalAnd";
32
- CustomOperationType[CustomOperationType["LogicalOr"] = 26] = "LogicalOr";
33
- CustomOperationType[CustomOperationType["NullCoalesce"] = 27] = "NullCoalesce";
34
- })(CustomOperationType || (exports.CustomOperationType = CustomOperationType = {}));
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.customOperationsRegistry = void 0;
4
- /**
5
- * Represents a registry for custom operations
6
- */
7
- class CustomOperationsRegistry {
8
- constructor() {
9
- // --- Stores the register objects by their type ID
10
- this._registry = new Map();
11
- }
12
- /**
13
- * Registers the specified calculator
14
- * @param key Custom data object type
15
- * @param calculator Calculator instance
16
- */
17
- register(key, calculator) {
18
- this._registry.set(key, calculator);
19
- }
20
- /**
21
- * Gets the operation object for the specified type
22
- * @param key Type key
23
- * @return Operations object, if found; otherwise, undefined
24
- */
25
- getOperationsObjectByKey(key) {
26
- return this._registry.get(key);
27
- }
28
- /**
29
- * Gets all registered custom operations
30
- */
31
- getAllOperations() {
32
- return new Map(this._registry);
33
- }
34
- }
35
- // --- Register supported types
36
- const internalRegistry = new CustomOperationsRegistry();
37
- /**
38
- * The singleton instance of our registry
39
- */
40
- exports.customOperationsRegistry = internalRegistry;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OverflowInCalculationError = exports.UnexpectedTypeError = void 0;
4
- exports.isCustomUiData = isCustomUiData;
5
- /**
6
- * Type guard function for the CustomUiData type
7
- * @param data Object to guard
8
- */
9
- function isCustomUiData(data) {
10
- return data._custom_data_type_ !== undefined;
11
- }
12
- /**
13
- * Base class for all custom UI data related errors
14
- */
15
- class CustomUiDataError extends Error {
16
- constructor(message) {
17
- super(message);
18
- Object.setPrototypeOf(this, CustomUiDataError.prototype);
19
- }
20
- }
21
- /**
22
- * This error is raised when an operation gets an unexpected type
23
- */
24
- class UnexpectedTypeError extends CustomUiDataError {
25
- constructor(expectedType, detail) {
26
- super(`You must use ${expectedType} with the operation${detail ? " (" + detail + ")" : ""}`);
27
- Object.setPrototypeOf(this, UnexpectedTypeError.prototype);
28
- }
29
- }
30
- exports.UnexpectedTypeError = UnexpectedTypeError;
31
- /**
32
- * This error is raised when an operation gets an unexpected type
33
- */
34
- class OverflowInCalculationError extends CustomUiDataError {
35
- constructor(number) {
36
- super(`The decimal ${number} is too large to be saved`);
37
- Object.setPrototypeOf(this, OverflowInCalculationError.prototype);
38
- }
39
- }
40
- exports.OverflowInCalculationError = OverflowInCalculationError;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSyncProxy = getSyncProxy;
4
- const EngineError_1 = require("../EngineError");
5
- /**
6
- * Gets a proxy function for one that does not support async operations
7
- * @param fn Function to replace with a proxy
8
- * @param origArgs Original function arguments
9
- * @param context Function context ("this" of the function invocation)
10
- * @return The proxy, if found; otherwise the original function
11
- */
12
- function getSyncProxy(fn, origArgs, context) {
13
- const proxyInfo = syncProxies.get(fn);
14
- if (!proxyInfo)
15
- return fn;
16
- if (proxyInfo.validator) {
17
- const message = proxyInfo.validator(origArgs);
18
- if (message) {
19
- throw new EngineError_1.StatementExecutionError(message);
20
- }
21
- }
22
- origArgs.unshift(context);
23
- return proxyInfo.proxyFn;
24
- }
25
- // Async implementations for JavaScript functions that do not support async arguments
26
- const syncProxies = new Map();
27
- syncProxies.set(Array.prototype.sort, { proxyFn: sortAborter });
28
- function sortAborter() {
29
- throw new Error("The script engine does not support the sort() method as it " +
30
- "sorts an array in-place. Use the toSorted() function instead.");
31
- }
@@ -1,153 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PARSED_MARK_PROP = void 0;
4
- exports.collectCodeBehindFromSource = collectCodeBehindFromSource;
5
- exports.removeCodeBehindTokensFromTree = removeCodeBehindTokensFromTree;
6
- const tree_visitor_1 = require("./tree-visitor");
7
- const modules_1 = require("./modules");
8
- exports.PARSED_MARK_PROP = "__PARSED__";
9
- // --- Collect module statements from a parsed module
10
- function collectCodeBehindFromSource(moduleName, source, moduleResolver, moduleNameResolver) {
11
- const result = {
12
- vars: {},
13
- moduleErrors: {},
14
- functions: {},
15
- };
16
- const collectedFunctions = {};
17
- // --- Parse the module (recursively, including imported modules) in restrictive mode
18
- const parsedModule = (0, modules_1.parseScriptModule)(moduleName, source, moduleResolver, true);
19
- if ((0, modules_1.isModuleErrors)(parsedModule)) {
20
- return Object.assign(Object.assign({}, result), { moduleErrors: parsedModule });
21
- }
22
- const mainModuleResolvedName = moduleNameResolver(parsedModule.name);
23
- // --- Collect statements from the module
24
- parsedModule.statements.forEach((stmt) => {
25
- switch (stmt.type) {
26
- case "VarS":
27
- stmt.declarations.forEach((decl) => {
28
- if (decl.id in result.vars) {
29
- throw new Error(`Duplicated var declaration: '${decl.id}'`);
30
- }
31
- result.vars[decl.id] = {
32
- [exports.PARSED_MARK_PROP]: true,
33
- source: decl.expression.source,
34
- tree: decl.expression,
35
- };
36
- });
37
- break;
38
- case "FuncD":
39
- addFunctionDeclaration(mainModuleResolvedName, stmt);
40
- break;
41
- case "ImportD":
42
- // --- Do nothing
43
- break;
44
- default:
45
- throw new Error(`'${stmt.type}' is not allowed in a code-behind module.`);
46
- }
47
- });
48
- collectFuncs(parsedModule);
49
- return result;
50
- /** TODO: this exposes all the functions that were imported by any imported module
51
- * to the root module. Has the effect of imported functions beeing global to the root of the import tree.*/
52
- function collectFuncs(currentModule) {
53
- var _a, _b;
54
- const resolvedModuleName = moduleNameResolver(currentModule.name);
55
- if ((_a = collectedFunctions === null || collectedFunctions === void 0 ? void 0 : collectedFunctions[resolvedModuleName]) === null || _a === void 0 ? void 0 : _a.collectedImportsFrom) {
56
- return;
57
- }
58
- for (const modName in currentModule.imports) {
59
- const resolvedImportedModuleName = moduleNameResolver(modName);
60
- // if (mainModuleResolvedName === resolvedImportedModuleName) {
61
- // continue;
62
- // }
63
- const mod = currentModule.imports[modName];
64
- for (const obj of Object.values(mod)) {
65
- if (obj.type === "FuncD") {
66
- addFunctionDeclaration(resolvedImportedModuleName, obj);
67
- }
68
- }
69
- }
70
- (_b = collectedFunctions[resolvedModuleName]) !== null && _b !== void 0 ? _b : (collectedFunctions[resolvedModuleName] = { collectedImportsFrom: true });
71
- collectedFunctions[resolvedModuleName].collectedImportsFrom = true;
72
- for (let nextModule of currentModule.importedModules) {
73
- collectFuncs(nextModule);
74
- }
75
- }
76
- // --- Collect function declaration data
77
- function addFunctionDeclaration(resolvedModuleName, stmt) {
78
- var _a, _b, _c, _d, _e, _f;
79
- var _g;
80
- if (((_b = (_a = collectedFunctions === null || collectedFunctions === void 0 ? void 0 : collectedFunctions[resolvedModuleName]) === null || _a === void 0 ? void 0 : _a.functions) === null || _b === void 0 ? void 0 : _b[stmt.name]) !== undefined) {
81
- return;
82
- }
83
- if (stmt.name in result.functions) {
84
- throw new Error(`Duplicated function declaration: '${stmt.name}'`);
85
- }
86
- const funcSource = stmt.args.length === 1
87
- ? `${stmt.args[0].source} => ${stmt.statement.source}`
88
- : `(${stmt.args.map((a) => a.source).join(", ")}) => ${stmt.statement.source}`;
89
- const arrow = {
90
- type: "ArrowE",
91
- args: stmt.args.slice(),
92
- statement: stmt.statement,
93
- closureContext: (0, modules_1.obtainClosures)({
94
- childThreads: [],
95
- blocks: [{ vars: {} }],
96
- loops: [],
97
- breakLabelValue: -1,
98
- }),
99
- };
100
- // --- Remove the circular reference from the function to its closure context
101
- const functionSelf = (_d = (_c = arrow.closureContext[0]) === null || _c === void 0 ? void 0 : _c.vars) === null || _d === void 0 ? void 0 : _d[stmt.name];
102
- if (functionSelf === null || functionSelf === void 0 ? void 0 : functionSelf.closureContext) {
103
- delete functionSelf.closureContext;
104
- }
105
- (_e = collectedFunctions[resolvedModuleName]) !== null && _e !== void 0 ? _e : (collectedFunctions[resolvedModuleName] = { functions: {}, collectedImportsFrom: false });
106
- (_f = (_g = collectedFunctions[resolvedModuleName]).functions) !== null && _f !== void 0 ? _f : (_g.functions = {});
107
- collectedFunctions[resolvedModuleName].functions[stmt.name] = {
108
- [exports.PARSED_MARK_PROP]: true,
109
- source: funcSource,
110
- tree: arrow,
111
- };
112
- result.functions[stmt.name] = {
113
- [exports.PARSED_MARK_PROP]: true,
114
- source: funcSource,
115
- tree: arrow,
116
- };
117
- }
118
- }
119
- // --- Remove all code-behind tokens from the tree
120
- function removeCodeBehindTokensFromTree(declarations) {
121
- if (!declarations)
122
- return;
123
- const state = {
124
- data: null,
125
- cancel: false,
126
- skipChildren: false,
127
- };
128
- Object.keys(declarations.vars).forEach((key) => {
129
- removeTokens(declarations.vars[key]);
130
- });
131
- Object.keys(declarations.functions).forEach((key) => {
132
- removeTokens(declarations.functions[key]);
133
- });
134
- function removeTokens(declaration) {
135
- const nodeVisitor = (before, visited, state) => {
136
- if (before) {
137
- if (visited) {
138
- delete visited.startPosition;
139
- delete visited.endPosition;
140
- delete visited.startLine;
141
- delete visited.endLine;
142
- delete visited.startColumn;
143
- delete visited.endColumn;
144
- delete visited.startToken;
145
- delete visited.endToken;
146
- // delete visited.source;
147
- }
148
- }
149
- return state;
150
- };
151
- (0, tree_visitor_1.visitNode)(declaration.tree, state, nodeVisitor, nodeVisitor);
152
- }
153
- }