Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/worktrees/agent-a56a86cd
Submodule agent-a56a86cd added at 1654b1
1 change: 1 addition & 0 deletions .claude/worktrees/agent-a9b692e8
Submodule agent-a9b692e8 added at 44b53a
1 change: 1 addition & 0 deletions .claude/worktrees/agent-aa3bc5c6
Submodule agent-aa3bc5c6 added at e4afc8
1 change: 1 addition & 0 deletions .claude/worktrees/agent-ad128e34
Submodule agent-ad128e34 added at a9ee7e
1 change: 1 addition & 0 deletions .claude/worktrees/cs-10651-skipped-tests
Submodule cs-10651-skipped-tests added at 7d4c4a
1 change: 1 addition & 0 deletions .claude/worktrees/cs-10723-issue-scoped-pipeline
Submodule cs-10723-issue-scoped-pipeline added at e7fd70
1 change: 1 addition & 0 deletions packages/ai-bot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand Down
8 changes: 5 additions & 3 deletions packages/base/default-templates/markdown.gts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import { eq } from '@cardstack/boxel-ui/helpers';

import {
extractMermaidBlocks,
hasCodeBlocks,
markdownToHtml,
preloadMarkdownLanguages,
processKatexPlaceholders,
replaceMermaidSvgs,
resolveCardReference,
trimJsonExtension,
} from '@cardstack/runtime-common';
import {
hasCodeBlocks,
markdownToHtml,
preloadMarkdownLanguages,
} from '@cardstack/runtime-common/marked-sync';
import { type BaseDef, type CardDef, getComponent } from '../card-api';
import { CardContextConsumer } from '../field-component';
function wrapTablesHtml(html: string | null | undefined): string {
Expand Down
1 change: 1 addition & 0 deletions packages/billing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand Down
1 change: 1 addition & 0 deletions packages/bot-runner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand Down
12 changes: 9 additions & 3 deletions packages/catalog-realm/blog-app/blog-post.gts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ import { Author } from './author';
import { formatDatetime, BlogApp as BlogAppCard } from './blog-app';
import { BlogCategory, categoryStyle } from './blog-category';
import { User } from './user';
import { markdownToHtml } from '@cardstack/runtime-common';
import { markdownToHtml } from '@cardstack/runtime-common/marked-sync';
import FeaturedImageField from '../fields/featured-image';

class EmbeddedTemplate extends Component<typeof BlogPost> {
<template>
<article class='embedded-blog-post'>
<div class='thumbnail' style={{setBackgroundImage @model.cardThumbnailURL}} />
<div
class='thumbnail'
style={{setBackgroundImage @model.cardThumbnailURL}}
/>
{{#if @model.categories.length}}
<div class='categories'>
{{#each @model.categories as |category|}}
Expand Down Expand Up @@ -129,7 +132,10 @@ class EmbeddedTemplate extends Component<typeof BlogPost> {
class FittedTemplate extends Component<typeof BlogPost> {
<template>
<article class='fitted-blog-post'>
<div class='thumbnail' style={{setBackgroundImage @model.cardThumbnailURL}} />
<div
class='thumbnail'
style={{setBackgroundImage @model.cardThumbnailURL}}
/>
<div class='categories'>
{{#each @model.categories as |category|}}
<div class='category' style={{categoryStyle category}}>
Expand Down
12 changes: 9 additions & 3 deletions packages/experiments-realm/blog-post.gts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import { Author } from './author';
import { formatDatetime, BlogApp as BlogAppCard } from './blog-app';
import { BlogCategory, categoryStyle } from './blog-category';
import { User } from './user';
import { markdownToHtml } from '@cardstack/runtime-common';
import { markdownToHtml } from '@cardstack/runtime-common/marked-sync';

class EmbeddedTemplate extends Component<typeof BlogPost> {
<template>
<article class='embedded-blog-post'>
<div class='thumbnail' style={{setBackgroundImage @model.cardThumbnailURL}} />
<div
class='thumbnail'
style={{setBackgroundImage @model.cardThumbnailURL}}
/>
{{#if @model.categories.length}}
<div class='categories'>
{{#each @model.categories as |category|}}
Expand Down Expand Up @@ -129,7 +132,10 @@ class EmbeddedTemplate extends Component<typeof BlogPost> {
class FittedTemplate extends Component<typeof BlogPost> {
<template>
<article class='fitted-blog-post'>
<div class='thumbnail' style={{setBackgroundImage @model.cardThumbnailURL}} />
<div
class='thumbnail'
style={{setBackgroundImage @model.cardThumbnailURL}}
/>
<div class='categories'>
{{#each @model.categories as |category|}}
<div class='category' style={{categoryStyle category}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cached, tracked } from '@glimmer/tracking';
import { Alert } from '@cardstack/boxel-ui/components';
import { and, bool, eq } from '@cardstack/boxel-ui/helpers';

import { markdownToHtml } from '@cardstack/runtime-common';
import { markdownToHtml } from '@cardstack/runtime-common/marked-sync';

import CodeBlock from '@cardstack/host/components/ai-assistant/code-block';

Expand Down
2 changes: 1 addition & 1 deletion packages/host/app/components/ai-assistant/toast.gts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TrackedObject } from 'tracked-built-ins';
import { BoxelButton, IconButton } from '@cardstack/boxel-ui/components';
import { IconX } from '@cardstack/boxel-ui/icons';

import { markdownToHtml } from '@cardstack/runtime-common';
import { markdownToHtml } from '@cardstack/runtime-common/marked-sync';

import type { Message } from '@cardstack/host/lib/matrix-classes/message';
import type LocalPersistenceService from '@cardstack/host/services/local-persistence-service';
Expand Down
4 changes: 4 additions & 0 deletions packages/host/app/lib/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ export function shimExternals(virtualNetwork: VirtualNetwork) {
id: 'uuid',
resolve: () => import('uuid'),
});
virtualNetwork.shimAsyncModule({
id: '@cardstack/runtime-common/marked-sync',
resolve: () => import('@cardstack/runtime-common/marked-sync.ts'),
});

shimModulesForLiveTests(virtualNetwork);

Expand Down
2 changes: 1 addition & 1 deletion packages/host/app/lib/matrix-classes/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cached, tracked } from '@glimmer/tracking';

import { TrackedArray } from 'tracked-built-ins';

import { markdownToHtml } from '@cardstack/runtime-common';
import { escapeHtmlOutsideCodeBlocks } from '@cardstack/runtime-common/helpers/html';
import { markdownToHtml } from '@cardstack/runtime-common/marked-sync';

import {
parseHtmlContent,
Expand Down
2 changes: 2 additions & 0 deletions packages/host/tests/integration/realm-indexing-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -4535,6 +4535,7 @@ module(`Integration | realm indexing`, function (hooks) {
'https://packages/@cardstack/boxel-ui/icons',
'https://packages/@cardstack/boxel-ui/modifiers',
'https://packages/@cardstack/runtime-common',
'https://packages/@cardstack/runtime-common/marked-sync',
'https://packages/@ember/component',
'https://packages/@ember/component/template-only',
'https://packages/@ember/helper',
Expand Down Expand Up @@ -4672,6 +4673,7 @@ module(`Integration | realm indexing`, function (hooks) {
'https://packages/@cardstack/boxel-ui/icons',
'https://packages/@cardstack/boxel-ui/modifiers',
'https://packages/@cardstack/runtime-common',
'https://packages/@cardstack/runtime-common/marked-sync',
'https://packages/@ember/component',
'https://packages/@ember/component/template-only',
'https://packages/@ember/helper',
Expand Down
37 changes: 10 additions & 27 deletions packages/host/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand All @@ -24,31 +25,15 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"paths": {
"@cardstack/host/tests/*": [
"tests/*"
],
"@cardstack/host/*": [
"app/*"
],
"@cardstack/boxel-host/commands/*": [
"app/commands/*"
],
"https://cardstack.com/base/*": [
"../base/*"
],
"@cardstack/catalog/*": [
"../catalog-realm/*"
],
"@cardstack/openrouter/*": [
"../openrouter-realm/*"
],
"*": [
"types/*"
]
"@cardstack/host/tests/*": ["tests/*"],
"@cardstack/host/*": ["app/*"],
"@cardstack/boxel-host/commands/*": ["app/commands/*"],
"https://cardstack.com/base/*": ["../base/*"],
"@cardstack/catalog/*": ["../catalog-realm/*"],
"@cardstack/openrouter/*": ["../openrouter-realm/*"],
"*": ["types/*"]
},
"types": [
"@cardstack/local-types"
]
"types": ["@cardstack/local-types"]
},
"include": [
"../base/**/*",
Expand All @@ -59,7 +44,5 @@
"tests/**/*",
"types/**/*"
],
"exclude": [
"../base/**/__boxel/**"
]
"exclude": ["../base/**/__boxel/**"]
}
1 change: 1 addition & 0 deletions packages/postgres/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "NodeNext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand Down
28 changes: 7 additions & 21 deletions packages/realm-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
Expand All @@ -24,27 +25,12 @@
"skipLibCheck": true,
"strict": true,
"paths": {
"https://cardstack.com/base/*": [
"../base/*"
],
"@cardstack/boxel-ui": [
"../boxel-ui/addon"
],
"@cardstack/boxel-ui/*": [
"../boxel-ui/addon/*"
]
"https://cardstack.com/base/*": ["../base/*"],
"@cardstack/boxel-ui": ["../boxel-ui/addon"],
"@cardstack/boxel-ui/*": ["../boxel-ui/addon/*"]
},
"types": [
"@cardstack/local-types"
]
"types": ["@cardstack/local-types"]
},
"include": [
"../base/**/*",
"./**/*"
],
"exclude": [
"../base/**/__boxel/**",
"./realms/**",
"./tests/fixtures/**"
]
"include": ["../base/**/*", "./**/*"],
"exclude": ["../base/**/__boxel/**", "./realms/**", "./tests/fixtures/**"]
}
2 changes: 1 addition & 1 deletion packages/runtime-common/bfm-card-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { escapeHtml } from './helpers/html';
import { resolveCardReference } from './card-reference-resolver';
import { trimJsonExtension } from './url';
import { FITTED_FORMATS } from './formats';
import type { TokenizerAndRendererExtension } from 'marked';
import type { TokenizerAndRendererExtension } from './marked.mts';

// Regex patterns for stripping code before extraction.
// These avoid backtick-in-regex issues that break content-tag in .gts files.
Expand Down
5 changes: 4 additions & 1 deletion packages/runtime-common/bfm-math.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { escapeHtml } from './helpers/html';
import type { MarkedExtension, TokenizerAndRendererExtension } from 'marked';
import type {
MarkedExtension,
TokenizerAndRendererExtension,
} from './marked.mts';

// Regex patterns adapted from marked-katex-extension.
// Inline: $...$ or $$...$$ on one line, with standard spacing rules.
Expand Down
7 changes: 1 addition & 6 deletions packages/runtime-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,7 @@ export {

export type { JWTPayload } from './realm-auth-client';
export { sanitizeHtml } from './dompurify-runtime';
export {
hasCodeBlocks,
markedSync,
markdownToHtml,
preloadMarkdownLanguages,
} from './marked-sync';

export { getPlural } from './pluralize-runtime';

import type {
Expand Down
40 changes: 13 additions & 27 deletions packages/runtime-common/marked-sync.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import { Marked } from 'marked';
import { sanitizeHtml } from './dompurify-runtime';
import { escapeHtml } from './helpers/html';
import { bfmCardReferenceExtensions } from './bfm-card-references';
import { markedKatexPlaceholder } from './bfm-math';
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
// These packages declare "type": "module" which causes TS1479 under Node16
// module resolution (runtime-common lacks "type": "module"). Load via CJS.
// Unwrap .default for ESM default exports — webpack unwraps automatically but
// esbuild (used by workspace-sync-cli) preserves the { default: fn } wrapper.
type MarkedExtensionFactory = (
opts?: object,
) => import('marked').MarkedExtension;
function unwrapDefault<T>(mod: T | { default: T }): T {
return (mod as { default: T }).default ?? (mod as T);
}
const markedAlert = unwrapDefault(
require('marked-alert'),
) as MarkedExtensionFactory;
const markedFootnote = unwrapDefault(
require('marked-footnote'),
) as MarkedExtensionFactory;
const markedExtendedTables = unwrapDefault(
require('marked-extended-tables/lib/index.cjs'),
) as () => import('marked').MarkedExtension;
/* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
import { gfmHeadingId } from 'marked-gfm-heading-id';

import {
Marked,
gfmHeadingId,
markedAlert,
markedFootnote,
markedExtendedTables,
} from './marked.mts';

import type * as _MonacoSDK from 'monaco-editor';
type MonacoSDK = typeof _MonacoSDK;

Expand Down Expand Up @@ -87,23 +73,23 @@ const DEFAULT_MARKED_SYNC_OPTIONS = {

/**
* Renders code with syntax highlighting using the Monaco editor SDK.
*
*
* This function tokenizes code using Monaco's editor capabilities to generate
* HTML with syntax highlighting spans. Each line is colorized separately and
* combined into a pre/code block with Monaco token classes.
*
*
* @param code - The source code string to highlight
* @param language - The programming language for syntax highlighting (e.g., 'typescript', 'javascript')
* @param opts - Configuration options
* @param opts.monaco - Optional Monaco SDK instance. Required for highlighting to occur
* @param opts.monacoTheme - Optional theme name to apply before colorizing (e.g., 'vs-dark', 'vs-light')
* @param opts.tabSize - Optional tab size for indentation rendering
* @param opts.enableMonacoSyntaxHighlighting - Flag to enable/disable Monaco syntax highlighting. If false, function returns null immediately
*
*
let editor = monaco?.editor;
if (monaco === null || !editor?.createModel || !editor?.colorizeModelLine) {
* or an error occurs during colorization
*
*
* @throws Does not throw; catches all errors and returns null instead
*/
function renderWithMonaco(
Expand Down
7 changes: 7 additions & 0 deletions packages/runtime-common/marked.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { Marked } from 'marked';
export type { MarkedExtension, TokenizerAndRendererExtension } from 'marked';
export { default as markedAlert } from 'marked-alert';
export { default as markedFootnote } from 'marked-footnote';
// @ts-expect-error no upstream types
export { default as markedExtendedTables } from 'marked-extended-tables/src/index.js';
export { gfmHeadingId } from 'marked-gfm-heading-id';
Loading
Loading