xmlui 0.9.43 → 0.9.45

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 (43) hide show
  1. package/dist/lib/{index-ODN_c1bh.mjs → apiInterceptorWorker-DzZYVTsV.mjs} +1920 -1362
  2. package/dist/lib/{core-BZ7lCE9p.mjs → core-CvFpTAHi.mjs} +154 -154
  3. package/dist/lib/{index-ClyH3BAn.mjs → index-erPY1EdW.mjs} +8823 -8695
  4. package/dist/lib/index.css +1 -1
  5. package/dist/lib/language-server-web-worker.mjs +1 -1
  6. package/dist/lib/language-server.mjs +1 -1
  7. package/dist/lib/{metadata-utils-DI1nTN3y.mjs → metadata-utils-Cf8v_9Lr.mjs} +7 -7
  8. package/dist/lib/{server-common-C3t9MFME.mjs → server-common-kMTAr-QU.mjs} +210 -178
  9. package/dist/lib/{transform-BV--wKhF.mjs → transform-DU7v4c9h.mjs} +1193 -1158
  10. package/dist/lib/xmlui-parser.d.ts +10 -3
  11. package/dist/lib/xmlui-parser.mjs +31 -30
  12. package/dist/lib/{xmlui-serializer-D5UV-ftG.mjs → xmlui-serializer-B3OkRzrr.mjs} +9 -9
  13. package/dist/lib/xmlui.d.ts +72 -1
  14. package/dist/lib/xmlui.mjs +33 -27
  15. package/dist/metadata/style.css +1 -1
  16. package/dist/metadata/xmlui-metadata.mjs +4264 -4234
  17. package/dist/metadata/xmlui-metadata.umd.js +10 -10
  18. package/dist/scripts/package.json +5 -1
  19. package/dist/scripts/src/components/App/App.js +140 -27
  20. package/dist/scripts/src/components/App/AppNative.js +2 -1
  21. package/dist/scripts/src/components/App/IndexerContext.js +44 -0
  22. package/dist/scripts/src/components/App/SearchContext.js +35 -0
  23. package/dist/scripts/src/components/CodeBlock/CodeBlock.js +1 -0
  24. package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +42 -34
  25. package/dist/scripts/src/components/CodeBlock/highlight-code.js +18 -6
  26. package/dist/scripts/src/components/Markdown/MarkdownNative.js +63 -27
  27. package/dist/scripts/src/components/NestedApp/NestedApp.js +4 -3
  28. package/dist/scripts/src/components/NestedApp/NestedAppNative.js +61 -66
  29. package/dist/scripts/src/components/Table/TableNative.js +4 -4
  30. package/dist/scripts/src/components/TableOfContents/TableOfContents.js +9 -1
  31. package/dist/scripts/src/components/Text/Text.js +2 -2
  32. package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -1
  33. package/dist/scripts/src/components/Theme/ThemeNative.js +5 -0
  34. package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.js +1 -0
  35. package/dist/scripts/src/components-core/loader/DataLoader.js +9 -1
  36. package/dist/scripts/src/components-core/rendering/Container.js +7 -0
  37. package/dist/scripts/src/components-core/theming/ThemeProvider.js +1 -2
  38. package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +10 -4
  39. package/dist/scripts/src/parsers/xmlui-parser/parser.js +74 -30
  40. package/dist/standalone/xmlui-standalone.es.d.ts +132 -2
  41. package/dist/standalone/xmlui-standalone.umd.js +234 -223
  42. package/package.json +5 -1
  43. package/dist/lib/apiInterceptorWorker-D4BjYgiG.mjs +0 -563
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.43",
3
+ "version": "0.9.45",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -105,6 +105,7 @@
105
105
  "vite-plugin-svgr": "4.2.0",
106
106
  "vscode-languageserver": "^9.0.1",
107
107
  "vscode-languageserver-textdocument": "^1.0.11",
108
+ "xml-formatter": "^3.6.6",
108
109
  "yargs": "17.7.2"
109
110
  },
110
111
  "devDependencies": {
@@ -148,6 +149,9 @@
148
149
  "@rollup/rollup-linux-x64-gnu": "4.20.0",
149
150
  "@rollup/rollup-win32-x64-msvc": "4.20.0"
150
151
  },
152
+ "resolutions": {
153
+ "@radix-ui/react-dismissable-layer": "1.1.10"
154
+ },
151
155
  "files": [
152
156
  "dist",
153
157
  "src/styles"
@@ -13,6 +13,10 @@ const metadata_helpers_1 = require("../../components/metadata-helpers");
13
13
  const AppLayoutContext_1 = require("./AppLayoutContext");
14
14
  const AppNative_1 = require("./AppNative");
15
15
  const react_1 = require("react");
16
+ const IndexerContext_1 = require("./IndexerContext");
17
+ const react_dom_1 = require("react-dom");
18
+ const AppContext_1 = require("../../components-core/AppContext");
19
+ const SearchContext_1 = require("./SearchContext");
16
20
  const COMP = "App";
17
21
  exports.AppMd = (0, ComponentDefs_1.createMetadata)({
18
22
  status: "stable",
@@ -75,7 +79,7 @@ exports.AppMd = (0, ComponentDefs_1.createMetadata)({
75
79
  },
76
80
  themeVars: (0, themeVars_1.parseScssVar)(App_module_scss_1.default.themeVars),
77
81
  themeVarDescriptions: {
78
- "maxWidthcontentApp": "This theme variable defines the maximum width of the main content. If the main " +
82
+ "maxWidth-content-App": "This theme variable defines the maximum width of the main content. If the main " +
79
83
  "content is broader, the engine adds margins to keep the expected maximum size.",
80
84
  "boxShadow‑header‑App": "This theme variable sets the shadow of the app's header section.",
81
85
  "boxShadow‑navPanel‑App": "This theme variable sets the shadow of the app's navigation panel section " +
@@ -153,11 +157,11 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
153
157
  const cache = new Map();
154
158
  return (searchLabel, hierarchy) => {
155
159
  // Create a cache key (could be improved with a better serialization of hierarchy)
156
- const cacheKey = searchLabel + '_' + hierarchy.length;
160
+ const cacheKey = searchLabel + "_" + hierarchy.length;
157
161
  if (cache.has(cacheKey)) {
158
162
  return cache.get(cacheKey);
159
163
  }
160
- const result = hierarchy.some(node => {
164
+ const result = hierarchy.some((node) => {
161
165
  if (node.label === searchLabel) {
162
166
  return true;
163
167
  }
@@ -174,11 +178,7 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
174
178
  const findOrCreateNavGroup = (0, react_1.useMemo)(() => {
175
179
  return (navItems, groupLabel) => {
176
180
  // --- Check if a NavGroup with this label already exists
177
- const existingGroup = navItems.find(item => {
178
- var _a;
179
- return item.type === "NavGroup" &&
180
- ((_a = item.props) === null || _a === void 0 ? void 0 : _a.label) === groupLabel;
181
- });
181
+ const existingGroup = navItems.find((item) => { var _a; return item.type === "NavGroup" && ((_a = item.props) === null || _a === void 0 ? void 0 : _a.label) === groupLabel; });
182
182
  if (existingGroup) {
183
183
  return existingGroup;
184
184
  }
@@ -186,15 +186,15 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
186
186
  const newGroup = {
187
187
  type: "NavGroup",
188
188
  props: {
189
- label: groupLabel
189
+ label: groupLabel,
190
190
  },
191
- children: []
191
+ children: [],
192
192
  };
193
193
  navItems.push(newGroup);
194
194
  return newGroup;
195
195
  };
196
196
  }, []);
197
- const { AppHeader, Footer, NavPanel, restChildren } = (0, react_1.useMemo)(() => {
197
+ const { AppHeader, Footer, NavPanel, Pages, restChildren } = (0, react_1.useMemo)(() => {
198
198
  var _a;
199
199
  let AppHeader;
200
200
  let Footer;
@@ -254,7 +254,7 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
254
254
  NavPanel = {
255
255
  type: "NavPanel",
256
256
  props: {},
257
- children: extraNavs
257
+ children: extraNavs,
258
258
  };
259
259
  }
260
260
  }
@@ -262,9 +262,16 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
262
262
  AppHeader,
263
263
  Footer,
264
264
  NavPanel,
265
+ Pages,
265
266
  restChildren,
266
267
  };
267
- }, [node.children, parseHierarchyLabels, labelExistsInHierarchy, findOrCreateNavGroup]);
268
+ }, [
269
+ node.children,
270
+ extractValue,
271
+ parseHierarchyLabels,
272
+ labelExistsInHierarchy,
273
+ findOrCreateNavGroup,
274
+ ]);
268
275
  // --- Memoize all app props to prevent unnecessary re-renders
269
276
  const appProps = (0, react_1.useMemo)(() => ({
270
277
  scrollWholePage: extractValue.asOptionalBoolean(node.props.scrollWholePage, true),
@@ -278,7 +285,7 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
278
285
  logoDark: extractValue(node.props["logo-dark"]),
279
286
  logoLight: extractValue(node.props["logo-light"]),
280
287
  defaultTone: extractValue(node.props.defaultTone),
281
- defaultTheme: extractValue(node.props.defaultTheme)
288
+ defaultTheme: extractValue(node.props.defaultTheme),
282
289
  }), [
283
290
  extractValue,
284
291
  layoutType,
@@ -292,14 +299,124 @@ function AppNode({ node, extractValue, renderChild, style, lookupEventHandler })
292
299
  node.props["logo-light"],
293
300
  node.props.defaultTone,
294
301
  node.props.defaultTheme,
295
- style
302
+ style,
296
303
  ]);
297
304
  // Memoize the rendered children to prevent unnecessary re-renders
298
305
  const renderedHeader = (0, react_1.useMemo)(() => renderChild(AppHeader), [AppHeader, renderChild]);
299
306
  const renderedFooter = (0, react_1.useMemo)(() => renderChild(Footer), [Footer, renderChild]);
300
307
  const renderedNavPanel = (0, react_1.useMemo)(() => renderChild(NavPanel), [NavPanel, renderChild]);
301
308
  const renderedContent = (0, react_1.useMemo)(() => renderChild(restChildren), [restChildren, renderChild]);
302
- return ((0, jsx_runtime_1.jsx)(AppNative_1.App, Object.assign({}, appProps, { header: renderedHeader, footer: renderedFooter, navPanel: renderedNavPanel, navPanelDef: NavPanel, logoContentDef: node.props.logoTemplate, renderChild: renderChild, children: renderedContent })));
309
+ return ((0, jsx_runtime_1.jsxs)(AppNative_1.App, Object.assign({}, appProps, { header: renderedHeader, footer: renderedFooter, navPanel: renderedNavPanel, navPanelDef: NavPanel, logoContentDef: node.props.logoTemplate, renderChild: renderChild, children: [renderedContent, (0, jsx_runtime_1.jsx)(SearchIndexCollector, { Pages: Pages, renderChild: renderChild })] })));
310
+ }
311
+ const HIDDEN_STYLE = {
312
+ display: "none",
313
+ };
314
+ function SearchIndexCollector({ Pages, renderChild }) {
315
+ var _a, _b;
316
+ const appContext = (0, AppContext_1.useAppContext)();
317
+ const indexerContextValue = (0, react_1.useMemo)(() => ({ indexing: true }), []);
318
+ const setIndexing = (0, SearchContext_1.useSearchContextSetIndexing)();
319
+ const [isClient, setIsClient] = (0, react_1.useState)(false);
320
+ (0, react_1.useEffect)(() => {
321
+ setIsClient(true); // Ensure document.body is available
322
+ return () => {
323
+ setIndexing(false);
324
+ };
325
+ }, [setIndexing]);
326
+ // 1. Memoize the list of pages to be indexed
327
+ const pagesToIndex = (0, react_1.useMemo)(() => {
328
+ var _a;
329
+ return (((_a = Pages === null || Pages === void 0 ? void 0 : Pages.children) === null || _a === void 0 ? void 0 : _a.filter((child) => {
330
+ var _a;
331
+ return child.type === "Page" && // Ensure 'Page' matches your actual component type name
332
+ ((_a = child.props) === null || _a === void 0 ? void 0 : _a.url) && // Ensure URL exists
333
+ !child.props.url.includes("*") &&
334
+ !child.props.url.includes(":");
335
+ })) || []);
336
+ }, [Pages === null || Pages === void 0 ? void 0 : Pages.children]);
337
+ const [currentIndex, setCurrentIndex] = (0, react_1.useState)(0);
338
+ const [isDoneIndexing, setIsDoneIndexing] = (0, react_1.useState)(false);
339
+ const [, startTransitionParent] = (0, react_1.useTransition)(); // Transition for parent updates
340
+ const handlePageIndexed = (0, react_1.useCallback)(() => {
341
+ startTransitionParent(() => {
342
+ // Transition the update to the next page
343
+ setCurrentIndex((prevIndex) => {
344
+ const nextIndex = prevIndex + 1;
345
+ if (nextIndex >= pagesToIndex.length) {
346
+ // console.log("All pages indexed.");
347
+ setIsDoneIndexing(true); // All pages processed
348
+ }
349
+ return nextIndex;
350
+ });
351
+ });
352
+ }, [pagesToIndex.length]); // Recreate if the total number of pages changes
353
+ if (!((_a = appContext.appGlobals) === null || _a === void 0 ? void 0 : _a.searchIndexEnabled) || isDoneIndexing || !isClient) {
354
+ return null;
355
+ }
356
+ const currentPageToProcess = pagesToIndex[currentIndex];
357
+ if (!currentPageToProcess) {
358
+ // This can happen if pagesToIndex is empty or currentIndex went out of bounds unexpectedly.
359
+ // Setting isDoneIndexing if pagesToIndex is empty initially.
360
+ if (pagesToIndex.length === 0 && currentIndex === 0 && !isDoneIndexing) {
361
+ setIsDoneIndexing(true);
362
+ }
363
+ return null;
364
+ }
365
+ return ((0, jsx_runtime_1.jsx)(IndexerContext_1.IndexerContext.Provider, { value: indexerContextValue, children: (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { style: HIDDEN_STYLE, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(PageIndexer, { Page: currentPageToProcess, renderChild: renderChild, onIndexed: handlePageIndexed }, ((_b = currentPageToProcess.props) === null || _b === void 0 ? void 0 : _b.url) || currentIndex) }), document.body) }));
366
+ }
367
+ function PageIndexer({ Page, renderChild, onIndexed, }) {
368
+ var _a, _b;
369
+ const contentRef = (0, react_1.useRef)(null);
370
+ const pageUrl = ((_a = Page.props) === null || _a === void 0 ? void 0 : _a.url) || "";
371
+ const navLabel = ((_b = Page.props) === null || _b === void 0 ? void 0 : _b.navLabel) || "";
372
+ const searchContextUpdater = (0, SearchContext_1.useSearchContextUpdater)();
373
+ const [isContentRendered, setIsContentRendered] = (0, react_1.useState)(false);
374
+ const [isCollected, setIsCollected] = (0, react_1.useState)(false);
375
+ const [isProcessing, startTransition] = (0, react_1.useTransition)();
376
+ // Effect 1: Schedule the rendering of the Page's children (low priority)
377
+ (0, react_1.useEffect)(() => {
378
+ // console.log(`PageIndexer (${pageUrl}): Scheduling content render.`);
379
+ startTransition(() => {
380
+ setIsContentRendered(true); // This will trigger rendering of Page.children
381
+ });
382
+ }, [pageUrl]); // Re-run if the Page prop itself changes identity (due to key in parent)
383
+ // Effect 2: Extract content once Page.children is rendered and ref is available (low priority)
384
+ (0, react_1.useEffect)(() => {
385
+ if (isContentRendered && contentRef.current && !isCollected && !isProcessing) {
386
+ // console.log(`PageIndexer (${pageUrl}): Content rendered, scheduling extraction.`);
387
+ startTransition(() => {
388
+ // console.log(`PageIndexer (${pageUrl}): Starting extraction...`);
389
+ const currentContent = contentRef.current; // Capture ref value
390
+ if (!currentContent)
391
+ return;
392
+ const clone = currentContent.cloneNode(true);
393
+ const elementsToRemove = clone.querySelectorAll("style, script");
394
+ elementsToRemove.forEach((el) => el.remove());
395
+ const textContent = (clone.textContent || "").trim().replace(/\s+/g, " ");
396
+ const titleElement = currentContent.querySelector("h1");
397
+ const title = titleElement ? titleElement.innerText : (navLabel || pageUrl.split("/").pop() || pageUrl);
398
+ const entry = {
399
+ title: title,
400
+ content: textContent,
401
+ path: pageUrl,
402
+ };
403
+ searchContextUpdater(entry);
404
+ // console.log(`PageIndexer (${pageUrl}): Extraction complete, signaling parent.`);
405
+ onIndexed(); // Signal completion to parent
406
+ setIsCollected(true); // Mark as collected
407
+ });
408
+ }
409
+ }, [isContentRendered, pageUrl, searchContextUpdater, onIndexed, isCollected, isProcessing, navLabel]); // Ensure all dependencies are listed
410
+ // If this PageIndexer instance's work is done, or content not yet rendered, render nothing.
411
+ // The parent (SearchIndexCollector) will unmount this and mount the next one.
412
+ if (isCollected || !isContentRendered) {
413
+ // console.log(`PageIndexer (${pageUrl}): Null render (isCollected: ${isCollected}, isContentRendered: ${isContentRendered})`);
414
+ return null;
415
+ }
416
+ // This part renders when isContentRendered is true and isCollected is false.
417
+ // The content needs to be in the DOM for contentRef.current to be populated.
418
+ // console.log(`PageIndexer (${pageUrl}): Rendering content for ref population.`);
419
+ return (0, jsx_runtime_1.jsx)("div", { ref: contentRef, children: renderChild(Page.children) });
303
420
  }
304
421
  exports.appRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.AppMd, ({ node, extractValue, renderChild, layoutCss, lookupEventHandler }) => {
305
422
  return ((0, jsx_runtime_1.jsx)(AppNode, { node: node, renderChild: renderChild, extractValue: extractValue, style: layoutCss, lookupEventHandler: lookupEventHandler }));
@@ -323,7 +440,7 @@ function processNavItems(items, parentHierarchy, extractValue) {
323
440
  parentHierarchy.push({
324
441
  type: "NavLink",
325
442
  label: labelValue,
326
- path: itemPath ? extractValue(itemPath) : undefined
443
+ path: itemPath ? extractValue(itemPath) : undefined,
327
444
  });
328
445
  }
329
446
  }
@@ -336,7 +453,7 @@ function processNavItems(items, parentHierarchy, extractValue) {
336
453
  const groupNode = {
337
454
  type: "NavGroup",
338
455
  label: labelValue,
339
- children: []
456
+ children: [],
340
457
  };
341
458
  // --- Add to parent hierarchy
342
459
  parentHierarchy.push(groupNode);
@@ -387,8 +504,8 @@ function extractNavPanelFromPages(Pages, NavPanel, processedNavRef, extractValue
387
504
  type: "NavLink",
388
505
  props: {
389
506
  label: hierarchyLabels[0],
390
- to: url
391
- }
507
+ to: url,
508
+ },
392
509
  });
393
510
  }
394
511
  return;
@@ -409,18 +526,14 @@ function extractNavPanelFromPages(Pages, NavPanel, processedNavRef, extractValue
409
526
  // --- Add the leaf NavLink to the deepest NavGroup
410
527
  const leafLabel = hierarchyLabels[hierarchyLabels.length - 1];
411
528
  // --- Check if this NavLink already exists at this level
412
- const existingNavLink = currentLevel.find(item => {
413
- var _a;
414
- return item.type === "NavLink" &&
415
- ((_a = item.props) === null || _a === void 0 ? void 0 : _a.label) === leafLabel;
416
- });
529
+ const existingNavLink = currentLevel.find((item) => { var _a; return item.type === "NavLink" && ((_a = item.props) === null || _a === void 0 ? void 0 : _a.label) === leafLabel; });
417
530
  if (!existingNavLink) {
418
531
  currentLevel.push({
419
532
  type: "NavLink",
420
533
  props: {
421
534
  label: leafLabel,
422
- to: url
423
- }
535
+ to: url,
536
+ },
424
537
  });
425
538
  }
426
539
  }
@@ -31,6 +31,7 @@ const css_utils_1 = require("../../components-core/utils/css-utils");
31
31
  const Sheet_1 = require("../../components/App/Sheet");
32
32
  const AppHeaderNative_1 = require("../../components/AppHeader/AppHeaderNative");
33
33
  const AppLayoutContext_1 = require("./AppLayoutContext");
34
+ const SearchContext_1 = require("./SearchContext");
34
35
  function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollbarGutters = false, onReady = lodash_es_1.noop, header, navPanel, footer, navPanelDef, logoContentDef, logo, logoDark, logoLight, defaultTone, defaultTheme, renderChild, name, }) {
35
36
  const { getThemeVar } = (0, ThemeContext_1.useTheme)();
36
37
  const { setActiveThemeTone, setActiveThemeId, themes } = (0, ThemeContext_1.useThemes)();
@@ -227,7 +228,7 @@ function App({ children, style, layout, loggedInUser, scrollWholePage, noScrollb
227
228
  const handleOpenChange = (0, react_1.useCallback)((open) => {
228
229
  setDrawerVisible(open);
229
230
  }, []);
230
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [memoizedHelmet, (0, jsx_runtime_1.jsxs)(AppLayoutContext_1.AppLayoutContext.Provider, { value: layoutContextValue, children: [(0, jsx_runtime_1.jsx)(Sheet_1.Sheet, { open: drawerVisible, onOpenChange: handleOpenChange, children: (0, jsx_runtime_1.jsx)(Sheet_1.SheetContent, { side: "left", children: memoizedNavPanelInDrawer }) }), content] })] }));
231
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [memoizedHelmet, (0, jsx_runtime_1.jsxs)(AppLayoutContext_1.AppLayoutContext.Provider, { value: layoutContextValue, children: [(0, jsx_runtime_1.jsx)(Sheet_1.Sheet, { open: drawerVisible, onOpenChange: handleOpenChange, children: (0, jsx_runtime_1.jsx)(Sheet_1.SheetContent, { side: "left", children: memoizedNavPanelInDrawer }) }), (0, jsx_runtime_1.jsx)(SearchContext_1.SearchContextProvider, { children: content })] })] }));
231
232
  }
232
233
  function getAppLayoutOrientation(appLayout) {
233
234
  switch (appLayout) {
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.IndexerContext = void 0;
37
+ exports.useIndexerContext = useIndexerContext;
38
+ const react_1 = __importStar(require("react"));
39
+ exports.IndexerContext = react_1.default.createContext({
40
+ indexing: false
41
+ });
42
+ function useIndexerContext() {
43
+ return (0, react_1.useContext)(exports.IndexerContext);
44
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSearchContextSetIndexing = exports.useSearchContextContent = exports.useSearchContextUpdater = exports.SearchContextProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_context_selector_1 = require("use-context-selector");
6
+ const react_1 = require("react");
7
+ const constants_1 = require("../../components-core/constants");
8
+ const SearchContext = (0, use_context_selector_1.createContext)(null);
9
+ const SearchContextProvider = ({ children }) => {
10
+ const [content, setContent] = (0, react_1.useState)(constants_1.EMPTY_OBJECT);
11
+ const [isIndexing, setIsIndexing] = (0, react_1.useState)(true);
12
+ const storeContent = (0, react_1.useCallback)((entry) => {
13
+ setContent((prevContent) => (Object.assign(Object.assign({}, prevContent), { [entry.path]: entry })));
14
+ }, []);
15
+ const value = (0, react_1.useMemo)(() => ({
16
+ content,
17
+ storeContent,
18
+ isIndexing,
19
+ setIsIndexing
20
+ }), [content, isIndexing, storeContent]);
21
+ return (0, jsx_runtime_1.jsx)(SearchContext.Provider, { value: value, children: children });
22
+ };
23
+ exports.SearchContextProvider = SearchContextProvider;
24
+ const useSearchContextUpdater = () => {
25
+ return (0, use_context_selector_1.useContextSelector)(SearchContext, (value) => value.storeContent);
26
+ };
27
+ exports.useSearchContextUpdater = useSearchContextUpdater;
28
+ const useSearchContextContent = () => {
29
+ return (0, use_context_selector_1.useContextSelector)(SearchContext, (value) => value.content);
30
+ };
31
+ exports.useSearchContextContent = useSearchContextContent;
32
+ const useSearchContextSetIndexing = () => {
33
+ return (0, use_context_selector_1.useContextSelector)(SearchContext, (value) => value.setIsIndexing);
34
+ };
35
+ exports.useSearchContextSetIndexing = useSearchContextSetIndexing;
@@ -24,6 +24,7 @@ exports.CodeBlockMd = (0, ComponentDefs_1.createMetadata)({
24
24
  "backgroundColor-CodeBlock-highlightRow": "rgba($color-primary-200-rgb, .25)",
25
25
  "backgroundColor-CodeBlock-highlightString": "rgba($color-primary-200-rgb, .5)",
26
26
  "borderRadius-CodeBlock": "$space-2",
27
+ "borderColor-CodeBlock-highlightString-emphasis": "$color-attention",
27
28
  dark: {
28
29
  "backgroundColor-CodeBlock-header": "$color-surface-200",
29
30
  "backgroundColor-CodeBlock": "$color-surface-50",
@@ -17,9 +17,9 @@ const react_hot_toast_1 = __importDefault(require("react-hot-toast"));
17
17
  const unist_util_visit_1 = require("unist-util-visit");
18
18
  function CodeBlock({ children, meta, textToCopy, style }) {
19
19
  if (!meta) {
20
- return ((0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlock, style: style, children: children }));
20
+ return ((0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlock, style: style, children: (0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlockContent, children: children }) }));
21
21
  }
22
- return ((0, jsx_runtime_1.jsxs)("div", { className: CodeBlock_module_scss_1.default.codeBlock, style: style, children: [meta.filename && ((0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlockHeader, children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { variant: "em", children: meta.filename }) })), (0, jsx_runtime_1.jsxs)("div", { className: CodeBlock_module_scss_1.default.codeBlockCopyWrapper, children: [children, (0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlockCopyButton, children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "outlined", themeColor: "primary", size: "sm", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "copy", "aria-hidden": true }), onClick: () => {
22
+ return ((0, jsx_runtime_1.jsxs)("div", { className: CodeBlock_module_scss_1.default.codeBlock, style: style, children: [meta.filename && ((0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlockHeader, children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { variant: "em", children: meta.filename }) })), (0, jsx_runtime_1.jsxs)("div", { className: CodeBlock_module_scss_1.default.codeBlockContent, children: [children, (0, jsx_runtime_1.jsx)("div", { className: CodeBlock_module_scss_1.default.codeBlockCopyButton, children: (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "outlined", themeColor: "primary", size: "sm", icon: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "copy", "aria-hidden": true }), onClick: () => {
23
23
  if (!textToCopy)
24
24
  return;
25
25
  navigator.clipboard.writeText(textToCopy);
@@ -76,43 +76,51 @@ function markdownCodeBlockParser() {
76
76
  item = item.trim();
77
77
  if (item === "")
78
78
  return acc;
79
- if (item.indexOf("=") === -1) {
80
- if (item.startsWith("/") && item.endsWith("/")) {
81
- const unparsedSubstrings = acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data];
82
- const newItemBase64 = decodeValue(item.substring(1, item.length - 1));
83
- if (!unparsedSubstrings) {
84
- acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data] = newItemBase64;
85
- }
86
- else {
87
- acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data] =
88
- `${unparsedSubstrings} ${newItemBase64}`;
89
- }
79
+ if (item.toLocaleLowerCase().startsWith("filename=")) {
80
+ const index = item.indexOf("=");
81
+ acc[highlight_code_1.CodeHighlighterMetaKeys.filename.data] = item
82
+ .substring(index + 1)
83
+ .replace(/"(.+)"/, "$1")
84
+ .replace(/'(.+)'/, "$1");
85
+ }
86
+ if (item.startsWith("/") && item.endsWith("/")) {
87
+ const unparsedSubstrings = acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data];
88
+ const newItemBase64 = decodeValue(item.substring(1, item.length - 1));
89
+ if (!unparsedSubstrings) {
90
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data] = newItemBase64;
90
91
  }
91
- if (item.startsWith("{") && item.endsWith("}")) {
92
- const unparsedRows = acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data];
93
- const newItem = item.substring(1, item.length - 1);
94
- if (!unparsedRows) {
95
- acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data] = newItem;
96
- }
97
- else {
98
- acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data] = `${unparsedRows}, ${newItem}`;
99
- }
92
+ else {
93
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstrings.data] =
94
+ `${unparsedSubstrings} ${newItemBase64}`;
100
95
  }
101
- if (item === "copy") {
102
- acc[highlight_code_1.CodeHighlighterMetaKeys.copy.data] = "true";
96
+ }
97
+ if (item.startsWith("!/") && item.endsWith("/")) {
98
+ const unparsedSubstrings = acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstringsEmphasized.data];
99
+ const newItemBase64 = decodeValue(item.substring(2, item.length - 1));
100
+ if (!unparsedSubstrings) {
101
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstringsEmphasized.data] = newItemBase64;
103
102
  }
104
- if (item === "rowNumbers") {
105
- acc[highlight_code_1.CodeHighlighterMetaKeys.rowNumbers.data] = "true";
103
+ else {
104
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightSubstringsEmphasized.data] =
105
+ `${unparsedSubstrings} ${newItemBase64}`;
106
106
  }
107
- return acc;
108
107
  }
109
- const index = item.indexOf("=");
110
- if (item.substring(0, index) !== "filename")
111
- return acc;
112
- acc["dataFilename"] = item
113
- .substring(index + 1)
114
- .replace(/"(.+)"/, "$1")
115
- .replace(/'(.+)'/, "$1");
108
+ if (item.startsWith("{") && item.endsWith("}")) {
109
+ const unparsedRows = acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data];
110
+ const newItem = item.substring(1, item.length - 1);
111
+ if (!unparsedRows) {
112
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data] = newItem;
113
+ }
114
+ else {
115
+ acc[highlight_code_1.CodeHighlighterMetaKeys.highlightRows.data] = `${unparsedRows}, ${newItem}`;
116
+ }
117
+ }
118
+ if (item === "copy") {
119
+ acc[highlight_code_1.CodeHighlighterMetaKeys.copy.data] = "true";
120
+ }
121
+ if (item === "rowNumbers") {
122
+ acc[highlight_code_1.CodeHighlighterMetaKeys.rowNumbers.data] = "true";
123
+ }
116
124
  return acc;
117
125
  }, {});
118
126
  nodeData.hProperties = Object.assign(Object.assign({}, nodeData.hProperties), parsedMeta);
@@ -18,6 +18,7 @@ exports.isCodeHighlighter = isCodeHighlighter;
18
18
  const react_1 = require("react");
19
19
  const highlightRowsClass = "codeBlockHighlightRow";
20
20
  const highlightSubstringsClass = "codeBlockHighlightString";
21
+ const highlightSubstringsEmphasisClass = "codeBlockHighlightStringEmphasis";
21
22
  /*
22
23
  * Encode string, returns base64 value
23
24
  * @Params: string
@@ -27,11 +28,11 @@ function encodeValue(value) {
27
28
  return null;
28
29
  }
29
30
  const valueToString = value.toString();
30
- if (typeof window !== 'undefined') {
31
+ if (typeof window !== "undefined") {
31
32
  return window.atob(valueToString);
32
33
  }
33
- const buff = Buffer.from(valueToString, 'base64');
34
- return buff.toString('ascii');
34
+ const buff = Buffer.from(valueToString, "base64");
35
+ return buff.toString("ascii");
35
36
  }
36
37
  /**
37
38
  * This function handles two things:
@@ -126,9 +127,13 @@ function extractMetaFromChildren(node, keys, code = "") {
126
127
  [exports.CodeHighlighterMetaKeys.language.prop]: meta[exports.CodeHighlighterMetaKeys.language.data],
127
128
  [exports.CodeHighlighterMetaKeys.copy.prop]: parseBoolean(meta[exports.CodeHighlighterMetaKeys.copy.data]),
128
129
  [exports.CodeHighlighterMetaKeys.filename.prop]: meta[exports.CodeHighlighterMetaKeys.filename.data],
129
- [exports.CodeHighlighterMetaKeys.rowNumbers.prop]: parseBoolean(meta[exports.CodeHighlighterMetaKeys.rowNumbers.data]),
130
+ // NOTE: Row numbers are disabled for now, because applying the highlight class removes the "numbered" class
131
+ /* [CodeHighlighterMetaKeys.rowNumbers.prop]: parseBoolean(
132
+ meta[CodeHighlighterMetaKeys.rowNumbers.data],
133
+ ), */
130
134
  [exports.CodeHighlighterMetaKeys.highlightRows.prop]: parseRowHighlights(code.split("\n").length, meta[exports.CodeHighlighterMetaKeys.highlightRows.data]),
131
135
  [exports.CodeHighlighterMetaKeys.highlightSubstrings.prop]: parseSubstringHighlights(code, meta[exports.CodeHighlighterMetaKeys.highlightSubstrings.data]),
136
+ [exports.CodeHighlighterMetaKeys.highlightSubstringsEmphasized.prop]: parseSubstringHighlights(code, meta[exports.CodeHighlighterMetaKeys.highlightSubstringsEmphasized.data], true),
132
137
  };
133
138
  }
134
139
  return {};
@@ -182,7 +187,7 @@ function parseRowHighlights(codeLines, str) {
182
187
  return parsed;
183
188
  }
184
189
  }
185
- function parseSubstringHighlights(code, str) {
190
+ function parseSubstringHighlights(code, str, emphasized = false) {
186
191
  if (!str)
187
192
  return [];
188
193
  if (!code)
@@ -190,6 +195,7 @@ function parseSubstringHighlights(code, str) {
190
195
  return str
191
196
  .split(" ")
192
197
  .map((item) => encodeValue(item))
198
+ .filter((item) => item.trim() !== "")
193
199
  .reduce((acc, item) => acc.concat(findAllNonOverlappingSubstrings(code, item)), []);
194
200
  function findAllNonOverlappingSubstrings(str, code) {
195
201
  const result = [];
@@ -202,7 +208,9 @@ function parseSubstringHighlights(code, str) {
202
208
  result.push({
203
209
  start: index,
204
210
  end: index + searchLength,
205
- properties: { class: highlightSubstringsClass },
211
+ properties: {
212
+ class: emphasized ? highlightSubstringsEmphasisClass : highlightSubstringsClass,
213
+ },
206
214
  });
207
215
  startIndex = index + searchLength; // Jump past this match
208
216
  }
@@ -219,5 +227,9 @@ exports.CodeHighlighterMetaKeys = {
219
227
  rowNumbers: { data: "data-row-numbers", prop: "rowNumbers" },
220
228
  highlightRows: { data: "data-highlight-rows", prop: "highlightRows" },
221
229
  highlightSubstrings: { data: "data-highlight-substrings", prop: "highlightSubstrings" },
230
+ highlightSubstringsEmphasized: {
231
+ data: "data-highlight-substrings-emp",
232
+ prop: "highlightSubstringsEmphasized",
233
+ },
222
234
  };
223
235
  exports.CodeHighlighterMetaKeysData = Object.values(exports.CodeHighlighterMetaKeys).map((item) => item.data);