@jwilleke/ngdpbase-types 0.0.0 → 5.19.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/LICENSE +201 -0
- package/README.md +16 -2
- package/lib/packages/ngdpbase-types/index.d.ts +32 -0
- package/lib/packages/ngdpbase-types/testing.d.ts +43 -0
- package/lib/packages/ngdpbase-types/testing.js +53 -0
- package/lib/src/cache/CacheDependencies.d.ts +50 -0
- package/lib/src/cache/CacheDependencies.js +50 -0
- package/lib/src/cache/ICacheAdapter.d.ts +86 -0
- package/lib/src/cache/RegionCache.d.ts +171 -0
- package/lib/src/context/ActorContext.d.ts +48 -0
- package/lib/src/context/ActorContext.js +33 -0
- package/lib/src/context/ApiContext.d.ts +194 -0
- package/lib/src/context/ApiContext.js +273 -0
- package/lib/src/context/BaseContext.d.ts +110 -0
- package/lib/src/context/BaseContext.js +143 -0
- package/lib/src/context/JobContext.d.ts +153 -0
- package/lib/src/context/JobContext.js +144 -0
- package/lib/src/context/WikiContext.d.ts +404 -0
- package/lib/src/context/bootActions.d.ts +64 -0
- package/lib/src/context/bootActions.js +111 -0
- package/lib/src/converters/HtmlConverter.d.ts +70 -0
- package/lib/src/converters/IContentConverter.d.ts +94 -0
- package/lib/src/converters/JSPWikiConverter.d.ts +117 -0
- package/lib/src/converters/conversionWarning.d.ts +15 -0
- package/lib/src/converters/ncm/bridge.d.ts +22 -0
- package/lib/src/converters/ncm/existing.d.ts +23 -0
- package/lib/src/converters/ncm/fix/blocks.d.ts +89 -0
- package/lib/src/converters/ncm/fix/bulletMarkers.d.ts +21 -0
- package/lib/src/converters/ncm/fix/index.d.ts +36 -0
- package/lib/src/converters/ncm/fix/jspwikiBullets.d.ts +20 -0
- package/lib/src/converters/ncm/fix/jspwikiCodeMarkers.d.ts +38 -0
- package/lib/src/converters/ncm/fix/jspwikiHeadings.d.ts +25 -0
- package/lib/src/converters/ncm/fix/jspwikiIndent.d.ts +24 -0
- package/lib/src/converters/ncm/fix/jspwikiInsert.d.ts +21 -0
- package/lib/src/converters/ncm/fix/jspwikiItalic.d.ts +29 -0
- package/lib/src/converters/ncm/fix/jspwikiLinkLeftovers.d.ts +27 -0
- package/lib/src/converters/ncm/fix/moreInformationFooter.d.ts +25 -0
- package/lib/src/converters/ncm/fix/styleClosers.d.ts +25 -0
- package/lib/src/converters/ncm/fix/tightenLists.d.ts +30 -0
- package/lib/src/converters/ncm/fix/types.d.ts +33 -0
- package/lib/src/converters/ncm/footnotes.d.ts +39 -0
- package/lib/src/converters/ncm/images.d.ts +49 -0
- package/lib/src/converters/ncm/index.d.ts +20 -0
- package/lib/src/converters/ncm/links.d.ts +21 -0
- package/lib/src/converters/ncm/normalize.d.ts +39 -0
- package/lib/src/converters/ncm/placeholder.d.ts +25 -0
- package/lib/src/converters/ncm/tables.d.ts +36 -0
- package/lib/src/converters/ncm/types.d.ts +42 -0
- package/lib/src/http/egressPolicy.d.ts +52 -0
- package/lib/src/http/guardedFetch.d.ts +89 -0
- package/lib/src/http/guardedFetch.js +113 -0
- package/lib/src/http/guardedLookup.d.ts +48 -0
- package/lib/src/http/guardedLookup.js +73 -0
- package/lib/src/http/ssrf.d.ts +83 -0
- package/lib/src/http/ssrf.js +311 -0
- package/lib/src/mail/MailProvider.d.ts +36 -0
- package/lib/src/mail/NodemailerMailProvider.d.ts +26 -0
- package/lib/src/managers/AddonsManager.d.ts +691 -0
- package/lib/src/managers/AgentTokenManager.d.ts +269 -0
- package/lib/src/managers/AssetManager.d.ts +116 -0
- package/lib/src/managers/AttachmentManager.d.ts +1032 -0
- package/lib/src/managers/AuthManager.d.ts +1257 -0
- package/lib/src/managers/BackgroundJobManager.d.ts +434 -0
- package/lib/src/managers/BaseManager.d.ts +427 -0
- package/lib/src/managers/BaseManager.js +415 -0
- package/lib/src/managers/CacheManager.d.ts +159 -0
- package/lib/src/managers/CatalogManager.d.ts +235 -0
- package/lib/src/managers/CommentManager.d.ts +75 -0
- package/lib/src/managers/ConfigurationManager.d.ts +747 -0
- package/lib/src/managers/DatabaseManager.d.ts +188 -0
- package/lib/src/managers/DatabaseManager.js +590 -0
- package/lib/src/managers/EmailManager.d.ts +47 -0
- package/lib/src/managers/ExportManager.d.ts +129 -0
- package/lib/src/managers/ExportManager.js +420 -0
- package/lib/src/managers/FootnoteManager.d.ts +118 -0
- package/lib/src/managers/MediaManager.d.ts +279 -0
- package/lib/src/managers/MetricsManager.d.ts +89 -0
- package/lib/src/managers/NotificationManager.d.ts +165 -0
- package/lib/src/managers/OidcManager.d.ts +210 -0
- package/lib/src/managers/OrganizationManager.d.ts +107 -0
- package/lib/src/managers/PageManager.d.ts +1645 -0
- package/lib/src/managers/PersonManager.d.ts +48 -0
- package/lib/src/managers/PluginManager.d.ts +179 -0
- package/lib/src/managers/PluginManager.js +393 -0
- package/lib/src/managers/PolicyEvaluator.d.ts +213 -0
- package/lib/src/managers/RenderingManager.d.ts +358 -0
- package/lib/src/managers/RoleManager.d.ts +134 -0
- package/lib/src/managers/SearchManager.d.ts +402 -0
- package/lib/src/managers/ShareManager.d.ts +251 -0
- package/lib/src/managers/TemplateManager.d.ts +176 -0
- package/lib/src/managers/ThemeManager.d.ts +56 -0
- package/lib/src/managers/UserManager.d.ts +480 -0
- package/lib/src/managers/ValidationManager.d.ts +426 -0
- package/lib/src/managers/VariableManager.d.ts +145 -0
- package/lib/src/middleware/csrf.d.ts +3 -0
- package/lib/src/parsers/LinkParser.d.ts +457 -0
- package/lib/src/parsers/MarkupParser.d.ts +769 -0
- package/lib/src/parsers/context/ParseContext.d.ts +314 -0
- package/lib/src/parsers/data/emoji-map.d.ts +18 -0
- package/lib/src/parsers/dom/DOMBuilder.d.ts +210 -0
- package/lib/src/parsers/dom/DOMParser.d.ts +252 -0
- package/lib/src/parsers/dom/Tokenizer.d.ts +358 -0
- package/lib/src/parsers/dom/WikiDocument.d.ts +272 -0
- package/lib/src/parsers/dom/handlers/DOMLinkHandler.d.ts +260 -0
- package/lib/src/parsers/dom/handlers/DOMPluginHandler.d.ts +212 -0
- package/lib/src/parsers/dom/handlers/DOMVariableHandler.d.ts +171 -0
- package/lib/src/parsers/filters/BaseFilter.d.ts +269 -0
- package/lib/src/parsers/filters/FilterChain.d.ts +320 -0
- package/lib/src/parsers/handlers/BaseSyntaxHandler.d.ts +331 -0
- package/lib/src/parsers/handlers/HandlerRegistry.d.ts +225 -0
- package/lib/src/parsers/handlers/JSPWikiPreprocessor.d.ts +89 -0
- package/lib/src/parsers/handlers/LinkParserHandler.d.ts +80 -0
- package/lib/src/parsers/handlers/PluginSyntaxHandler.d.ts +78 -0
- package/lib/src/parsers/handlers/WikiFormHandler.d.ts +149 -0
- package/lib/src/parsers/handlers/WikiTagHandler.d.ts +125 -0
- package/lib/src/parsers/jspwikiTableRow.d.ts +39 -0
- package/lib/src/parsers/styleBlockSyntax.d.ts +14 -0
- package/lib/src/plugins/types.d.ts +79 -0
- package/lib/src/providers/AgentTokenAuthProvider.d.ts +40 -0
- package/lib/src/providers/AuthentikBearerAuthProvider.d.ts +75 -0
- package/lib/src/providers/BaseAttachmentProvider.d.ts +197 -0
- package/lib/src/providers/BaseAuthProvider.d.ts +220 -0
- package/lib/src/providers/BaseCacheProvider.d.ts +140 -0
- package/lib/src/providers/BaseCredentialsProvider.d.ts +84 -0
- package/lib/src/providers/BaseDatabaseProvider.d.ts +22 -0
- package/lib/src/providers/BaseDatabaseProvider.js +12 -0
- package/lib/src/providers/BaseLoggingProvider.d.ts +68 -0
- package/lib/src/providers/BaseLoggingProvider.js +37 -0
- package/lib/src/providers/BaseMediaProvider.d.ts +308 -0
- package/lib/src/providers/BasePageProvider.d.ts +337 -0
- package/lib/src/providers/BaseProvider.d.ts +98 -0
- package/lib/src/providers/BaseProvider.js +74 -0
- package/lib/src/providers/BaseSearchProvider.d.ts +362 -0
- package/lib/src/providers/BasicAttachmentProvider.d.ts +599 -0
- package/lib/src/providers/CloudflareAccessAuthProvider.d.ts +72 -0
- package/lib/src/providers/FileCredentialsProvider.d.ts +33 -0
- package/lib/src/providers/FileJobStateProvider.d.ts +58 -0
- package/lib/src/providers/FileLoggingProvider.d.ts +43 -0
- package/lib/src/providers/FileLoggingProvider.js +120 -0
- package/lib/src/providers/FileOidcAdapter.d.ts +25 -0
- package/lib/src/providers/FileSystemMediaProvider.d.ts +403 -0
- package/lib/src/providers/LunrSearchProvider.d.ts +280 -0
- package/lib/src/providers/MagicLinkAuthProvider.d.ts +125 -0
- package/lib/src/providers/NullCacheProvider.d.ts +72 -0
- package/lib/src/providers/OidcAuthProvider.d.ts +180 -0
- package/lib/src/providers/OidcBearerAuthProvider.d.ts +30 -0
- package/lib/src/providers/PasskeyAuthProvider.d.ts +58 -0
- package/lib/src/providers/PasswordAuthProvider.d.ts +20 -0
- package/lib/src/providers/SqliteDatabaseProvider.d.ts +55 -0
- package/lib/src/providers/SqliteDatabaseProvider.js +90 -0
- package/lib/src/providers/SqliteJobStateProvider.d.ts +41 -0
- package/lib/src/providers/databaseMigrations.d.ts +8 -0
- package/lib/src/providers/databaseMigrations.js +47 -0
- package/lib/src/providers/jobState.d.ts +99 -0
- package/lib/src/providers/lunrQueryToMiniSearch.d.ts +32 -0
- package/lib/src/providers/mediaFilenameDate.d.ts +22 -0
- package/lib/src/providers/sqliteBackup.d.ts +128 -0
- package/lib/src/providers/sqliteBackup.js +365 -0
- package/lib/src/providers/sqliteLocation.d.ts +17 -0
- package/lib/src/providers/sqliteLocation.js +55 -0
- package/lib/src/providers/sqliteMigrations.d.ts +48 -0
- package/lib/src/providers/sqliteMigrations.js +72 -0
- package/lib/src/rendering/githubAlerts.d.ts +22 -0
- package/lib/src/rendering/htmlPolicy.d.ts +76 -0
- package/lib/src/rendering/markdownConverter.d.ts +73 -0
- package/lib/src/security/PolicyDecisionPoint.d.ts +245 -0
- package/lib/src/security/PolicyInformationPoint.d.ts +448 -0
- package/lib/src/security/pageActions.d.ts +40 -0
- package/lib/src/security/permissions.generated.d.ts +78 -0
- package/lib/src/types/Asset.d.ts +414 -0
- package/lib/src/types/Catalog.d.ts +61 -0
- package/lib/src/types/Comment.d.ts +11 -0
- package/lib/src/types/Config.d.ts +388 -0
- package/lib/src/types/Organization.d.ts +78 -0
- package/lib/src/types/OrganizationProvider.d.ts +38 -0
- package/lib/src/types/Page.d.ts +220 -0
- package/lib/src/types/Person.d.ts +56 -0
- package/lib/src/types/PersonProvider.d.ts +25 -0
- package/lib/src/types/Policy.d.ts +139 -0
- package/lib/src/types/Policy.js +17 -0
- package/lib/src/types/Provider.d.ts +810 -0
- package/lib/src/types/Role.d.ts +84 -0
- package/lib/src/types/RoleProvider.d.ts +35 -0
- package/lib/src/types/Schema.d.ts +425 -0
- package/lib/src/types/Share.d.ts +172 -0
- package/lib/src/types/Share.js +81 -0
- package/lib/src/types/User.d.ts +304 -0
- package/lib/src/types/Version.d.ts +189 -0
- package/lib/src/types/WikiEngine.d.ts +128 -0
- package/lib/src/types/express.d.ts +120 -0
- package/lib/src/types/express.js +1 -0
- package/lib/src/types/guards.d.ts +78 -0
- package/lib/src/types/heic-decode.d.ts +16 -0
- package/lib/src/types/index.d.ts +19 -0
- package/lib/src/types/linkedom.d.ts +77 -0
- package/lib/src/types/markdown-it-plugins.d.ts +21 -0
- package/lib/src/utils/DeltaStorage.d.ts +118 -0
- package/lib/src/utils/LocaleUtils.d.ts +105 -0
- package/lib/src/utils/LocaleUtils.js +294 -0
- package/lib/src/utils/PageNameMatcher.d.ts +98 -0
- package/lib/src/utils/PathPreflight.d.ts +38 -0
- package/lib/src/utils/PathPreflight.js +50 -0
- package/lib/src/utils/SectionUtils.d.ts +40 -0
- package/lib/src/utils/addonConfigLayer.d.ts +144 -0
- package/lib/src/utils/addonConfigLayer.js +382 -0
- package/lib/src/utils/addonDatabaseRules.d.ts +25 -0
- package/lib/src/utils/addonDatabaseRules.js +57 -0
- package/lib/src/utils/addonHost.d.ts +51 -0
- package/lib/src/utils/addonHost.js +72 -0
- package/lib/src/utils/addonInstaller.d.ts +109 -0
- package/lib/src/utils/addonLock.d.ts +37 -0
- package/lib/src/utils/addonLock.js +48 -0
- package/lib/src/utils/addonPageSync.d.ts +45 -0
- package/lib/src/utils/addonProvenance.d.ts +48 -0
- package/lib/src/utils/addonTarball.d.ts +41 -0
- package/lib/src/utils/addonsPathResolver.d.ts +76 -0
- package/lib/src/utils/addonsPathResolver.js +129 -0
- package/lib/src/utils/assetMetadataTags.d.ts +66 -0
- package/lib/src/utils/atomicWrite.d.ts +28 -0
- package/lib/src/utils/auditConfigChange.d.ts +57 -0
- package/lib/src/utils/auditEventNames.d.ts +50 -0
- package/lib/src/utils/auditEventNames.generated.d.ts +169 -0
- package/lib/src/utils/auditEventNames.generated.js +174 -0
- package/lib/src/utils/auditEventNames.js +49 -0
- package/lib/src/utils/auditEvents.d.ts +265 -0
- package/lib/src/utils/auditEvents.js +309 -0
- package/lib/src/utils/auditRegistry.d.ts +102 -0
- package/lib/src/utils/auditRegistry.js +168 -0
- package/lib/src/utils/bip39English.d.ts +2 -0
- package/lib/src/utils/configEnvKeys.d.ts +68 -0
- package/lib/src/utils/configFiles.d.ts +74 -0
- package/lib/src/utils/configFiles.js +150 -0
- package/lib/src/utils/delegation.d.ts +48 -0
- package/lib/src/utils/deriveUsername.d.ts +21 -0
- package/lib/src/utils/explainMediaPath.d.ts +123 -0
- package/lib/src/utils/formerTitles.d.ts +69 -0
- package/lib/src/utils/frontmatterAccess.d.ts +54 -0
- package/lib/src/utils/headlessAdminPassword.d.ts +55 -0
- package/lib/src/utils/imageTransform.d.ts +52 -0
- package/lib/src/utils/instanceEnvSecret.d.ts +51 -0
- package/lib/src/utils/jobSlots.d.ts +43 -0
- package/lib/src/utils/keywordNormalizer.d.ts +127 -0
- package/lib/src/utils/logger.d.ts +70 -0
- package/lib/src/utils/logger.js +106 -0
- package/lib/src/utils/magicLinkDeviceState.d.ts +95 -0
- package/lib/src/utils/managerUtils.d.ts +40 -0
- package/lib/src/utils/migrateLegacyPrivateAttachments.d.ts +15 -0
- package/lib/src/utils/orgFilename.d.ts +22 -0
- package/lib/src/utils/pageFeature.d.ts +27 -0
- package/lib/src/utils/pageFrontmatter.d.ts +21 -0
- package/lib/src/utils/pageNotes.d.ts +150 -0
- package/lib/src/utils/pageTitleRule.d.ts +37 -0
- package/lib/src/utils/pageToArticle.d.ts +59 -0
- package/lib/src/utils/pageUrl.d.ts +18 -0
- package/lib/src/utils/passwordChange.d.ts +12 -0
- package/lib/src/utils/passwordHash.d.ts +60 -0
- package/lib/src/utils/permissionCatalog.d.ts +52 -0
- package/lib/src/utils/pluginFormatters.d.ts +452 -0
- package/lib/src/utils/pluginFormatters.js +714 -0
- package/lib/src/utils/privateLinkRewrite.d.ts +42 -0
- package/lib/src/utils/privateStoreAccess.d.ts +57 -0
- package/lib/src/utils/privateStoreAccess.js +65 -0
- package/lib/src/utils/privateStoreCatalogs.d.ts +40 -0
- package/lib/src/utils/privateStoreCrypto.d.ts +127 -0
- package/lib/src/utils/privateStoreDoor.d.ts +181 -0
- package/lib/src/utils/privateStoreExport.d.ts +72 -0
- package/lib/src/utils/privateStoreFiles.d.ts +120 -0
- package/lib/src/utils/privateStoreMeta.d.ts +64 -0
- package/lib/src/utils/privateStoreMigrations.d.ts +37 -0
- package/lib/src/utils/privateStorePath.d.ts +259 -0
- package/lib/src/utils/privateStorePath.js +436 -0
- package/lib/src/utils/privateStoreTakeout.d.ts +76 -0
- package/lib/src/utils/privateStoreUnlock.d.ts +175 -0
- package/lib/src/utils/proxyClaim.d.ts +59 -0
- package/lib/src/utils/proxyClaim.js +30 -0
- package/lib/src/utils/redactPrivateNames.d.ts +21 -0
- package/lib/src/utils/redactPrivateNames.js +89 -0
- package/lib/src/utils/redactSecrets.d.ts +58 -0
- package/lib/src/utils/redactSecrets.js +171 -0
- package/lib/src/utils/renameLinkRewrite.d.ts +112 -0
- package/lib/src/utils/roleGrants.d.ts +35 -0
- package/lib/src/utils/safeRedirect.d.ts +32 -0
- package/lib/src/utils/schedule.d.ts +54 -0
- package/lib/src/utils/secretFileMode.d.ts +17 -0
- package/lib/src/utils/seededShippedPages.d.ts +45 -0
- package/lib/src/utils/sensitiveValues.d.ts +59 -0
- package/lib/src/utils/sensitiveValues.js +106 -0
- package/lib/src/utils/sessionEnd.d.ts +12 -0
- package/lib/src/utils/sessionGeneration.d.ts +24 -0
- package/lib/src/utils/sessionIdle.d.ts +41 -0
- package/lib/src/utils/sessionLimits.d.ts +68 -0
- package/lib/src/utils/shareLockbox.d.ts +64 -0
- package/lib/src/utils/sigstoreTrustedRoot.d.ts +33 -0
- package/lib/src/utils/sniffMime.d.ts +21 -0
- package/lib/src/utils/storeSearchIndex.d.ts +75 -0
- package/lib/src/utils/subjectMayDo.d.ts +21 -0
- package/lib/src/utils/systemCategoryRules.d.ts +30 -0
- package/lib/src/utils/systemCategoryRules.js +41 -0
- package/lib/src/utils/userCreateError.d.ts +62 -0
- package/lib/src/utils/username.d.ts +53 -0
- package/lib/src/utils/vaultUrlRewrite.d.ts +27 -0
- package/lib/src/utils/version.d.ts +84 -0
- package/lib/src/utils/videoFrame.d.ts +21 -0
- package/package.json +54 -3
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import BaseManager from '../managers/BaseManager.js';
|
|
2
|
+
import { HandlerRegistry } from './handlers/HandlerRegistry.js';
|
|
3
|
+
import BaseSyntaxHandler from './handlers/BaseSyntaxHandler.js';
|
|
4
|
+
import FilterChain from './filters/FilterChain.js';
|
|
5
|
+
import { DOMParser as WikiDOMParser } from './dom/DOMParser.js';
|
|
6
|
+
import DOMVariableHandler from './dom/handlers/DOMVariableHandler.js';
|
|
7
|
+
import DOMPluginHandler from './dom/handlers/DOMPluginHandler.js';
|
|
8
|
+
import DOMLinkHandler from './dom/handlers/DOMLinkHandler.js';
|
|
9
|
+
import ParseContext from './context/ParseContext.js';
|
|
10
|
+
import WikiDocument from './dom/WikiDocument.js';
|
|
11
|
+
import type RegionCache from '../cache/RegionCache.js';
|
|
12
|
+
import type { WikiEngine } from '../types/WikiEngine.js';
|
|
13
|
+
/** Configuration for MarkupParser */
|
|
14
|
+
export interface MarkupParserConfig extends Record<string, unknown> {
|
|
15
|
+
/** Whether MarkupParser is enabled */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Whether caching is enabled */
|
|
18
|
+
caching: boolean;
|
|
19
|
+
/** Cache TTL in seconds */
|
|
20
|
+
cacheTTL: number;
|
|
21
|
+
/** Handler registry configuration */
|
|
22
|
+
handlerRegistry: HandlerRegistryConfig;
|
|
23
|
+
/** Handler configurations */
|
|
24
|
+
handlers: Record<string, HandlerConfig>;
|
|
25
|
+
/** Cache configuration */
|
|
26
|
+
cache: CacheConfig;
|
|
27
|
+
/** Performance configuration */
|
|
28
|
+
performance: PerformanceConfig;
|
|
29
|
+
/** Emoji shortcode conversion */
|
|
30
|
+
emoji?: {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Handler registry configuration */
|
|
35
|
+
export interface HandlerRegistryConfig {
|
|
36
|
+
/** Whether to enable dependency resolution */
|
|
37
|
+
enableDependencyResolution?: boolean;
|
|
38
|
+
/** Maximum handler priority */
|
|
39
|
+
maxPriority?: number;
|
|
40
|
+
/** Maximum number of handlers */
|
|
41
|
+
maxHandlers?: number;
|
|
42
|
+
/** Whether to allow duplicate priorities */
|
|
43
|
+
allowDuplicatePriorities?: boolean;
|
|
44
|
+
/** Whether to enable conflict detection */
|
|
45
|
+
enableConflictDetection?: boolean;
|
|
46
|
+
/** Default handler timeout in ms */
|
|
47
|
+
defaultTimeout?: number;
|
|
48
|
+
}
|
|
49
|
+
/** Individual handler configuration */
|
|
50
|
+
export interface HandlerConfig {
|
|
51
|
+
/** Whether handler is enabled */
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
/** Handler priority */
|
|
54
|
+
priority: number;
|
|
55
|
+
}
|
|
56
|
+
/** Cache configuration */
|
|
57
|
+
export interface CacheConfig {
|
|
58
|
+
/** Parse results cache strategy */
|
|
59
|
+
parseResults: CacheStrategyConfig;
|
|
60
|
+
/** Whether to enable metrics */
|
|
61
|
+
metricsEnabled: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Cache strategy configuration */
|
|
64
|
+
export interface CacheStrategyConfig {
|
|
65
|
+
/** Whether this strategy is enabled */
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
/** Time to live in seconds */
|
|
68
|
+
ttl: number;
|
|
69
|
+
/** Maximum cache size */
|
|
70
|
+
maxSize: number;
|
|
71
|
+
}
|
|
72
|
+
/** Performance configuration */
|
|
73
|
+
export interface PerformanceConfig {
|
|
74
|
+
/** Whether performance monitoring is enabled */
|
|
75
|
+
monitoring: boolean;
|
|
76
|
+
/** Alert thresholds */
|
|
77
|
+
alertThresholds: AlertThresholds;
|
|
78
|
+
}
|
|
79
|
+
/** Performance alert thresholds */
|
|
80
|
+
export interface AlertThresholds {
|
|
81
|
+
/** Parse time threshold in milliseconds */
|
|
82
|
+
parseTime: number;
|
|
83
|
+
/** Cache hit ratio threshold (0-1) */
|
|
84
|
+
cacheHitRatio: number;
|
|
85
|
+
/** Error rate threshold (0-1) */
|
|
86
|
+
errorRate: number;
|
|
87
|
+
/** Minimum cache samples for metrics */
|
|
88
|
+
minCacheSamples: number;
|
|
89
|
+
}
|
|
90
|
+
/** Parse context */
|
|
91
|
+
export interface ParseContextData {
|
|
92
|
+
/** Page name */
|
|
93
|
+
pageName?: string;
|
|
94
|
+
/** User name */
|
|
95
|
+
userName?: string;
|
|
96
|
+
/** User context object */
|
|
97
|
+
userContext?: unknown;
|
|
98
|
+
/** Request information */
|
|
99
|
+
requestInfo?: unknown;
|
|
100
|
+
/** Code blocks extracted during parsing */
|
|
101
|
+
codeBlocks?: string[];
|
|
102
|
+
/** Protected HTML blocks */
|
|
103
|
+
protectedBlocks?: string[];
|
|
104
|
+
/** Syntax tokens */
|
|
105
|
+
syntaxTokens?: unknown[];
|
|
106
|
+
/** Additional context properties */
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/** Extracted JSPWiki element */
|
|
110
|
+
export interface ExtractedElement {
|
|
111
|
+
/** Element type */
|
|
112
|
+
type: 'variable' | 'plugin' | 'link' | 'escaped' | 'style' | 'inline-style' | 'footnote-ref' | 'footnote-def' | 'code' | 'fenced-code';
|
|
113
|
+
/** Original syntax */
|
|
114
|
+
syntax: string;
|
|
115
|
+
/** Unique ID */
|
|
116
|
+
id: number;
|
|
117
|
+
/** Position in content */
|
|
118
|
+
position?: number;
|
|
119
|
+
/** Variable name (for variables) */
|
|
120
|
+
varName?: string;
|
|
121
|
+
/** Plugin/tag inner content (for plugins) */
|
|
122
|
+
inner?: string;
|
|
123
|
+
/** Link target (for links) */
|
|
124
|
+
target?: string;
|
|
125
|
+
/** Escaped literal content (for escaped) */
|
|
126
|
+
literal?: string;
|
|
127
|
+
/** CSS class name (for style blocks) */
|
|
128
|
+
className?: string;
|
|
129
|
+
/** Style block content (for style blocks) */
|
|
130
|
+
styleContent?: string;
|
|
131
|
+
/** Accumulated CSS classes from parent style blocks (for nested styles) */
|
|
132
|
+
accumulatedClasses?: string[];
|
|
133
|
+
/** Footnote identifier — the id portion of [^id] or [^id]: text */
|
|
134
|
+
footnoteId?: string;
|
|
135
|
+
/** Footnote definition text — the content after [^id]: */
|
|
136
|
+
footnoteText?: string;
|
|
137
|
+
/** Raw text content for inline code spans (`...`) and fenced code blocks (```...```) */
|
|
138
|
+
codeContent?: string;
|
|
139
|
+
/** Language tag from fenced code blocks (e.g. 'javascript' from ```javascript) */
|
|
140
|
+
codeLanguage?: string;
|
|
141
|
+
/** #907: inline-style variant — css | sup | sub | strike | class (#938) */
|
|
142
|
+
inlineVariant?: 'css' | 'sup' | 'sub' | 'strike' | 'class';
|
|
143
|
+
/** #907: raw CSS declarations for inline-style variant 'css' (parenthesis body) */
|
|
144
|
+
cssRaw?: string;
|
|
145
|
+
/** #938: space-separated class list for inline-style variant 'class' */
|
|
146
|
+
classNames?: string;
|
|
147
|
+
}
|
|
148
|
+
/** Result of extraction */
|
|
149
|
+
export interface ExtractionResult {
|
|
150
|
+
/** Sanitized content with placeholders */
|
|
151
|
+
sanitized: string;
|
|
152
|
+
/** Extracted JSPWiki elements */
|
|
153
|
+
jspwikiElements: ExtractedElement[];
|
|
154
|
+
/** Unique UUID for this extraction */
|
|
155
|
+
uuid: string;
|
|
156
|
+
}
|
|
157
|
+
/** Parser metrics */
|
|
158
|
+
export interface ParserMetrics {
|
|
159
|
+
/** Number of parses performed */
|
|
160
|
+
parseCount: number;
|
|
161
|
+
/** Total parse time in milliseconds */
|
|
162
|
+
totalParseTime: number;
|
|
163
|
+
/** Number of errors */
|
|
164
|
+
errorCount: number;
|
|
165
|
+
/** Number of cache hits */
|
|
166
|
+
cacheHits: number;
|
|
167
|
+
/** Number of cache misses */
|
|
168
|
+
cacheMisses: number;
|
|
169
|
+
/** Cache metrics by strategy */
|
|
170
|
+
cacheMetrics: Map<string, CacheMetrics>;
|
|
171
|
+
}
|
|
172
|
+
/** Cache metrics for a strategy */
|
|
173
|
+
export interface CacheMetrics {
|
|
174
|
+
/** Number of cache hits */
|
|
175
|
+
hits: number;
|
|
176
|
+
/** Number of cache misses */
|
|
177
|
+
misses: number;
|
|
178
|
+
/** Number of cache sets */
|
|
179
|
+
sets: number;
|
|
180
|
+
}
|
|
181
|
+
/** Performance monitor state */
|
|
182
|
+
export interface PerformanceMonitor {
|
|
183
|
+
/** Performance alerts */
|
|
184
|
+
alerts: PerformanceAlert[];
|
|
185
|
+
/** Last check timestamp */
|
|
186
|
+
lastCheck: number;
|
|
187
|
+
/** Check interval in milliseconds */
|
|
188
|
+
checkInterval: number;
|
|
189
|
+
/** Recent parse times */
|
|
190
|
+
recentParseTimes: ParseTimeEntry[];
|
|
191
|
+
/** Recent error rates */
|
|
192
|
+
recentErrorRates: number[];
|
|
193
|
+
/** Maximum recent entries to keep */
|
|
194
|
+
maxRecentEntries: number;
|
|
195
|
+
}
|
|
196
|
+
/** Performance alert */
|
|
197
|
+
export interface PerformanceAlert {
|
|
198
|
+
/** Alert type */
|
|
199
|
+
type: string;
|
|
200
|
+
/** Alert message */
|
|
201
|
+
message: string;
|
|
202
|
+
/** Timestamp */
|
|
203
|
+
timestamp: string;
|
|
204
|
+
/** Related metrics */
|
|
205
|
+
metrics: unknown;
|
|
206
|
+
}
|
|
207
|
+
/** Parse time entry */
|
|
208
|
+
export interface ParseTimeEntry {
|
|
209
|
+
/** Parse time in milliseconds */
|
|
210
|
+
time: number;
|
|
211
|
+
/** Whether this was a cache hit */
|
|
212
|
+
cacheHit: boolean;
|
|
213
|
+
/** Timestamp */
|
|
214
|
+
timestamp: number;
|
|
215
|
+
}
|
|
216
|
+
/** Extended metrics returned by getMetrics() */
|
|
217
|
+
export interface ExtendedMetrics extends ParserMetrics {
|
|
218
|
+
/** Average parse time */
|
|
219
|
+
averageParseTime: number;
|
|
220
|
+
/** Cache hit ratio */
|
|
221
|
+
cacheHitRatio: number;
|
|
222
|
+
/** Handler registry stats */
|
|
223
|
+
handlerRegistry?: unknown;
|
|
224
|
+
/** Filter chain stats */
|
|
225
|
+
filterChain?: unknown;
|
|
226
|
+
/** Cache strategies stats */
|
|
227
|
+
cacheStrategies?: Record<string, unknown>;
|
|
228
|
+
/** Performance monitoring stats */
|
|
229
|
+
performance?: unknown;
|
|
230
|
+
}
|
|
231
|
+
declare class MarkupParser extends BaseManager {
|
|
232
|
+
/** Handler registry for syntax handlers */
|
|
233
|
+
handlerRegistry: HandlerRegistry;
|
|
234
|
+
/** Content filter chain */
|
|
235
|
+
filterChain: FilterChain | null;
|
|
236
|
+
/** Parse result cache */
|
|
237
|
+
cache: RegionCache | null;
|
|
238
|
+
/** Caching strategies by content type */
|
|
239
|
+
cacheStrategies: Record<string, RegionCache>;
|
|
240
|
+
/** Performance monitoring state */
|
|
241
|
+
performanceMonitor: PerformanceMonitor | null;
|
|
242
|
+
/** Parser performance metrics */
|
|
243
|
+
metrics: ParserMetrics;
|
|
244
|
+
/** DOM-based parser for JSPWiki syntax */
|
|
245
|
+
domParser: WikiDOMParser;
|
|
246
|
+
/** Variable expansion handler */
|
|
247
|
+
domVariableHandler: DOMVariableHandler;
|
|
248
|
+
/** Plugin execution handler */
|
|
249
|
+
domPluginHandler: DOMPluginHandler;
|
|
250
|
+
/** Link resolution handler */
|
|
251
|
+
domLinkHandler: DOMLinkHandler;
|
|
252
|
+
/** Parser configuration - overrides BaseManager's generic config */
|
|
253
|
+
protected config: MarkupParserConfig;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a new MarkupParser instance
|
|
256
|
+
*/
|
|
257
|
+
constructor(engine: WikiEngine);
|
|
258
|
+
/**
|
|
259
|
+
* Initialize the MarkupParser
|
|
260
|
+
*/
|
|
261
|
+
initialize(config?: Partial<MarkupParserConfig>): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Check if MarkupParser is initialized (required for RenderingManager integration)
|
|
264
|
+
* @returns {boolean} - True if initialized
|
|
265
|
+
*/
|
|
266
|
+
isInitialized(): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Register default syntax handlers based on configuration
|
|
269
|
+
*/
|
|
270
|
+
registerDefaultHandlers(): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Load configuration from ConfigurationManager
|
|
273
|
+
*/
|
|
274
|
+
loadConfiguration(): void;
|
|
275
|
+
/**
|
|
276
|
+
* Configure handler registry with loaded configuration
|
|
277
|
+
* NOTE: Removed - HandlerRegistry.config is private, no public setter available.
|
|
278
|
+
* HandlerRegistry uses default configuration which is sufficient.
|
|
279
|
+
*/
|
|
280
|
+
/**
|
|
281
|
+
* Initialize advanced caching integration with multiple cache strategies
|
|
282
|
+
*/
|
|
283
|
+
initializeAdvancedCaching(): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Initialize performance monitoring system
|
|
286
|
+
*/
|
|
287
|
+
initializePerformanceMonitoring(): void;
|
|
288
|
+
/** The configured `ngdpbase.markup.html-policy`, read when it is needed (#1623). */
|
|
289
|
+
private configuredHtmlPolicy;
|
|
290
|
+
/**
|
|
291
|
+
* Main parsing method - uses WikiDocument DOM extraction pipeline
|
|
292
|
+
* @param content - Raw content to parse
|
|
293
|
+
* @param context - Parsing context (page, user, etc.)
|
|
294
|
+
* @returns Processed HTML content
|
|
295
|
+
*/
|
|
296
|
+
parse(content: string, context?: Record<string, unknown>): Promise<string>;
|
|
297
|
+
/**
|
|
298
|
+
* Render without the page cache: expand the template variables, run the
|
|
299
|
+
* extraction pipeline, record the timing. #1751 split this out of parse()
|
|
300
|
+
* so the read-through calls it; parse() still owns the error fallback.
|
|
301
|
+
*/
|
|
302
|
+
private renderUncached;
|
|
303
|
+
/**
|
|
304
|
+
* Register a syntax handler
|
|
305
|
+
* @param handler - Handler instance
|
|
306
|
+
* @param options - Registration options
|
|
307
|
+
* @returns True if registration successful
|
|
308
|
+
*/
|
|
309
|
+
registerHandler(handler: BaseSyntaxHandler, options?: Record<string, unknown>): Promise<boolean>;
|
|
310
|
+
/**
|
|
311
|
+
* Get handler type from handler ID for configuration lookup (modular mapping)
|
|
312
|
+
* @param handlerId - Handler ID
|
|
313
|
+
* @returns Handler type or null
|
|
314
|
+
*/
|
|
315
|
+
getHandlerTypeFromId(handlerId: string): string | null;
|
|
316
|
+
/**
|
|
317
|
+
* Get configuration for a specific handler type
|
|
318
|
+
* @param handlerType - Handler type (plugin, wikitag, etc.)
|
|
319
|
+
* @returns Handler configuration
|
|
320
|
+
*/
|
|
321
|
+
getHandlerConfig(handlerType: string): HandlerConfig;
|
|
322
|
+
/**
|
|
323
|
+
* Unregister a syntax handler
|
|
324
|
+
* @param handlerId - Handler identifier
|
|
325
|
+
* @returns True if unregistration successful
|
|
326
|
+
*/
|
|
327
|
+
unregisterHandler(handlerId: string): Promise<boolean>;
|
|
328
|
+
/**
|
|
329
|
+
* Get handler by ID
|
|
330
|
+
* @param handlerId - Handler identifier
|
|
331
|
+
* @returns Handler or null if not found
|
|
332
|
+
*/
|
|
333
|
+
getHandler(handlerId: string): unknown;
|
|
334
|
+
/**
|
|
335
|
+
* Get all handlers sorted by priority
|
|
336
|
+
* @param enabledOnly - Only return enabled handlers
|
|
337
|
+
* @returns Handlers sorted by priority
|
|
338
|
+
*/
|
|
339
|
+
getHandlers(enabledOnly?: boolean): unknown[];
|
|
340
|
+
/**
|
|
341
|
+
* Get the FilterChain (#596), which FilterManager owns (#1117).
|
|
342
|
+
*
|
|
343
|
+
* A delegating view kept for existing callers (the admin stats route,
|
|
344
|
+
* legacy save-path lookups). New code should ask FilterManager directly.
|
|
345
|
+
* Returns null when the pipeline is disabled or the manager is absent —
|
|
346
|
+
* callers should treat a null chain as "validation skipped, proceed".
|
|
347
|
+
*
|
|
348
|
+
* @returns The FilterChain instance, or null
|
|
349
|
+
*/
|
|
350
|
+
getFilterChain(): FilterChain | null;
|
|
351
|
+
/**
|
|
352
|
+
* Enable handler by ID
|
|
353
|
+
* @param handlerId - Handler identifier
|
|
354
|
+
* @returns True if successful
|
|
355
|
+
*/
|
|
356
|
+
enableHandler(handlerId: string): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Disable handler by ID
|
|
359
|
+
* @param handlerId - Handler identifier
|
|
360
|
+
* @returns True if successful
|
|
361
|
+
*/
|
|
362
|
+
disableHandler(handlerId: string): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Generate cache key for content and context
|
|
365
|
+
* @param content - Content to cache
|
|
366
|
+
* @param context - Parse context
|
|
367
|
+
* @returns Cache key
|
|
368
|
+
*/
|
|
369
|
+
/**
|
|
370
|
+
* #907: sanitize a raw inline-CSS declaration string against the security
|
|
371
|
+
* config. Returns validated `prop: val; …` (empty when disabled or nothing
|
|
372
|
+
* passes). Shared by the DOM inline-style node builder.
|
|
373
|
+
*
|
|
374
|
+
* Gate: `ngdpbase.style.security.allow-inline-css`. Each property must be in
|
|
375
|
+
* `ngdpbase.style.security.allowed-properties`; values with `javascript:`,
|
|
376
|
+
* `url(`, `expression(`, or angle brackets are dropped.
|
|
377
|
+
*/
|
|
378
|
+
private sanitizeInlineCss;
|
|
379
|
+
/**
|
|
380
|
+
* #907: build a DOM node for an inline JSPWiki style — the unified path that
|
|
381
|
+
* replaced the Step 0.55 string replacements. `variant` selects the wrapper
|
|
382
|
+
* (`css` → `<span style>`, `sup` → `<sup>`, `sub` → `<sub>`, `strike` →
|
|
383
|
+
* `<del>`); `inner` is resolved for wiki syntax via appendWikiNodes (parity
|
|
384
|
+
* with block styles). For `css` with inline CSS disabled or no safe
|
|
385
|
+
* declarations, the wrapper degrades to a plain `<span>` (content preserved,
|
|
386
|
+
* never leaked as literal markup). Used by BOTH the top-level extraction
|
|
387
|
+
* resolver and the cell/block scanner (appendWikiNodes).
|
|
388
|
+
*/
|
|
389
|
+
private buildInlineStyleNode;
|
|
390
|
+
/**
|
|
391
|
+
* Whether this parse may be cached in a map the whole process shares
|
|
392
|
+
* (#1423). A page in an encrypted store resolves only through its owner's
|
|
393
|
+
* unlocked session, so `PageManager.isSharedIndexable` — the same question
|
|
394
|
+
* #1419 asks of the search index and the link graph — answers false for it.
|
|
395
|
+
*
|
|
396
|
+
* A parse with no page name behind it (a preview, a snippet, an addon
|
|
397
|
+
* rendering a string) is cacheable as before: there is no page to be sealed.
|
|
398
|
+
*/
|
|
399
|
+
private isSharedIndexable;
|
|
400
|
+
/**
|
|
401
|
+
* What a `[store/Title]` link on THIS page is resolved against (#1457):
|
|
402
|
+
* the private titles the reader can see in the page owner's stores.
|
|
403
|
+
*
|
|
404
|
+
* Only on a private page. Its HTML is never cached for sharing — the same
|
|
405
|
+
* `isSharedIndexable` question above is false for every private name — so
|
|
406
|
+
* its links may be answered for the reader in front of them, and the owner
|
|
407
|
+
* of a page that is not there gets a red link to its editor. A public page's
|
|
408
|
+
* render is shared by role and keeps one appearance for everyone (operator,
|
|
409
|
+
* 2026-09-23).
|
|
410
|
+
*
|
|
411
|
+
* One lookup per render, as the reader — the context as it arrived, never
|
|
412
|
+
* rebuilt and never defaulted. With no reader, no page manager, or a lookup
|
|
413
|
+
* that throws there is no answer, and every link stays neutral rather than
|
|
414
|
+
* claiming a page is missing.
|
|
415
|
+
*/
|
|
416
|
+
private resolvePrivateLinkTitles;
|
|
417
|
+
generateCacheKey(content: string, context: ParseContextData): string;
|
|
418
|
+
/**
|
|
419
|
+
* Extract style blocks using state-stack parsing for proper nesting support
|
|
420
|
+
*
|
|
421
|
+
* Uses JSPWiki-style state tracking:
|
|
422
|
+
* - When %%class-name found: push to stack with accumulated classes from parents
|
|
423
|
+
* - When /% found: pop from stack, create element with all accumulated classes
|
|
424
|
+
*
|
|
425
|
+
* @param content - Content to extract style blocks from
|
|
426
|
+
* @param elements - Array to push extracted elements into
|
|
427
|
+
* @param uuid - UUID for placeholders
|
|
428
|
+
* @param startId - Starting ID for elements
|
|
429
|
+
* @returns Object with processed content and next available ID
|
|
430
|
+
*/
|
|
431
|
+
private extractStyleBlocksWithStack;
|
|
432
|
+
/**
|
|
433
|
+
* Extract JSPWiki-specific syntax from content for DOM-based processing
|
|
434
|
+
*
|
|
435
|
+
* This method implements the pre-extraction strategy from Issue #114.
|
|
436
|
+
* Instead of tokenizing both markdown and JSPWiki syntax (which causes conflicts),
|
|
437
|
+
* we extract ONLY JSPWiki syntax and let markdown-it handle all markdown.
|
|
438
|
+
*
|
|
439
|
+
* Extraction order:
|
|
440
|
+
* 1. Variables: [{$username}] → __JSPWIKI_uuid_0__
|
|
441
|
+
* 2. Plugins: [{TableOfContents}] → __JSPWIKI_uuid_1__
|
|
442
|
+
* 3. Escaped: [[{$var}] → __JSPWIKI_uuid_2__ (stores literal [{$var}])
|
|
443
|
+
* 4. Wiki links: [PageName] → __JSPWIKI_uuid_3__ (but not markdown [text](url))
|
|
444
|
+
*
|
|
445
|
+
* Code blocks are already protected by Phase 1 preprocessing, so JSPWiki syntax
|
|
446
|
+
* inside code blocks won't be extracted.
|
|
447
|
+
*
|
|
448
|
+
* @param {string} content - Raw wiki content
|
|
449
|
+
* @param {ParseContext} context - Parse context (for code block protection)
|
|
450
|
+
* @returns {Object} - { sanitized, jspwikiElements, uuid }
|
|
451
|
+
*
|
|
452
|
+
* Related: #114 (WikiDocument DOM Solution), #115 (Phase 1 Implementation)
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* const input = "## Heading\n\nUser: [{$username}]";
|
|
456
|
+
* const { sanitized, jspwikiElements, uuid } = parser.extractJSPWikiSyntax(input);
|
|
457
|
+
* // sanitized: "## Heading\n\nUser: <span data-jspwiki-placeholder="abc123-0"></span>"
|
|
458
|
+
* // jspwikiElements: [{ type: 'variable', varName: '$username', id: 0, ... }]
|
|
459
|
+
* // uuid: "abc123"
|
|
460
|
+
*/
|
|
461
|
+
extractJSPWikiSyntax(content: string, _context?: Record<string, unknown>): {
|
|
462
|
+
sanitized: string;
|
|
463
|
+
jspwikiElements: ExtractedElement[];
|
|
464
|
+
uuid: string;
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* Creates a text node for escaped JSPWiki syntax
|
|
468
|
+
*
|
|
469
|
+
* This is a helper method for Phase 2 DOM node creation (Issue #116).
|
|
470
|
+
* Escaped syntax like [[{$var}]] should render as literal text [{$var}].
|
|
471
|
+
*
|
|
472
|
+
* @param element - Extracted escaped element
|
|
473
|
+
* @param wikiDocument - WikiDocument to create node in
|
|
474
|
+
* @returns DOM node containing the escaped literal text
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* const element = { type: 'escaped', literal: '[{$username}]', id: 0, ... };
|
|
478
|
+
* const node = createTextNodeForEscaped(element, wikiDoc);
|
|
479
|
+
* // Returns: <span class="wiki-escaped" data-jspwiki-id="0">[{$username}]</span>
|
|
480
|
+
*/
|
|
481
|
+
createTextNodeForEscaped(element: ExtractedElement, wikiDocument: WikiDocument): unknown;
|
|
482
|
+
/**
|
|
483
|
+
* #1368: when `node`'s only content is one `<p>`, replace the `<p>` with its
|
|
484
|
+
* children. Leaves anything else — several paragraphs, a list, text beside
|
|
485
|
+
* the paragraph — as it is.
|
|
486
|
+
*/
|
|
487
|
+
private static unwrapSoleParagraph;
|
|
488
|
+
/**
|
|
489
|
+
* Creates a DOM node from a JSPWiki style block (%%class-name ... /%)
|
|
490
|
+
*
|
|
491
|
+
* This handles table-related style classes (table-striped, sortable, etc.)
|
|
492
|
+
* by parsing JSPWiki table syntax and creating HTML tables with proper styling.
|
|
493
|
+
* For non-table styles, wraps content in a styled div/span.
|
|
494
|
+
*
|
|
495
|
+
* @param element - Extracted style element
|
|
496
|
+
* @param context - Rendering context
|
|
497
|
+
* @param wikiDocument - WikiDocument to create node in
|
|
498
|
+
* @returns DOM node for the styled content
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* // For table styles:
|
|
502
|
+
* const element = { type: 'style', className: 'table-striped', styleContent: '|| H1 ||\n| D1 |' };
|
|
503
|
+
* const node = createNodeFromStyleBlock(element, context, wikiDoc);
|
|
504
|
+
* // Returns: <table class="table table-striped">...</table>
|
|
505
|
+
*/
|
|
506
|
+
createNodeFromStyleBlock(element: ExtractedElement, context: ParseContext, wikiDocument: WikiDocument): Promise<unknown>;
|
|
507
|
+
/**
|
|
508
|
+
* Creates an HTML table node from JSPWiki table syntax
|
|
509
|
+
*
|
|
510
|
+
* @param content - JSPWiki table content (|| header || and | cell | syntax)
|
|
511
|
+
* @param className - CSS class to apply (e.g., 'table-striped')
|
|
512
|
+
* @param elementId - Element ID for tracking
|
|
513
|
+
* @param wikiDocument - WikiDocument to create node in
|
|
514
|
+
* @returns HTML table element
|
|
515
|
+
*/
|
|
516
|
+
/**
|
|
517
|
+
* Named HTML entities decoded inside DOM-built inner text (#907 follow-up).
|
|
518
|
+
* Authors write ` `, `©`, etc. as raw entities in wiki source; when
|
|
519
|
+
* that text becomes a real DOM text node its `&` would otherwise serialize to
|
|
520
|
+
* `&` and the literal ` ` would show. Decoding to the actual char
|
|
521
|
+
* makes serialization round-trip correctly. Kept small on purpose — the
|
|
522
|
+
* common set; numeric `&#…;`/`&#x…;` are handled generically.
|
|
523
|
+
*/
|
|
524
|
+
private static readonly NAMED_ENTITIES;
|
|
525
|
+
/**
|
|
526
|
+
* Decode a small set of named + all numeric HTML entities in plain text.
|
|
527
|
+
* Single pass, so a double-encoded `&nbsp;` decodes only its outer `&`
|
|
528
|
+
* (never double-decodes). Text nodes re-escape on serialization, so this is
|
|
529
|
+
* display-idempotent and cannot introduce markup. Code spans are NOT run
|
|
530
|
+
* through this — literal ` ` in backticks stays literal.
|
|
531
|
+
*/
|
|
532
|
+
private decodeTextEntities;
|
|
533
|
+
/**
|
|
534
|
+
* Scans `content` for all JSPWiki wiki syntax (mirrors Steps 1–4 of extractJSPWikiSyntax)
|
|
535
|
+
* and appends the resolved child nodes directly to `node`. Text between matches is appended
|
|
536
|
+
* as text nodes. Used by createNodeFromStyleBlock and populateCell (via createTableNode).
|
|
537
|
+
*
|
|
538
|
+
* @param content - Raw cell/block text containing wiki syntax
|
|
539
|
+
* @param node - Target element to append children to
|
|
540
|
+
* @param context - ParseContext for variable/plugin resolution
|
|
541
|
+
* @param wikiDocument - WikiDocument for node creation
|
|
542
|
+
* @param idStart - Starting ID for created elements (must not collide with outer IDs)
|
|
543
|
+
*/
|
|
544
|
+
/**
|
|
545
|
+
* Append `text` to `node` with the inline Markdown rules applied and its
|
|
546
|
+
* HTML escaped (#1351) — `renderInlineMarkdown`, parsed into nodes. Text
|
|
547
|
+
* with nothing to render goes in as a plain text node.
|
|
548
|
+
*/
|
|
549
|
+
private appendInlineMarkdown;
|
|
550
|
+
private appendWikiNodes;
|
|
551
|
+
/**
|
|
552
|
+
* Build the DOM node for one wikiPattern match — the shared body of
|
|
553
|
+
* appendWikiNodes and appendMarkdownBlockNodes, so both resolve wiki syntax
|
|
554
|
+
* identically. Always returns a node; the literal cases return a text node.
|
|
555
|
+
*/
|
|
556
|
+
private createWikiNodeFromMatch;
|
|
557
|
+
/**
|
|
558
|
+
* Is this style block a raw code/CSS dump rather than prose? (#1039)
|
|
559
|
+
*
|
|
560
|
+
* These must NOT go through the markdown pass. `%%add-css` is JSPWiki's
|
|
561
|
+
* convention for a stylesheet, and running markdown-it over CSS corrupts it:
|
|
562
|
+
* a CSS comment's asterisks read as emphasis markers, so a comment around the
|
|
563
|
+
* word `pagination.less` rendered as `/<em>pagination.less</em>/` on nine CSS
|
|
564
|
+
* documentation pages. Those pages exist to show the CSS accurately, so that
|
|
565
|
+
* is a real defect rather than a cosmetic one.
|
|
566
|
+
*
|
|
567
|
+
* Two signals, both cheap: the class name, and a CSS comment anywhere in the
|
|
568
|
+
* content (which catches a stylesheet pasted into a differently-named block).
|
|
569
|
+
* Checked against the full corpus — every mangled block matched, and no block
|
|
570
|
+
* containing real markdown did.
|
|
571
|
+
*/
|
|
572
|
+
private static isRawCodeBlock;
|
|
573
|
+
/** `&`, `<`, `>` only — enough to keep source text inert through markdown-it. */
|
|
574
|
+
private escapeForMarkdown;
|
|
575
|
+
/**
|
|
576
|
+
* Resolve a style block's BLOCK content with both the wiki pass and the
|
|
577
|
+
* markdown pass (#1039).
|
|
578
|
+
*
|
|
579
|
+
* Style-block content is lifted out at Step 0.5, before markdown-it runs on the
|
|
580
|
+
* document, and was then handed to appendWikiNodes — which resolves wiki
|
|
581
|
+
* syntax and emits everything else as text nodes. So markdown inside a block
|
|
582
|
+
* reached the reader as literal source: `## Introduction` displayed its own
|
|
583
|
+
* hashes, and `**bold**` its own asterisks, while the identical markup one
|
|
584
|
+
* line outside the block rendered normally. 12 pages were affected.
|
|
585
|
+
*
|
|
586
|
+
* Raw HTML worked in there by accident, which is why it went unnoticed — an
|
|
587
|
+
* author who reached for `<br>` got a line break and had no reason to suspect
|
|
588
|
+
* the block was inert. That is also how the one raw `<br>` that #1038's
|
|
589
|
+
* migration could not convert came to exist.
|
|
590
|
+
*
|
|
591
|
+
* ## Why slots rather than converting each text run
|
|
592
|
+
*
|
|
593
|
+
* Wiki syntax must still resolve to the same nodes it does today, so the two
|
|
594
|
+
* passes have to interleave. Converting each text run between wiki matches
|
|
595
|
+
* separately would cut block constructs in half — a list item containing a
|
|
596
|
+
* link would become a one-item list, a stray fragment, and another list.
|
|
597
|
+
*
|
|
598
|
+
* Instead every wiki match is replaced by an empty slot span, markdown-it runs
|
|
599
|
+
* over the whole scaffold, and the resolved nodes are swapped back in
|
|
600
|
+
* afterwards. Block structure survives because markdown-it sees the block whole.
|
|
601
|
+
*
|
|
602
|
+
* ## Why the text is escaped first
|
|
603
|
+
*
|
|
604
|
+
* Text between matches is escaped before markdown-it sees it, which keeps the
|
|
605
|
+
* exact inertness the text-node path had: `<script>` in a block stays visible
|
|
606
|
+
* text, as it does today. Markdown syntax is untouched by that escaping, so
|
|
607
|
+
* this is strictly additive — it grants markdown without granting raw HTML.
|
|
608
|
+
*/
|
|
609
|
+
private appendMarkdownBlockNodes;
|
|
610
|
+
/**
|
|
611
|
+
* Split a table cell on its line breaks — `<br>` or NCM's `\\` / `\\\` —
|
|
612
|
+
* leaving inline code spans intact (#1038).
|
|
613
|
+
*
|
|
614
|
+
* A plain `cell.split(/<br\s*\/?>|\\{2,3}/i)` was the first cut, and it broke
|
|
615
|
+
* the pages that DOCUMENT these sequences. `Using Current Time Plugin` has a
|
|
616
|
+
* SimpleDateFormat reference table whose "escape for text" row carries `\\`
|
|
617
|
+
* as its example value; splitting emptied that cell and put a line break in
|
|
618
|
+
* it, so the page stopped showing the thing it was explaining.
|
|
619
|
+
*
|
|
620
|
+
* Backticking the value does not rescue it on its own. Splitting first cuts
|
|
621
|
+
* `` `\\` `` into two lone backticks, which are no longer a code span by the
|
|
622
|
+
* time the wiki/plain decision runs — the cell then renders literal
|
|
623
|
+
* backticks AROUND a break, which is worse than where it started. Keeping
|
|
624
|
+
* the span whole is what lets appendWikiNodes see it and emit `<code>`.
|
|
625
|
+
*
|
|
626
|
+
* Only %%style tables need this. A plain markdown table reaches
|
|
627
|
+
* JSPWikiPreprocessor, where inline code is placeholder-extracted upstream
|
|
628
|
+
* and never arrives here as backticks at all — which is precisely why a
|
|
629
|
+
* plain-table probe reported this method as redundant. It is not.
|
|
630
|
+
*
|
|
631
|
+
* Code is inert elsewhere in this pipeline for the same reason —
|
|
632
|
+
* SecurityFilter.collectErrors blanks it before scanning, and
|
|
633
|
+
* migrate-br-to-ncm skips it — so a style-block cell should not be the one
|
|
634
|
+
* place a backtick fails to mean "this is a literal".
|
|
635
|
+
*
|
|
636
|
+
* A break outside the span still splits: `` `\\` is an escape\\next `` gives
|
|
637
|
+
* two segments, not three.
|
|
638
|
+
*/
|
|
639
|
+
private splitCellOnBreaks;
|
|
640
|
+
private createTableNode;
|
|
641
|
+
/**
|
|
642
|
+
* Creates a DOM node from an extracted element (Phase 2 dispatcher)
|
|
643
|
+
*
|
|
644
|
+
* This is the dispatcher method for Phase 2 that routes extracted elements
|
|
645
|
+
* to the appropriate handler based on element type.
|
|
646
|
+
*
|
|
647
|
+
* @param element - Extracted element from extractJSPWikiSyntax()
|
|
648
|
+
* @param context - Rendering context
|
|
649
|
+
* @param wikiDocument - WikiDocument to create node in
|
|
650
|
+
* @returns DOM node for the element
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* const element = { type: 'variable', varName: '$username', id: 0 };
|
|
654
|
+
* const node = await createDOMNode(element, context, wikiDoc);
|
|
655
|
+
* // Returns: <span class="wiki-variable">JohnDoe</span>
|
|
656
|
+
*/
|
|
657
|
+
createDOMNode(element: ExtractedElement, context: ParseContext, wikiDocument: WikiDocument): Promise<unknown>;
|
|
658
|
+
/**
|
|
659
|
+
* Merges DOM nodes back into markdown-it HTML (Phase 3)
|
|
660
|
+
*
|
|
661
|
+
* Replaces HTML comment placeholders (<!--JSPWIKI-uuid-id-->) in the HTML with
|
|
662
|
+
* the rendered DOM nodes. Processes nodes in reverse ID order to
|
|
663
|
+
* handle nested JSPWiki syntax correctly.
|
|
664
|
+
*
|
|
665
|
+
* Uses HTML comments as placeholders to avoid markdown-it interpreting them as markdown.
|
|
666
|
+
*
|
|
667
|
+
* @param html - HTML from markdown-it with placeholders
|
|
668
|
+
* @param nodes - Array of DOM nodes with data-jspwiki-id
|
|
669
|
+
* @param uuid - UUID from extraction phase
|
|
670
|
+
* @returns Final HTML with nodes merged in
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* // Input HTML: "<p>User: <!--JSPWIKI-abc123-0--></p>"
|
|
674
|
+
* // Node 0: <span data-jspwiki-id="0">JohnDoe</span>
|
|
675
|
+
* // Output: "<p>User: <span>JohnDoe</span></p>"
|
|
676
|
+
*/
|
|
677
|
+
mergeDOMNodes(html: string, nodes: unknown[], uuid: string): string;
|
|
678
|
+
/**
|
|
679
|
+
* Put rendered HTML where its placeholder sits in markdown-it's output.
|
|
680
|
+
* Shared by DOM nodes and by trusted handler output (#1623).
|
|
681
|
+
*/
|
|
682
|
+
private static placeRendered;
|
|
683
|
+
/**
|
|
684
|
+
* #1368: is `offset` inside an open <p>? The nearest tag before it that opens
|
|
685
|
+
* or closes a container decides: `<p>` says yes; `</p>`, a list item, a cell,
|
|
686
|
+
* a quote or a div says no.
|
|
687
|
+
*/
|
|
688
|
+
private static insideParagraph;
|
|
689
|
+
/**
|
|
690
|
+
* #1368: rendered HTML that starts with a block element. `p` since #1623:
|
|
691
|
+
* trusted handler output (a `<wiki:Include>`) is a rendered page, and a
|
|
692
|
+
* paragraph cannot sit in a paragraph either.
|
|
693
|
+
*/
|
|
694
|
+
private static readonly BLOCK_START;
|
|
695
|
+
/**
|
|
696
|
+
* Parses wiki markup using DOM extraction strategy (Phase 1-3)
|
|
697
|
+
*
|
|
698
|
+
* This is the new parsing method that implements the WikiDocument DOM solution:
|
|
699
|
+
* 1. Extract JSPWiki syntax (variables, plugins, links, escaped)
|
|
700
|
+
* 2. Create DOM nodes from extracted elements
|
|
701
|
+
* 3. Let markdown-it parse the sanitized markdown
|
|
702
|
+
* 4. Merge DOM nodes back into the HTML
|
|
703
|
+
*
|
|
704
|
+
* This approach fixes the markdown heading bug by letting markdown-it handle
|
|
705
|
+
* ALL markdown parsing while WikiDocument handles ONLY JSPWiki syntax.
|
|
706
|
+
*
|
|
707
|
+
* @param content - Wiki markup content
|
|
708
|
+
* @param context - Rendering context
|
|
709
|
+
* @returns Rendered HTML
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* const html = await parser.parseWithDOMExtraction('## Hello\nUser: [{$username}]', context);
|
|
713
|
+
* // Returns: "<h2>Hello</h2>\n<p>User: <span>JohnDoe</span></p>"
|
|
714
|
+
*/
|
|
715
|
+
parseWithDOMExtraction(content: string, context: Record<string, unknown>): Promise<string>;
|
|
716
|
+
/**
|
|
717
|
+
* Get performance metrics
|
|
718
|
+
*/
|
|
719
|
+
getMetrics(): ExtendedMetrics;
|
|
720
|
+
/**
|
|
721
|
+
* Reset performance metrics
|
|
722
|
+
*/
|
|
723
|
+
resetMetrics(): void;
|
|
724
|
+
/**
|
|
725
|
+
* Get cached parse result
|
|
726
|
+
* @param cacheKey - Cache key
|
|
727
|
+
* @returns Cached result or null
|
|
728
|
+
*/
|
|
729
|
+
getCachedParseResult(cacheKey: string): Promise<string | null>;
|
|
730
|
+
/**
|
|
731
|
+
* Cache parse result
|
|
732
|
+
* @param cacheKey - Cache key
|
|
733
|
+
* @param content - Content to cache
|
|
734
|
+
*/
|
|
735
|
+
cacheParseResult(cacheKey: string, content: string): Promise<void>;
|
|
736
|
+
/**
|
|
737
|
+
* Update cache metrics for specific strategy
|
|
738
|
+
* @param strategy - Cache strategy name
|
|
739
|
+
* @param operation - Operation type (hit, miss, set)
|
|
740
|
+
*/
|
|
741
|
+
updateCacheMetrics(strategy: string, operation: 'hit' | 'miss' | 'set'): void;
|
|
742
|
+
/**
|
|
743
|
+
* Update performance metrics and check thresholds
|
|
744
|
+
* @param processingTime - Processing time in milliseconds
|
|
745
|
+
* @param cacheHit - Whether this was a cache hit
|
|
746
|
+
*/
|
|
747
|
+
updatePerformanceMetrics(processingTime: number, cacheHit: boolean): void;
|
|
748
|
+
/**
|
|
749
|
+
* Check performance thresholds and generate alerts
|
|
750
|
+
*/
|
|
751
|
+
checkPerformanceThresholds(): void;
|
|
752
|
+
/**
|
|
753
|
+
* Generate performance alert
|
|
754
|
+
* @param type - Alert type
|
|
755
|
+
* @param message - Alert message
|
|
756
|
+
*/
|
|
757
|
+
generatePerformanceAlert(type: string, message: string): void;
|
|
758
|
+
/**
|
|
759
|
+
* Get performance alerts
|
|
760
|
+
* @returns Array of performance alerts
|
|
761
|
+
*/
|
|
762
|
+
getPerformanceAlerts(): unknown[];
|
|
763
|
+
/**
|
|
764
|
+
* Clear performance alerts
|
|
765
|
+
*/
|
|
766
|
+
clearPerformanceAlerts(): void;
|
|
767
|
+
shutdown(): Promise<void>;
|
|
768
|
+
}
|
|
769
|
+
export default MarkupParser;
|