@file-viewer/renderer-text 3.1.2 → 3.2.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/README.en.md +3 -135
- package/README.md +3 -124
- package/bin/copy-xml-profile-assets.mjs +3 -3
- package/dist/code.d.ts +0 -7
- package/dist/code.js +6 -138
- package/dist/html.js +2 -4
- package/dist/index.js +6 -2
- package/dist/largeText.js +39 -24
- package/dist/lrc.d.ts +2 -0
- package/dist/lrc.js +185 -0
- package/dist/lrcParser.d.ts +23 -0
- package/dist/lrcParser.js +83 -0
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +95 -31
- package/dist/markdownAnchors.d.ts +1 -0
- package/dist/markdownAnchors.js +66 -0
- package/dist/optionalCapabilities.d.ts +0 -4
- package/dist/optionalCapabilities.js +0 -4
- package/dist/patch.js +2 -2
- package/dist/prettyPrint.d.ts +0 -7
- package/dist/prettyPrint.js +0 -9
- package/dist/sanitizeHtml.d.ts +0 -1
- package/dist/sanitizeHtml.js +0 -1
- package/dist/syntaxGrammars/data.d.ts +10 -0
- package/dist/syntaxGrammars/data.js +8 -0
- package/dist/syntaxGrammars/documents.d.ts +5 -0
- package/dist/syntaxGrammars/documents.js +3 -0
- package/dist/syntaxGrammars/managed.d.ts +7 -0
- package/dist/syntaxGrammars/managed.js +5 -0
- package/dist/syntaxGrammars/native.d.ts +10 -0
- package/dist/syntaxGrammars/native.js +8 -0
- package/dist/syntaxGrammars/php.d.ts +5 -0
- package/dist/syntaxGrammars/php.js +3 -0
- package/dist/syntaxGrammars/scripting.d.ts +9 -0
- package/dist/syntaxGrammars/scripting.js +7 -0
- package/dist/syntaxGrammars/tooling.d.ts +8 -0
- package/dist/syntaxGrammars/tooling.js +6 -0
- package/dist/syntaxGrammars/web.d.ts +8 -0
- package/dist/syntaxGrammars/web.js +6 -0
- package/dist/syntaxHighlight.d.ts +5 -0
- package/dist/syntaxHighlight.js +167 -0
- package/dist/xml-profiles.d.ts +0 -1
- package/dist/xml-profiles.js +0 -1
- package/dist/xml.js +6 -11
- package/dist/xmlEngines.js +3 -4
- package/dist/xmlSafety.d.ts +0 -1
- package/dist/xmlSafety.js +0 -3
- package/dist/xmlWasmMemory.d.ts +0 -6
- package/dist/xmlWasmMemory.js +0 -6
- package/file-viewer.capability.json +1 -1
- package/licenses/xml-profiles/NOTICE.md +1 -1
- package/package.json +84 -29
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const languageMap = {
|
|
2
|
+
xhtml: 'xml',
|
|
3
|
+
rss: 'xml',
|
|
4
|
+
atom: 'xml',
|
|
5
|
+
xjb: 'xml',
|
|
6
|
+
xsd: 'xml',
|
|
7
|
+
xsl: 'xml',
|
|
8
|
+
plist: 'xml',
|
|
9
|
+
wsf: 'xml',
|
|
10
|
+
svg: 'xml',
|
|
11
|
+
zsh: 'bash',
|
|
12
|
+
'c++': 'cpp',
|
|
13
|
+
'h++': 'cpp',
|
|
14
|
+
hh: 'cpp',
|
|
15
|
+
hxx: 'cpp',
|
|
16
|
+
cxx: 'cpp',
|
|
17
|
+
'c#': 'csharp',
|
|
18
|
+
mkdown: 'markdown',
|
|
19
|
+
mkd: 'markdown',
|
|
20
|
+
gemspec: 'ruby',
|
|
21
|
+
podspec: 'ruby',
|
|
22
|
+
thor: 'ruby',
|
|
23
|
+
irb: 'ruby',
|
|
24
|
+
golang: 'go',
|
|
25
|
+
jsp: 'java',
|
|
26
|
+
kts: 'kotlin',
|
|
27
|
+
ktm: 'kotlin',
|
|
28
|
+
ktx: 'kotlin',
|
|
29
|
+
pluto: 'lua',
|
|
30
|
+
mk: 'makefile',
|
|
31
|
+
mak: 'makefile',
|
|
32
|
+
make: 'makefile',
|
|
33
|
+
pl: 'perl',
|
|
34
|
+
pm: 'perl',
|
|
35
|
+
mm: 'objectivec',
|
|
36
|
+
objc: 'objectivec',
|
|
37
|
+
'obj-c': 'objectivec',
|
|
38
|
+
'obj-c++': 'objectivec',
|
|
39
|
+
'objective-c++': 'objectivec',
|
|
40
|
+
text: 'plaintext',
|
|
41
|
+
gyp: 'python',
|
|
42
|
+
ipython: 'python',
|
|
43
|
+
pycon: 'python-repl',
|
|
44
|
+
console: 'shell',
|
|
45
|
+
shellsession: 'shell',
|
|
46
|
+
mts: 'typescript',
|
|
47
|
+
cts: 'typescript',
|
|
48
|
+
vb: 'vbnet',
|
|
49
|
+
bash: 'bash',
|
|
50
|
+
c: 'c',
|
|
51
|
+
cc: 'cpp',
|
|
52
|
+
cjs: 'javascript',
|
|
53
|
+
cpp: 'cpp',
|
|
54
|
+
cs: 'csharp',
|
|
55
|
+
css: 'css',
|
|
56
|
+
diff: 'diff',
|
|
57
|
+
patch: 'diff',
|
|
58
|
+
bundle: 'plaintext',
|
|
59
|
+
bdl: 'plaintext',
|
|
60
|
+
gv: 'plaintext',
|
|
61
|
+
go: 'go',
|
|
62
|
+
graphql: 'graphql',
|
|
63
|
+
gql: 'graphql',
|
|
64
|
+
h: 'c',
|
|
65
|
+
hcl: 'plaintext',
|
|
66
|
+
hpp: 'cpp',
|
|
67
|
+
html: 'xml',
|
|
68
|
+
htm: 'xml',
|
|
69
|
+
http: 'http',
|
|
70
|
+
ini: 'ini',
|
|
71
|
+
ipynb: 'json',
|
|
72
|
+
java: 'java',
|
|
73
|
+
js: 'javascript',
|
|
74
|
+
json: 'json',
|
|
75
|
+
json5: 'json',
|
|
76
|
+
jsonc: 'json',
|
|
77
|
+
jsx: 'javascript',
|
|
78
|
+
kt: 'kotlin',
|
|
79
|
+
log: 'plaintext',
|
|
80
|
+
md: 'markdown',
|
|
81
|
+
markdown: 'markdown',
|
|
82
|
+
mjs: 'javascript',
|
|
83
|
+
php: 'php',
|
|
84
|
+
proto: 'protobuf',
|
|
85
|
+
py: 'python',
|
|
86
|
+
rb: 'ruby',
|
|
87
|
+
react: 'javascript',
|
|
88
|
+
rs: 'rust',
|
|
89
|
+
sh: 'bash',
|
|
90
|
+
sql: 'sql',
|
|
91
|
+
swift: 'swift',
|
|
92
|
+
tex: 'latex',
|
|
93
|
+
toml: 'ini',
|
|
94
|
+
ts: 'typescript',
|
|
95
|
+
tsx: 'typescript',
|
|
96
|
+
txt: 'plaintext',
|
|
97
|
+
vue: 'xml',
|
|
98
|
+
xml: 'xml',
|
|
99
|
+
yaml: 'yaml',
|
|
100
|
+
yml: 'yaml'
|
|
101
|
+
};
|
|
102
|
+
const grammarFamilies = [
|
|
103
|
+
{
|
|
104
|
+
names: ['c', 'cpp', 'objectivec', 'rust', 'swift', 'go', 'wasm'],
|
|
105
|
+
load: () => import('./syntaxGrammars/native.js')
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
names: ['java', 'kotlin', 'csharp', 'vbnet'],
|
|
109
|
+
load: () => import('./syntaxGrammars/managed.js')
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
names: ['javascript', 'typescript', 'css', 'less', 'scss'],
|
|
113
|
+
load: () => import('./syntaxGrammars/web.js')
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
names: ['python', 'python-repl', 'ruby', 'perl', 'lua', 'r'],
|
|
117
|
+
load: () => import('./syntaxGrammars/scripting.js')
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
names: ['bash', 'shell', 'makefile', 'ini', 'diff'],
|
|
121
|
+
load: () => import('./syntaxGrammars/tooling.js')
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
names: ['json', 'yaml', 'xml', 'http', 'protobuf', 'graphql', 'sql'],
|
|
125
|
+
load: () => import('./syntaxGrammars/data.js')
|
|
126
|
+
},
|
|
127
|
+
{ names: ['php', 'php-template'], load: () => import('./syntaxGrammars/php.js') },
|
|
128
|
+
{ names: ['markdown', 'latex'], load: () => import('./syntaxGrammars/documents.js') }
|
|
129
|
+
];
|
|
130
|
+
const languageLoaders = Object.fromEntries(grammarFamilies.flatMap(({ names, load }) => names.map((name) => [name, async () => ({ default: (await load()).default[name] })])));
|
|
131
|
+
let highlighterPromise = null;
|
|
132
|
+
const registeredLanguages = new Set();
|
|
133
|
+
export const resolveLanguage = (type) => {
|
|
134
|
+
const normalized = type.trim().toLowerCase();
|
|
135
|
+
return languageMap[normalized] || (languageLoaders[normalized] ? normalized : 'plaintext');
|
|
136
|
+
};
|
|
137
|
+
export const escapeHtml = (value) => {
|
|
138
|
+
return value.replace(/[&<>"']/g, (char) => {
|
|
139
|
+
const entities = {
|
|
140
|
+
'&': '&',
|
|
141
|
+
'<': '<',
|
|
142
|
+
'>': '>',
|
|
143
|
+
'"': '"',
|
|
144
|
+
"'": '''
|
|
145
|
+
};
|
|
146
|
+
return entities[char];
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export const loadHighlighter = async () => {
|
|
150
|
+
if (!highlighterPromise) {
|
|
151
|
+
highlighterPromise = import('highlight.js/lib/core').then((module) => module.default);
|
|
152
|
+
}
|
|
153
|
+
return highlighterPromise;
|
|
154
|
+
};
|
|
155
|
+
export const registerLanguageOnce = async (hljs, name) => {
|
|
156
|
+
if (registeredLanguages.has(name)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
const loader = languageLoaders[name];
|
|
160
|
+
if (!loader) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const { default: language } = await loader();
|
|
164
|
+
hljs.registerLanguage(name, language);
|
|
165
|
+
registeredLanguages.add(name);
|
|
166
|
+
return true;
|
|
167
|
+
};
|
package/dist/xml-profiles.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export type { FileViewerXmlProfile, FileViewerXmlManifest, FileViewerXmlOptions, FileViewerXmlDiagnostic, FileViewerXmlDiagnosticCode } from '@file-viewer/core';
|
|
2
2
|
export type { FileViewerXmlRenderedInstance } from './xml.js';
|
|
3
|
-
/** Register the built-in WASM implementation. Loading and execution remain lazy. */
|
|
4
3
|
export declare function enableFileViewerXmlProfiles(): () => void;
|
package/dist/xml-profiles.js
CHANGED
package/dist/xml.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createHtmlPreviewDocument } from './html.js';
|
|
|
4
4
|
import { applyXmlProfiles } from './xmlProfiles.js';
|
|
5
5
|
import { checkXmlAbort, XmlProfileError } from './xmlSafety.js';
|
|
6
6
|
export default async function renderXml(buffer, target, context) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
8
8
|
const options = (_b = (_a = context === null || context === void 0 ? void 0 : context.options) === null || _a === void 0 ? void 0 : _a.xml) !== null && _b !== void 0 ? _b : {};
|
|
9
9
|
const doc = target.ownerDocument;
|
|
10
10
|
const controller = new AbortController();
|
|
@@ -58,8 +58,6 @@ export default async function renderXml(buffer, target, context) {
|
|
|
58
58
|
return;
|
|
59
59
|
view = next;
|
|
60
60
|
root.dataset.xmlView = next;
|
|
61
|
-
// Keep the sandbox's layout alive while the opaque source layer covers it.
|
|
62
|
-
// Hiding an out-of-process iframe can leave a blank compositor surface on return.
|
|
63
61
|
frame.inert = next !== 'rendered';
|
|
64
62
|
frame.setAttribute('aria-hidden', String(next !== 'rendered'));
|
|
65
63
|
frame.style.pointerEvents = next === 'rendered' ? '' : 'none';
|
|
@@ -85,7 +83,6 @@ export default async function renderXml(buffer, target, context) {
|
|
|
85
83
|
frame === null || frame === void 0 ? void 0 : frame.removeAttribute('srcdoc');
|
|
86
84
|
frame === null || frame === void 0 ? void 0 : frame.remove();
|
|
87
85
|
frame = undefined;
|
|
88
|
-
// Only remove this render's DOM; a later render may already own the target.
|
|
89
86
|
root.remove();
|
|
90
87
|
root.replaceChildren();
|
|
91
88
|
style.remove();
|
|
@@ -113,7 +110,7 @@ export default async function renderXml(buffer, target, context) {
|
|
|
113
110
|
try {
|
|
114
111
|
(_a = options.onDiagnostic) === null || _a === void 0 ? void 0 : _a.call(options, { ...safe });
|
|
115
112
|
}
|
|
116
|
-
catch {
|
|
113
|
+
catch { }
|
|
117
114
|
try {
|
|
118
115
|
(_c = (_b = context === null || context === void 0 ? void 0 : context.options) === null || _b === void 0 ? void 0 : _b.onDiagnostic) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
119
116
|
code: `xml-profile-${safe.code}`,
|
|
@@ -121,13 +118,11 @@ export default async function renderXml(buffer, target, context) {
|
|
|
121
118
|
message: safe.message, detail: { profileId: safe.profileId }
|
|
122
119
|
});
|
|
123
120
|
}
|
|
124
|
-
catch {
|
|
121
|
+
catch { }
|
|
125
122
|
};
|
|
126
123
|
let timeout;
|
|
127
124
|
try {
|
|
128
125
|
checkXmlAbort(signal);
|
|
129
|
-
// Pretty printing would change the displayed source. Pass the exact input
|
|
130
|
-
// bytes to the existing renderer, with only that display option disabled.
|
|
131
126
|
sourceInstance = await renderCode(buffer, sourceTarget, 'xml', {
|
|
132
127
|
...context, signal,
|
|
133
128
|
options: { ...context === null || context === void 0 ? void 0 : context.options, text: { ...(_l = context === null || context === void 0 ? void 0 : context.options) === null || _l === void 0 ? void 0 : _l.text, prettyPrint: false } }
|
|
@@ -140,14 +135,14 @@ export default async function renderXml(buffer, target, context) {
|
|
|
140
135
|
if (!Number.isFinite(milliseconds) || milliseconds < 1)
|
|
141
136
|
throw new XmlProfileError('invalid-manifest', 'XML timeout must be a positive number.');
|
|
142
137
|
timeout = setTimeout(() => controller.abort(new XmlProfileError('timeout', 'XML profile processing timed out.')), Math.min(milliseconds, 60000));
|
|
143
|
-
const source = decodeFileViewerTextBuffer(buffer, (_p = (_o = context === null || context === void 0 ? void 0 : context.options) === null || _o === void 0 ? void 0 : _o.text) === null || _p === void 0 ? void 0 : _p.encoding).text;
|
|
138
|
+
const source = decodeFileViewerTextBuffer(buffer, (_p = (_o = context === null || context === void 0 ? void 0 : context.options) === null || _o === void 0 ? void 0 : _o.text) === null || _p === void 0 ? void 0 : _p.encoding, (_r = (_q = context === null || context === void 0 ? void 0 : context.options) === null || _q === void 0 ? void 0 : _q.text) === null || _r === void 0 ? void 0 : _r.fallbackEncoding).text;
|
|
144
139
|
const result = await applyXmlProfiles(source, buffer.byteLength, options, doc, signal, emit);
|
|
145
140
|
checkXmlAbort(signal);
|
|
146
141
|
if (result && !disposed) {
|
|
147
142
|
const html = createHtmlPreviewDocument(doc, result.html);
|
|
148
143
|
frame = doc.createElement('iframe');
|
|
149
144
|
frame.className = 'xml-profile-rendered';
|
|
150
|
-
frame.title = (
|
|
145
|
+
frame.title = (_t = (_s = options.labels) === null || _s === void 0 ? void 0 : _s.viewRendered) !== null && _t !== void 0 ? _t : 'Rendered XML';
|
|
151
146
|
frame.setAttribute('sandbox', '');
|
|
152
147
|
frame.referrerPolicy = 'no-referrer';
|
|
153
148
|
frame.srcdoc = html;
|
|
@@ -155,7 +150,7 @@ export default async function renderXml(buffer, target, context) {
|
|
|
155
150
|
profileId = result.profileId;
|
|
156
151
|
root.dataset.xmlProfile = profileId;
|
|
157
152
|
controls.hidden = false;
|
|
158
|
-
setView((
|
|
153
|
+
setView((_u = options.initialView) !== null && _u !== void 0 ? _u : 'rendered');
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
156
|
catch (error) {
|
package/dist/xmlEngines.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { checkXmlAbort, XmlProfileError } from './xmlSafety.js';
|
|
2
2
|
import { limitXmlWasmMemory } from './xmlWasmMemory.js';
|
|
3
|
-
// This function is serialized into an isolated worker alongside the unmodified,
|
|
4
|
-
// pinned upstream factory. Keep it self-contained (no module-scope references).
|
|
5
3
|
function runXsltWorker() {
|
|
6
4
|
const scope = globalThis;
|
|
7
5
|
const NativeModule = WebAssembly.Module;
|
|
@@ -56,8 +54,6 @@ function runXsltWorker() {
|
|
|
56
54
|
if (end === bound)
|
|
57
55
|
throw new Error('XSLT output exceeds its byte limit.');
|
|
58
56
|
const mime = new TextDecoder().decode(heap.subarray(mimePointer, mimePointer + 32)).split('\0')[0];
|
|
59
|
-
// A fragment without xsl:output is commonly serialized as application/xml.
|
|
60
|
-
// Both serializations are sanitized as inert HTML by the host, never executed.
|
|
61
57
|
if (mime !== 'text/html' && mime !== 'application/xml')
|
|
62
58
|
throw new Error('XSLT did not produce HTML-compatible output.');
|
|
63
59
|
scope.postMessage({ html: new TextDecoder('utf-8', { fatal: true }).decode(heap.subarray(result, end)) });
|
|
@@ -81,6 +77,9 @@ function runXsdWorker() {
|
|
|
81
77
|
scope.onmessage = async ({ data }) => {
|
|
82
78
|
let errors = '';
|
|
83
79
|
try {
|
|
80
|
+
if (!data.wasm || !WebAssembly.validate(data.wasm)) {
|
|
81
|
+
throw new Error('Invalid XML Schema WASM binary.');
|
|
82
|
+
}
|
|
84
83
|
await Module({
|
|
85
84
|
inputFiles: [
|
|
86
85
|
{ fileName: 'input.xml', contents: data.xml },
|
package/dist/xmlSafety.d.ts
CHANGED
|
@@ -15,5 +15,4 @@ export declare function checkXmlAbort(signal: AbortSignal): void;
|
|
|
15
15
|
export declare function sameOriginXmlUrl(value: string, base: string, origin: string): string;
|
|
16
16
|
export declare function fetchXmlBytes(url: string, maxBytes: number, signal: AbortSignal): Promise<Uint8Array>;
|
|
17
17
|
export declare function parseSafeXml(source: string, documentRef: Document, kind: 'xml' | 'xsd' | 'xslt'): XMLDocument;
|
|
18
|
-
/** Only the engine copy is normalized; the source renderer keeps the original buffer. */
|
|
19
18
|
export declare function xmlEngineText(source: string): string;
|
package/dist/xmlSafety.js
CHANGED
|
@@ -99,7 +99,6 @@ const XSD = 'http://www.w3.org/2001/XMLSchema';
|
|
|
99
99
|
const XSL = 'http://www.w3.org/1999/XSL/Transform';
|
|
100
100
|
export function parseSafeXml(source, documentRef, kind) {
|
|
101
101
|
var _a;
|
|
102
|
-
// Reject declarations before invoking any XML parser, including entity expansion.
|
|
103
102
|
if (/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(source)) {
|
|
104
103
|
throw new XmlProfileError('unsafe-resource', 'DTD and entity declarations are disabled for XML profiles.');
|
|
105
104
|
}
|
|
@@ -126,7 +125,6 @@ export function parseSafeXml(source, documentRef, kind) {
|
|
|
126
125
|
if (kind !== 'xslt')
|
|
127
126
|
continue;
|
|
128
127
|
for (const attribute of Array.from(element.attributes)) {
|
|
129
|
-
// DOM values decode character references, so document() cannot bypass this guard.
|
|
130
128
|
if (/(?:^|[^\w.-])document\s*\(/.test(attribute.value) ||
|
|
131
129
|
(attribute.localName === 'extension-element-prefixes' && attribute.value.trim())) {
|
|
132
130
|
throw new XmlProfileError('unsafe-resource', 'XSLT document() and extension instructions are disabled.');
|
|
@@ -140,7 +138,6 @@ export function parseSafeXml(source, documentRef, kind) {
|
|
|
140
138
|
}
|
|
141
139
|
return doc;
|
|
142
140
|
}
|
|
143
|
-
/** Only the engine copy is normalized; the source renderer keeps the original buffer. */
|
|
144
141
|
export function xmlEngineText(source) {
|
|
145
142
|
return source.replace(/^(\uFEFF?<\?xml\s[^?]*?encoding\s*=\s*)(["'])[^"']*\2/, '$1"UTF-8"');
|
|
146
143
|
}
|
package/dist/xmlWasmMemory.d.ts
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clamp the standard WASM memory section before compilation. xslt-polyfill's
|
|
3
|
-
* SINGLE_FILE build defines (rather than imports) memory, so an Emscripten
|
|
4
|
-
* wasmMemory option cannot constrain it. No instructions or data are changed.
|
|
5
|
-
* Keep this function self-contained: it is serialized into the XSLT worker.
|
|
6
|
-
*/
|
|
7
1
|
export declare function limitXmlWasmMemory(input: BufferSource, maxPages?: number): Uint8Array<ArrayBuffer>;
|
package/dist/xmlWasmMemory.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clamp the standard WASM memory section before compilation. xslt-polyfill's
|
|
3
|
-
* SINGLE_FILE build defines (rather than imports) memory, so an Emscripten
|
|
4
|
-
* wasmMemory option cannot constrain it. No instructions or data are changed.
|
|
5
|
-
* Keep this function self-contained: it is serialized into the XSLT worker.
|
|
6
|
-
*/
|
|
7
1
|
export function limitXmlWasmMemory(input, maxPages = 1024) {
|
|
8
2
|
const bytes = ArrayBuffer.isView(input)
|
|
9
3
|
? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"id": "text",
|
|
5
5
|
"packageName": "@file-viewer/renderer-text",
|
|
6
6
|
"rendererIds": ["markdown", "code"],
|
|
7
|
-
"formats": ["md", "markdown", "txt", "json", "js", "mjs", "cjs", "css", "java", "py", "html", "htm", "jsx", "ts", "tsx", "xml", "log", "vue", "yaml", "yml", "ini", "sh", "bash", "sql", "go", "rs", "php", "c", "cpp", "cc", "h", "hpp", "cs", "jsonc", "json5", "ipynb", "toml", "proto", "hcl", "tex", "gv", "http", "react", "rb", "swift", "kt"],
|
|
7
|
+
"formats": ["md", "markdown", "txt", "lrc", "json", "js", "mjs", "cjs", "css", "java", "py", "html", "htm", "jsx", "ts", "tsx", "xml", "log", "vue", "yaml", "yml", "ini", "sh", "bash", "sql", "go", "rs", "php", "c", "cpp", "cc", "h", "hpp", "cs", "jsonc", "json5", "ipynb", "toml", "proto", "hcl", "tex", "gv", "http", "react", "rb", "swift", "kt"],
|
|
8
8
|
"assets": { "rendererIds": [] },
|
|
9
9
|
"license": { "spdx": "Apache-2.0", "policy": "permissive" },
|
|
10
10
|
"weight": "standard",
|
|
@@ -8,7 +8,7 @@ the engine's instructions or data, nor install the automatic page polyfill.
|
|
|
8
8
|
|
|
9
9
|
| Component | Verified upstream notice | Included notice |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| xslt-polyfill 1.0.
|
|
11
|
+
| xslt-polyfill 1.0.31 | [BSD-3-Clause](https://github.com/mfreed7/xslt_polyfill/blob/main/LICENSE) | xslt-polyfill-LICENSE.txt |
|
|
12
12
|
| xmllint-wasm 5.3.0 | [MIT](https://github.com/noppa/xmllint-wasm/blob/master/COPYING) | xmllint-wasm-COPYING.txt |
|
|
13
13
|
| XSLT libxml2 submodule | [Copyright at c34742f](https://github.com/GNOME/libxml2/blob/c34742f3017f6d39f3e4ccae4f70172238160ef8/Copyright) | libxml2-xslt-Copyright.txt |
|
|
14
14
|
| XSD libxml2 submodule | [Copyright at eb0a2f2](https://github.com/GNOME/libxml2/blob/eb0a2f2b91566384f378d870ffcd69c0a24162cc/Copyright) | libxml2-xsd-Copyright.txt |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-text",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone code, text, and Markdown renderer for File Viewer; Mermaid, patch diff, and Git bundle tools are explicit opt-in capabilities.",
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/flyfish-dev/file-viewer.git"
|
|
32
|
-
"directory": "packages/renderers/text"
|
|
31
|
+
"url": "git+https://github.com/flyfish-dev/file-viewer.git"
|
|
33
32
|
},
|
|
34
33
|
"homepage": "https://doc.file-viewer.app/guide/on-demand-renderers",
|
|
35
34
|
"bugs": {
|
|
@@ -60,34 +59,91 @@
|
|
|
60
59
|
"file-viewer-xml-assets": "./bin/copy-xml-profile-assets.mjs"
|
|
61
60
|
},
|
|
62
61
|
"files": [
|
|
63
|
-
"
|
|
62
|
+
"bin/copy-xml-profile-assets.mjs",
|
|
63
|
+
"dist/code.d.ts",
|
|
64
|
+
"dist/code.js",
|
|
65
|
+
"dist/codeStyle.d.ts",
|
|
66
|
+
"dist/codeStyle.js",
|
|
67
|
+
"dist/gitBundle.d.ts",
|
|
68
|
+
"dist/gitBundle.js",
|
|
69
|
+
"dist/html.d.ts",
|
|
70
|
+
"dist/html.js",
|
|
71
|
+
"dist/index.d.ts",
|
|
72
|
+
"dist/index.js",
|
|
73
|
+
"dist/largeText.d.ts",
|
|
74
|
+
"dist/largeText.js",
|
|
75
|
+
"dist/lrc.d.ts",
|
|
76
|
+
"dist/lrc.js",
|
|
77
|
+
"dist/lrcParser.d.ts",
|
|
78
|
+
"dist/lrcParser.js",
|
|
79
|
+
"dist/markdown.d.ts",
|
|
80
|
+
"dist/markdown.js",
|
|
81
|
+
"dist/markdownAnchors.d.ts",
|
|
82
|
+
"dist/markdownAnchors.js",
|
|
83
|
+
"dist/optionalCapabilities.d.ts",
|
|
84
|
+
"dist/optionalCapabilities.js",
|
|
85
|
+
"dist/patch.d.ts",
|
|
86
|
+
"dist/patch.js",
|
|
87
|
+
"dist/prettyPrint.d.ts",
|
|
88
|
+
"dist/prettyPrint.js",
|
|
89
|
+
"dist/sanitizeHtml.d.ts",
|
|
90
|
+
"dist/sanitizeHtml.js",
|
|
91
|
+
"dist/syntaxGrammars/data.d.ts",
|
|
92
|
+
"dist/syntaxGrammars/data.js",
|
|
93
|
+
"dist/syntaxGrammars/documents.d.ts",
|
|
94
|
+
"dist/syntaxGrammars/documents.js",
|
|
95
|
+
"dist/syntaxGrammars/managed.d.ts",
|
|
96
|
+
"dist/syntaxGrammars/managed.js",
|
|
97
|
+
"dist/syntaxGrammars/native.d.ts",
|
|
98
|
+
"dist/syntaxGrammars/native.js",
|
|
99
|
+
"dist/syntaxGrammars/php.d.ts",
|
|
100
|
+
"dist/syntaxGrammars/php.js",
|
|
101
|
+
"dist/syntaxGrammars/scripting.d.ts",
|
|
102
|
+
"dist/syntaxGrammars/scripting.js",
|
|
103
|
+
"dist/syntaxGrammars/tooling.d.ts",
|
|
104
|
+
"dist/syntaxGrammars/tooling.js",
|
|
105
|
+
"dist/syntaxGrammars/web.d.ts",
|
|
106
|
+
"dist/syntaxGrammars/web.js",
|
|
107
|
+
"dist/syntaxHighlight.d.ts",
|
|
108
|
+
"dist/syntaxHighlight.js",
|
|
109
|
+
"dist/xml-profiles.d.ts",
|
|
110
|
+
"dist/xml-profiles.js",
|
|
111
|
+
"dist/xml.d.ts",
|
|
112
|
+
"dist/xml.js",
|
|
113
|
+
"dist/xmlEngines.d.ts",
|
|
114
|
+
"dist/xmlEngines.js",
|
|
115
|
+
"dist/xmlProfiles.d.ts",
|
|
116
|
+
"dist/xmlProfiles.js",
|
|
117
|
+
"dist/xmlRegistration.d.ts",
|
|
118
|
+
"dist/xmlRegistration.js",
|
|
119
|
+
"dist/xmlSafety.d.ts",
|
|
120
|
+
"dist/xmlSafety.js",
|
|
121
|
+
"dist/xmlWasmMemory.d.ts",
|
|
122
|
+
"dist/xmlWasmMemory.js",
|
|
64
123
|
"file-viewer.capability.json",
|
|
65
|
-
"README.md",
|
|
66
|
-
"README.en.md",
|
|
67
124
|
"LICENSE",
|
|
68
|
-
"
|
|
69
|
-
"licenses/xml-profiles"
|
|
125
|
+
"licenses/xml-profiles/libxml2-xsd-Copyright.txt",
|
|
126
|
+
"licenses/xml-profiles/libxml2-xslt-Copyright.txt",
|
|
127
|
+
"licenses/xml-profiles/libxslt-Copyright.txt",
|
|
128
|
+
"licenses/xml-profiles/NOTICE.md",
|
|
129
|
+
"licenses/xml-profiles/xmllint-wasm-COPYING.txt",
|
|
130
|
+
"licenses/xml-profiles/xslt-polyfill-LICENSE.txt",
|
|
131
|
+
"licenses/xml-profiles/zlib-LICENSE.txt",
|
|
132
|
+
"README.en.md",
|
|
133
|
+
"README.md"
|
|
70
134
|
],
|
|
71
135
|
"dependencies": {
|
|
72
|
-
"@file-viewer/core": "3.
|
|
136
|
+
"@file-viewer/core": "3.2.0",
|
|
137
|
+
"@types/pako": "^2.0.4",
|
|
73
138
|
"@prettier/plugin-xml": "3.4.2",
|
|
74
|
-
"dompurify": "3.4.
|
|
139
|
+
"dompurify": "3.4.16",
|
|
75
140
|
"highlight.js": "^11.11.1",
|
|
76
141
|
"marked": "^18.0.12",
|
|
77
|
-
"prettier": "3.9.
|
|
78
|
-
},
|
|
79
|
-
"devDependencies": {
|
|
80
|
-
"diff2html": "^3.4.56",
|
|
81
|
-
"mermaid": "^11.17.2",
|
|
82
|
-
"pako": "^2.2.0",
|
|
83
|
-
"jsdom": "^27.4.0",
|
|
84
|
-
"typescript": "^6.0.3",
|
|
85
|
-
"xmllint-wasm": "5.3.0",
|
|
86
|
-
"xslt-polyfill": "1.0.29"
|
|
142
|
+
"prettier": "3.9.9"
|
|
87
143
|
},
|
|
88
144
|
"peerDependencies": {
|
|
89
145
|
"xmllint-wasm": "5.3.0",
|
|
90
|
-
"xslt-polyfill": "1.0.
|
|
146
|
+
"xslt-polyfill": "1.0.31"
|
|
91
147
|
},
|
|
92
148
|
"peerDependenciesMeta": {
|
|
93
149
|
"xmllint-wasm": {
|
|
@@ -98,12 +154,11 @@
|
|
|
98
154
|
}
|
|
99
155
|
},
|
|
100
156
|
"fileViewer": {
|
|
101
|
-
"capabilityManifest": "./file-viewer.capability.json"
|
|
157
|
+
"capabilityManifest": "./file-viewer.capability.json",
|
|
158
|
+
"distribution": {
|
|
159
|
+
"schemaVersion": 1,
|
|
160
|
+
"mode": "runtime-only"
|
|
161
|
+
}
|
|
102
162
|
},
|
|
103
|
-
"license": "Apache-2.0"
|
|
104
|
-
|
|
105
|
-
"build": "tsc -b tsconfig.json && node --test test/*.test.mjs",
|
|
106
|
-
"type-check": "tsc -b tsconfig.json",
|
|
107
|
-
"test:xml-profiles:browser": "node test/issue-305-xml-profiles.browser.mjs"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
163
|
+
"license": "Apache-2.0"
|
|
164
|
+
}
|