diff --git a/.changeset/README.md b/.changeset/README.md
deleted file mode 100644
index e5b6d8d6a6..0000000000
--- a/.changeset/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Changesets
-
-Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
-with multi-package repos, or single-package repos to help you version and publish your code. You can
-find the full documentation for it [in our repository](https://github.com/changesets/changesets)
-
-We have a quick list of common questions to get you started engaging with this project in
-[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
diff --git a/.changeset/big-jeans-press.md b/.changeset/big-jeans-press.md
deleted file mode 100644
index 72860338ed..0000000000
--- a/.changeset/big-jeans-press.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@gitbook/react-openapi': patch
----
-
-Add heredoc support for cURL JSON body
diff --git a/.changeset/breezy-nights-repair.md b/.changeset/breezy-nights-repair.md
deleted file mode 100644
index 1f4aa422c3..0000000000
--- a/.changeset/breezy-nights-repair.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Fix webframe height issue
diff --git a/.changeset/busy-weeks-add.md b/.changeset/busy-weeks-add.md
deleted file mode 100644
index 4d105b51d0..0000000000
--- a/.changeset/busy-weeks-add.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Add breadcrumbs to search results
diff --git a/.changeset/calm-shirts-tie.md b/.changeset/calm-shirts-tie.md
deleted file mode 100644
index 2ecafaa2e6..0000000000
--- a/.changeset/calm-shirts-tie.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@gitbook/react-openapi': patch
----
-
-Re-arrange OpenAPI Scopes for OAuth2
diff --git a/.changeset/cold-dancers-buy.md b/.changeset/cold-dancers-buy.md
deleted file mode 100644
index 04e8cb5e1e..0000000000
--- a/.changeset/cold-dancers-buy.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-SearchInput fixes — Translate Clear button, Bold theme color, "Esc" keyboard shortcut
diff --git a/.changeset/config.json b/.changeset/config.json
deleted file mode 100644
index 8cbae7d6e5..0000000000
--- a/.changeset/config.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
- "changelog": "@changesets/cli/changelog",
- "commit": false,
- "fixed": [],
- "linked": [],
- "access": "public",
- "baseBranch": "main",
- "updateInternalDependencies": "patch",
- "ignore": []
-}
diff --git a/.changeset/curvy-forks-joke.md b/.changeset/curvy-forks-joke.md
deleted file mode 100644
index 03de176c94..0000000000
--- a/.changeset/curvy-forks-joke.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Fix search container shadow
diff --git a/.changeset/early-cobras-raise.md b/.changeset/early-cobras-raise.md
deleted file mode 100644
index 01eedec3e5..0000000000
--- a/.changeset/early-cobras-raise.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Update dropdown menu styling
diff --git a/.changeset/frank-doors-smell.md b/.changeset/frank-doors-smell.md
deleted file mode 100644
index 399dc02361..0000000000
--- a/.changeset/frank-doors-smell.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Printable collapsed code block
diff --git a/.changeset/fruity-banks-doubt.md b/.changeset/fruity-banks-doubt.md
deleted file mode 100644
index 82be5cb98f..0000000000
--- a/.changeset/fruity-banks-doubt.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Revert contentref anchor title
diff --git a/.changeset/goofy-bats-chew.md b/.changeset/goofy-bats-chew.md
deleted file mode 100644
index a177c32262..0000000000
--- a/.changeset/goofy-bats-chew.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-'@gitbook/openapi-parser': patch
-'@gitbook/react-openapi': patch
----
-
-Bump Scalar
diff --git a/.changeset/hot-suits-wear.md b/.changeset/hot-suits-wear.md
deleted file mode 100644
index 75c37046e3..0000000000
--- a/.changeset/hot-suits-wear.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Reword "Everywhere" search scope to "All docs"
diff --git a/.changeset/huge-worms-follow.md b/.changeset/huge-worms-follow.md
deleted file mode 100644
index 12c84fc5ac..0000000000
--- a/.changeset/huge-worms-follow.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@gitbook/react-openapi': patch
----
-
-Disable OpenAPI "Try it" when no servers are defined
diff --git a/.changeset/lazy-snails-warn.md b/.changeset/lazy-snails-warn.md
deleted file mode 100644
index e2467abfea..0000000000
--- a/.changeset/lazy-snails-warn.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"gitbook": patch
----
-
-Move the "Ask
- Docs - Community - Developer Docs - Changelog - Bug reports - Feature requests
- Welcome to GitBook, the platform for managing technical knowledge for teams. This repository contains the open source code used to render GitBook's published content.
- GitBook
+GitBook
+=======
-
-
-
-```
+#### Plugins
+
+Plugins can be used to extend your book's functionality. Read [GitbookIO/plugin](https://github.com/GitbookIO/plugin) for more information about how to build a plugin for GitBook.
-## Acknowledgements
+##### Official plugins:
-GitBook wouldn't be possible without these projects:
+| Name | Description |
+| ----- | ---- |
+| [exercises](https://github.com/GitbookIO/plugin-exercises) | Add interactive exercises to your book. |
+| [quizzes](https://github.com/GitbookIO/plugin-quizzes) | Add interactive quizzes to your book. |
+| [mathjax](https://github.com/GitbookIO/plugin-mathjax) | Displays mathematical notation in the book. |
+| [mixpanel](https://github.com/GitbookIO/plugin-mixpanel) | Mixpanel tracking for your book |
+| [infinitescroll](https://github.com/GitbookIO/gitbook-plugin-infinitescroll) | Infinite Scrolling |
-- [Next.js](https://nextjs.org/)
-- [Bun](https://bun.sh/)
-- [Tailwind CSS](https://tailwindcss.com/)
-- [Framer Motion](https://www.npmjs.com/package/framer-motion)
+##### Other plugins:
-## Contributors
+| Name | Description |
+| ----- | ---- |
+| [Google Analytics](https://github.com/GitbookIO/plugin-ga) | Google Analytics tracking for your book |
+| [Disqus](https://github.com/GitbookIO/plugin-disqus) | Disqus comments integration in your book |
+| [Autocover](https://github.com/GitbookIO/plugin-autocover) | Generate a cover for your book |
+| [Transform annoted quotes to notes](https://github.com/erixtekila/gitbook-plugin-richquotes) | Allow extra markdown markup to render blockquotes as nice notes |
+| [Send code to console](https://github.com/erixtekila/gitbook-plugin-toconsole) | Evaluate javascript block in the browser inspector's console |
+| [Revealable sections](https://github.com/mrpotes/gitbook-plugin-reveal) | Reveal sections of the page using buttons made from the first title in each section |
+| [Markdown within HTML](https://github.com/mrpotes/gitbook-plugin-nestedmd) | Process markdown within HTML blocks - allows custom layout options for individual pages |
+| [Bootstrap JavaScript plugins](https://github.com/mrpotes/gitbook-plugin-bootstrapjs) | Use the [Bootstrap JavaScript plugins](http://getbootstrap.com/javascript) in your online GitBook |
+| [Piwik Open Analytics](https://github.com/emmanuel-keller/gitbook-plugin-piwik) | Piwik Open Analytics tracking for your book |
+| [Heading Anchors](https://github.com/rlmv/gitbook-plugin-anchors) | Add linkable Github-style anchors to headings |
+| [JSBin](https://github.com/jcouyang/gitbook-plugin-jsbin) | Embedded jsbin frame into your book |
+| [gitbook-grvis](https://github.com/romanlytkin/gitbook-grvis) | Gitbook GrViz plugin is used to select from markdown dot and converting it into a picture format svg |
+| [gitbook-plantuml](https://github.com/romanlytkin/gitbook-plantuml) | Gitbook PlantUml plugin is used to select from markdown uml and converting it into a picture format svg |
-
-
-
+#### Debugging
-## Legacy GitBook (Deprecated)
+You can use the environment variable `DEBUG=true` to get better error messages (with stack trace). For example:
-Our previous version of GitBook and it's CLI tool are now deprecated. You can still view the old repository and it's commits on this [branch](https://github.com/GitbookIO/gitbook/tree/legacy).
+```
+$ export DEBUG=true
+$ gitbook build ./
+```
diff --git a/assets/published-site.png b/assets/published-site.png
deleted file mode 100644
index 1522c9fb9a..0000000000
Binary files a/assets/published-site.png and /dev/null differ
diff --git a/bin/build.js b/bin/build.js
new file mode 100644
index 0000000000..965a2112f0
--- /dev/null
+++ b/bin/build.js
@@ -0,0 +1,63 @@
+var path = require('path');
+var Q = require('q');
+var _ = require('lodash');
+var fs = require('fs');
+
+var utils = require('./utils');
+var generate = require("../lib/generate");
+var parse = require("../lib/parse");
+var generators = require("../lib/generate").generators;
+
+var buildCommand = function(command) {
+ return command
+ .option('-v, --verbose', 'Activate verbose mode, useful for debugging errors')
+ .option('-o, --output
' for non-pre containers
+
+ */
+ function fixMarkup(value) {
+ if (options.tabReplace) {
+ value = value.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1, offset, s) {
+ return p1.replace(/\t/g, options.tabReplace);
+ });
+ }
+ if (options.useBR) {
+ value = value.replace(/\n/g, '
');
+ }
+ return value;
+ }
+
+ function buildClassName(prevClassName, currentLang, resultLang) {
+ var language = currentLang ? aliases[currentLang] : resultLang,
+ result = [prevClassName.trim()];
+
+ if (!prevClassName.match(/(\s|^)hljs(\s|$)/)) {
+ result.push('hljs');
+ }
+
+ if (language) {
+ result.push(language);
+ }
+
+ return result.join(' ').trim();
+ }
+
+ /*
+ Applies highlighting to a DOM node containing code. Accepts a DOM node and
+ two optional parameters for fixMarkup.
+ */
+ function highlightBlock(block) {
+ var language = blockLanguage(block);
+ if (/no(-?)highlight/.test(language))
+ return;
+
+ var node;
+ if (options.useBR) {
+ node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
+ node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/
/g, '\n');
+ } else {
+ node = block;
+ }
+ var text = node.textContent;
+ var result = language ? highlight(language, text, true) : highlightAuto(text);
+
+ var originalStream = nodeStream(node);
+ if (originalStream.length) {
+ var resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
+ resultNode.innerHTML = result.value;
+ result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
+ }
+ result.value = fixMarkup(result.value);
+
+ block.innerHTML = result.value;
+ block.className = buildClassName(block.className, language, result.language);
+ block.result = {
+ language: result.language,
+ re: result.relevance
+ };
+ if (result.second_best) {
+ block.second_best = {
+ language: result.second_best.language,
+ re: result.second_best.relevance
+ };
+ }
+ }
+
+ var options = {
+ classPrefix: 'hljs-',
+ tabReplace: null,
+ useBR: false,
+ languages: undefined
+ };
+
+ /*
+ Updates highlight.js global options with values passed in the form of an object
+ */
+ function configure(user_options) {
+ options = inherit(options, user_options);
+ }
+
+ /*
+ Applies highlighting to all
blocks on a page.
+ */
+ function initHighlighting() {
+ if (initHighlighting.called)
+ return;
+ initHighlighting.called = true;
+
+ var blocks = document.querySelectorAll('pre code');
+ Array.prototype.forEach.call(blocks, highlightBlock);
+ }
+
+ /*
+ Attaches highlighting to the page load event.
+ */
+ function initHighlightingOnLoad() {
+ addEventListener('DOMContentLoaded', initHighlighting, false);
+ addEventListener('load', initHighlighting, false);
+ }
+
+ var languages = {};
+ var aliases = {};
+
+ function registerLanguage(name, language) {
+ var lang = languages[name] = language(this);
+ if (lang.aliases) {
+ lang.aliases.forEach(function(alias) {aliases[alias] = name;});
+ }
+ }
+
+ function listLanguages() {
+ return Object.keys(languages);
+ }
+
+ function getLanguage(name) {
+ return languages[name] || languages[aliases[name]];
+ }
+
+ /* Interface definition */
+
+ this.highlight = highlight;
+ this.highlightAuto = highlightAuto;
+ this.fixMarkup = fixMarkup;
+ this.highlightBlock = highlightBlock;
+ this.configure = configure;
+ this.initHighlighting = initHighlighting;
+ this.initHighlightingOnLoad = initHighlightingOnLoad;
+ this.registerLanguage = registerLanguage;
+ this.listLanguages = listLanguages;
+ this.getLanguage = getLanguage;
+ this.inherit = inherit;
+
+ // Common regexps
+ this.IDENT_RE = '[a-zA-Z][a-zA-Z0-9_]*';
+ this.UNDERSCORE_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_]*';
+ this.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
+ this.C_NUMBER_RE = '(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
+ this.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
+ this.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
+
+ // Common modes
+ this.BACKSLASH_ESCAPE = {
+ begin: '\\\\[\\s\\S]', relevance: 0
+ };
+ this.APOS_STRING_MODE = {
+ className: 'string',
+ begin: '\'', end: '\'',
+ illegal: '\\n',
+ contains: [this.BACKSLASH_ESCAPE]
+ };
+ this.QUOTE_STRING_MODE = {
+ className: 'string',
+ begin: '"', end: '"',
+ illegal: '\\n',
+ contains: [this.BACKSLASH_ESCAPE]
+ };
+ this.PHRASAL_WORDS_MODE = {
+ begin: /\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/
+ };
+ this.C_LINE_COMMENT_MODE = {
+ className: 'comment',
+ begin: '//', end: '$',
+ contains: [this.PHRASAL_WORDS_MODE]
+ };
+ this.C_BLOCK_COMMENT_MODE = {
+ className: 'comment',
+ begin: '/\\*', end: '\\*/',
+ contains: [this.PHRASAL_WORDS_MODE]
+ };
+ this.HASH_COMMENT_MODE = {
+ className: 'comment',
+ begin: '#', end: '$',
+ contains: [this.PHRASAL_WORDS_MODE]
+ };
+ this.NUMBER_MODE = {
+ className: 'number',
+ begin: this.NUMBER_RE,
+ relevance: 0
+ };
+ this.C_NUMBER_MODE = {
+ className: 'number',
+ begin: this.C_NUMBER_RE,
+ relevance: 0
+ };
+ this.BINARY_NUMBER_MODE = {
+ className: 'number',
+ begin: this.BINARY_NUMBER_RE,
+ relevance: 0
+ };
+ this.CSS_NUMBER_MODE = {
+ className: 'number',
+ begin: this.NUMBER_RE + '(' +
+ '%|em|ex|ch|rem' +
+ '|vw|vh|vmin|vmax' +
+ '|cm|mm|in|pt|pc|px' +
+ '|deg|grad|rad|turn' +
+ '|s|ms' +
+ '|Hz|kHz' +
+ '|dpi|dpcm|dppx' +
+ ')?',
+ relevance: 0
+ };
+ this.REGEXP_MODE = {
+ className: 'regexp',
+ begin: /\//, end: /\/[gimuy]*/,
+ illegal: /\n/,
+ contains: [
+ this.BACKSLASH_ESCAPE,
+ {
+ begin: /\[/, end: /\]/,
+ relevance: 0,
+ contains: [this.BACKSLASH_ESCAPE]
+ }
+ ]
+ };
+ this.TITLE_MODE = {
+ className: 'title',
+ begin: this.IDENT_RE,
+ relevance: 0
+ };
+ this.UNDERSCORE_TITLE_MODE = {
+ className: 'title',
+ begin: this.UNDERSCORE_IDENT_RE,
+ relevance: 0
+ };
+};
+module.exports = Highlight;
+},{}],29:[function(require,module,exports){
+var Highlight = require('./highlight');
+var hljs = new Highlight();
+
+hljs.registerLanguage('1c', require('./languages/1c'));
+hljs.registerLanguage('actionscript', require('./languages/actionscript'));
+hljs.registerLanguage('apache', require('./languages/apache'));
+hljs.registerLanguage('applescript', require('./languages/applescript'));
+hljs.registerLanguage('xml', require('./languages/xml'));
+hljs.registerLanguage('asciidoc', require('./languages/asciidoc'));
+hljs.registerLanguage('autohotkey', require('./languages/autohotkey'));
+hljs.registerLanguage('avrasm', require('./languages/avrasm'));
+hljs.registerLanguage('axapta', require('./languages/axapta'));
+hljs.registerLanguage('bash', require('./languages/bash'));
+hljs.registerLanguage('brainfuck', require('./languages/brainfuck'));
+hljs.registerLanguage('capnproto', require('./languages/capnproto'));
+hljs.registerLanguage('clojure', require('./languages/clojure'));
+hljs.registerLanguage('cmake', require('./languages/cmake'));
+hljs.registerLanguage('coffeescript', require('./languages/coffeescript'));
+hljs.registerLanguage('cpp', require('./languages/cpp'));
+hljs.registerLanguage('cs', require('./languages/cs'));
+hljs.registerLanguage('css', require('./languages/css'));
+hljs.registerLanguage('d', require('./languages/d'));
+hljs.registerLanguage('markdown', require('./languages/markdown'));
+hljs.registerLanguage('dart', require('./languages/dart'));
+hljs.registerLanguage('delphi', require('./languages/delphi'));
+hljs.registerLanguage('diff', require('./languages/diff'));
+hljs.registerLanguage('django', require('./languages/django'));
+hljs.registerLanguage('dos', require('./languages/dos'));
+hljs.registerLanguage('dust', require('./languages/dust'));
+hljs.registerLanguage('elixir', require('./languages/elixir'));
+hljs.registerLanguage('ruby', require('./languages/ruby'));
+hljs.registerLanguage('erb', require('./languages/erb'));
+hljs.registerLanguage('erlang-repl', require('./languages/erlang-repl'));
+hljs.registerLanguage('erlang', require('./languages/erlang'));
+hljs.registerLanguage('fix', require('./languages/fix'));
+hljs.registerLanguage('fsharp', require('./languages/fsharp'));
+hljs.registerLanguage('gcode', require('./languages/gcode'));
+hljs.registerLanguage('gherkin', require('./languages/gherkin'));
+hljs.registerLanguage('glsl', require('./languages/glsl'));
+hljs.registerLanguage('go', require('./languages/go'));
+hljs.registerLanguage('gradle', require('./languages/gradle'));
+hljs.registerLanguage('groovy', require('./languages/groovy'));
+hljs.registerLanguage('haml', require('./languages/haml'));
+hljs.registerLanguage('handlebars', require('./languages/handlebars'));
+hljs.registerLanguage('haskell', require('./languages/haskell'));
+hljs.registerLanguage('haxe', require('./languages/haxe'));
+hljs.registerLanguage('http', require('./languages/http'));
+hljs.registerLanguage('ini', require('./languages/ini'));
+hljs.registerLanguage('java', require('./languages/java'));
+hljs.registerLanguage('javascript', require('./languages/javascript'));
+hljs.registerLanguage('json', require('./languages/json'));
+hljs.registerLanguage('lasso', require('./languages/lasso'));
+hljs.registerLanguage('less', require('./languages/less'));
+hljs.registerLanguage('lisp', require('./languages/lisp'));
+hljs.registerLanguage('livecodeserver', require('./languages/livecodeserver'));
+hljs.registerLanguage('livescript', require('./languages/livescript'));
+hljs.registerLanguage('lua', require('./languages/lua'));
+hljs.registerLanguage('makefile', require('./languages/makefile'));
+hljs.registerLanguage('mathematica', require('./languages/mathematica'));
+hljs.registerLanguage('matlab', require('./languages/matlab'));
+hljs.registerLanguage('mel', require('./languages/mel'));
+hljs.registerLanguage('mizar', require('./languages/mizar'));
+hljs.registerLanguage('monkey', require('./languages/monkey'));
+hljs.registerLanguage('nginx', require('./languages/nginx'));
+hljs.registerLanguage('nimrod', require('./languages/nimrod'));
+hljs.registerLanguage('nix', require('./languages/nix'));
+hljs.registerLanguage('nsis', require('./languages/nsis'));
+hljs.registerLanguage('objectivec', require('./languages/objectivec'));
+hljs.registerLanguage('ocaml', require('./languages/ocaml'));
+hljs.registerLanguage('oxygene', require('./languages/oxygene'));
+hljs.registerLanguage('parser3', require('./languages/parser3'));
+hljs.registerLanguage('perl', require('./languages/perl'));
+hljs.registerLanguage('php', require('./languages/php'));
+hljs.registerLanguage('powershell', require('./languages/powershell'));
+hljs.registerLanguage('processing', require('./languages/processing'));
+hljs.registerLanguage('profile', require('./languages/profile'));
+hljs.registerLanguage('protobuf', require('./languages/protobuf'));
+hljs.registerLanguage('puppet', require('./languages/puppet'));
+hljs.registerLanguage('python', require('./languages/python'));
+hljs.registerLanguage('q', require('./languages/q'));
+hljs.registerLanguage('r', require('./languages/r'));
+hljs.registerLanguage('rib', require('./languages/rib'));
+hljs.registerLanguage('rsl', require('./languages/rsl'));
+hljs.registerLanguage('ruleslanguage', require('./languages/ruleslanguage'));
+hljs.registerLanguage('rust', require('./languages/rust'));
+hljs.registerLanguage('scala', require('./languages/scala'));
+hljs.registerLanguage('scheme', require('./languages/scheme'));
+hljs.registerLanguage('scilab', require('./languages/scilab'));
+hljs.registerLanguage('scss', require('./languages/scss'));
+hljs.registerLanguage('smalltalk', require('./languages/smalltalk'));
+hljs.registerLanguage('sql', require('./languages/sql'));
+hljs.registerLanguage('stylus', require('./languages/stylus'));
+hljs.registerLanguage('swift', require('./languages/swift'));
+hljs.registerLanguage('tcl', require('./languages/tcl'));
+hljs.registerLanguage('tex', require('./languages/tex'));
+hljs.registerLanguage('thrift', require('./languages/thrift'));
+hljs.registerLanguage('twig', require('./languages/twig'));
+hljs.registerLanguage('typescript', require('./languages/typescript'));
+hljs.registerLanguage('vala', require('./languages/vala'));
+hljs.registerLanguage('vbnet', require('./languages/vbnet'));
+hljs.registerLanguage('vbscript', require('./languages/vbscript'));
+hljs.registerLanguage('vbscript-html', require('./languages/vbscript-html'));
+hljs.registerLanguage('vhdl', require('./languages/vhdl'));
+hljs.registerLanguage('vim', require('./languages/vim'));
+hljs.registerLanguage('x86asm', require('./languages/x86asm'));
+hljs.registerLanguage('xl', require('./languages/xl'));
+
+module.exports = hljs;
+},{"./highlight":28,"./languages/1c":30,"./languages/actionscript":31,"./languages/apache":32,"./languages/applescript":33,"./languages/asciidoc":34,"./languages/autohotkey":35,"./languages/avrasm":36,"./languages/axapta":37,"./languages/bash":38,"./languages/brainfuck":39,"./languages/capnproto":40,"./languages/clojure":41,"./languages/cmake":42,"./languages/coffeescript":43,"./languages/cpp":44,"./languages/cs":45,"./languages/css":46,"./languages/d":47,"./languages/dart":48,"./languages/delphi":49,"./languages/diff":50,"./languages/django":51,"./languages/dos":52,"./languages/dust":53,"./languages/elixir":54,"./languages/erb":55,"./languages/erlang":57,"./languages/erlang-repl":56,"./languages/fix":58,"./languages/fsharp":59,"./languages/gcode":60,"./languages/gherkin":61,"./languages/glsl":62,"./languages/go":63,"./languages/gradle":64,"./languages/groovy":65,"./languages/haml":66,"./languages/handlebars":67,"./languages/haskell":68,"./languages/haxe":69,"./languages/http":70,"./languages/ini":71,"./languages/java":72,"./languages/javascript":73,"./languages/json":74,"./languages/lasso":75,"./languages/less":76,"./languages/lisp":77,"./languages/livecodeserver":78,"./languages/livescript":79,"./languages/lua":80,"./languages/makefile":81,"./languages/markdown":82,"./languages/mathematica":83,"./languages/matlab":84,"./languages/mel":85,"./languages/mizar":86,"./languages/monkey":87,"./languages/nginx":88,"./languages/nimrod":89,"./languages/nix":90,"./languages/nsis":91,"./languages/objectivec":92,"./languages/ocaml":93,"./languages/oxygene":94,"./languages/parser3":95,"./languages/perl":96,"./languages/php":97,"./languages/powershell":98,"./languages/processing":99,"./languages/profile":100,"./languages/protobuf":101,"./languages/puppet":102,"./languages/python":103,"./languages/q":104,"./languages/r":105,"./languages/rib":106,"./languages/rsl":107,"./languages/ruby":108,"./languages/ruleslanguage":109,"./languages/rust":110,"./languages/scala":111,"./languages/scheme":112,"./languages/scilab":113,"./languages/scss":114,"./languages/smalltalk":115,"./languages/sql":116,"./languages/stylus":117,"./languages/swift":118,"./languages/tcl":119,"./languages/tex":120,"./languages/thrift":121,"./languages/twig":122,"./languages/typescript":123,"./languages/vala":124,"./languages/vbnet":125,"./languages/vbscript":127,"./languages/vbscript-html":126,"./languages/vhdl":128,"./languages/vim":129,"./languages/x86asm":130,"./languages/xl":131,"./languages/xml":132}],30:[function(require,module,exports){
+module.exports = function(hljs){
+ var IDENT_RE_RU = '[a-zA-Zа-яА-Я][a-zA-Z0-9_а-яА-Я]*';
+ var OneS_KEYWORDS = 'возврат дата для если и или иначе иначеесли исключение конецесли ' +
+ 'конецпопытки конецпроцедуры конецфункции конеццикла константа не перейти перем ' +
+ 'перечисление по пока попытка прервать продолжить процедура строка тогда фс функция цикл ' +
+ 'число экспорт';
+ var OneS_BUILT_IN = 'ansitooem oemtoansi ввестивидсубконто ввестидату ввестизначение ' +
+ 'ввестиперечисление ввестипериод ввестиплансчетов ввестистроку ввестичисло вопрос ' +
+ 'восстановитьзначение врег выбранныйплансчетов вызватьисключение датагод датамесяц ' +
+ 'датачисло добавитьмесяц завершитьработусистемы заголовоксистемы записьжурналарегистрации ' +
+ 'запуститьприложение зафиксироватьтранзакцию значениевстроку значениевстрокувнутр ' +
+ 'значениевфайл значениеизстроки значениеизстрокивнутр значениеизфайла имякомпьютера ' +
+ 'имяпользователя каталогвременныхфайлов каталогиб каталогпользователя каталогпрограммы ' +
+ 'кодсимв командасистемы конгода конецпериодаби конецрассчитанногопериодаби ' +
+ 'конецстандартногоинтервала конквартала конмесяца коннедели лев лог лог10 макс ' +
+ 'максимальноеколичествосубконто мин монопольныйрежим названиеинтерфейса названиенабораправ ' +
+ 'назначитьвид назначитьсчет найти найтипомеченныенаудаление найтиссылки началопериодаби ' +
+ 'началостандартногоинтервала начатьтранзакцию начгода начквартала начмесяца начнедели ' +
+ 'номерднягода номерднянедели номернеделигода нрег обработкаожидания окр описаниеошибки ' +
+ 'основнойжурналрасчетов основнойплансчетов основнойязык открытьформу открытьформумодально ' +
+ 'отменитьтранзакцию очиститьокносообщений периодстр полноеимяпользователя получитьвремята ' +
+ 'получитьдатута получитьдокументта получитьзначенияотбора получитьпозициюта ' +
+ 'получитьпустоезначение получитьта прав праводоступа предупреждение префиксавтонумерации ' +
+ 'пустаястрока пустоезначение рабочаядаттьпустоезначение рабочаядата разделительстраниц ' +
+ 'разделительстрок разм разобратьпозициюдокумента рассчитатьрегистрына ' +
+ 'рассчитатьрегистрыпо сигнал симв символтабуляции создатьобъект сокрл сокрлп сокрп ' +
+ 'сообщить состояние сохранитьзначение сред статусвозврата стрдлина стрзаменить ' +
+ 'стрколичествострок стрполучитьстроку стрчисловхождений сформироватьпозициюдокумента ' +
+ 'счетпокоду текущаядата текущеевремя типзначения типзначениястр удалитьобъекты ' +
+ 'установитьтана установитьтапо фиксшаблон формат цел шаблон';
+ var DQUOTE = {className: 'dquote', begin: '""'};
+ var STR_START = {
+ className: 'string',
+ begin: '"', end: '"|$',
+ contains: [DQUOTE]
+ };
+ var STR_CONT = {
+ className: 'string',
+ begin: '\\|', end: '"|$',
+ contains: [DQUOTE]
+ };
+
+ return {
+ case_insensitive: true,
+ lexemes: IDENT_RE_RU,
+ keywords: {keyword: OneS_KEYWORDS, built_in: OneS_BUILT_IN},
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.NUMBER_MODE,
+ STR_START, STR_CONT,
+ {
+ className: 'function',
+ begin: '(процедура|функция)', end: '$',
+ lexemes: IDENT_RE_RU,
+ keywords: 'процедура функция',
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE_RU}),
+ {
+ className: 'tail',
+ endsWithParent: true,
+ contains: [
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ lexemes: IDENT_RE_RU,
+ keywords: 'знач',
+ contains: [STR_START, STR_CONT]
+ },
+ {
+ className: 'export',
+ begin: 'экспорт', endsWithParent: true,
+ lexemes: IDENT_RE_RU,
+ keywords: 'экспорт',
+ contains: [hljs.C_LINE_COMMENT_MODE]
+ }
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE
+ ]
+ },
+ {className: 'preprocessor', begin: '#', end: '$'},
+ {className: 'date', begin: '\'\\d{2}\\.\\d{2}\\.(\\d{2}|\\d{4})\''}
+ ]
+ };
+};
+},{}],31:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
+ var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';
+
+ var AS3_REST_ARG_MODE = {
+ className: 'rest_arg',
+ begin: '[.]{3}', end: IDENT_RE,
+ relevance: 10
+ };
+
+ return {
+ aliases: ['as'],
+ keywords: {
+ keyword: 'as break case catch class const continue default delete do dynamic each ' +
+ 'else extends final finally for function get if implements import in include ' +
+ 'instanceof interface internal is namespace native new override package private ' +
+ 'protected public return set static super switch this throw try typeof use var void ' +
+ 'while with',
+ literal: 'true false null undefined'
+ },
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'package',
+ beginKeywords: 'package', end: '{',
+ contains: [hljs.TITLE_MODE]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
+ contains: [
+ {
+ beginKeywords: 'extends implements'
+ },
+ hljs.TITLE_MODE
+ ]
+ },
+ {
+ className: 'preprocessor',
+ beginKeywords: 'import include', end: ';'
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: '[{;]', excludeEnd: true,
+ illegal: '\\S',
+ contains: [
+ hljs.TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ AS3_REST_ARG_MODE
+ ]
+ },
+ {
+ className: 'type',
+ begin: ':',
+ end: IDENT_FUNC_RETURN_TYPE_RE,
+ relevance: 10
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],32:[function(require,module,exports){
+module.exports = function(hljs) {
+ var NUMBER = {className: 'number', begin: '[\\$%]\\d+'};
+ return {
+ aliases: ['apacheconf'],
+ case_insensitive: true,
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {className: 'tag', begin: '?', end: '>'},
+ {
+ className: 'keyword',
+ begin: /\w+/,
+ relevance: 0,
+ // keywords aren’t needed for highlighting per se, they only boost relevance
+ // for a very generally defined mode (starts with a word, ends with line-end
+ keywords: {
+ common:
+ 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
+ 'sethandler errordocument loadmodule options header listen serverroot ' +
+ 'servername'
+ },
+ starts: {
+ end: /$/,
+ relevance: 0,
+ keywords: {
+ literal: 'on off all'
+ },
+ contains: [
+ {
+ className: 'sqbracket',
+ begin: '\\s\\[', end: '\\]$'
+ },
+ {
+ className: 'cbracket',
+ begin: '[\\$%]\\{', end: '\\}',
+ contains: ['self', NUMBER]
+ },
+ NUMBER,
+ hljs.QUOTE_STRING_MODE
+ ]
+ }
+ }
+ ],
+ illegal: /\S/
+ };
+};
+},{}],33:[function(require,module,exports){
+module.exports = function(hljs) {
+ var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: ''});
+ var PARAMS = {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ contains: ['self', hljs.C_NUMBER_MODE, STRING]
+ };
+ var COMMENTS = [
+ {
+ className: 'comment',
+ begin: '--', end: '$'
+ },
+ {
+ className: 'comment',
+ begin: '\\(\\*', end: '\\*\\)',
+ contains: ['self', {begin: '--', end: '$'}] //allow nesting
+ },
+ hljs.HASH_COMMENT_MODE
+ ];
+
+ return {
+ aliases: ['osascript'],
+ keywords: {
+ keyword:
+ 'about above after against and around as at back before beginning ' +
+ 'behind below beneath beside between but by considering ' +
+ 'contain contains continue copy div does eighth else end equal ' +
+ 'equals error every exit fifth first for fourth from front ' +
+ 'get given global if ignoring in into is it its last local me ' +
+ 'middle mod my ninth not of on onto or over prop property put ref ' +
+ 'reference repeat returning script second set seventh since ' +
+ 'sixth some tell tenth that the|0 then third through thru ' +
+ 'timeout times to transaction try until where while whose with ' +
+ 'without',
+ constant:
+ 'AppleScript false linefeed return pi quote result space tab true',
+ type:
+ 'alias application boolean class constant date file integer list ' +
+ 'number real record string text',
+ command:
+ 'activate beep count delay launch log offset read round ' +
+ 'run say summarize write',
+ property:
+ 'character characters contents day frontmost id item length ' +
+ 'month name paragraph paragraphs rest reverse running time version ' +
+ 'weekday word words year'
+ },
+ contains: [
+ STRING,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'type',
+ begin: '\\bPOSIX file\\b'
+ },
+ {
+ className: 'command',
+ begin:
+ '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' +
+ 'mount volume|path to|(close|open for) access|(get|set) eof|' +
+ 'current date|do shell script|get volume settings|random number|' +
+ 'set volume|system attribute|system info|time to GMT|' +
+ '(load|run|store) script|scripting components|' +
+ 'ASCII (character|number)|localized string|' +
+ 'choose (application|color|file|file name|' +
+ 'folder|from list|remote application|URL)|' +
+ 'display (alert|dialog))\\b|^\\s*return\\b'
+ },
+ {
+ className: 'constant',
+ begin:
+ '\\b(text item delimiters|current application|missing value)\\b'
+ },
+ {
+ className: 'keyword',
+ begin:
+ '\\b(apart from|aside from|instead of|out of|greater than|' +
+ "isn't|(doesn't|does not) (equal|come before|come after|contain)|" +
+ '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' +
+ 'contained by|comes (before|after)|a (ref|reference))\\b'
+ },
+ {
+ className: 'property',
+ begin:
+ '\\b(POSIX path|(date|time) string|quoted form)\\b'
+ },
+ {
+ className: 'function_start',
+ beginKeywords: 'on',
+ illegal: '[${=;\\n]',
+ contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS]
+ }
+ ].concat(COMMENTS),
+ illegal: '//|->|=>'
+ };
+};
+},{}],34:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ contains: [
+ // block comment
+ {
+ className: 'comment',
+ begin: '^/{4,}\\n',
+ end: '\\n/{4,}$',
+ // can also be done as...
+ //begin: '^/{4,}$',
+ //end: '^/{4,}$',
+ relevance: 10
+ },
+ // line comment
+ {
+ className: 'comment',
+ begin: '^//',
+ end: '$',
+ relevance: 0
+ },
+ // title
+ {
+ className: 'title',
+ begin: '^\\.\\w.*$'
+ },
+ // example, admonition & sidebar blocks
+ {
+ begin: '^[=\\*]{4,}\\n',
+ end: '\\n^[=\\*]{4,}$',
+ relevance: 10
+ },
+ // headings
+ {
+ className: 'header',
+ begin: '^(={1,5}) .+?( \\1)?$',
+ relevance: 10
+ },
+ {
+ className: 'header',
+ begin: '^[^\\[\\]\\n]+?\\n[=\\-~\\^\\+]{2,}$',
+ relevance: 10
+ },
+ // document attributes
+ {
+ className: 'attribute',
+ begin: '^:.+?:',
+ end: '\\s',
+ excludeEnd: true,
+ relevance: 10
+ },
+ // block attributes
+ {
+ className: 'attribute',
+ begin: '^\\[.+?\\]$',
+ relevance: 0
+ },
+ // quoteblocks
+ {
+ className: 'blockquote',
+ begin: '^_{4,}\\n',
+ end: '\\n_{4,}$',
+ relevance: 10
+ },
+ // listing and literal blocks
+ {
+ className: 'code',
+ begin: '^[\\-\\.]{4,}\\n',
+ end: '\\n[\\-\\.]{4,}$',
+ relevance: 10
+ },
+ // passthrough blocks
+ {
+ begin: '^\\+{4,}\\n',
+ end: '\\n\\+{4,}$',
+ contains: [
+ {
+ begin: '<', end: '>',
+ subLanguage: 'xml',
+ relevance: 0
+ }
+ ],
+ relevance: 10
+ },
+ // lists (can only capture indicators)
+ {
+ className: 'bullet',
+ begin: '^(\\*+|\\-+|\\.+|[^\\n]+?::)\\s+'
+ },
+ // admonition
+ {
+ className: 'label',
+ begin: '^(NOTE|TIP|IMPORTANT|WARNING|CAUTION):\\s+',
+ relevance: 10
+ },
+ // inline strong
+ {
+ className: 'strong',
+ // must not follow a word character or be followed by an asterisk or space
+ begin: '\\B\\*(?![\\*\\s])',
+ end: '(\\n{2}|\\*)',
+ // allow escaped asterisk followed by word char
+ contains: [
+ {
+ begin: '\\\\*\\w',
+ relevance: 0
+ }
+ ]
+ },
+ // inline emphasis
+ {
+ className: 'emphasis',
+ // must not follow a word character or be followed by a single quote or space
+ begin: '\\B\'(?![\'\\s])',
+ end: '(\\n{2}|\')',
+ // allow escaped single quote followed by word char
+ contains: [
+ {
+ begin: '\\\\\'\\w',
+ relevance: 0
+ }
+ ],
+ relevance: 0
+ },
+ // inline emphasis (alt)
+ {
+ className: 'emphasis',
+ // must not follow a word character or be followed by an underline or space
+ begin: '_(?![_\\s])',
+ end: '(\\n{2}|_)',
+ relevance: 0
+ },
+ // inline double smart quotes
+ {
+ className: 'smartquote',
+ begin: "``.+?''",
+ relevance: 10
+ },
+ // inline single smart quotes
+ {
+ className: 'smartquote',
+ begin: "`.+?'",
+ relevance: 10
+ },
+ // inline code snippets (TODO should get same treatment as strong and emphasis)
+ {
+ className: 'code',
+ begin: '(`.+?`|\\+.+?\\+)',
+ relevance: 0
+ },
+ // indented literal block
+ {
+ className: 'code',
+ begin: '^[ \\t]',
+ end: '$',
+ relevance: 0
+ },
+ // horizontal rules
+ {
+ className: 'horizontal_rule',
+ begin: '^\'{3,}[ \\t]*$',
+ relevance: 10
+ },
+ // images and links
+ {
+ begin: '(link:)?(http|https|ftp|file|irc|image:?):\\S+\\[.*?\\]',
+ returnBegin: true,
+ contains: [
+ {
+ //className: 'macro',
+ begin: '(link|image:?):',
+ relevance: 0
+ },
+ {
+ className: 'link_url',
+ begin: '\\w',
+ end: '[^\\[]+',
+ relevance: 0
+ },
+ {
+ className: 'link_label',
+ begin: '\\[',
+ end: '\\]',
+ excludeBegin: true,
+ excludeEnd: true,
+ relevance: 0
+ }
+ ],
+ relevance: 10
+ }
+ ]
+ };
+};
+},{}],35:[function(require,module,exports){
+module.exports = function(hljs) {
+ var BACKTICK_ESCAPE = {
+ className: 'escape',
+ begin: '`[\\s\\S]'
+ };
+ var COMMENTS = {
+ className: 'comment',
+ begin: ';', end: '$',
+ relevance: 0
+ };
+ var BUILT_IN = [
+ {
+ className: 'built_in',
+ begin: 'A_[a-zA-Z0-9]+'
+ },
+ {
+ className: 'built_in',
+ beginKeywords: 'ComSpec Clipboard ClipboardAll ErrorLevel'
+ }
+ ];
+
+ return {
+ case_insensitive: true,
+ keywords: {
+ keyword: 'Break Continue Else Gosub If Loop Return While',
+ literal: 'A true false NOT AND OR'
+ },
+ contains: BUILT_IN.concat([
+ BACKTICK_ESCAPE,
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [BACKTICK_ESCAPE]}),
+ COMMENTS,
+ {
+ className: 'number',
+ begin: hljs.NUMBER_RE,
+ relevance: 0
+ },
+ {
+ className: 'var_expand', // FIXME
+ begin: '%', end: '%',
+ illegal: '\\n',
+ contains: [BACKTICK_ESCAPE]
+ },
+ {
+ className: 'label',
+ contains: [BACKTICK_ESCAPE],
+ variants: [
+ {begin: '^[^\\n";]+::(?!=)'},
+ {begin: '^[^\\n";]+:(?!=)', relevance: 0} // zero relevance as it catches a lot of things
+ // followed by a single ':' in many languages
+ ]
+ },
+ {
+ // consecutive commas, not for highlighting but just for relevance
+ begin: ',\\s*,',
+ relevance: 10
+ }
+ ])
+ }
+};
+},{}],36:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ case_insensitive: true,
+ lexemes: '\\.?' + hljs.IDENT_RE,
+ keywords: {
+ keyword:
+ /* mnemonic */
+ 'adc add adiw and andi asr bclr bld brbc brbs brcc brcs break breq brge brhc brhs ' +
+ 'brid brie brlo brlt brmi brne brpl brsh brtc brts brvc brvs bset bst call cbi cbr ' +
+ 'clc clh cli cln clr cls clt clv clz com cp cpc cpi cpse dec eicall eijmp elpm eor ' +
+ 'fmul fmuls fmulsu icall ijmp in inc jmp ld ldd ldi lds lpm lsl lsr mov movw mul ' +
+ 'muls mulsu neg nop or ori out pop push rcall ret reti rjmp rol ror sbc sbr sbrc sbrs ' +
+ 'sec seh sbi sbci sbic sbis sbiw sei sen ser ses set sev sez sleep spm st std sts sub ' +
+ 'subi swap tst wdr',
+ built_in:
+ /* general purpose registers */
+ 'r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 ' +
+ 'r23 r24 r25 r26 r27 r28 r29 r30 r31 x|0 xh xl y|0 yh yl z|0 zh zl ' +
+ /* IO Registers (ATMega128) */
+ 'ucsr1c udr1 ucsr1a ucsr1b ubrr1l ubrr1h ucsr0c ubrr0h tccr3c tccr3a tccr3b tcnt3h ' +
+ 'tcnt3l ocr3ah ocr3al ocr3bh ocr3bl ocr3ch ocr3cl icr3h icr3l etimsk etifr tccr1c ' +
+ 'ocr1ch ocr1cl twcr twdr twar twsr twbr osccal xmcra xmcrb eicra spmcsr spmcr portg ' +
+ 'ddrg ping portf ddrf sreg sph spl xdiv rampz eicrb eimsk gimsk gicr eifr gifr timsk ' +
+ 'tifr mcucr mcucsr tccr0 tcnt0 ocr0 assr tccr1a tccr1b tcnt1h tcnt1l ocr1ah ocr1al ' +
+ 'ocr1bh ocr1bl icr1h icr1l tccr2 tcnt2 ocr2 ocdr wdtcr sfior eearh eearl eedr eecr ' +
+ 'porta ddra pina portb ddrb pinb portc ddrc pinc portd ddrd pind spdr spsr spcr udr0 ' +
+ 'ucsr0a ucsr0b ubrr0l acsr admux adcsr adch adcl porte ddre pine pinf',
+ preprocessor:
+ '.byte .cseg .db .def .device .dseg .dw .endmacro .equ .eseg .exit .include .list ' +
+ '.listmac .macro .nolist .org .set'
+ },
+ contains: [
+ hljs.C_BLOCK_COMMENT_MODE,
+ {className: 'comment', begin: ';', end: '$', relevance: 0},
+ hljs.C_NUMBER_MODE, // 0x..., decimal, float
+ hljs.BINARY_NUMBER_MODE, // 0b...
+ {
+ className: 'number',
+ begin: '\\b(\\$[a-zA-Z0-9]+|0o[0-7]+)' // $..., 0o...
+ },
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ begin: '\'', end: '[^\\\\]\'',
+ illegal: '[^\\\\][^\']'
+ },
+ {className: 'label', begin: '^[A-Za-z0-9_.$]+:'},
+ {className: 'preprocessor', begin: '#', end: '$'},
+ { // подстановка в «.macro»
+ className: 'localvars',
+ begin: '@[0-9]+'
+ }
+ ]
+ };
+};
+},{}],37:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: 'false int abstract private char boolean static null if for true ' +
+ 'while long throw finally protected final return void enum else ' +
+ 'break new catch byte super case short default double public try this switch ' +
+ 'continue reverse firstfast firstonly forupdate nofetch sum avg minof maxof count ' +
+ 'order group by asc desc index hint like dispaly edit client server ttsbegin ' +
+ 'ttscommit str real date container anytype common div mod',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$'
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
+ illegal: ':',
+ contains: [
+ {beginKeywords: 'extends implements'},
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ }
+ ]
+ };
+};
+},{}],38:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VAR = {
+ className: 'variable',
+ variants: [
+ {begin: /\$[\w\d#@][\w\d_]*/},
+ {begin: /\$\{(.*?)\}/}
+ ]
+ };
+ var QUOTE_STRING = {
+ className: 'string',
+ begin: /"/, end: /"/,
+ contains: [
+ hljs.BACKSLASH_ESCAPE,
+ VAR,
+ {
+ className: 'variable',
+ begin: /\$\(/, end: /\)/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ }
+ ]
+ };
+ var APOS_STRING = {
+ className: 'string',
+ begin: /'/, end: /'/
+ };
+
+ return {
+ aliases: ['sh', 'zsh'],
+ lexemes: /-?[a-z\.]+/,
+ keywords: {
+ keyword:
+ 'if then else elif fi for break continue while in do done exit return set '+
+ 'declare case esac export exec function',
+ literal:
+ 'true false',
+ built_in:
+ 'printf echo read cd pwd pushd popd dirs let eval unset typeset readonly '+
+ 'getopts source shopt caller type hash bind help sudo',
+ operator:
+ '-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
+ },
+ contains: [
+ {
+ className: 'shebang',
+ begin: /^#![^\n]+sh\s*$/,
+ relevance: 10
+ },
+ {
+ className: 'function',
+ begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
+ returnBegin: true,
+ contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
+ relevance: 0
+ },
+ hljs.HASH_COMMENT_MODE,
+ hljs.NUMBER_MODE,
+ QUOTE_STRING,
+ APOS_STRING,
+ VAR
+ ]
+ };
+};
+},{}],39:[function(require,module,exports){
+module.exports = function(hljs){
+ var LITERAL = {
+ className: 'literal',
+ begin: '[\\+\\-]',
+ relevance: 0
+ };
+ return {
+ aliases: ['bf'],
+ contains: [
+ {
+ className: 'comment',
+ begin: '[^\\[\\]\\.,\\+\\-<> \r\n]',
+ returnEnd: true,
+ end: '[\\[\\]\\.,\\+\\-<> \r\n]',
+ relevance: 0
+ },
+ {
+ className: 'title',
+ begin: '[\\[\\]]',
+ relevance: 0
+ },
+ {
+ className: 'string',
+ begin: '[\\.,]',
+ relevance: 0
+ },
+ {
+ // this mode works as the only relevance counter
+ begin: /\+\+|\-\-/, returnBegin: true,
+ contains: [LITERAL]
+ },
+ LITERAL
+ ]
+ };
+};
+},{}],40:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['capnp'],
+ keywords: {
+ keyword:
+ 'struct enum interface union group import using const annotation extends in of on as with from fixed',
+ built_in:
+ 'Void Bool Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 ' +
+ 'Text Data AnyPointer AnyStruct Capability List',
+ literal:
+ 'true false'
+ },
+ contains: [
+ hljs.QUOTE_STRING_MODE,
+ hljs.NUMBER_MODE,
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'shebang',
+ begin: /@0x[\w\d]{16};/,
+ illegal: /\n/
+ },
+ {
+ className: 'number',
+ begin: /@\d+\b/
+ },
+ {
+ className: 'class',
+ beginKeywords: 'struct enum', end: /\{/,
+ illegal: /\n/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
+ })
+ ]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'interface', end: /\{/,
+ illegal: /\n/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
+ })
+ ]
+ }
+ ]
+ };
+};
+},{}],41:[function(require,module,exports){
+module.exports = function(hljs) {
+ var keywords = {
+ built_in:
+ // Clojure keywords
+ 'def cond apply if-not if-let if not not= = < > <= >= == + / * - rem '+
+ 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '+
+ 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '+
+ 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '+
+ 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . '+
+ 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last '+
+ 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate '+
+ 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext '+
+ 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends '+
+ 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler '+
+ 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter '+
+ 'monitor-exit defmacro defn defn- macroexpand macroexpand-1 for dosync and or '+
+ 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert '+
+ 'peek pop doto proxy defstruct first rest cons defprotocol cast coll deftype defrecord last butlast '+
+ 'sigs reify second ffirst fnext nfirst nnext defmulti defmethod meta with-meta ns in-ns create-ns import '+
+ 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! '+
+ 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger '+
+ 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline '+
+ 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking '+
+ 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! '+
+ 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! '+
+ 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty '+
+ 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list '+
+ 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer '+
+ 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate '+
+ 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta '+
+ 'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
+ };
+
+ var SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>\'';
+ var SYMBOL_RE = '[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:]*';
+ var SIMPLE_NUMBER_RE = '[-+]?\\d+(\\.\\d+)?';
+
+ var SYMBOL = {
+ begin: SYMBOL_RE,
+ relevance: 0
+ };
+ var NUMBER = {
+ className: 'number', begin: SIMPLE_NUMBER_RE,
+ relevance: 0
+ };
+ var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null});
+ var COMMENT = {
+ className: 'comment',
+ begin: ';', end: '$',
+ relevance: 0
+ };
+ var COLLECTION = {
+ className: 'collection',
+ begin: '[\\[\\{]', end: '[\\]\\}]'
+ };
+ var HINT = {
+ className: 'comment',
+ begin: '\\^' + SYMBOL_RE
+ };
+ var HINT_COL = {
+ className: 'comment',
+ begin: '\\^\\{', end: '\\}'
+
+ };
+ var KEY = {
+ className: 'attribute',
+ begin: '[:]' + SYMBOL_RE
+ };
+ var LIST = {
+ className: 'list',
+ begin: '\\(', end: '\\)'
+ };
+ var BODY = {
+ endsWithParent: true,
+ keywords: {literal: 'true false nil'},
+ relevance: 0
+ };
+ var NAME = {
+ keywords: keywords,
+ lexemes: SYMBOL_RE,
+ className: 'keyword', begin: SYMBOL_RE,
+ starts: BODY
+ };
+
+ LIST.contains = [{className: 'comment', begin: 'comment'}, NAME, BODY];
+ BODY.contains = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, SYMBOL];
+ COLLECTION.contains = [LIST, STRING, HINT, COMMENT, KEY, COLLECTION, NUMBER, SYMBOL];
+
+ return {
+ aliases: ['clj'],
+ illegal: /\S/,
+ contains: [
+ COMMENT,
+ LIST,
+ {
+ className: 'prompt',
+ begin: /^=> /,
+ starts: {end: /\n\n|\Z/} // eat up prompt output to not interfere with the illegal
+ }
+ ]
+ }
+};
+},{}],42:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['cmake.in'],
+ case_insensitive: true,
+ keywords: {
+ keyword:
+ 'add_custom_command add_custom_target add_definitions add_dependencies ' +
+ 'add_executable add_library add_subdirectory add_test aux_source_directory ' +
+ 'break build_command cmake_minimum_required cmake_policy configure_file ' +
+ 'create_test_sourcelist define_property else elseif enable_language enable_testing ' +
+ 'endforeach endfunction endif endmacro endwhile execute_process export find_file ' +
+ 'find_library find_package find_path find_program fltk_wrap_ui foreach function ' +
+ 'get_cmake_property get_directory_property get_filename_component get_property ' +
+ 'get_source_file_property get_target_property get_test_property if include ' +
+ 'include_directories include_external_msproject include_regular_expression install ' +
+ 'link_directories load_cache load_command macro mark_as_advanced message option ' +
+ 'output_required_files project qt_wrap_cpp qt_wrap_ui remove_definitions return ' +
+ 'separate_arguments set set_directory_properties set_property ' +
+ 'set_source_files_properties set_target_properties set_tests_properties site_name ' +
+ 'source_group string target_link_libraries try_compile try_run unset variable_watch ' +
+ 'while build_name exec_program export_library_dependencies install_files ' +
+ 'install_programs install_targets link_libraries make_directory remove subdir_depends ' +
+ 'subdirs use_mangled_mesa utility_source variable_requires write_file ' +
+ 'qt5_use_modules qt5_use_package qt5_wrap_cpp on off true false and or',
+ operator:
+ 'equal less greater strless strgreater strequal matches'
+ },
+ contains: [
+ {
+ className: 'envvar',
+ begin: '\\${', end: '}'
+ },
+ hljs.HASH_COMMENT_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.NUMBER_MODE
+ ]
+ };
+};
+},{}],43:[function(require,module,exports){
+module.exports = function(hljs) {
+ var KEYWORDS = {
+ keyword:
+ // JS keywords
+ 'in if for while finally new do return else break catch instanceof throw try this ' +
+ 'switch continue typeof delete debugger super ' +
+ // Coffee keywords
+ 'then unless until loop of by when and or is isnt not',
+ literal:
+ // JS literals
+ 'true false null undefined ' +
+ // Coffee literals
+ 'yes no on off',
+ reserved:
+ 'case default function var void with const let enum export import native ' +
+ '__hasProp __extends __slice __bind __indexOf',
+ built_in:
+ 'npm require console print module global window document'
+ };
+ var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
+ var SUBST = {
+ className: 'subst',
+ begin: /#\{/, end: /}/,
+ keywords: KEYWORDS
+ };
+ var EXPRESSIONS = [
+ hljs.BINARY_NUMBER_MODE,
+ hljs.inherit(hljs.C_NUMBER_MODE, {starts: {end: '(\\s*/)?', relevance: 0}}), // a number tries to eat the following slash to prevent treating it as a regexp
+ {
+ className: 'string',
+ variants: [
+ {
+ begin: /'''/, end: /'''/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: /'/, end: /'/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: /"""/, end: /"""/,
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ },
+ {
+ begin: /"/, end: /"/,
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ }
+ ]
+ },
+ {
+ className: 'regexp',
+ variants: [
+ {
+ begin: '///', end: '///',
+ contains: [SUBST, hljs.HASH_COMMENT_MODE]
+ },
+ {
+ begin: '//[gim]*',
+ relevance: 0
+ },
+ {
+ // regex can't start with space to parse x / 2 / 3 as two divisions
+ // regex can't start with *, and it supports an "illegal" in the main mode
+ begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/
+ }
+ ]
+ },
+ {
+ className: 'property',
+ begin: '@' + JS_IDENT_RE
+ },
+ {
+ begin: '`', end: '`',
+ excludeBegin: true, excludeEnd: true,
+ subLanguage: 'javascript'
+ }
+ ];
+ SUBST.contains = EXPRESSIONS;
+
+ var TITLE = hljs.inherit(hljs.TITLE_MODE, {begin: JS_IDENT_RE});
+ var PARAMS_RE = '(\\(.*\\))?\\s*\\B[-=]>';
+ var PARAMS = {
+ className: 'params',
+ begin: '\\([^\\(]', returnBegin: true,
+ /* We need another contained nameless mode to not have every nested
+ pair of parens to be called "params" */
+ contains: [{
+ begin: /\(/, end: /\)/,
+ keywords: KEYWORDS,
+ contains: ['self'].concat(EXPRESSIONS)
+ }]
+ };
+
+ return {
+ aliases: ['coffee', 'cson', 'iced'],
+ keywords: KEYWORDS,
+ illegal: /\/\*/,
+ contains: EXPRESSIONS.concat([
+ {
+ className: 'comment',
+ begin: '###', end: '###',
+ contains: [hljs.PHRASAL_WORDS_MODE]
+ },
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'function',
+ begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + PARAMS_RE, end: '[-=]>',
+ returnBegin: true,
+ contains: [TITLE, PARAMS]
+ },
+ {
+ // anonymous function start
+ begin: /[:\(,=]\s*/,
+ relevance: 0,
+ contains: [
+ {
+ className: 'function',
+ begin: PARAMS_RE, end: '[-=]>',
+ returnBegin: true,
+ contains: [PARAMS]
+ }
+ ]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class',
+ end: '$',
+ illegal: /[:="\[\]]/,
+ contains: [
+ {
+ beginKeywords: 'extends',
+ endsWithParent: true,
+ illegal: /[:="\[\]]/,
+ contains: [TITLE]
+ },
+ TITLE
+ ]
+ },
+ {
+ className: 'attribute',
+ begin: JS_IDENT_RE + ':', end: ':',
+ returnBegin: true, returnEnd: true,
+ relevance: 0
+ }
+ ])
+ };
+};
+},{}],44:[function(require,module,exports){
+module.exports = function(hljs) {
+ var CPP_KEYWORDS = {
+ keyword: 'false int float while private char catch export virtual operator sizeof ' +
+ 'dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace ' +
+ 'unsigned long throw volatile static protected bool template mutable if public friend ' +
+ 'do return goto auto void enum else break new extern using true class asm case typeid ' +
+ 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
+ 'switch continue wchar_t inline delete alignof char16_t char32_t constexpr decltype ' +
+ 'noexcept nullptr static_assert thread_local restrict _Bool complex _Complex _Imaginary',
+ built_in: 'std string cin cout cerr clog stringstream istringstream ostringstream ' +
+ 'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' +
+ 'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' +
+ 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
+ 'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
+ 'isxdigit tolower toupper labs ldexp log10 log malloc memchr memcmp memcpy memset modf pow ' +
+ 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
+ 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
+ 'vfprintf vprintf vsprintf'
+ };
+ return {
+ aliases: ['c', 'h', 'c++', 'h++'],
+ keywords: CPP_KEYWORDS,
+ illegal: '',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ begin: '\'\\\\?.', end: '\'',
+ illegal: '.'
+ },
+ {
+ className: 'number',
+ begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)'
+ },
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$',
+ keywords: 'if else elif endif define undef warning error line pragma',
+ contains: [
+ {
+ begin: 'include\\s*[<"]', end: '[>"]',
+ keywords: 'include',
+ illegal: '\\n'
+ },
+ hljs.C_LINE_COMMENT_MODE
+ ]
+ },
+ {
+ className: 'stl_container',
+ begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>',
+ keywords: CPP_KEYWORDS,
+ contains: ['self']
+ },
+ {
+ begin: hljs.IDENT_RE + '::'
+ }
+ ]
+ };
+};
+},{}],45:[function(require,module,exports){
+module.exports = function(hljs) {
+ var KEYWORDS =
+ // Normal keywords.
+ 'abstract as base bool break byte case catch char checked const continue decimal ' +
+ 'default delegate do double else enum event explicit extern false finally fixed float ' +
+ 'for foreach goto if implicit in int interface internal is lock long new null ' +
+ 'object operator out override params private protected public readonly ref return sbyte ' +
+ 'sealed short sizeof stackalloc static string struct switch this throw true try typeof ' +
+ 'uint ulong unchecked unsafe ushort using virtual volatile void while async await ' +
+ 'protected public private internal ' +
+ // Contextual keywords.
+ 'ascending descending from get group into join let orderby partial select set value var ' +
+ 'where yield';
+ var GENERIC_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '>)?';
+ return {
+ aliases: ['csharp'],
+ keywords: KEYWORDS,
+ illegal: /::/,
+ contains: [
+ {
+ className: 'comment',
+ begin: '///', end: '$', returnBegin: true,
+ contains: [
+ {
+ className: 'xmlDocTag',
+ variants: [
+ {
+ begin: '///', relevance: 0
+ },
+ {
+ begin: ''
+ },
+ {
+ begin: '?', end: '>'
+ }
+ ]
+ }
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$',
+ keywords: 'if else elif endif define undef warning error line region endregion pragma checksum'
+ },
+ {
+ className: 'string',
+ begin: '@"', end: '"',
+ contains: [{begin: '""'}]
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ beginKeywords: 'class namespace interface', end: /[{;=]/,
+ illegal: /[^\s:]/,
+ contains: [
+ hljs.TITLE_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ },
+ {
+ // this prevents 'new Name(...)' from being recognized as a function definition
+ beginKeywords: 'new', end: /\s/,
+ relevance: 0
+ },
+ {
+ className: 'function',
+ begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
+ excludeEnd: true,
+ keywords: KEYWORDS,
+ contains: [
+ {
+ begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
+ contains: [hljs.TITLE_MODE]
+ },
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ keywords: KEYWORDS,
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ }
+ ]
+ };
+};
+},{}],46:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
+ var FUNCTION = {
+ className: 'function',
+ begin: IDENT_RE + '\\(',
+ returnBegin: true,
+ excludeEnd: true,
+ end: '\\('
+ };
+ return {
+ case_insensitive: true,
+ illegal: '[=/|\']',
+ contains: [
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'id', begin: '\\#[A-Za-z0-9_-]+'
+ },
+ {
+ className: 'class', begin: '\\.[A-Za-z0-9_-]+',
+ relevance: 0
+ },
+ {
+ className: 'attr_selector',
+ begin: '\\[', end: '\\]',
+ illegal: '$'
+ },
+ {
+ className: 'pseudo',
+ begin: ':(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\"\\\']+'
+ },
+ {
+ className: 'at_rule',
+ begin: '@(font-face|page)',
+ lexemes: '[a-z-]+',
+ keywords: 'font-face page'
+ },
+ {
+ className: 'at_rule',
+ begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
+ // because it doesn’t let it to be parsed as
+ // a rule set but instead drops parser into
+ // the default mode which is how it should be.
+ contains: [
+ {
+ className: 'keyword',
+ begin: /\S+/
+ },
+ {
+ begin: /\s/, endsWithParent: true, excludeEnd: true,
+ relevance: 0,
+ contains: [
+ FUNCTION,
+ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE,
+ hljs.CSS_NUMBER_MODE
+ ]
+ }
+ ]
+ },
+ {
+ className: 'tag', begin: IDENT_RE,
+ relevance: 0
+ },
+ {
+ className: 'rules',
+ begin: '{', end: '}',
+ illegal: '[^\\s]',
+ relevance: 0,
+ contains: [
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'rule',
+ begin: '[^\\s]', returnBegin: true, end: ';', endsWithParent: true,
+ contains: [
+ {
+ className: 'attribute',
+ begin: '[A-Z\\_\\.\\-]+', end: ':',
+ excludeEnd: true,
+ illegal: '[^\\s]',
+ starts: {
+ className: 'value',
+ endsWithParent: true, excludeEnd: true,
+ contains: [
+ FUNCTION,
+ hljs.CSS_NUMBER_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'hexcolor', begin: '#[0-9A-Fa-f]+'
+ },
+ {
+ className: 'important', begin: '!important'
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],47:[function(require,module,exports){
+module.exports = /**
+ * Known issues:
+ *
+ * - invalid hex string literals will be recognized as a double quoted strings
+ * but 'x' at the beginning of string will not be matched
+ *
+ * - delimited string literals are not checked for matching end delimiter
+ * (not possible to do with js regexp)
+ *
+ * - content of token string is colored as a string (i.e. no keyword coloring inside a token string)
+ * also, content of token string is not validated to contain only valid D tokens
+ *
+ * - special token sequence rule is not strictly following D grammar (anything following #line
+ * up to the end of line is matched as special token sequence)
+ */
+
+function(hljs) {
+ /**
+ * Language keywords
+ *
+ * @type {Object}
+ */
+ var D_KEYWORDS = {
+ keyword:
+ 'abstract alias align asm assert auto body break byte case cast catch class ' +
+ 'const continue debug default delete deprecated do else enum export extern final ' +
+ 'finally for foreach foreach_reverse|10 goto if immutable import in inout int ' +
+ 'interface invariant is lazy macro mixin module new nothrow out override package ' +
+ 'pragma private protected public pure ref return scope shared static struct ' +
+ 'super switch synchronized template this throw try typedef typeid typeof union ' +
+ 'unittest version void volatile while with __FILE__ __LINE__ __gshared|10 ' +
+ '__thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__',
+ built_in:
+ 'bool cdouble cent cfloat char creal dchar delegate double dstring float function ' +
+ 'idouble ifloat ireal long real short string ubyte ucent uint ulong ushort wchar ' +
+ 'wstring',
+ literal:
+ 'false null true'
+ };
+
+ /**
+ * Number literal regexps
+ *
+ * @type {String}
+ */
+ var decimal_integer_re = '(0|[1-9][\\d_]*)',
+ decimal_integer_nosus_re = '(0|[1-9][\\d_]*|\\d[\\d_]*|[\\d_]+?\\d)',
+ binary_integer_re = '0[bB][01_]+',
+ hexadecimal_digits_re = '([\\da-fA-F][\\da-fA-F_]*|_[\\da-fA-F][\\da-fA-F_]*)',
+ hexadecimal_integer_re = '0[xX]' + hexadecimal_digits_re,
+
+ decimal_exponent_re = '([eE][+-]?' + decimal_integer_nosus_re + ')',
+ decimal_float_re = '(' + decimal_integer_nosus_re + '(\\.\\d*|' + decimal_exponent_re + ')|' +
+ '\\d+\\.' + decimal_integer_nosus_re + decimal_integer_nosus_re + '|' +
+ '\\.' + decimal_integer_re + decimal_exponent_re + '?' +
+ ')',
+ hexadecimal_float_re = '(0[xX](' +
+ hexadecimal_digits_re + '\\.' + hexadecimal_digits_re + '|'+
+ '\\.?' + hexadecimal_digits_re +
+ ')[pP][+-]?' + decimal_integer_nosus_re + ')',
+
+ integer_re = '(' +
+ decimal_integer_re + '|' +
+ binary_integer_re + '|' +
+ hexadecimal_integer_re +
+ ')',
+
+ float_re = '(' +
+ hexadecimal_float_re + '|' +
+ decimal_float_re +
+ ')';
+
+ /**
+ * Escape sequence supported in D string and character literals
+ *
+ * @type {String}
+ */
+ var escape_sequence_re = '\\\\(' +
+ '[\'"\\?\\\\abfnrtv]|' + // common escapes
+ 'u[\\dA-Fa-f]{4}|' + // four hex digit unicode codepoint
+ '[0-7]{1,3}|' + // one to three octal digit ascii char code
+ 'x[\\dA-Fa-f]{2}|' + // two hex digit ascii char code
+ 'U[\\dA-Fa-f]{8}' + // eight hex digit unicode codepoint
+ ')|' +
+ '&[a-zA-Z\\d]{2,};'; // named character entity
+
+ /**
+ * D integer number literals
+ *
+ * @type {Object}
+ */
+ var D_INTEGER_MODE = {
+ className: 'number',
+ begin: '\\b' + integer_re + '(L|u|U|Lu|LU|uL|UL)?',
+ relevance: 0
+ };
+
+ /**
+ * [D_FLOAT_MODE description]
+ * @type {Object}
+ */
+ var D_FLOAT_MODE = {
+ className: 'number',
+ begin: '\\b(' +
+ float_re + '([fF]|L|i|[fF]i|Li)?|' +
+ integer_re + '(i|[fF]i|Li)' +
+ ')',
+ relevance: 0
+ };
+
+ /**
+ * D character literal
+ *
+ * @type {Object}
+ */
+ var D_CHARACTER_MODE = {
+ className: 'string',
+ begin: '\'(' + escape_sequence_re + '|.)', end: '\'',
+ illegal: '.'
+ };
+
+ /**
+ * D string escape sequence
+ *
+ * @type {Object}
+ */
+ var D_ESCAPE_SEQUENCE = {
+ begin: escape_sequence_re,
+ relevance: 0
+ };
+
+ /**
+ * D double quoted string literal
+ *
+ * @type {Object}
+ */
+ var D_STRING_MODE = {
+ className: 'string',
+ begin: '"',
+ contains: [D_ESCAPE_SEQUENCE],
+ end: '"[cwd]?'
+ };
+
+ /**
+ * D wysiwyg and delimited string literals
+ *
+ * @type {Object}
+ */
+ var D_WYSIWYG_DELIMITED_STRING_MODE = {
+ className: 'string',
+ begin: '[rq]"',
+ end: '"[cwd]?',
+ relevance: 5
+ };
+
+ /**
+ * D alternate wysiwyg string literal
+ *
+ * @type {Object}
+ */
+ var D_ALTERNATE_WYSIWYG_STRING_MODE = {
+ className: 'string',
+ begin: '`',
+ end: '`[cwd]?'
+ };
+
+ /**
+ * D hexadecimal string literal
+ *
+ * @type {Object}
+ */
+ var D_HEX_STRING_MODE = {
+ className: 'string',
+ begin: 'x"[\\da-fA-F\\s\\n\\r]*"[cwd]?',
+ relevance: 10
+ };
+
+ /**
+ * D delimited string literal
+ *
+ * @type {Object}
+ */
+ var D_TOKEN_STRING_MODE = {
+ className: 'string',
+ begin: 'q"\\{',
+ end: '\\}"'
+ };
+
+ /**
+ * Hashbang support
+ *
+ * @type {Object}
+ */
+ var D_HASHBANG_MODE = {
+ className: 'shebang',
+ begin: '^#!',
+ end: '$',
+ relevance: 5
+ };
+
+ /**
+ * D special token sequence
+ *
+ * @type {Object}
+ */
+ var D_SPECIAL_TOKEN_SEQUENCE_MODE = {
+ className: 'preprocessor',
+ begin: '#(line)',
+ end: '$',
+ relevance: 5
+ };
+
+ /**
+ * D attributes
+ *
+ * @type {Object}
+ */
+ var D_ATTRIBUTE_MODE = {
+ className: 'keyword',
+ begin: '@[a-zA-Z_][a-zA-Z_\\d]*'
+ };
+
+ /**
+ * D nesting comment
+ *
+ * @type {Object}
+ */
+ var D_NESTING_COMMENT_MODE = {
+ className: 'comment',
+ begin: '\\/\\+',
+ contains: ['self'],
+ end: '\\+\\/',
+ relevance: 10
+ };
+
+ return {
+ lexemes: hljs.UNDERSCORE_IDENT_RE,
+ keywords: D_KEYWORDS,
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ D_NESTING_COMMENT_MODE,
+ D_HEX_STRING_MODE,
+ D_STRING_MODE,
+ D_WYSIWYG_DELIMITED_STRING_MODE,
+ D_ALTERNATE_WYSIWYG_STRING_MODE,
+ D_TOKEN_STRING_MODE,
+ D_FLOAT_MODE,
+ D_INTEGER_MODE,
+ D_CHARACTER_MODE,
+ D_HASHBANG_MODE,
+ D_SPECIAL_TOKEN_SEQUENCE_MODE,
+ D_ATTRIBUTE_MODE
+ ]
+ };
+};
+},{}],48:[function(require,module,exports){
+module.exports = function (hljs) {
+ var SUBST = {
+ className: 'subst',
+ begin: '\\$\\{', end: '}',
+ keywords: 'true false null this is new super'
+ };
+
+ var STRING = {
+ className: 'string',
+ variants: [
+ {
+ begin: 'r\'\'\'', end: '\'\'\''
+ },
+ {
+ begin: 'r"""', end: '"""'
+ },
+ {
+ begin: 'r\'', end: '\'',
+ illegal: '\\n'
+ },
+ {
+ begin: 'r"', end: '"',
+ illegal: '\\n'
+ },
+ {
+ begin: '\'\'\'', end: '\'\'\'',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ },
+ {
+ begin: '"""', end: '"""',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ },
+ {
+ begin: '\'', end: '\'',
+ illegal: '\\n',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ },
+ {
+ begin: '"', end: '"',
+ illegal: '\\n',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
+ }
+ ]
+ };
+ SUBST.contains = [
+ hljs.C_NUMBER_MODE, STRING
+ ];
+
+ var KEYWORDS = {
+ keyword: 'assert break case catch class const continue default do else enum extends false final finally for if ' +
+ 'in is new null rethrow return super switch this throw true try var void while with',
+ literal: 'abstract as dynamic export external factory get implements import library operator part set static typedef',
+ built_in:
+ // dart:core
+ 'print Comparable DateTime Duration Function Iterable Iterator List Map Match Null Object Pattern RegExp Set ' +
+ 'Stopwatch String StringBuffer StringSink Symbol Type Uri bool double int num ' +
+ // dart:html
+ 'document window querySelector querySelectorAll Element ElementList'
+ };
+
+ return {
+ keywords: KEYWORDS,
+ contains: [
+ STRING,
+ {
+ className: 'dartdoc',
+ begin: '/\\*\\*', end: '\\*/',
+ subLanguage: 'markdown',
+ subLanguageMode: 'continuous'
+ },
+ {
+ className: 'dartdoc',
+ begin: '///', end: '$',
+ subLanguage: 'markdown',
+ subLanguageMode: 'continuous'
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
+ contains: [
+ {
+ beginKeywords: 'extends implements'
+ },
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'annotation', begin: '@[A-Za-z]+'
+ },
+ {
+ begin: '=>' // No markup, just a relevance booster
+ }
+ ]
+ }
+};
+},{}],49:[function(require,module,exports){
+module.exports = function(hljs) {
+ var KEYWORDS =
+ 'exports register file shl array record property for mod while set ally label uses raise not ' +
+ 'stored class safecall var interface or private static exit index inherited to else stdcall ' +
+ 'override shr asm far resourcestring finalization packed virtual out and protected library do ' +
+ 'xorwrite goto near function end div overload object unit begin string on inline repeat until ' +
+ 'destructor write message program with read initialization except default nil if case cdecl in ' +
+ 'downto threadvar of try pascal const external constructor type public then implementation ' +
+ 'finally published procedure';
+ var COMMENT = {
+ className: 'comment',
+ variants: [
+ {begin: /\{/, end: /\}/, relevance: 0},
+ {begin: /\(\*/, end: /\*\)/, relevance: 10}
+ ]
+ };
+ var STRING = {
+ className: 'string',
+ begin: /'/, end: /'/,
+ contains: [{begin: /''/}]
+ };
+ var CHAR_STRING = {
+ className: 'string', begin: /(#\d+)+/
+ };
+ var CLASS = {
+ begin: hljs.IDENT_RE + '\\s*=\\s*class\\s*\\(', returnBegin: true,
+ contains: [
+ hljs.TITLE_MODE
+ ]
+ };
+ var FUNCTION = {
+ className: 'function',
+ beginKeywords: 'function constructor destructor procedure', end: /[:;]/,
+ keywords: 'function constructor|10 destructor|10 procedure|10',
+ contains: [
+ hljs.TITLE_MODE,
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ keywords: KEYWORDS,
+ contains: [STRING, CHAR_STRING]
+ },
+ COMMENT
+ ]
+ };
+ return {
+ case_insensitive: true,
+ keywords: KEYWORDS,
+ illegal: /("|\$[G-Zg-z]|\/\*|<\/)/,
+ contains: [
+ COMMENT, hljs.C_LINE_COMMENT_MODE,
+ STRING, CHAR_STRING,
+ hljs.NUMBER_MODE,
+ CLASS,
+ FUNCTION
+ ]
+ };
+};
+},{}],50:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['patch'],
+ contains: [
+ {
+ className: 'chunk',
+ relevance: 10,
+ variants: [
+ {begin: /^\@\@ +\-\d+,\d+ +\+\d+,\d+ +\@\@$/},
+ {begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/},
+ {begin: /^\-\-\- +\d+,\d+ +\-\-\-\-$/}
+ ]
+ },
+ {
+ className: 'header',
+ variants: [
+ {begin: /Index: /, end: /$/},
+ {begin: /=====/, end: /=====$/},
+ {begin: /^\-\-\-/, end: /$/},
+ {begin: /^\*{3} /, end: /$/},
+ {begin: /^\+\+\+/, end: /$/},
+ {begin: /\*{5}/, end: /\*{5}$/}
+ ]
+ },
+ {
+ className: 'addition',
+ begin: '^\\+', end: '$'
+ },
+ {
+ className: 'deletion',
+ begin: '^\\-', end: '$'
+ },
+ {
+ className: 'change',
+ begin: '^\\!', end: '$'
+ }
+ ]
+ };
+};
+},{}],51:[function(require,module,exports){
+module.exports = function(hljs) {
+ var FILTER = {
+ className: 'filter',
+ begin: /\|[A-Za-z]+\:?/,
+ keywords:
+ 'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags ' +
+ 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands ' +
+ 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode ' +
+ 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort ' +
+ 'dictsortreversed default_if_none pluralize lower join center default ' +
+ 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first ' +
+ 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize ' +
+ 'localtime utc timezone',
+ contains: [
+ {className: 'argument', begin: /"/, end: /"/},
+ {className: 'argument', begin: /'/, end: /'/}
+ ]
+ };
+
+ return {
+ aliases: ['jinja'],
+ case_insensitive: true,
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ className: 'template_comment',
+ begin: /\{%\s*comment\s*%}/, end: /\{%\s*endcomment\s*%}/
+ },
+ {
+ className: 'template_comment',
+ begin: /\{#/, end: /#}/
+ },
+ {
+ className: 'template_tag',
+ begin: /\{%/, end: /%}/,
+ keywords:
+ 'comment endcomment load templatetag ifchanged endifchanged if endif firstof for ' +
+ 'endfor in ifnotequal endifnotequal widthratio extends include spaceless ' +
+ 'endspaceless regroup by as ifequal endifequal ssi now with cycle url filter ' +
+ 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif ' +
+ 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix ' +
+ 'plural get_current_language language get_available_languages ' +
+ 'get_current_language_bidi get_language_info get_language_info_list localize ' +
+ 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone ' +
+ 'verbatim',
+ contains: [FILTER]
+ },
+ {
+ className: 'variable',
+ begin: /\{\{/, end: /}}/,
+ contains: [FILTER]
+ }
+ ]
+ };
+};
+},{}],52:[function(require,module,exports){
+module.exports = function(hljs) {
+ var COMMENT = {
+ className: 'comment',
+ begin: /@?rem\b/, end: /$/,
+ relevance: 10
+ };
+ var LABEL = {
+ className: 'label',
+ begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)',
+ relevance: 0
+ };
+ return {
+ aliases: ['bat', 'cmd'],
+ case_insensitive: true,
+ keywords: {
+ flow: 'if else goto for in do call exit not exist errorlevel defined',
+ operator: 'equ neq lss leq gtr geq',
+ keyword: 'shift cd dir echo setlocal endlocal set pause copy',
+ stream: 'prn nul lpt3 lpt2 lpt1 con com4 com3 com2 com1 aux',
+ winutils: 'ping net ipconfig taskkill xcopy ren del',
+ built_in: 'append assoc at attrib break cacls cd chcp chdir chkdsk chkntfs cls cmd color ' +
+ 'comp compact convert date dir diskcomp diskcopy doskey erase fs ' +
+ 'find findstr format ftype graftabl help keyb label md mkdir mode more move path ' +
+ 'pause print popd pushd promt rd recover rem rename replace restore rmdir shift' +
+ 'sort start subst time title tree type ver verify vol',
+ },
+ contains: [
+ {
+ className: 'envvar', begin: /%%[^ ]|%[^ ]+?%|![^ ]+?!/
+ },
+ {
+ className: 'function',
+ begin: LABEL.begin, end: 'goto:eof',
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'}),
+ COMMENT
+ ]
+ },
+ {
+ className: 'number', begin: '\\b\\d+',
+ relevance: 0
+ },
+ COMMENT
+ ]
+ };
+};
+},{}],53:[function(require,module,exports){
+module.exports = function(hljs) {
+ var EXPRESSION_KEYWORDS = 'if eq ne lt lte gt gte select default math sep';
+ return {
+ aliases: ['dst'],
+ case_insensitive: true,
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ className: 'expression',
+ begin: '{', end: '}',
+ relevance: 0,
+ contains: [
+ {
+ className: 'begin-block', begin: '\#[a-zA-Z\-\ \.]+',
+ keywords: EXPRESSION_KEYWORDS
+ },
+ {
+ className: 'string',
+ begin: '"', end: '"'
+ },
+ {
+ className: 'end-block', begin: '\\\/[a-zA-Z\-\ \.]+',
+ keywords: EXPRESSION_KEYWORDS
+ },
+ {
+ className: 'variable', begin: '[a-zA-Z\-\.]+',
+ keywords: EXPRESSION_KEYWORDS,
+ relevance: 0
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],54:[function(require,module,exports){
+module.exports = function(hljs) {
+ var ELIXIR_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?';
+ var ELIXIR_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?';
+ var ELIXIR_KEYWORDS =
+ 'and false then defined module in return redo retry end for true self when ' +
+ 'next until do begin unless nil break not case cond alias while ensure or ' +
+ 'include use alias fn quote';
+ var SUBST = {
+ className: 'subst',
+ begin: '#\\{', end: '}',
+ lexemes: ELIXIR_IDENT_RE,
+ keywords: ELIXIR_KEYWORDS
+ };
+ var STRING = {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
+ variants: [
+ {
+ begin: /'/, end: /'/
+ },
+ {
+ begin: /"/, end: /"/
+ }
+ ]
+ };
+ var PARAMS = {
+ endsWithParent: true, returnEnd: true,
+ lexemes: ELIXIR_IDENT_RE,
+ keywords: ELIXIR_KEYWORDS,
+ relevance: 0
+ };
+ var FUNCTION = {
+ className: 'function',
+ beginKeywords: 'def defmacro', end: /\bdo\b/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ begin: ELIXIR_METHOD_RE,
+ starts: PARAMS
+ })
+ ]
+ };
+ var CLASS = hljs.inherit(FUNCTION, {
+ className: 'class',
+ beginKeywords: 'defmodule defrecord', end: /\bdo\b|$|;/
+ })
+ var ELIXIR_DEFAULT_CONTAINS = [
+ STRING,
+ hljs.HASH_COMMENT_MODE,
+ CLASS,
+ FUNCTION,
+ {
+ className: 'constant',
+ begin: '(\\b[A-Z_]\\w*(.)?)+',
+ relevance: 0
+ },
+ {
+ className: 'symbol',
+ begin: ':',
+ contains: [STRING, {begin: ELIXIR_METHOD_RE}],
+ relevance: 0
+ },
+ {
+ className: 'symbol',
+ begin: ELIXIR_IDENT_RE + ':',
+ relevance: 0
+ },
+ {
+ className: 'number',
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
+ relevance: 0
+ },
+ {
+ className: 'variable',
+ begin: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'
+ },
+ {
+ begin: '->'
+ },
+ { // regexp container
+ begin: '(' + hljs.RE_STARTERS_RE + ')\\s*',
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'regexp',
+ illegal: '\\n',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
+ variants: [
+ {
+ begin: '/', end: '/[a-z]*'
+ },
+ {
+ begin: '%r\\[', end: '\\][a-z]*'
+ }
+ ]
+ }
+ ],
+ relevance: 0
+ }
+ ];
+ SUBST.contains = ELIXIR_DEFAULT_CONTAINS;
+ PARAMS.contains = ELIXIR_DEFAULT_CONTAINS;
+
+ return {
+ lexemes: ELIXIR_IDENT_RE,
+ keywords: ELIXIR_KEYWORDS,
+ contains: ELIXIR_DEFAULT_CONTAINS
+ };
+};
+},{}],55:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ className: 'comment',
+ begin: '<%#', end: '%>',
+ },
+ {
+ begin: '<%[%=-]?', end: '[%-]?%>',
+ subLanguage: 'ruby',
+ excludeBegin: true,
+ excludeEnd: true
+ }
+ ]
+ };
+};
+},{}],56:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ special_functions:
+ 'spawn spawn_link self',
+ reserved:
+ 'after and andalso|10 band begin bnot bor bsl bsr bxor case catch cond div end fun if ' +
+ 'let not of or orelse|10 query receive rem try when xor'
+ },
+ contains: [
+ {
+ className: 'prompt', begin: '^[0-9]+> ',
+ relevance: 10
+ },
+ {
+ className: 'comment',
+ begin: '%', end: '$'
+ },
+ {
+ className: 'number',
+ begin: '\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)',
+ relevance: 0
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'constant', begin: '\\?(::)?([A-Z]\\w*(::)?)+'
+ },
+ {
+ className: 'arrow', begin: '->'
+ },
+ {
+ className: 'ok', begin: 'ok'
+ },
+ {
+ className: 'exclamation_mark', begin: '!'
+ },
+ {
+ className: 'function_or_atom',
+ begin: '(\\b[a-z\'][a-zA-Z0-9_\']*:[a-z\'][a-zA-Z0-9_\']*)|(\\b[a-z\'][a-zA-Z0-9_\']*)',
+ relevance: 0
+ },
+ {
+ className: 'variable',
+ begin: '[A-Z][a-zA-Z0-9_\']*',
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],57:[function(require,module,exports){
+module.exports = function(hljs) {
+ var BASIC_ATOM_RE = '[a-z\'][a-zA-Z0-9_\']*';
+ var FUNCTION_NAME_RE = '(' + BASIC_ATOM_RE + ':' + BASIC_ATOM_RE + '|' + BASIC_ATOM_RE + ')';
+ var ERLANG_RESERVED = {
+ keyword:
+ 'after and andalso|10 band begin bnot bor bsl bzr bxor case catch cond div end fun if ' +
+ 'let not of orelse|10 query receive rem try when xor',
+ literal:
+ 'false true'
+ };
+
+ var COMMENT = {
+ className: 'comment',
+ begin: '%', end: '$'
+ };
+ var NUMBER = {
+ className: 'number',
+ begin: '\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)',
+ relevance: 0
+ };
+ var NAMED_FUN = {
+ begin: 'fun\\s+' + BASIC_ATOM_RE + '/\\d+'
+ };
+ var FUNCTION_CALL = {
+ begin: FUNCTION_NAME_RE + '\\(', end: '\\)',
+ returnBegin: true,
+ relevance: 0,
+ contains: [
+ {
+ className: 'function_name', begin: FUNCTION_NAME_RE,
+ relevance: 0
+ },
+ {
+ begin: '\\(', end: '\\)', endsWithParent: true,
+ returnEnd: true,
+ relevance: 0
+ // "contains" defined later
+ }
+ ]
+ };
+ var TUPLE = {
+ className: 'tuple',
+ begin: '{', end: '}',
+ relevance: 0
+ // "contains" defined later
+ };
+ var VAR1 = {
+ className: 'variable',
+ begin: '\\b_([A-Z][A-Za-z0-9_]*)?',
+ relevance: 0
+ };
+ var VAR2 = {
+ className: 'variable',
+ begin: '[A-Z][a-zA-Z0-9_]*',
+ relevance: 0
+ };
+ var RECORD_ACCESS = {
+ begin: '#' + hljs.UNDERSCORE_IDENT_RE,
+ relevance: 0,
+ returnBegin: true,
+ contains: [
+ {
+ className: 'record_name',
+ begin: '#' + hljs.UNDERSCORE_IDENT_RE,
+ relevance: 0
+ },
+ {
+ begin: '{', end: '}',
+ relevance: 0
+ // "contains" defined later
+ }
+ ]
+ };
+
+ var BLOCK_STATEMENTS = {
+ beginKeywords: 'fun receive if try case', end: 'end',
+ keywords: ERLANG_RESERVED
+ };
+ BLOCK_STATEMENTS.contains = [
+ COMMENT,
+ NAMED_FUN,
+ hljs.inherit(hljs.APOS_STRING_MODE, {className: ''}),
+ BLOCK_STATEMENTS,
+ FUNCTION_CALL,
+ hljs.QUOTE_STRING_MODE,
+ NUMBER,
+ TUPLE,
+ VAR1, VAR2,
+ RECORD_ACCESS
+ ];
+
+ var BASIC_MODES = [
+ COMMENT,
+ NAMED_FUN,
+ BLOCK_STATEMENTS,
+ FUNCTION_CALL,
+ hljs.QUOTE_STRING_MODE,
+ NUMBER,
+ TUPLE,
+ VAR1, VAR2,
+ RECORD_ACCESS
+ ];
+ FUNCTION_CALL.contains[1].contains = BASIC_MODES;
+ TUPLE.contains = BASIC_MODES;
+ RECORD_ACCESS.contains[1].contains = BASIC_MODES;
+
+ var PARAMS = {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ contains: BASIC_MODES
+ };
+ return {
+ aliases: ['erl'],
+ keywords: ERLANG_RESERVED,
+ illegal: '(|\\*=|\\+=|-=|/\\*|\\*/|\\(\\*|\\*\\))',
+ contains: [
+ {
+ className: 'function',
+ begin: '^' + BASIC_ATOM_RE + '\\s*\\(', end: '->',
+ returnBegin: true,
+ illegal: '\\(|#|//|/\\*|\\\\|:|;',
+ contains: [
+ PARAMS,
+ hljs.inherit(hljs.TITLE_MODE, {begin: BASIC_ATOM_RE})
+ ],
+ starts: {
+ end: ';|\\.',
+ keywords: ERLANG_RESERVED,
+ contains: BASIC_MODES
+ }
+ },
+ COMMENT,
+ {
+ className: 'pp',
+ begin: '^-', end: '\\.',
+ relevance: 0,
+ excludeEnd: true,
+ returnBegin: true,
+ lexemes: '-' + hljs.IDENT_RE,
+ keywords:
+ '-module -record -undef -export -ifdef -ifndef -author -copyright -doc -vsn ' +
+ '-import -include -include_lib -compile -define -else -endif -file -behaviour ' +
+ '-behavior -spec',
+ contains: [PARAMS]
+ },
+ NUMBER,
+ hljs.QUOTE_STRING_MODE,
+ RECORD_ACCESS,
+ VAR1, VAR2,
+ TUPLE,
+ {begin: /\.$/} // relevance booster
+ ]
+ };
+};
+},{}],58:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ contains: [
+ {
+ begin: /[^\u2401\u0001]+/,
+ end: /[\u2401\u0001]/,
+ excludeEnd: true,
+ returnBegin: true,
+ returnEnd: false,
+ contains: [
+ {
+ begin: /([^\u2401\u0001=]+)/,
+ end: /=([^\u2401\u0001=]+)/,
+ returnEnd: true,
+ returnBegin: false,
+ className: 'attribute'
+ },
+ {
+ begin: /=/,
+ end: /([\u2401\u0001])/,
+ excludeEnd: true,
+ excludeBegin: true,
+ className: 'string'
+ }]
+ }],
+ case_insensitive: true
+ };
+};
+},{}],59:[function(require,module,exports){
+module.exports = function(hljs) {
+ var TYPEPARAM = {
+ begin: '<', end: '>',
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: /'[a-zA-Z0-9_]+/})
+ ]
+ };
+
+ return {
+ aliases: ['fs'],
+ keywords:
+ // monad builder keywords (at top, matches before non-bang kws)
+ 'yield! return! let! do!' +
+ // regular keywords
+ 'abstract and as assert base begin class default delegate do done ' +
+ 'downcast downto elif else end exception extern false finally for ' +
+ 'fun function global if in inherit inline interface internal lazy let ' +
+ 'match member module mutable namespace new null of open or ' +
+ 'override private public rec return sig static struct then to ' +
+ 'true try type upcast use val void when while with yield',
+ contains: [
+ {
+ className: 'string',
+ begin: '@"', end: '"',
+ contains: [{begin: '""'}]
+ },
+ {
+ className: 'string',
+ begin: '"""', end: '"""'
+ },
+ {
+ className: 'comment',
+ begin: '\\(\\*', end: '\\*\\)'
+ },
+ {
+ className: 'class',
+ beginKeywords: 'type', end: '\\(|=|$', excludeEnd: true,
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE,
+ TYPEPARAM
+ ]
+ },
+ {
+ className: 'annotation',
+ begin: '\\[<', end: '>\\]',
+ relevance: 10
+ },
+ {
+ className: 'attribute',
+ begin: '\\B(\'[A-Za-z])\\b',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],60:[function(require,module,exports){
+module.exports = function(hljs) {
+ var GCODE_IDENT_RE = '[A-Z_][A-Z0-9_.]*';
+ var GCODE_CLOSE_RE = '\\%';
+ var GCODE_KEYWORDS = {
+ literal:
+ '',
+ built_in:
+ '',
+ keyword:
+ 'IF DO WHILE ENDWHILE CALL ENDIF SUB ENDSUB GOTO REPEAT ENDREPEAT ' +
+ 'EQ LT GT NE GE LE OR XOR'
+ };
+ var GCODE_START = {
+ className: 'preprocessor',
+ begin: '([O])([0-9]+)'
+ };
+ var GCODE_CODE = [
+ hljs.C_LINE_COMMENT_MODE,
+ {
+ className: 'comment',
+ begin: /\(/, end: /\)/,
+ contains: [hljs.PHRASAL_WORDS_MODE]
+ },
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.inherit(hljs.C_NUMBER_MODE, {begin: '([-+]?([0-9]*\\.?[0-9]+\\.?))|' + hljs.C_NUMBER_RE}),
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
+ {
+ className: 'keyword',
+ begin: '([G])([0-9]+\\.?[0-9]?)'
+ },
+ {
+ className: 'title',
+ begin: '([M])([0-9]+\\.?[0-9]?)'
+ },
+ {
+ className: 'title',
+ begin: '(VC|VS|#)',
+ end: '(\\d+)'
+ },
+ {
+ className: 'title',
+ begin: '(VZOFX|VZOFY|VZOFZ)'
+ },
+ {
+ className: 'built_in',
+ begin: '(ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN)(\\[)',
+ end: '([-+]?([0-9]*\\.?[0-9]+\\.?))(\\])'
+ },
+ {
+ className: 'label',
+ variants: [
+ {
+ begin: 'N', end: '\\d+',
+ illegal: '\\W'
+ }
+ ]
+ }
+ ];
+
+ return {
+ aliases: ['nc'],
+ // Some implementations (CNC controls) of G-code are interoperable with uppercase and lowercase letters seamlessly.
+ // However, most prefer all uppercase and uppercase is customary.
+ case_insensitive: true,
+ lexemes: GCODE_IDENT_RE,
+ keywords: GCODE_KEYWORDS,
+ contains: [
+ {
+ className: 'preprocessor',
+ begin: GCODE_CLOSE_RE
+ },
+ GCODE_START
+ ].concat(GCODE_CODE)
+ };
+};
+},{}],61:[function(require,module,exports){
+module.exports = function (hljs) {
+ return {
+ aliases: ['feature'],
+ keywords: 'Feature Background Ability Business\ Need Scenario Scenarios Scenario\ Outline Scenario\ Template Examples Given And Then But When',
+ contains: [
+ {
+ className: 'keyword',
+ begin: '\\*'
+ },
+ {
+ className: 'comment',
+ begin: '@[^@\r\n\t ]+', end: '$'
+ },
+ {
+ className: 'string',
+ begin: '\\|', end: '\\$'
+ },
+ {
+ className: 'variable',
+ begin: '<', end: '>',
+ },
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'string',
+ begin: '"""', end: '"""'
+ },
+ hljs.QUOTE_STRING_MODE
+ ]
+ };
+};
+},{}],62:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword:
+ 'atomic_uint attribute bool break bvec2 bvec3 bvec4 case centroid coherent const continue default ' +
+ 'discard dmat2 dmat2x2 dmat2x3 dmat2x4 dmat3 dmat3x2 dmat3x3 dmat3x4 dmat4 dmat4x2 dmat4x3 ' +
+ 'dmat4x4 do double dvec2 dvec3 dvec4 else flat float for highp if iimage1D iimage1DArray ' +
+ 'iimage2D iimage2DArray iimage2DMS iimage2DMSArray iimage2DRect iimage3D iimageBuffer iimageCube ' +
+ 'iimageCubeArray image1D image1DArray image2D image2DArray image2DMS image2DMSArray image2DRect ' +
+ 'image3D imageBuffer imageCube imageCubeArray in inout int invariant isampler1D isampler1DArray ' +
+ 'isampler2D isampler2DArray isampler2DMS isampler2DMSArray isampler2DRect isampler3D isamplerBuffer ' +
+ 'isamplerCube isamplerCubeArray ivec2 ivec3 ivec4 layout lowp mat2 mat2x2 mat2x3 mat2x4 mat3 mat3x2 ' +
+ 'mat3x3 mat3x4 mat4 mat4x2 mat4x3 mat4x4 mediump noperspective out patch precision readonly restrict ' +
+ 'return sample sampler1D sampler1DArray sampler1DArrayShadow sampler1DShadow sampler2D sampler2DArray ' +
+ 'sampler2DArrayShadow sampler2DMS sampler2DMSArray sampler2DRect sampler2DRectShadow sampler2DShadow ' +
+ 'sampler3D samplerBuffer samplerCube samplerCubeArray samplerCubeArrayShadow samplerCubeShadow smooth ' +
+ 'struct subroutine switch uimage1D uimage1DArray uimage2D uimage2DArray uimage2DMS uimage2DMSArray ' +
+ 'uimage2DRect uimage3D uimageBuffer uimageCube uimageCubeArray uint uniform usampler1D usampler1DArray ' +
+ 'usampler2D usampler2DArray usampler2DMS usampler2DMSArray usampler2DRect usampler3D usamplerBuffer ' +
+ 'usamplerCube usamplerCubeArray uvec2 uvec3 uvec4 varying vec2 vec3 vec4 void volatile while writeonly',
+ built_in:
+ 'gl_BackColor gl_BackLightModelProduct gl_BackLightProduct gl_BackMaterial ' +
+ 'gl_BackSecondaryColor gl_ClipDistance gl_ClipPlane gl_ClipVertex gl_Color ' +
+ 'gl_DepthRange gl_EyePlaneQ gl_EyePlaneR gl_EyePlaneS gl_EyePlaneT gl_Fog gl_FogCoord ' +
+ 'gl_FogFragCoord gl_FragColor gl_FragCoord gl_FragData gl_FragDepth gl_FrontColor ' +
+ 'gl_FrontFacing gl_FrontLightModelProduct gl_FrontLightProduct gl_FrontMaterial ' +
+ 'gl_FrontSecondaryColor gl_InstanceID gl_InvocationID gl_Layer gl_LightModel ' +
+ 'gl_LightSource gl_MaxAtomicCounterBindings gl_MaxAtomicCounterBufferSize ' +
+ 'gl_MaxClipDistances gl_MaxClipPlanes gl_MaxCombinedAtomicCounterBuffers ' +
+ 'gl_MaxCombinedAtomicCounters gl_MaxCombinedImageUniforms gl_MaxCombinedImageUnitsAndFragmentOutputs ' +
+ 'gl_MaxCombinedTextureImageUnits gl_MaxDrawBuffers gl_MaxFragmentAtomicCounterBuffers ' +
+ 'gl_MaxFragmentAtomicCounters gl_MaxFragmentImageUniforms gl_MaxFragmentInputComponents ' +
+ 'gl_MaxFragmentUniformComponents gl_MaxFragmentUniformVectors gl_MaxGeometryAtomicCounterBuffers ' +
+ 'gl_MaxGeometryAtomicCounters gl_MaxGeometryImageUniforms gl_MaxGeometryInputComponents ' +
+ 'gl_MaxGeometryOutputComponents gl_MaxGeometryOutputVertices gl_MaxGeometryTextureImageUnits ' +
+ 'gl_MaxGeometryTotalOutputComponents gl_MaxGeometryUniformComponents gl_MaxGeometryVaryingComponents ' +
+ 'gl_MaxImageSamples gl_MaxImageUnits gl_MaxLights gl_MaxPatchVertices gl_MaxProgramTexelOffset ' +
+ 'gl_MaxTessControlAtomicCounterBuffers gl_MaxTessControlAtomicCounters gl_MaxTessControlImageUniforms ' +
+ 'gl_MaxTessControlInputComponents gl_MaxTessControlOutputComponents gl_MaxTessControlTextureImageUnits ' +
+ 'gl_MaxTessControlTotalOutputComponents gl_MaxTessControlUniformComponents ' +
+ 'gl_MaxTessEvaluationAtomicCounterBuffers gl_MaxTessEvaluationAtomicCounters ' +
+ 'gl_MaxTessEvaluationImageUniforms gl_MaxTessEvaluationInputComponents gl_MaxTessEvaluationOutputComponents ' +
+ 'gl_MaxTessEvaluationTextureImageUnits gl_MaxTessEvaluationUniformComponents ' +
+ 'gl_MaxTessGenLevel gl_MaxTessPatchComponents gl_MaxTextureCoords gl_MaxTextureImageUnits ' +
+ 'gl_MaxTextureUnits gl_MaxVaryingComponents gl_MaxVaryingFloats gl_MaxVaryingVectors ' +
+ 'gl_MaxVertexAtomicCounterBuffers gl_MaxVertexAtomicCounters gl_MaxVertexAttribs ' +
+ 'gl_MaxVertexImageUniforms gl_MaxVertexOutputComponents gl_MaxVertexTextureImageUnits ' +
+ 'gl_MaxVertexUniformComponents gl_MaxVertexUniformVectors gl_MaxViewports gl_MinProgramTexelOffset'+
+ 'gl_ModelViewMatrix gl_ModelViewMatrixInverse gl_ModelViewMatrixInverseTranspose ' +
+ 'gl_ModelViewMatrixTranspose gl_ModelViewProjectionMatrix gl_ModelViewProjectionMatrixInverse ' +
+ 'gl_ModelViewProjectionMatrixInverseTranspose gl_ModelViewProjectionMatrixTranspose ' +
+ 'gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 gl_MultiTexCoord4 ' +
+ 'gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 gl_Normal gl_NormalMatrix ' +
+ 'gl_NormalScale gl_ObjectPlaneQ gl_ObjectPlaneR gl_ObjectPlaneS gl_ObjectPlaneT gl_PatchVerticesIn ' +
+ 'gl_PerVertex gl_Point gl_PointCoord gl_PointSize gl_Position gl_PrimitiveID gl_PrimitiveIDIn ' +
+ 'gl_ProjectionMatrix gl_ProjectionMatrixInverse gl_ProjectionMatrixInverseTranspose ' +
+ 'gl_ProjectionMatrixTranspose gl_SampleID gl_SampleMask gl_SampleMaskIn gl_SamplePosition ' +
+ 'gl_SecondaryColor gl_TessCoord gl_TessLevelInner gl_TessLevelOuter gl_TexCoord gl_TextureEnvColor ' +
+ 'gl_TextureMatrixInverseTranspose gl_TextureMatrixTranspose gl_Vertex gl_VertexID ' +
+ 'gl_ViewportIndex gl_in gl_out EmitStreamVertex EmitVertex EndPrimitive EndStreamPrimitive ' +
+ 'abs acos acosh all any asin asinh atan atanh atomicCounter atomicCounterDecrement ' +
+ 'atomicCounterIncrement barrier bitCount bitfieldExtract bitfieldInsert bitfieldReverse ' +
+ 'ceil clamp cos cosh cross dFdx dFdy degrees determinant distance dot equal exp exp2 faceforward ' +
+ 'findLSB findMSB floatBitsToInt floatBitsToUint floor fma fract frexp ftransform fwidth greaterThan ' +
+ 'greaterThanEqual imageAtomicAdd imageAtomicAnd imageAtomicCompSwap imageAtomicExchange ' +
+ 'imageAtomicMax imageAtomicMin imageAtomicOr imageAtomicXor imageLoad imageStore imulExtended ' +
+ 'intBitsToFloat interpolateAtCentroid interpolateAtOffset interpolateAtSample inverse inversesqrt ' +
+ 'isinf isnan ldexp length lessThan lessThanEqual log log2 matrixCompMult max memoryBarrier ' +
+ 'min mix mod modf noise1 noise2 noise3 noise4 normalize not notEqual outerProduct packDouble2x32 ' +
+ 'packHalf2x16 packSnorm2x16 packSnorm4x8 packUnorm2x16 packUnorm4x8 pow radians reflect refract ' +
+ 'round roundEven shadow1D shadow1DLod shadow1DProj shadow1DProjLod shadow2D shadow2DLod shadow2DProj ' +
+ 'shadow2DProjLod sign sin sinh smoothstep sqrt step tan tanh texelFetch texelFetchOffset texture ' +
+ 'texture1D texture1DLod texture1DProj texture1DProjLod texture2D texture2DLod texture2DProj ' +
+ 'texture2DProjLod texture3D texture3DLod texture3DProj texture3DProjLod textureCube textureCubeLod ' +
+ 'textureGather textureGatherOffset textureGatherOffsets textureGrad textureGradOffset textureLod ' +
+ 'textureLodOffset textureOffset textureProj textureProjGrad textureProjGradOffset textureProjLod ' +
+ 'textureProjLodOffset textureProjOffset textureQueryLod textureSize transpose trunc uaddCarry ' +
+ 'uintBitsToFloat umulExtended unpackDouble2x32 unpackHalf2x16 unpackSnorm2x16 unpackSnorm4x8 ' +
+ 'unpackUnorm2x16 unpackUnorm4x8 usubBorrow gl_TextureMatrix gl_TextureMatrixInverse',
+ literal: 'true false'
+ },
+ illegal: '"',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$'
+ }
+ ]
+ };
+};
+},{}],63:[function(require,module,exports){
+module.exports = function(hljs) {
+ var GO_KEYWORDS = {
+ keyword:
+ 'break default func interface select case map struct chan else goto package switch ' +
+ 'const fallthrough if range type continue for import return var go defer',
+ constant:
+ 'true false iota nil',
+ typename:
+ 'bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 ' +
+ 'uint16 uint32 uint64 int uint uintptr rune',
+ built_in:
+ 'append cap close complex copy imag len make new panic print println real recover delete'
+ };
+ return {
+ aliases: ["golang"],
+ keywords: GO_KEYWORDS,
+ illegal: '',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ begin: '\'', end: '[^\\\\]\''
+ },
+ {
+ className: 'string',
+ begin: '`', end: '`'
+ },
+ {
+ className: 'number',
+ begin: '[^a-zA-Z_0-9](\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s)(\\+|\\-)?\\d+)?',
+ relevance: 0
+ },
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],64:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ case_insensitive: true,
+ keywords: {
+ keyword:
+ 'task project allprojects subprojects artifacts buildscript configurations ' +
+ 'dependencies repositories sourceSets description delete from into include ' +
+ 'exclude source classpath destinationDir includes options sourceCompatibility ' +
+ 'targetCompatibility group flatDir doLast doFirst flatten todir fromdir ant ' +
+ 'def abstract break case catch continue default do else extends final finally ' +
+ 'for if implements instanceof native new private protected public return static ' +
+ 'switch synchronized throw throws transient try volatile while strictfp package ' +
+ 'import false null super this true antlrtask checkstyle codenarc copy boolean ' +
+ 'byte char class double float int interface long short void compile runTime ' +
+ 'file fileTree abs any append asList asWritable call collect compareTo count ' +
+ 'div dump each eachByte eachFile eachLine every find findAll flatten getAt ' +
+ 'getErr getIn getOut getText grep immutable inject inspect intersect invokeMethods ' +
+ 'isCase join leftShift minus multiply newInputStream newOutputStream newPrintWriter ' +
+ 'newReader newWriter next plus pop power previous print println push putAt read ' +
+ 'readBytes readLines reverse reverseEach round size sort splitEachLine step subMap ' +
+ 'times toInteger toList tokenize upto waitForOrKill withPrintWriter withReader ' +
+ 'withStream withWriter withWriterAppend write writeLine'
+ },
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.NUMBER_MODE,
+ hljs.REGEXP_MODE
+
+ ]
+ }
+};
+},{}],65:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ typename: 'byte short char int long boolean float double void',
+ literal : 'true false null',
+ keyword:
+ // groovy specific keywords
+ 'def as in assert trait ' +
+ // common keywords with Java
+ 'super this abstract static volatile transient public private protected synchronized final ' +
+ 'class interface enum if else for while switch case break default continue ' +
+ 'throw throws try catch finally implements extends new import package return instanceof'
+ },
+
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ {
+ className: 'javadoc',
+ begin: '/\\*\\*', end: '\\*//*',
+ contains: [
+ {
+ className: 'javadoctag', begin: '@[A-Za-z]+'
+ }
+ ]
+ },
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'string',
+ begin: '"""', end: '"""'
+ },
+ {
+ className: 'string',
+ begin: "'''", end: "'''"
+ },
+ {
+ className: 'string',
+ begin: "\\$/", end: "/\\$",
+ relevance: 10
+ },
+ hljs.APOS_STRING_MODE,
+ {
+ className: 'regexp',
+ begin: /~?\/[^\/\n]+\//,
+ contains: [
+ hljs.BACKSLASH_ESCAPE
+ ]
+ },
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'shebang',
+ begin: "^#!/usr/bin/env", end: '$',
+ illegal: '\n'
+ },
+ hljs.BINARY_NUMBER_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'class interface trait enum', end: '{',
+ illegal: ':',
+ contains: [
+ {beginKeywords: 'extends implements'},
+ hljs.UNDERSCORE_TITLE_MODE,
+ ]
+ },
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'annotation', begin: '@[A-Za-z]+'
+ },
+ {
+ // highlight map keys and named parameters as strings
+ className: 'string', begin: /[^\?]{0}[A-Za-z0-9_$]+ *:/
+ },
+ {
+ // catch middle element of the ternary operator
+ // to avoid highlight it as a label, named parameter, or map key
+ begin: /\?/, end: /\:/
+ },
+ {
+ // highlight labeled statements
+ className: 'label', begin: '^\\s*[A-Za-z0-9_$]+:',
+ relevance: 0
+ },
+ ]
+ }
+};
+},{}],66:[function(require,module,exports){
+module.exports = // TODO support filter tags like :javascript, support inline HTML
+function(hljs) {
+ return {
+ case_insensitive: true,
+ contains: [
+ {
+ className: 'doctype',
+ begin: '^!!!( (5|1\\.1|Strict|Frameset|Basic|Mobile|RDFa|XML\\b.*))?$',
+ relevance: 10
+ },
+ {
+ className: 'comment',
+ // FIXME these comments should be allowed to span indented lines
+ begin: '^\\s*(!=#|=#|-#|/).*$',
+ relevance: 0
+ },
+ {
+ begin: '^\\s*(-|=|!=)(?!#)',
+ starts: {
+ end: '\\n',
+ subLanguage: 'ruby'
+ }
+ },
+ {
+ className: 'tag',
+ begin: '^\\s*%',
+ contains: [
+ {
+ className: 'title',
+ begin: '\\w+'
+ },
+ {
+ className: 'value',
+ begin: '[#\\.]\\w+'
+ },
+ {
+ begin: '{\\s*',
+ end: '\\s*}',
+ excludeEnd: true,
+ contains: [
+ {
+ //className: 'attribute',
+ begin: ':\\w+\\s*=>',
+ end: ',\\s+',
+ returnBegin: true,
+ endsWithParent: true,
+ contains: [
+ {
+ className: 'symbol',
+ begin: ':\\w+'
+ },
+ {
+ className: 'string',
+ begin: '"',
+ end: '"'
+ },
+ {
+ className: 'string',
+ begin: '\'',
+ end: '\''
+ },
+ {
+ begin: '\\w+',
+ relevance: 0
+ }
+ ]
+ }
+ ]
+ },
+ {
+ begin: '\\(\\s*',
+ end: '\\s*\\)',
+ excludeEnd: true,
+ contains: [
+ {
+ //className: 'attribute',
+ begin: '\\w+\\s*=',
+ end: '\\s+',
+ returnBegin: true,
+ endsWithParent: true,
+ contains: [
+ {
+ className: 'attribute',
+ begin: '\\w+',
+ relevance: 0
+ },
+ {
+ className: 'string',
+ begin: '"',
+ end: '"'
+ },
+ {
+ className: 'string',
+ begin: '\'',
+ end: '\''
+ },
+ {
+ begin: '\\w+',
+ relevance: 0
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ className: 'bullet',
+ begin: '^\\s*[=~]\\s*',
+ relevance: 0
+ },
+ {
+ begin: '#{',
+ starts: {
+ end: '}',
+ subLanguage: 'ruby'
+ }
+ }
+ ]
+ };
+};
+},{}],67:[function(require,module,exports){
+module.exports = function(hljs) {
+ var EXPRESSION_KEYWORDS = 'each in with if else unless bindattr action collection debugger log outlet template unbound view yield';
+ return {
+ aliases: ['hbs', 'html.hbs', 'html.handlebars'],
+ case_insensitive: true,
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ className: 'expression',
+ begin: '{{', end: '}}',
+ contains: [
+ {
+ className: 'begin-block', begin: '\#[a-zA-Z\-\ \.]+',
+ keywords: EXPRESSION_KEYWORDS
+ },
+ {
+ className: 'string',
+ begin: '"', end: '"'
+ },
+ {
+ className: 'end-block', begin: '\\\/[a-zA-Z\-\ \.]+',
+ keywords: EXPRESSION_KEYWORDS
+ },
+ {
+ className: 'variable', begin: '[a-zA-Z\-\.]+',
+ keywords: EXPRESSION_KEYWORDS
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],68:[function(require,module,exports){
+module.exports = function(hljs) {
+
+ var COMMENT = {
+ className: 'comment',
+ variants: [
+ { begin: '--', end: '$' },
+ { begin: '{-', end: '-}'
+ , contains: ['self']
+ }
+ ]
+ };
+
+ var PRAGMA = {
+ className: 'pragma',
+ begin: '{-#', end: '#-}'
+ };
+
+ var PREPROCESSOR = {
+ className: 'preprocessor',
+ begin: '^#', end: '$'
+ };
+
+ var CONSTRUCTOR = {
+ className: 'type',
+ begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (build-in, infix).
+ relevance: 0
+ };
+
+ var LIST = {
+ className: 'container',
+ begin: '\\(', end: '\\)',
+ illegal: '"',
+ contains: [
+ PRAGMA,
+ COMMENT,
+ PREPROCESSOR,
+ {className: 'type', begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'},
+ hljs.inherit(hljs.TITLE_MODE, {begin: '[_a-z][\\w\']*'})
+ ]
+ };
+
+ var RECORD = {
+ className: 'container',
+ begin: '{', end: '}',
+ contains: LIST.contains
+ };
+
+ return {
+ aliases: ['hs'],
+ keywords:
+ 'let in if then else case of where do module import hiding ' +
+ 'qualified type data newtype deriving class instance as default ' +
+ 'infix infixl infixr foreign export ccall stdcall cplusplus ' +
+ 'jvm dotnet safe unsafe family forall mdo proc rec',
+ contains: [
+
+ // Top-level constructions.
+
+ {
+ className: 'module',
+ begin: '\\bmodule\\b', end: 'where',
+ keywords: 'module where',
+ contains: [LIST, COMMENT],
+ illegal: '\\W\\.|;'
+ },
+ {
+ className: 'import',
+ begin: '\\bimport\\b', end: '$',
+ keywords: 'import|0 qualified as hiding',
+ contains: [LIST, COMMENT],
+ illegal: '\\W\\.|;'
+ },
+
+ {
+ className: 'class',
+ begin: '^(\\s*)?(class|instance)\\b', end: 'where',
+ keywords: 'class family instance where',
+ contains: [CONSTRUCTOR, LIST, COMMENT]
+ },
+ {
+ className: 'typedef',
+ begin: '\\b(data|(new)?type)\\b', end: '$',
+ keywords: 'data family type newtype deriving',
+ contains: [PRAGMA, COMMENT, CONSTRUCTOR, LIST, RECORD]
+ },
+ {
+ className: 'default',
+ beginKeywords: 'default', end: '$',
+ contains: [CONSTRUCTOR, LIST, COMMENT]
+ },
+ {
+ className: 'infix',
+ beginKeywords: 'infix infixl infixr', end: '$',
+ contains: [hljs.C_NUMBER_MODE, COMMENT]
+ },
+ {
+ className: 'foreign',
+ begin: '\\bforeign\\b', end: '$',
+ keywords: 'foreign import export ccall stdcall cplusplus jvm ' +
+ 'dotnet safe unsafe',
+ contains: [CONSTRUCTOR, hljs.QUOTE_STRING_MODE, COMMENT]
+ },
+ {
+ className: 'shebang',
+ begin: '#!\\/usr\\/bin\\/env\ runhaskell', end: '$'
+ },
+
+ // "Whitespaces".
+
+ PRAGMA,
+ COMMENT,
+ PREPROCESSOR,
+
+ // Literals and names.
+
+ // TODO: characters.
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ CONSTRUCTOR,
+ hljs.inherit(hljs.TITLE_MODE, {begin: '^[_a-z][\\w\']*'}),
+
+ {begin: '->|<-'} // No markup, relevance booster
+ ]
+ };
+};
+},{}],69:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
+ var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';
+
+ return {
+ aliases: ['hx'],
+ keywords: {
+ keyword: 'break callback case cast catch class continue default do dynamic else enum extends extern ' +
+ 'for function here if implements import in inline interface never new override package private ' +
+ 'public return static super switch this throw trace try typedef untyped using var while',
+ literal: 'true false null'
+ },
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
+ contains: [
+ {
+ beginKeywords: 'extends implements'
+ },
+ hljs.TITLE_MODE
+ ]
+ },
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$',
+ keywords: 'if else elseif end error'
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: '[{;]', excludeEnd: true,
+ illegal: '\\S',
+ contains: [
+ hljs.TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ },
+ {
+ className: 'type',
+ begin: ':',
+ end: IDENT_FUNC_RETURN_TYPE_RE,
+ relevance: 10
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],70:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ illegal: '\\S',
+ contains: [
+ {
+ className: 'status',
+ begin: '^HTTP/[0-9\\.]+', end: '$',
+ contains: [{className: 'number', begin: '\\b\\d{3}\\b'}]
+ },
+ {
+ className: 'request',
+ begin: '^[A-Z]+ (.*?) HTTP/[0-9\\.]+$', returnBegin: true, end: '$',
+ contains: [
+ {
+ className: 'string',
+ begin: ' ', end: ' ',
+ excludeBegin: true, excludeEnd: true
+ }
+ ]
+ },
+ {
+ className: 'attribute',
+ begin: '^\\w', end: ': ', excludeEnd: true,
+ illegal: '\\n|\\s|=',
+ starts: {className: 'string', end: '$'}
+ },
+ {
+ begin: '\\n\\n',
+ starts: {subLanguage: '', endsWithParent: true}
+ }
+ ]
+ };
+};
+},{}],71:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ case_insensitive: true,
+ illegal: /\S/,
+ contains: [
+ {
+ className: 'comment',
+ begin: ';', end: '$'
+ },
+ {
+ className: 'title',
+ begin: '^\\[', end: '\\]'
+ },
+ {
+ className: 'setting',
+ begin: '^[a-z0-9\\[\\]_-]+[ \\t]*=[ \\t]*', end: '$',
+ contains: [
+ {
+ className: 'value',
+ endsWithParent: true,
+ keywords: 'on off true false yes no',
+ contains: [hljs.QUOTE_STRING_MODE, hljs.NUMBER_MODE],
+ relevance: 0
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],72:[function(require,module,exports){
+module.exports = function(hljs) {
+ var GENERIC_IDENT_RE = hljs.UNDERSCORE_IDENT_RE + '(<' + hljs.UNDERSCORE_IDENT_RE + '>)?';
+ var KEYWORDS =
+ 'false synchronized int abstract float private char boolean static null if const ' +
+ 'for true while long throw strictfp finally protected import native final return void ' +
+ 'enum else break transient new catch instanceof byte super volatile case assert short ' +
+ 'package default double public try this switch continue throws protected public private';
+ return {
+ aliases: ['jsp'],
+ keywords: KEYWORDS,
+ illegal: /<\//,
+ contains: [
+ {
+ className: 'javadoc',
+ begin: '/\\*\\*', end: '\\*/',
+ relevance: 0,
+ contains: [{
+ className: 'javadoctag', begin: '(^|\\s)@[A-Za-z]+'
+ }]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: /[{;=]/, excludeEnd: true,
+ keywords: 'class interface',
+ illegal: /[:"\[\]]/,
+ contains: [
+ {beginKeywords: 'extends implements'},
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ {
+ // this prevents 'new Name(...), or throw ...' from being recognized as a function definition
+ beginKeywords: 'new throw', end: /\s/,
+ relevance: 0
+ },
+ {
+ className: 'function',
+ begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
+ excludeEnd: true,
+ keywords: KEYWORDS,
+ contains: [
+ {
+ begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
+ },
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ keywords: KEYWORDS,
+ contains: [
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ },
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'annotation', begin: '@[A-Za-z]+'
+ }
+ ]
+ };
+};
+},{}],73:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['js'],
+ keywords: {
+ keyword:
+ 'in if for while finally var new function do return void else break catch ' +
+ 'instanceof with throw case default try this switch continue typeof delete ' +
+ 'let yield const class',
+ literal:
+ 'true false null undefined NaN Infinity',
+ built_in:
+ 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' +
+ 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' +
+ 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' +
+ 'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
+ 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
+ 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
+ 'module console window document'
+ },
+ contains: [
+ {
+ className: 'pi',
+ begin: /^\s*('|")use strict('|")/,
+ relevance: 10
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ { // "value" container
+ begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
+ keywords: 'return throw case',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.REGEXP_MODE,
+ { // E4X
+ begin: /, end: />;/,
+ relevance: 0,
+ subLanguage: 'xml'
+ }
+ ],
+ relevance: 0
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: /\{/, excludeEnd: true,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: /[A-Za-z$_][0-9A-Za-z$_]*/}),
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ],
+ illegal: /["'\(]/
+ }
+ ],
+ illegal: /\[|%/
+ },
+ {
+ begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
+ },
+ {
+ begin: '\\.' + hljs.IDENT_RE, relevance: 0 // hack: prevents detection of keywords after dots
+ }
+ ]
+ };
+};
+},{}],74:[function(require,module,exports){
+module.exports = function(hljs) {
+ var LITERALS = {literal: 'true false null'};
+ var TYPES = [
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE
+ ];
+ var VALUE_CONTAINER = {
+ className: 'value',
+ end: ',', endsWithParent: true, excludeEnd: true,
+ contains: TYPES,
+ keywords: LITERALS
+ };
+ var OBJECT = {
+ begin: '{', end: '}',
+ contains: [
+ {
+ className: 'attribute',
+ begin: '\\s*"', end: '"\\s*:\\s*', excludeBegin: true, excludeEnd: true,
+ contains: [hljs.BACKSLASH_ESCAPE],
+ illegal: '\\n',
+ starts: VALUE_CONTAINER
+ }
+ ],
+ illegal: '\\S'
+ };
+ var ARRAY = {
+ begin: '\\[', end: '\\]',
+ contains: [hljs.inherit(VALUE_CONTAINER, {className: null})], // inherit is also a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents
+ illegal: '\\S'
+ };
+ TYPES.splice(TYPES.length, 0, OBJECT, ARRAY);
+ return {
+ contains: TYPES,
+ keywords: LITERALS,
+ illegal: '\\S'
+ };
+};
+},{}],75:[function(require,module,exports){
+module.exports = function(hljs) {
+ var LASSO_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_.]*';
+ var LASSO_ANGLE_RE = '<\\?(lasso(script)?|=)';
+ var LASSO_CLOSE_RE = '\\]|\\?>';
+ var LASSO_KEYWORDS = {
+ literal:
+ 'true false none minimal full all void and or not ' +
+ 'bw nbw ew new cn ncn lt lte gt gte eq neq rx nrx ft',
+ built_in:
+ 'array date decimal duration integer map pair string tag xml null ' +
+ 'bytes list queue set stack staticarray tie local var variable ' +
+ 'global data self inherited',
+ keyword:
+ 'error_code error_msg error_pop error_push error_reset cache ' +
+ 'database_names database_schemanames database_tablenames define_tag ' +
+ 'define_type email_batch encode_set html_comment handle handle_error ' +
+ 'header if inline iterate ljax_target link link_currentaction ' +
+ 'link_currentgroup link_currentrecord link_detail link_firstgroup ' +
+ 'link_firstrecord link_lastgroup link_lastrecord link_nextgroup ' +
+ 'link_nextrecord link_prevgroup link_prevrecord log loop ' +
+ 'namespace_using output_none portal private protect records referer ' +
+ 'referrer repeating resultset rows search_args search_arguments ' +
+ 'select sort_args sort_arguments thread_atomic value_list while ' +
+ 'abort case else if_empty if_false if_null if_true loop_abort ' +
+ 'loop_continue loop_count params params_up return return_value ' +
+ 'run_children soap_definetag soap_lastrequest soap_lastresponse ' +
+ 'tag_name ascending average by define descending do equals ' +
+ 'frozen group handle_failure import in into join let match max ' +
+ 'min on order parent protected provide public require returnhome ' +
+ 'skip split_thread sum take thread to trait type where with ' +
+ 'yield yieldhome'
+ };
+ var HTML_COMMENT = {
+ className: 'comment',
+ begin: '',
+ relevance: 0
+ };
+ var LASSO_NOPROCESS = {
+ className: 'preprocessor',
+ begin: '\\[noprocess\\]',
+ starts: {
+ className: 'markup',
+ end: '\\[/noprocess\\]',
+ returnEnd: true,
+ contains: [HTML_COMMENT]
+ }
+ };
+ var LASSO_START = {
+ className: 'preprocessor',
+ begin: '\\[/noprocess|' + LASSO_ANGLE_RE
+ };
+ var LASSO_DATAMEMBER = {
+ className: 'variable',
+ begin: '\'' + LASSO_IDENT_RE + '\''
+ };
+ var LASSO_CODE = [
+ hljs.C_LINE_COMMENT_MODE,
+ {
+ className: 'javadoc',
+ begin: '/\\*\\*!', end: '\\*/',
+ contains: [hljs.PHRASAL_WORDS_MODE]
+ },
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.inherit(hljs.C_NUMBER_MODE, {begin: hljs.C_NUMBER_RE + '|-?(infinity|nan)\\b'}),
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
+ {
+ className: 'string',
+ begin: '`', end: '`'
+ },
+ {
+ className: 'variable',
+ variants: [
+ {
+ begin: '[#$]' + LASSO_IDENT_RE
+ },
+ {
+ begin: '#', end: '\\d+',
+ illegal: '\\W'
+ }
+ ]
+ },
+ {
+ className: 'tag',
+ begin: '::\\s*', end: LASSO_IDENT_RE,
+ illegal: '\\W'
+ },
+ {
+ className: 'attribute',
+ variants: [
+ {
+ begin: '-' + hljs.UNDERSCORE_IDENT_RE,
+ relevance: 0
+ },
+ {
+ begin: '(\\.\\.\\.)'
+ }
+ ]
+ },
+ {
+ className: 'subst',
+ variants: [
+ {
+ begin: '->\\s*',
+ contains: [LASSO_DATAMEMBER]
+ },
+ {
+ begin: ':=|/(?!\\w)=?|[-+*%=<>&|!?\\\\]+',
+ relevance: 0
+ }
+ ]
+ },
+ {
+ className: 'built_in',
+ begin: '\\.\\.?',
+ relevance: 0,
+ contains: [LASSO_DATAMEMBER]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'define',
+ returnEnd: true, end: '\\(|=>',
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: hljs.UNDERSCORE_IDENT_RE + '(=(?!>))?'})
+ ]
+ }
+ ];
+ return {
+ aliases: ['ls', 'lassoscript'],
+ case_insensitive: true,
+ lexemes: LASSO_IDENT_RE + '|&[lg]t;',
+ keywords: LASSO_KEYWORDS,
+ contains: [
+ {
+ className: 'preprocessor',
+ begin: LASSO_CLOSE_RE,
+ relevance: 0,
+ starts: {
+ className: 'markup',
+ end: '\\[|' + LASSO_ANGLE_RE,
+ returnEnd: true,
+ relevance: 0,
+ contains: [HTML_COMMENT]
+ }
+ },
+ LASSO_NOPROCESS,
+ LASSO_START,
+ {
+ className: 'preprocessor',
+ begin: '\\[no_square_brackets',
+ starts: {
+ end: '\\[/no_square_brackets\\]', // not implemented in the language
+ lexemes: LASSO_IDENT_RE + '|&[lg]t;',
+ keywords: LASSO_KEYWORDS,
+ contains: [
+ {
+ className: 'preprocessor',
+ begin: LASSO_CLOSE_RE,
+ relevance: 0,
+ starts: {
+ className: 'markup',
+ end: LASSO_ANGLE_RE,
+ returnEnd: true,
+ contains: [HTML_COMMENT]
+ }
+ },
+ LASSO_NOPROCESS,
+ LASSO_START
+ ].concat(LASSO_CODE)
+ }
+ },
+ {
+ className: 'preprocessor',
+ begin: '\\[',
+ relevance: 0
+ },
+ {
+ className: 'shebang',
+ begin: '^#!.+lasso9\\b',
+ relevance: 10
+ }
+ ].concat(LASSO_CODE)
+ };
+};
+},{}],76:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '[\\w-]+'; // yes, Less identifiers may begin with a digit
+ var INTERP_IDENT_RE = '(' + IDENT_RE + '|@{' + IDENT_RE + '})+';
+
+ /* Generic Modes */
+
+ var RULES = [], VALUE = []; // forward def. for recursive modes
+
+ var STRING_MODE = function(c) { return {
+ // Less strings are not multiline (also include '~' for more consistent coloring of "escaped" strings)
+ className: 'string', begin: '~?' + c + '.*?' + c
+ };};
+
+ var IDENT_MODE = function(name, begin, relevance) { return {
+ className: name, begin: begin, relevance: relevance
+ };};
+
+ var FUNCT_MODE = function(name, ident, obj) {
+ return hljs.inherit({
+ className: name, begin: ident + '\\(', end: '\\(',
+ returnBegin: true, excludeEnd: true, relevance: 0
+ }, obj);
+ };
+
+ var PARENS_MODE = {
+ // used only to properly balance nested parens inside mixin call, def. arg list
+ begin: '\\(', end: '\\)', contains: VALUE, relevance: 0
+ };
+
+ // generic Less highlighter (used almost everywhere except selectors):
+ VALUE.push(
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ STRING_MODE("'"),
+ STRING_MODE('"'),
+ hljs.CSS_NUMBER_MODE, // fixme: it does not include dot for numbers like .5em :(
+ IDENT_MODE('hexcolor', '#[0-9A-Fa-f]+\\b'),
+ FUNCT_MODE('function', '(url|data-uri)', {
+ starts: {className: 'string', end: '[\\)\\n]', excludeEnd: true}
+ }),
+ FUNCT_MODE('function', IDENT_RE),
+ PARENS_MODE,
+ IDENT_MODE('variable', '@@?' + IDENT_RE, 10),
+ IDENT_MODE('variable', '@{' + IDENT_RE + '}'),
+ IDENT_MODE('built_in', '~?`[^`]*?`'), // inline javascript (or whatever host language) *multiline* string
+ { // @media features (it’s here to not duplicate things in AT_RULE_MODE with extra PARENS_MODE overriding):
+ className: 'attribute', begin: IDENT_RE + '\\s*:', end: ':', returnBegin: true, excludeEnd: true
+ }
+ );
+
+ var VALUE_WITH_RULESETS = VALUE.concat({
+ begin: '{', end: '}', contains: RULES,
+ });
+
+ var MIXIN_GUARD_MODE = {
+ beginKeywords: 'when', endsWithParent: true,
+ contains: [{beginKeywords: 'and not'}].concat(VALUE) // using this form to override VALUE’s 'function' match
+ };
+
+ /* Rule-Level Modes */
+
+ var RULE_MODE = {
+ className: 'attribute', begin: INTERP_IDENT_RE, relevance: 0,
+ starts: {end: '[;}]', returnEnd: true, contains: VALUE, illegal: '[<=$]'}
+ };
+
+ var AT_RULE_MODE = {
+ className: 'at_rule', // highlight only at-rule keyword
+ begin: '@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b',
+ starts: {end: '[;{}]', returnEnd: true, contains: VALUE, relevance: 0}
+ };
+
+ // variable definitions and calls
+ var VAR_RULE_MODE = {
+ className: 'variable',
+ variants: [
+ // using more strict pattern for higher relevance to increase chances of Less detection.
+ // this is *the only* Less specific statement used in most of the sources, so...
+ // (we’ll still often loose to the css-parser unless there's '//' comment,
+ // simply because 1 variable just can't beat 99 properties :)
+ {begin: '@' + IDENT_RE + '\\s*:', relevance: 15},
+ {begin: '@' + IDENT_RE}
+ ],
+ starts: {end: '[;}]', returnEnd: true, contains: VALUE_WITH_RULESETS}
+ };
+
+ var SELECTOR_MODE = {
+ // first parse unambiguous selectors (i.e. those not starting with tag)
+ // then fall into the scary lookahead-discriminator variant.
+ // this mode also handles mixin definitions and calls
+ variants: [{
+ begin: '[\\.#:&\\[]', end: '[;{}]' // mixin calls end with ';'
+ }, {
+ begin: '(?=' + INTERP_IDENT_RE + ')(' + [
+ '//.*', // line comment
+ '/\\*(?:[^*]|\\*+[^*/])*\\*+/', // block comment
+ '\\[[^\\]]*\\]', // attribute selector (it may contain strings we need to skip too)
+ '@{.*?}', // variable interpolation
+ '[^;}\'"`]', // non-selector terminals
+ ].join('|') + ')*?[^@\'"`]{', // at last
+ end: '{'
+ }],
+ returnBegin: true,
+ returnEnd: true,
+ illegal: '[<=\'$"]',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ MIXIN_GUARD_MODE,
+ IDENT_MODE('keyword', 'all\\b'),
+ IDENT_MODE('variable', '@{' + IDENT_RE + '}'), // otherwise it’s identified as tag
+ IDENT_MODE('tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags"
+ IDENT_MODE('id', '#' + INTERP_IDENT_RE),
+ IDENT_MODE('class', '\\.' + INTERP_IDENT_RE, 0),
+ IDENT_MODE('keyword', '&', 0),
+ FUNCT_MODE('pseudo', ':not'),
+ FUNCT_MODE('keyword', ':extend'),
+ IDENT_MODE('pseudo', '::?' + INTERP_IDENT_RE),
+ {className: 'attr_selector', begin: '\\[', end: '\\]'},
+ {begin: '\\(', end: '\\)', contains: VALUE_WITH_RULESETS}, // argument list of parametric mixins
+ {begin: '!important'} // eat !important after mixin call or it will be colored as tag
+ ]
+ };
+
+ RULES.push(
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ AT_RULE_MODE,
+ VAR_RULE_MODE,
+ SELECTOR_MODE,
+ RULE_MODE
+ );
+
+ return {
+ case_insensitive: true,
+ illegal: '[=>\'/<($"]',
+ contains: RULES
+ };
+};
+},{}],77:[function(require,module,exports){
+module.exports = function(hljs) {
+ var LISP_IDENT_RE = '[a-zA-Z_\\-\\+\\*\\/\\<\\=\\>\\&\\#][a-zA-Z0-9_\\-\\+\\*\\/\\<\\=\\>\\&\\#!]*';
+ var LISP_SIMPLE_NUMBER_RE = '(\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s)(\\+|\\-)?\\d+)?';
+ var SHEBANG = {
+ className: 'shebang',
+ begin: '^#!', end: '$'
+ };
+ var LITERAL = {
+ className: 'literal',
+ begin: '\\b(t{1}|nil)\\b'
+ };
+ var NUMBER = {
+ className: 'number',
+ variants: [
+ {begin: LISP_SIMPLE_NUMBER_RE, relevance: 0},
+ {begin: '#b[0-1]+(/[0-1]+)?'},
+ {begin: '#o[0-7]+(/[0-7]+)?'},
+ {begin: '#x[0-9a-f]+(/[0-9a-f]+)?'},
+ {begin: '#c\\(' + LISP_SIMPLE_NUMBER_RE + ' +' + LISP_SIMPLE_NUMBER_RE, end: '\\)'}
+ ]
+ };
+ var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null});
+ var COMMENT = {
+ className: 'comment',
+ begin: ';', end: '$', relevance: 0
+ };
+ var VARIABLE = {
+ className: 'variable',
+ begin: '\\*', end: '\\*'
+ };
+ var KEYWORD = {
+ className: 'keyword',
+ begin: '[:&]' + LISP_IDENT_RE
+ };
+ var QUOTED_LIST = {
+ begin: '\\(', end: '\\)',
+ contains: ['self', LITERAL, STRING, NUMBER]
+ };
+ var QUOTED = {
+ className: 'quoted',
+ contains: [NUMBER, STRING, VARIABLE, KEYWORD, QUOTED_LIST],
+ variants: [
+ {
+ begin: '[\'`]\\(', end: '\\)'
+ },
+ {
+ begin: '\\(quote ', end: '\\)',
+ keywords: 'quote'
+ }
+ ]
+ };
+ var QUOTED_ATOM = {
+ className: 'quoted',
+ begin: '\'' + LISP_IDENT_RE
+ };
+ var LIST = {
+ className: 'list',
+ begin: '\\(', end: '\\)'
+ };
+ var BODY = {
+ endsWithParent: true,
+ relevance: 0
+ };
+ LIST.contains = [{className: 'keyword', begin: LISP_IDENT_RE}, BODY];
+ BODY.contains = [QUOTED, QUOTED_ATOM, LIST, LITERAL, NUMBER, STRING, COMMENT, VARIABLE, KEYWORD];
+
+ return {
+ illegal: /\S/,
+ contains: [
+ NUMBER,
+ SHEBANG,
+ LITERAL,
+ STRING,
+ COMMENT,
+ QUOTED,
+ QUOTED_ATOM,
+ LIST
+ ]
+ };
+};
+},{}],78:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VARIABLE = {
+ className: 'variable', begin: '\\b[gtps][A-Z]+[A-Za-z0-9_\\-]*\\b|\\$_[A-Z]+',
+ relevance: 0
+ };
+ var COMMENT = {
+ className: 'comment', end: '$',
+ variants: [
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.HASH_COMMENT_MODE,
+ {
+ begin: '--'
+ },
+ {
+ begin: '[^:]//'
+ }
+ ]
+ };
+ var TITLE1 = hljs.inherit(hljs.TITLE_MODE, {
+ variants: [
+ {begin: '\\b_*rig[A-Z]+[A-Za-z0-9_\\-]*'},
+ {begin: '\\b_[a-z0-9\\-]+'}
+ ]
+ });
+ var TITLE2 = hljs.inherit(hljs.TITLE_MODE, {begin: '\\b([A-Za-z0-9_\\-]+)\\b'});
+ return {
+ case_insensitive: false,
+ keywords: {
+ keyword:
+ 'after byte bytes english the until http forever descending using line real8 with seventh ' +
+ 'for stdout finally element word fourth before black ninth sixth characters chars stderr ' +
+ 'uInt1 uInt1s uInt2 uInt2s stdin string lines relative rel any fifth items from middle mid ' +
+ 'at else of catch then third it file milliseconds seconds second secs sec int1 int1s int4 ' +
+ 'int4s internet int2 int2s normal text item last long detailed effective uInt4 uInt4s repeat ' +
+ 'end repeat URL in try into switch to words https token binfile each tenth as ticks tick ' +
+ 'system real4 by dateItems without char character ascending eighth whole dateTime numeric short ' +
+ 'first ftp integer abbreviated abbr abbrev private case while if',
+ constant:
+ 'SIX TEN FORMFEED NINE ZERO NONE SPACE FOUR FALSE COLON CRLF PI COMMA ENDOFFILE EOF EIGHT FIVE ' +
+ 'QUOTE EMPTY ONE TRUE RETURN CR LINEFEED RIGHT BACKSLASH NULL SEVEN TAB THREE TWO ' +
+ 'six ten formfeed nine zero none space four false colon crlf pi comma endoffile eof eight five ' +
+ 'quote empty one true return cr linefeed right backslash null seven tab three two ' +
+ 'RIVERSION RISTATE FILE_READ_MODE FILE_WRITE_MODE FILE_WRITE_MODE DIR_WRITE_MODE FILE_READ_UMASK ' +
+ 'FILE_WRITE_UMASK DIR_READ_UMASK DIR_WRITE_UMASK',
+ operator:
+ 'div mod wrap and or bitAnd bitNot bitOr bitXor among not in a an within ' +
+ 'contains ends with begins the keys of keys',
+ built_in:
+ 'put abs acos aliasReference annuity arrayDecode arrayEncode asin atan atan2 average avg base64Decode ' +
+ 'base64Encode baseConvert binaryDecode binaryEncode byteToNum cachedURL cachedURLs charToNum ' +
+ 'cipherNames commandNames compound compress constantNames cos date dateFormat decompress directories ' +
+ 'diskSpace DNSServers exp exp1 exp2 exp10 extents files flushEvents folders format functionNames global ' +
+ 'globals hasMemory hostAddress hostAddressToName hostName hostNameToAddress isNumber ISOToMac itemOffset ' +
+ 'keys len length libURLErrorData libUrlFormData libURLftpCommand libURLLastHTTPHeaders libURLLastRHHeaders ' +
+ 'libUrlMultipartFormAddPart libUrlMultipartFormData libURLVersion lineOffset ln ln1 localNames log log2 log10 ' +
+ 'longFilePath lower macToISO matchChunk matchText matrixMultiply max md5Digest median merge millisec ' +
+ 'millisecs millisecond milliseconds min monthNames num number numToByte numToChar offset open openfiles ' +
+ 'openProcesses openProcessIDs openSockets paramCount param params peerAddress pendingMessages platform ' +
+ 'processID random randomBytes replaceText result revCreateXMLTree revCreateXMLTreeFromFile revCurrentRecord ' +
+ 'revCurrentRecordIsFirst revCurrentRecordIsLast revDatabaseColumnCount revDatabaseColumnIsNull ' +
+ 'revDatabaseColumnLengths revDatabaseColumnNames revDatabaseColumnNamed revDatabaseColumnNumbered ' +
+ 'revDatabaseColumnTypes revDatabaseConnectResult revDatabaseCursors revDatabaseID revDatabaseTableNames ' +
+ 'revDatabaseType revDataFromQuery revdb_closeCursor revdb_columnbynumber revdb_columncount revdb_columnisnull ' +
+ 'revdb_columnlengths revdb_columnnames revdb_columntypes revdb_commit revdb_connect revdb_connections ' +
+ 'revdb_connectionerr revdb_currentrecord revdb_cursorconnection revdb_cursorerr revdb_cursors revdb_dbtype ' +
+ 'revdb_disconnect revdb_execute revdb_iseof revdb_isbof revdb_movefirst revdb_movelast revdb_movenext ' +
+ 'revdb_moveprev revdb_query revdb_querylist revdb_recordcount revdb_rollback revdb_tablenames ' +
+ 'revGetDatabaseDriverPath revNumberOfRecords revOpenDatabase revOpenDatabases revQueryDatabase ' +
+ 'revQueryDatabaseBlob revQueryResult revQueryIsAtStart revQueryIsAtEnd revUnixFromMacPath ' +
+ 'revXMLAttribute revXMLAttributes revXMLAttributeValues revXMLChildContents revXMLChildNames ' +
+ 'revXMLFirstChild revXMLMatchingNode revXMLNextSibling revXMLNodeContents revXMLNumberOfChildren ' +
+ 'revXMLParent revXMLPreviousSibling revXMLRootNode revXMLRPC_CreateRequest revXMLRPC_Documents ' +
+ 'revXMLRPC_Error revXMLRPC_Execute revXMLRPC_GetHost revXMLRPC_GetMethod revXMLRPC_GetParam revXMLText ' +
+ 'revXMLRPC_GetParamCount revXMLRPC_GetParamNode revXMLRPC_GetParamType revXMLRPC_GetPath revXMLRPC_GetPort ' +
+ 'revXMLRPC_GetProtocol revXMLRPC_GetRequest revXMLRPC_GetResponse revXMLRPC_GetSocket revXMLTree ' +
+ 'revXMLTrees revXMLValidateDTD revZipDescribeItem revZipEnumerateItems revZipOpenArchives round ' +
+ 'sec secs seconds sha1Digest shell shortFilePath sin specialFolderPath sqrt standardDeviation statRound ' +
+ 'stdDev sum sysError systemVersion tan tempName tick ticks time to toLower toUpper transpose trunc ' +
+ 'uniDecode uniEncode upper URLDecode URLEncode URLStatus value variableNames version waitDepth weekdayNames wordOffset ' +
+ 'add breakpoint cancel clear local variable file word line folder directory URL close socket process ' +
+ 'combine constant convert create new alias folder directory decrypt delete variable word line folder ' +
+ 'directory URL dispatch divide do encrypt filter get include intersect kill libURLDownloadToFile ' +
+ 'libURLFollowHttpRedirects libURLftpUpload libURLftpUploadFile libURLresetAll libUrlSetAuthCallback ' +
+ 'libURLSetCustomHTTPHeaders libUrlSetExpect100 libURLSetFTPListCommand libURLSetFTPMode libURLSetFTPStopTime ' +
+ 'libURLSetStatusCallback load multiply socket process post seek rel relative read from process rename ' +
+ 'replace require resetAll revAddXMLNode revAppendXML revCloseCursor revCloseDatabase revCommitDatabase ' +
+ 'revCopyFile revCopyFolder revCopyXMLNode revDeleteFolder revDeleteXMLNode revDeleteAllXMLTrees ' +
+ 'revDeleteXMLTree revExecuteSQL revGoURL revInsertXMLNode revMoveFolder revMoveToFirstRecord revMoveToLastRecord ' +
+ 'revMoveToNextRecord revMoveToPreviousRecord revMoveToRecord revMoveXMLNode revPutIntoXMLNode revRollBackDatabase ' +
+ 'revSetDatabaseDriverPath revSetXMLAttribute revXMLRPC_AddParam revXMLRPC_DeleteAllDocuments revXMLAddDTD ' +
+ 'revXMLRPC_Free revXMLRPC_FreeAll revXMLRPC_DeleteDocument revXMLRPC_DeleteParam revXMLRPC_SetHost ' +
+ 'revXMLRPC_SetMethod revXMLRPC_SetPort revXMLRPC_SetProtocol revXMLRPC_SetSocket revZipAddItemWithData ' +
+ 'revZipAddItemWithFile revZipAddUncompressedItemWithData revZipAddUncompressedItemWithFile revZipCancel ' +
+ 'revZipCloseArchive revZipDeleteItem revZipExtractItemToFile revZipExtractItemToVariable revZipSetProgressCallback ' +
+ 'revZipRenameItem revZipReplaceItemWithData revZipReplaceItemWithFile revZipOpenArchive send set sort split ' +
+ 'subtract union unload wait write'
+ },
+ contains: [
+ VARIABLE,
+ {
+ className: 'keyword',
+ begin: '\\bend\\sif\\b'
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: '$',
+ contains: [
+ VARIABLE,
+ TITLE2,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.BINARY_NUMBER_MODE,
+ hljs.C_NUMBER_MODE,
+ TITLE1
+ ]
+ },
+ {
+ className: 'function',
+ beginKeywords: 'end', end: '$',
+ contains: [
+ TITLE2,
+ TITLE1
+ ]
+ },
+ {
+ className: 'command',
+ beginKeywords: 'command on', end: '$',
+ contains: [
+ VARIABLE,
+ TITLE2,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.BINARY_NUMBER_MODE,
+ hljs.C_NUMBER_MODE,
+ TITLE1
+ ]
+ },
+ {
+ className: 'command',
+ beginKeywords: 'end', end: '$',
+ contains: [
+ TITLE2,
+ TITLE1
+ ]
+ },
+ {
+ className: 'preprocessor',
+ begin: '<\\?rev|<\\?lc|<\\?livecode',
+ relevance: 10
+ },
+ {
+ className: 'preprocessor',
+ begin: '<\\?'
+ },
+ {
+ className: 'preprocessor',
+ begin: '\\?>'
+ },
+ COMMENT,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.BINARY_NUMBER_MODE,
+ hljs.C_NUMBER_MODE,
+ TITLE1
+ ],
+ illegal: ';$|^\\[|^='
+ };
+};
+},{}],79:[function(require,module,exports){
+module.exports = function(hljs) {
+ var KEYWORDS = {
+ keyword:
+ // JS keywords
+ 'in if for while finally new do return else break catch instanceof throw try this ' +
+ 'switch continue typeof delete debugger case default function var with ' +
+ // LiveScript keywords
+ 'then unless until loop of by when and or is isnt not it that otherwise from to til fallthrough super ' +
+ 'case default function var void const let enum export import native ' +
+ '__hasProp __extends __slice __bind __indexOf',
+ literal:
+ // JS literals
+ 'true false null undefined ' +
+ // LiveScript literals
+ 'yes no on off it that void',
+ built_in:
+ 'npm require console print module global window document'
+ };
+ var JS_IDENT_RE = '[A-Za-z$_](?:\-[0-9A-Za-z$_]|[0-9A-Za-z$_])*';
+ var TITLE = hljs.inherit(hljs.TITLE_MODE, {begin: JS_IDENT_RE});
+ var SUBST = {
+ className: 'subst',
+ begin: /#\{/, end: /\}/,
+ keywords: KEYWORDS
+ };
+ var SUBST_SIMPLE = {
+ className: 'subst',
+ begin: /#[A-Za-z$_]/, end: /(?:\-[0-9A-Za-z$_]|[0-9A-Za-z$_])*/,
+ keywords: KEYWORDS
+ };
+ var EXPRESSIONS = [
+ hljs.BINARY_NUMBER_MODE,
+ {
+ className: 'number',
+ begin: '(\\b0[xX][a-fA-F0-9_]+)|(\\b\\d(\\d|_\\d)*(\\.(\\d(\\d|_\\d)*)?)?(_*[eE]([-+]\\d(_\\d|\\d)*)?)?[_a-z]*)',
+ relevance: 0,
+ starts: {end: '(\\s*/)?', relevance: 0} // a number tries to eat the following slash to prevent treating it as a regexp
+ },
+ {
+ className: 'string',
+ variants: [
+ {
+ begin: /'''/, end: /'''/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: /'/, end: /'/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: /"""/, end: /"""/,
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST, SUBST_SIMPLE]
+ },
+ {
+ begin: /"/, end: /"/,
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST, SUBST_SIMPLE]
+ },
+ {
+ begin: /\\/, end: /(\s|$)/,
+ excludeEnd: true
+ }
+ ]
+ },
+ {
+ className: 'pi',
+ variants: [
+ {
+ begin: '//', end: '//[gim]*',
+ contains: [SUBST, hljs.HASH_COMMENT_MODE]
+ },
+ {
+ // regex can't start with space to parse x / 2 / 3 as two divisions
+ // regex can't start with *, and it supports an "illegal" in the main mode
+ begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/
+ }
+ ]
+ },
+ {
+ className: 'property',
+ begin: '@' + JS_IDENT_RE
+ },
+ {
+ begin: '``', end: '``',
+ excludeBegin: true, excludeEnd: true,
+ subLanguage: 'javascript'
+ }
+ ];
+ SUBST.contains = EXPRESSIONS;
+
+ var PARAMS = {
+ className: 'params',
+ begin: '\\(', returnBegin: true,
+ /* We need another contained nameless mode to not have every nested
+ pair of parens to be called "params" */
+ contains: [
+ {
+ begin: /\(/, end: /\)/,
+ keywords: KEYWORDS,
+ contains: ['self'].concat(EXPRESSIONS)
+ }
+ ]
+ };
+
+ return {
+ aliases: ['ls'],
+ keywords: KEYWORDS,
+ illegal: /\/\*/,
+ contains: EXPRESSIONS.concat([
+ {
+ className: 'comment',
+ begin: '\\/\\*', end: '\\*\\/'
+ },
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'function',
+ contains: [TITLE, PARAMS],
+ returnBegin: true,
+ variants: [
+ {
+ begin: '(' + JS_IDENT_RE + '\\s*(?:=|:=)\\s*)?(\\(.*\\))?\\s*\\B\\->\\*?', end: '\\->\\*?'
+ },
+ {
+ begin: '(' + JS_IDENT_RE + '\\s*(?:=|:=)\\s*)?!?(\\(.*\\))?\\s*\\B[-~]{1,2}>\\*?', end: '[-~]{1,2}>\\*?'
+ },
+ {
+ begin: '(' + JS_IDENT_RE + '\\s*(?:=|:=)\\s*)?(\\(.*\\))?\\s*\\B!?[-~]{1,2}>\\*?', end: '!?[-~]{1,2}>\\*?'
+ }
+ ]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class',
+ end: '$',
+ illegal: /[:="\[\]]/,
+ contains: [
+ {
+ beginKeywords: 'extends',
+ endsWithParent: true,
+ illegal: /[:="\[\]]/,
+ contains: [TITLE]
+ },
+ TITLE
+ ]
+ },
+ {
+ className: 'attribute',
+ begin: JS_IDENT_RE + ':', end: ':',
+ returnBegin: true, returnEnd: true,
+ relevance: 0
+ }
+ ])
+ };
+};
+},{}],80:[function(require,module,exports){
+module.exports = function(hljs) {
+ var OPENING_LONG_BRACKET = '\\[=*\\[';
+ var CLOSING_LONG_BRACKET = '\\]=*\\]';
+ var LONG_BRACKETS = {
+ begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
+ contains: ['self']
+ };
+ var COMMENTS = [
+ {
+ className: 'comment',
+ begin: '--(?!' + OPENING_LONG_BRACKET + ')', end: '$'
+ },
+ {
+ className: 'comment',
+ begin: '--' + OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
+ contains: [LONG_BRACKETS],
+ relevance: 10
+ }
+ ]
+ return {
+ lexemes: hljs.UNDERSCORE_IDENT_RE,
+ keywords: {
+ keyword:
+ 'and break do else elseif end false for if in local nil not or repeat return then ' +
+ 'true until while',
+ built_in:
+ '_G _VERSION assert collectgarbage dofile error getfenv getmetatable ipairs load ' +
+ 'loadfile loadstring module next pairs pcall print rawequal rawget rawset require ' +
+ 'select setfenv setmetatable tonumber tostring type unpack xpcall coroutine debug ' +
+ 'io math os package string table'
+ },
+ contains: COMMENTS.concat([
+ {
+ className: 'function',
+ beginKeywords: 'function', end: '\\)',
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'}),
+ {
+ className: 'params',
+ begin: '\\(', endsWithParent: true,
+ contains: COMMENTS
+ }
+ ].concat(COMMENTS)
+ },
+ hljs.C_NUMBER_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
+ contains: [LONG_BRACKETS],
+ relevance: 5
+ }
+ ])
+ };
+};
+},{}],81:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VARIABLE = {
+ className: 'variable',
+ begin: /\$\(/, end: /\)/,
+ contains: [hljs.BACKSLASH_ESCAPE]
+ };
+ return {
+ aliases: ['mk', 'mak'],
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {
+ begin: /^\w+\s*\W*=/, returnBegin: true,
+ relevance: 0,
+ starts: {
+ className: 'constant',
+ end: /\s*\W*=/, excludeEnd: true,
+ starts: {
+ end: /$/,
+ relevance: 0,
+ contains: [
+ VARIABLE
+ ]
+ }
+ }
+ },
+ {
+ className: 'title',
+ begin: /^[\w]+:\s*$/
+ },
+ {
+ className: 'phony',
+ begin: /^\.PHONY:/, end: /$/,
+ keywords: '.PHONY', lexemes: /[\.\w]+/
+ },
+ {
+ begin: /^\t+/, end: /$/,
+ relevance: 0,
+ contains: [
+ hljs.QUOTE_STRING_MODE,
+ VARIABLE
+ ]
+ }
+ ]
+ };
+};
+},{}],82:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['md', 'mkdown', 'mkd'],
+ contains: [
+ // highlight headers
+ {
+ className: 'header',
+ variants: [
+ { begin: '^#{1,6}', end: '$' },
+ { begin: '^.+?\\n[=-]{2,}$' }
+ ]
+ },
+ // inline html
+ {
+ begin: '<', end: '>',
+ subLanguage: 'xml',
+ relevance: 0
+ },
+ // lists (indicators only)
+ {
+ className: 'bullet',
+ begin: '^([*+-]|(\\d+\\.))\\s+'
+ },
+ // strong segments
+ {
+ className: 'strong',
+ begin: '[*_]{2}.+?[*_]{2}'
+ },
+ // emphasis segments
+ {
+ className: 'emphasis',
+ variants: [
+ { begin: '\\*.+?\\*' },
+ { begin: '_.+?_'
+ , relevance: 0
+ }
+ ]
+ },
+ // blockquotes
+ {
+ className: 'blockquote',
+ begin: '^>\\s+', end: '$'
+ },
+ // code snippets
+ {
+ className: 'code',
+ variants: [
+ { begin: '`.+?`' },
+ { begin: '^( {4}|\t)', end: '$'
+ , relevance: 0
+ }
+ ]
+ },
+ // horizontal rules
+ {
+ className: 'horizontal_rule',
+ begin: '^[-\\*]{3,}', end: '$'
+ },
+ // using links - title and link
+ {
+ begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]',
+ returnBegin: true,
+ contains: [
+ {
+ className: 'link_label',
+ begin: '\\[', end: '\\]',
+ excludeBegin: true,
+ returnEnd: true,
+ relevance: 0
+ },
+ {
+ className: 'link_url',
+ begin: '\\]\\(', end: '\\)',
+ excludeBegin: true, excludeEnd: true
+ },
+ {
+ className: 'link_reference',
+ begin: '\\]\\[', end: '\\]',
+ excludeBegin: true, excludeEnd: true
+ }
+ ],
+ relevance: 10
+ },
+ {
+ begin: '^\\[\.+\\]:',
+ returnBegin: true,
+ contains: [
+ {
+ className: 'link_reference',
+ begin: '\\[', end: '\\]:',
+ excludeBegin: true, excludeEnd: true,
+ starts: {
+ className: 'link_url',
+ end: '$'
+ }
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],83:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['mma'],
+ lexemes: '(\\$|\\b)' + hljs.IDENT_RE + '\\b',
+ keywords: 'AbelianGroup Abort AbortKernels AbortProtect Above Abs Absolute AbsoluteCorrelation AbsoluteCorrelationFunction AbsoluteCurrentValue AbsoluteDashing AbsoluteFileName AbsoluteOptions AbsolutePointSize AbsoluteThickness AbsoluteTime AbsoluteTiming AccountingForm Accumulate Accuracy AccuracyGoal ActionDelay ActionMenu ActionMenuBox ActionMenuBoxOptions Active ActiveItem ActiveStyle AcyclicGraphQ AddOnHelpPath AddTo AdjacencyGraph AdjacencyList AdjacencyMatrix AdjustmentBox AdjustmentBoxOptions AdjustTimeSeriesForecast AffineTransform After AiryAi AiryAiPrime AiryAiZero AiryBi AiryBiPrime AiryBiZero AlgebraicIntegerQ AlgebraicNumber AlgebraicNumberDenominator AlgebraicNumberNorm AlgebraicNumberPolynomial AlgebraicNumberTrace AlgebraicRules AlgebraicRulesData Algebraics AlgebraicUnitQ Alignment AlignmentMarker AlignmentPoint All AllowedDimensions AllowGroupClose AllowInlineCells AllowKernelInitialization AllowReverseGroupClose AllowScriptLevelChange AlphaChannel AlternatingGroup AlternativeHypothesis Alternatives AmbientLight Analytic AnchoredSearch And AndersonDarlingTest AngerJ AngleBracket AngularGauge Animate AnimationCycleOffset AnimationCycleRepetitions AnimationDirection AnimationDisplayTime AnimationRate AnimationRepetitions AnimationRunning Animator AnimatorBox AnimatorBoxOptions AnimatorElements Annotation Annuity AnnuityDue Antialiasing Antisymmetric Apart ApartSquareFree Appearance AppearanceElements AppellF1 Append AppendTo Apply ArcCos ArcCosh ArcCot ArcCoth ArcCsc ArcCsch ArcSec ArcSech ArcSin ArcSinDistribution ArcSinh ArcTan ArcTanh Arg ArgMax ArgMin ArgumentCountQ ARIMAProcess ArithmeticGeometricMean ARMAProcess ARProcess Array ArrayComponents ArrayDepth ArrayFlatten ArrayPad ArrayPlot ArrayQ ArrayReshape ArrayRules Arrays Arrow Arrow3DBox ArrowBox Arrowheads AspectRatio AspectRatioFixed Assert Assuming Assumptions AstronomicalData Asynchronous AsynchronousTaskObject AsynchronousTasks AtomQ Attributes AugmentedSymmetricPolynomial AutoAction AutoDelete AutoEvaluateEvents AutoGeneratedPackage AutoIndent AutoIndentSpacings AutoItalicWords AutoloadPath AutoMatch Automatic AutomaticImageSize AutoMultiplicationSymbol AutoNumberFormatting AutoOpenNotebooks AutoOpenPalettes AutorunSequencing AutoScaling AutoScroll AutoSpacing AutoStyleOptions AutoStyleWords Axes AxesEdge AxesLabel AxesOrigin AxesStyle Axis ' +
+ 'BabyMonsterGroupB Back Background BackgroundTasksSettings Backslash Backsubstitution Backward Band BandpassFilter BandstopFilter BarabasiAlbertGraphDistribution BarChart BarChart3D BarLegend BarlowProschanImportance BarnesG BarOrigin BarSpacing BartlettHannWindow BartlettWindow BaseForm Baseline BaselinePosition BaseStyle BatesDistribution BattleLemarieWavelet Because BeckmannDistribution Beep Before Begin BeginDialogPacket BeginFrontEndInteractionPacket BeginPackage BellB BellY Below BenfordDistribution BeniniDistribution BenktanderGibratDistribution BenktanderWeibullDistribution BernoulliB BernoulliDistribution BernoulliGraphDistribution BernoulliProcess BernsteinBasis BesselFilterModel BesselI BesselJ BesselJZero BesselK BesselY BesselYZero Beta BetaBinomialDistribution BetaDistribution BetaNegativeBinomialDistribution BetaPrimeDistribution BetaRegularized BetweennessCentrality BezierCurve BezierCurve3DBox BezierCurve3DBoxOptions BezierCurveBox BezierCurveBoxOptions BezierFunction BilateralFilter Binarize BinaryFormat BinaryImageQ BinaryRead BinaryReadList BinaryWrite BinCounts BinLists Binomial BinomialDistribution BinomialProcess BinormalDistribution BiorthogonalSplineWavelet BipartiteGraphQ BirnbaumImportance BirnbaumSaundersDistribution BitAnd BitClear BitGet BitLength BitNot BitOr BitSet BitShiftLeft BitShiftRight BitXor Black BlackmanHarrisWindow BlackmanNuttallWindow BlackmanWindow Blank BlankForm BlankNullSequence BlankSequence Blend Block BlockRandom BlomqvistBeta BlomqvistBetaTest Blue Blur BodePlot BohmanWindow Bold Bookmarks Boole BooleanConsecutiveFunction BooleanConvert BooleanCountingFunction BooleanFunction BooleanGraph BooleanMaxterms BooleanMinimize BooleanMinterms Booleans BooleanTable BooleanVariables BorderDimensions BorelTannerDistribution Bottom BottomHatTransform BoundaryStyle Bounds Box BoxBaselineShift BoxData BoxDimensions Boxed Boxes BoxForm BoxFormFormatTypes BoxFrame BoxID BoxMargins BoxMatrix BoxRatios BoxRotation BoxRotationPoint BoxStyle BoxWhiskerChart Bra BracketingBar BraKet BrayCurtisDistance BreadthFirstScan Break Brown BrownForsytheTest BrownianBridgeProcess BrowserCategory BSplineBasis BSplineCurve BSplineCurve3DBox BSplineCurveBox BSplineCurveBoxOptions BSplineFunction BSplineSurface BSplineSurface3DBox BubbleChart BubbleChart3D BubbleScale BubbleSizes BulletGauge BusinessDayQ ButterflyGraph ButterworthFilterModel Button ButtonBar ButtonBox ButtonBoxOptions ButtonCell ButtonContents ButtonData ButtonEvaluator ButtonExpandable ButtonFrame ButtonFunction ButtonMargins ButtonMinHeight ButtonNote ButtonNotebook ButtonSource ButtonStyle ButtonStyleMenuListing Byte ByteCount ByteOrdering ' +
+ 'C CachedValue CacheGraphics CalendarData CalendarType CallPacket CanberraDistance Cancel CancelButton CandlestickChart Cap CapForm CapitalDifferentialD CardinalBSplineBasis CarmichaelLambda Cases Cashflow Casoratian Catalan CatalanNumber Catch CauchyDistribution CauchyWindow CayleyGraph CDF CDFDeploy CDFInformation CDFWavelet Ceiling Cell CellAutoOverwrite CellBaseline CellBoundingBox CellBracketOptions CellChangeTimes CellContents CellContext CellDingbat CellDynamicExpression CellEditDuplicate CellElementsBoundingBox CellElementSpacings CellEpilog CellEvaluationDuplicate CellEvaluationFunction CellEventActions CellFrame CellFrameColor CellFrameLabelMargins CellFrameLabels CellFrameMargins CellGroup CellGroupData CellGrouping CellGroupingRules CellHorizontalScrolling CellID CellLabel CellLabelAutoDelete CellLabelMargins CellLabelPositioning CellMargins CellObject CellOpen CellPrint CellProlog Cells CellSize CellStyle CellTags CellularAutomaton CensoredDistribution Censoring Center CenterDot CentralMoment CentralMomentGeneratingFunction CForm ChampernowneNumber ChanVeseBinarize Character CharacterEncoding CharacterEncodingsPath CharacteristicFunction CharacteristicPolynomial CharacterRange Characters ChartBaseStyle ChartElementData ChartElementDataFunction ChartElementFunction ChartElements ChartLabels ChartLayout ChartLegends ChartStyle Chebyshev1FilterModel Chebyshev2FilterModel ChebyshevDistance ChebyshevT ChebyshevU Check CheckAbort CheckAll Checkbox CheckboxBar CheckboxBox CheckboxBoxOptions ChemicalData ChessboardDistance ChiDistribution ChineseRemainder ChiSquareDistribution ChoiceButtons ChoiceDialog CholeskyDecomposition Chop Circle CircleBox CircleDot CircleMinus CirclePlus CircleTimes CirculantGraph CityData Clear ClearAll ClearAttributes ClearSystemCache ClebschGordan ClickPane Clip ClipboardNotebook ClipFill ClippingStyle ClipPlanes ClipRange Clock ClockGauge ClockwiseContourIntegral Close Closed CloseKernels ClosenessCentrality Closing ClosingAutoSave ClosingEvent ClusteringComponents CMYKColor Coarse Coefficient CoefficientArrays CoefficientDomain CoefficientList CoefficientRules CoifletWavelet Collect Colon ColonForm ColorCombine ColorConvert ColorData ColorDataFunction ColorFunction ColorFunctionScaling Colorize ColorNegate ColorOutput ColorProfileData ColorQuantize ColorReplace ColorRules ColorSelectorSettings ColorSeparate ColorSetter ColorSetterBox ColorSetterBoxOptions ColorSlider ColorSpace Column ColumnAlignments ColumnBackgrounds ColumnForm ColumnLines ColumnsEqual ColumnSpacings ColumnWidths CommonDefaultFormatTypes Commonest CommonestFilter CommonUnits CommunityBoundaryStyle CommunityGraphPlot CommunityLabels CommunityRegionStyle CompatibleUnitQ CompilationOptions CompilationTarget Compile Compiled CompiledFunction Complement CompleteGraph CompleteGraphQ CompleteKaryTree CompletionsListPacket Complex Complexes ComplexExpand ComplexInfinity ComplexityFunction ComponentMeasurements ' +
+ 'ComponentwiseContextMenu Compose ComposeList ComposeSeries Composition CompoundExpression CompoundPoissonDistribution CompoundPoissonProcess CompoundRenewalProcess Compress CompressedData Condition ConditionalExpression Conditioned Cone ConeBox ConfidenceLevel ConfidenceRange ConfidenceTransform ConfigurationPath Congruent Conjugate ConjugateTranspose Conjunction Connect ConnectedComponents ConnectedGraphQ ConnesWindow ConoverTest ConsoleMessage ConsoleMessagePacket ConsolePrint Constant ConstantArray Constants ConstrainedMax ConstrainedMin ContentPadding ContentsBoundingBox ContentSelectable ContentSize Context ContextMenu Contexts ContextToFilename ContextToFileName Continuation Continue ContinuedFraction ContinuedFractionK ContinuousAction ContinuousMarkovProcess ContinuousTimeModelQ ContinuousWaveletData ContinuousWaveletTransform ContourDetect ContourGraphics ContourIntegral ContourLabels ContourLines ContourPlot ContourPlot3D Contours ContourShading ContourSmoothing ContourStyle ContraharmonicMean Control ControlActive ControlAlignment ControllabilityGramian ControllabilityMatrix ControllableDecomposition ControllableModelQ ControllerDuration ControllerInformation ControllerInformationData ControllerLinking ControllerManipulate ControllerMethod ControllerPath ControllerState ControlPlacement ControlsRendering ControlType Convergents ConversionOptions ConversionRules ConvertToBitmapPacket ConvertToPostScript ConvertToPostScriptPacket Convolve ConwayGroupCo1 ConwayGroupCo2 ConwayGroupCo3 CoordinateChartData CoordinatesToolOptions CoordinateTransform CoordinateTransformData CoprimeQ Coproduct CopulaDistribution Copyable CopyDirectory CopyFile CopyTag CopyToClipboard CornerFilter CornerNeighbors Correlation CorrelationDistance CorrelationFunction CorrelationTest Cos Cosh CoshIntegral CosineDistance CosineWindow CosIntegral Cot Coth Count CounterAssignments CounterBox CounterBoxOptions CounterClockwiseContourIntegral CounterEvaluator CounterFunction CounterIncrements CounterStyle CounterStyleMenuListing CountRoots CountryData Covariance CovarianceEstimatorFunction CovarianceFunction CoxianDistribution CoxIngersollRossProcess CoxModel CoxModelFit CramerVonMisesTest CreateArchive CreateDialog CreateDirectory CreateDocument CreateIntermediateDirectories CreatePalette CreatePalettePacket CreateScheduledTask CreateTemporary CreateWindow CriticalityFailureImportance CriticalitySuccessImportance CriticalSection Cross CrossingDetect CrossMatrix Csc Csch CubeRoot Cubics Cuboid CuboidBox Cumulant CumulantGeneratingFunction Cup CupCap Curl CurlyDoubleQuote CurlyQuote CurrentImage CurrentlySpeakingPacket CurrentValue CurvatureFlowFilter CurveClosed Cyan CycleGraph CycleIndexPolynomial Cycles CyclicGroup Cyclotomic Cylinder CylinderBox CylindricalDecomposition ' +
+ 'D DagumDistribution DamerauLevenshteinDistance DampingFactor Darker Dashed Dashing DataCompression DataDistribution DataRange DataReversed Date DateDelimiters DateDifference DateFunction DateList DateListLogPlot DateListPlot DatePattern DatePlus DateRange DateString DateTicksFormat DaubechiesWavelet DavisDistribution DawsonF DayCount DayCountConvention DayMatchQ DayName DayPlus DayRange DayRound DeBruijnGraph Debug DebugTag Decimal DeclareKnownSymbols DeclarePackage Decompose Decrement DedekindEta Default DefaultAxesStyle DefaultBaseStyle DefaultBoxStyle DefaultButton DefaultColor DefaultControlPlacement DefaultDuplicateCellStyle DefaultDuration DefaultElement DefaultFaceGridsStyle DefaultFieldHintStyle DefaultFont DefaultFontProperties DefaultFormatType DefaultFormatTypeForStyle DefaultFrameStyle DefaultFrameTicksStyle DefaultGridLinesStyle DefaultInlineFormatType DefaultInputFormatType DefaultLabelStyle DefaultMenuStyle DefaultNaturalLanguage DefaultNewCellStyle DefaultNewInlineCellStyle DefaultNotebook DefaultOptions DefaultOutputFormatType DefaultStyle DefaultStyleDefinitions DefaultTextFormatType DefaultTextInlineFormatType DefaultTicksStyle DefaultTooltipStyle DefaultValues Defer DefineExternal DefineInputStreamMethod DefineOutputStreamMethod Definition Degree DegreeCentrality DegreeGraphDistribution DegreeLexicographic DegreeReverseLexicographic Deinitialization Del Deletable Delete DeleteBorderComponents DeleteCases DeleteContents DeleteDirectory DeleteDuplicates DeleteFile DeleteSmallComponents DeleteWithContents DeletionWarning Delimiter DelimiterFlashTime DelimiterMatching Delimiters Denominator DensityGraphics DensityHistogram DensityPlot DependentVariables Deploy Deployed Depth DepthFirstScan Derivative DerivativeFilter DescriptorStateSpace DesignMatrix Det DGaussianWavelet DiacriticalPositioning Diagonal DiagonalMatrix Dialog DialogIndent DialogInput DialogLevel DialogNotebook DialogProlog DialogReturn DialogSymbols Diamond DiamondMatrix DiceDissimilarity DictionaryLookup DifferenceDelta DifferenceOrder DifferenceRoot DifferenceRootReduce Differences DifferentialD DifferentialRoot DifferentialRootReduce DifferentiatorFilter DigitBlock DigitBlockMinimum DigitCharacter DigitCount DigitQ DihedralGroup Dilation Dimensions DiracComb DiracDelta DirectedEdge DirectedEdges DirectedGraph DirectedGraphQ DirectedInfinity Direction Directive Directory DirectoryName DirectoryQ DirectoryStack DirichletCharacter DirichletConvolve DirichletDistribution DirichletL DirichletTransform DirichletWindow DisableConsolePrintPacket DiscreteChirpZTransform DiscreteConvolve DiscreteDelta DiscreteHadamardTransform DiscreteIndicator DiscreteLQEstimatorGains DiscreteLQRegulatorGains DiscreteLyapunovSolve DiscreteMarkovProcess DiscretePlot DiscretePlot3D DiscreteRatio DiscreteRiccatiSolve DiscreteShift DiscreteTimeModelQ DiscreteUniformDistribution DiscreteVariables DiscreteWaveletData DiscreteWaveletPacketTransform ' +
+ 'DiscreteWaveletTransform Discriminant Disjunction Disk DiskBox DiskMatrix Dispatch DispersionEstimatorFunction Display DisplayAllSteps DisplayEndPacket DisplayFlushImagePacket DisplayForm DisplayFunction DisplayPacket DisplayRules DisplaySetSizePacket DisplayString DisplayTemporary DisplayWith DisplayWithRef DisplayWithVariable DistanceFunction DistanceTransform Distribute Distributed DistributedContexts DistributeDefinitions DistributionChart DistributionDomain DistributionFitTest DistributionParameterAssumptions DistributionParameterQ Dithering Div Divergence Divide DivideBy Dividers Divisible Divisors DivisorSigma DivisorSum DMSList DMSString Do DockedCells DocumentNotebook DominantColors DOSTextFormat Dot DotDashed DotEqual Dotted DoubleBracketingBar DoubleContourIntegral DoubleDownArrow DoubleLeftArrow DoubleLeftRightArrow DoubleLeftTee DoubleLongLeftArrow DoubleLongLeftRightArrow DoubleLongRightArrow DoubleRightArrow DoubleRightTee DoubleUpArrow DoubleUpDownArrow DoubleVerticalBar DoublyInfinite Down DownArrow DownArrowBar DownArrowUpArrow DownLeftRightVector DownLeftTeeVector DownLeftVector DownLeftVectorBar DownRightTeeVector DownRightVector DownRightVectorBar Downsample DownTee DownTeeArrow DownValues DragAndDrop DrawEdges DrawFrontFaces DrawHighlighted Drop DSolve Dt DualLinearProgramming DualSystemsModel DumpGet DumpSave DuplicateFreeQ Dynamic DynamicBox DynamicBoxOptions DynamicEvaluationTimeout DynamicLocation DynamicModule DynamicModuleBox DynamicModuleBoxOptions DynamicModuleParent DynamicModuleValues DynamicName DynamicNamespace DynamicReference DynamicSetting DynamicUpdating DynamicWrapper DynamicWrapperBox DynamicWrapperBoxOptions ' +
+ 'E EccentricityCentrality EdgeAdd EdgeBetweennessCentrality EdgeCapacity EdgeCapForm EdgeColor EdgeConnectivity EdgeCost EdgeCount EdgeCoverQ EdgeDashing EdgeDelete EdgeDetect EdgeForm EdgeIndex EdgeJoinForm EdgeLabeling EdgeLabels EdgeLabelStyle EdgeList EdgeOpacity EdgeQ EdgeRenderingFunction EdgeRules EdgeShapeFunction EdgeStyle EdgeThickness EdgeWeight Editable EditButtonSettings EditCellTagsSettings EditDistance EffectiveInterest Eigensystem Eigenvalues EigenvectorCentrality Eigenvectors Element ElementData Eliminate EliminationOrder EllipticE EllipticExp EllipticExpPrime EllipticF EllipticFilterModel EllipticK EllipticLog EllipticNomeQ EllipticPi EllipticReducedHalfPeriods EllipticTheta EllipticThetaPrime EmitSound EmphasizeSyntaxErrors EmpiricalDistribution Empty EmptyGraphQ EnableConsolePrintPacket Enabled Encode End EndAdd EndDialogPacket EndFrontEndInteractionPacket EndOfFile EndOfLine EndOfString EndPackage EngineeringForm Enter EnterExpressionPacket EnterTextPacket Entropy EntropyFilter Environment Epilog Equal EqualColumns EqualRows EqualTilde EquatedTo Equilibrium EquirippleFilterKernel Equivalent Erf Erfc Erfi ErlangB ErlangC ErlangDistribution Erosion ErrorBox ErrorBoxOptions ErrorNorm ErrorPacket ErrorsDialogSettings EstimatedDistribution EstimatedProcess EstimatorGains EstimatorRegulator EuclideanDistance EulerE EulerGamma EulerianGraphQ EulerPhi Evaluatable Evaluate Evaluated EvaluatePacket EvaluationCell EvaluationCompletionAction EvaluationElements EvaluationMode EvaluationMonitor EvaluationNotebook EvaluationObject EvaluationOrder Evaluator EvaluatorNames EvenQ EventData EventEvaluator EventHandler EventHandlerTag EventLabels ExactBlackmanWindow ExactNumberQ ExactRootIsolation ExampleData Except ExcludedForms ExcludePods Exclusions ExclusionsStyle Exists Exit ExitDialog Exp Expand ExpandAll ExpandDenominator ExpandFileName ExpandNumerator Expectation ExpectationE ExpectedValue ExpGammaDistribution ExpIntegralE ExpIntegralEi Exponent ExponentFunction ExponentialDistribution ExponentialFamily ExponentialGeneratingFunction ExponentialMovingAverage ExponentialPowerDistribution ExponentPosition ExponentStep Export ExportAutoReplacements ExportPacket ExportString Expression ExpressionCell ExpressionPacket ExpToTrig ExtendedGCD Extension ExtentElementFunction ExtentMarkers ExtentSize ExternalCall ExternalDataCharacterEncoding Extract ExtractArchive ExtremeValueDistribution ' +
+ 'FaceForm FaceGrids FaceGridsStyle Factor FactorComplete Factorial Factorial2 FactorialMoment FactorialMomentGeneratingFunction FactorialPower FactorInteger FactorList FactorSquareFree FactorSquareFreeList FactorTerms FactorTermsList Fail FailureDistribution False FARIMAProcess FEDisableConsolePrintPacket FeedbackSector FeedbackSectorStyle FeedbackType FEEnableConsolePrintPacket Fibonacci FieldHint FieldHintStyle FieldMasked FieldSize File FileBaseName FileByteCount FileDate FileExistsQ FileExtension FileFormat FileHash FileInformation FileName FileNameDepth FileNameDialogSettings FileNameDrop FileNameJoin FileNames FileNameSetter FileNameSplit FileNameTake FilePrint FileType FilledCurve FilledCurveBox Filling FillingStyle FillingTransform FilterRules FinancialBond FinancialData FinancialDerivative FinancialIndicator Find FindArgMax FindArgMin FindClique FindClusters FindCurvePath FindDistributionParameters FindDivisions FindEdgeCover FindEdgeCut FindEulerianCycle FindFaces FindFile FindFit FindGeneratingFunction FindGeoLocation FindGeometricTransform FindGraphCommunities FindGraphIsomorphism FindGraphPartition FindHamiltonianCycle FindIndependentEdgeSet FindIndependentVertexSet FindInstance FindIntegerNullVector FindKClan FindKClique FindKClub FindKPlex FindLibrary FindLinearRecurrence FindList FindMaximum FindMaximumFlow FindMaxValue FindMinimum FindMinimumCostFlow FindMinimumCut FindMinValue FindPermutation FindPostmanTour FindProcessParameters FindRoot FindSequenceFunction FindSettings FindShortestPath FindShortestTour FindThreshold FindVertexCover FindVertexCut Fine FinishDynamic FiniteAbelianGroupCount FiniteGroupCount FiniteGroupData First FirstPassageTimeDistribution FischerGroupFi22 FischerGroupFi23 FischerGroupFi24Prime FisherHypergeometricDistribution FisherRatioTest FisherZDistribution Fit FitAll FittedModel FixedPoint FixedPointList FlashSelection Flat Flatten FlattenAt FlatTopWindow FlipView Floor FlushPrintOutputPacket Fold FoldList Font FontColor FontFamily FontForm FontName FontOpacity FontPostScriptName FontProperties FontReencoding FontSize FontSlant FontSubstitutions FontTracking FontVariations FontWeight For ForAll Format FormatRules FormatType FormatTypeAutoConvert FormatValues FormBox FormBoxOptions FortranForm Forward ForwardBackward Fourier FourierCoefficient FourierCosCoefficient FourierCosSeries FourierCosTransform FourierDCT FourierDCTFilter FourierDCTMatrix FourierDST FourierDSTMatrix FourierMatrix FourierParameters FourierSequenceTransform FourierSeries FourierSinCoefficient FourierSinSeries FourierSinTransform FourierTransform FourierTrigSeries FractionalBrownianMotionProcess FractionalPart FractionBox FractionBoxOptions FractionLine Frame FrameBox FrameBoxOptions Framed FrameInset FrameLabel Frameless FrameMargins FrameStyle FrameTicks FrameTicksStyle FRatioDistribution FrechetDistribution FreeQ FrequencySamplingFilterKernel FresnelC FresnelS Friday FrobeniusNumber FrobeniusSolve ' +
+ 'FromCharacterCode FromCoefficientRules FromContinuedFraction FromDate FromDigits FromDMS Front FrontEndDynamicExpression FrontEndEventActions FrontEndExecute FrontEndObject FrontEndResource FrontEndResourceString FrontEndStackSize FrontEndToken FrontEndTokenExecute FrontEndValueCache FrontEndVersion FrontFaceColor FrontFaceOpacity Full FullAxes FullDefinition FullForm FullGraphics FullOptions FullSimplify Function FunctionExpand FunctionInterpolation FunctionSpace FussellVeselyImportance ' +
+ 'GaborFilter GaborMatrix GaborWavelet GainMargins GainPhaseMargins Gamma GammaDistribution GammaRegularized GapPenalty Gather GatherBy GaugeFaceElementFunction GaugeFaceStyle GaugeFrameElementFunction GaugeFrameSize GaugeFrameStyle GaugeLabels GaugeMarkers GaugeStyle GaussianFilter GaussianIntegers GaussianMatrix GaussianWindow GCD GegenbauerC General GeneralizedLinearModelFit GenerateConditions GeneratedCell GeneratedParameters GeneratingFunction Generic GenericCylindricalDecomposition GenomeData GenomeLookup GeodesicClosing GeodesicDilation GeodesicErosion GeodesicOpening GeoDestination GeodesyData GeoDirection GeoDistance GeoGridPosition GeometricBrownianMotionProcess GeometricDistribution GeometricMean GeometricMeanFilter GeometricTransformation GeometricTransformation3DBox GeometricTransformation3DBoxOptions GeometricTransformationBox GeometricTransformationBoxOptions GeoPosition GeoPositionENU GeoPositionXYZ GeoProjectionData GestureHandler GestureHandlerTag Get GetBoundingBoxSizePacket GetContext GetEnvironment GetFileName GetFrontEndOptionsDataPacket GetLinebreakInformationPacket GetMenusPacket GetPageBreakInformationPacket Glaisher GlobalClusteringCoefficient GlobalPreferences GlobalSession Glow GoldenRatio GompertzMakehamDistribution GoodmanKruskalGamma GoodmanKruskalGammaTest Goto Grad Gradient GradientFilter GradientOrientationFilter Graph GraphAssortativity GraphCenter GraphComplement GraphData GraphDensity GraphDiameter GraphDifference GraphDisjointUnion ' +
+ 'GraphDistance GraphDistanceMatrix GraphElementData GraphEmbedding GraphHighlight GraphHighlightStyle GraphHub Graphics Graphics3D Graphics3DBox Graphics3DBoxOptions GraphicsArray GraphicsBaseline GraphicsBox GraphicsBoxOptions GraphicsColor GraphicsColumn GraphicsComplex GraphicsComplex3DBox GraphicsComplex3DBoxOptions GraphicsComplexBox GraphicsComplexBoxOptions GraphicsContents GraphicsData GraphicsGrid GraphicsGridBox GraphicsGroup GraphicsGroup3DBox GraphicsGroup3DBoxOptions GraphicsGroupBox GraphicsGroupBoxOptions GraphicsGrouping GraphicsHighlightColor GraphicsRow GraphicsSpacing GraphicsStyle GraphIntersection GraphLayout GraphLinkEfficiency GraphPeriphery GraphPlot GraphPlot3D GraphPower GraphPropertyDistribution GraphQ GraphRadius GraphReciprocity GraphRoot GraphStyle GraphUnion Gray GrayLevel GreatCircleDistance Greater GreaterEqual GreaterEqualLess GreaterFullEqual GreaterGreater GreaterLess GreaterSlantEqual GreaterTilde Green Grid GridBaseline GridBox GridBoxAlignment GridBoxBackground GridBoxDividers GridBoxFrame GridBoxItemSize GridBoxItemStyle GridBoxOptions GridBoxSpacings GridCreationSettings GridDefaultElement GridElementStyleOptions GridFrame GridFrameMargins GridGraph GridLines GridLinesStyle GroebnerBasis GroupActionBase GroupCentralizer GroupElementFromWord GroupElementPosition GroupElementQ GroupElements GroupElementToWord GroupGenerators GroupMultiplicationTable GroupOrbits GroupOrder GroupPageBreakWithin GroupSetwiseStabilizer GroupStabilizer GroupStabilizerChain Gudermannian GumbelDistribution ' +
+ 'HaarWavelet HadamardMatrix HalfNormalDistribution HamiltonianGraphQ HammingDistance HammingWindow HankelH1 HankelH2 HankelMatrix HannPoissonWindow HannWindow HaradaNortonGroupHN HararyGraph HarmonicMean HarmonicMeanFilter HarmonicNumber Hash HashTable Haversine HazardFunction Head HeadCompose Heads HeavisideLambda HeavisidePi HeavisideTheta HeldGroupHe HeldPart HelpBrowserLookup HelpBrowserNotebook HelpBrowserSettings HermiteDecomposition HermiteH HermitianMatrixQ HessenbergDecomposition Hessian HexadecimalCharacter Hexahedron HexahedronBox HexahedronBoxOptions HiddenSurface HighlightGraph HighlightImage HighpassFilter HigmanSimsGroupHS HilbertFilter HilbertMatrix Histogram Histogram3D HistogramDistribution HistogramList HistogramTransform HistogramTransformInterpolation HitMissTransform HITSCentrality HodgeDual HoeffdingD HoeffdingDTest Hold HoldAll HoldAllComplete HoldComplete HoldFirst HoldForm HoldPattern HoldRest HolidayCalendar HomeDirectory HomePage Horizontal HorizontalForm HorizontalGauge HorizontalScrollPosition HornerForm HotellingTSquareDistribution HoytDistribution HTMLSave Hue HumpDownHump HumpEqual HurwitzLerchPhi HurwitzZeta HyperbolicDistribution HypercubeGraph HyperexponentialDistribution Hyperfactorial Hypergeometric0F1 Hypergeometric0F1Regularized Hypergeometric1F1 Hypergeometric1F1Regularized Hypergeometric2F1 Hypergeometric2F1Regularized HypergeometricDistribution HypergeometricPFQ HypergeometricPFQRegularized HypergeometricU Hyperlink HyperlinkCreationSettings Hyphenation HyphenationOptions HypoexponentialDistribution HypothesisTestData ' +
+ 'I Identity IdentityMatrix If IgnoreCase Im Image Image3D Image3DSlices ImageAccumulate ImageAdd ImageAdjust ImageAlign ImageApply ImageAspectRatio ImageAssemble ImageCache ImageCacheValid ImageCapture ImageChannels ImageClip ImageColorSpace ImageCompose ImageConvolve ImageCooccurrence ImageCorners ImageCorrelate ImageCorrespondingPoints ImageCrop ImageData ImageDataPacket ImageDeconvolve ImageDemosaic ImageDifference ImageDimensions ImageDistance ImageEffect ImageFeatureTrack ImageFileApply ImageFileFilter ImageFileScan ImageFilter ImageForestingComponents ImageForwardTransformation ImageHistogram ImageKeypoints ImageLevels ImageLines ImageMargins ImageMarkers ImageMeasurements ImageMultiply ImageOffset ImagePad ImagePadding ImagePartition ImagePeriodogram ImagePerspectiveTransformation ImageQ ImageRangeCache ImageReflect ImageRegion ImageResize ImageResolution ImageRotate ImageRotated ImageScaled ImageScan ImageSize ImageSizeAction ImageSizeCache ImageSizeMultipliers ImageSizeRaw ImageSubtract ImageTake ImageTransformation ImageTrim ImageType ImageValue ImageValuePositions Implies Import ImportAutoReplacements ImportString ImprovementImportance In IncidenceGraph IncidenceList IncidenceMatrix IncludeConstantBasis IncludeFileExtension IncludePods IncludeSingularTerm Increment Indent IndentingNewlineSpacings IndentMaxFraction IndependenceTest IndependentEdgeSetQ IndependentUnit IndependentVertexSetQ Indeterminate IndexCreationOptions Indexed IndexGraph IndexTag Inequality InexactNumberQ InexactNumbers Infinity Infix Information Inherited InheritScope Initialization InitializationCell InitializationCellEvaluation InitializationCellWarning InlineCounterAssignments InlineCounterIncrements InlineRules Inner Inpaint Input InputAliases InputAssumptions InputAutoReplacements InputField InputFieldBox InputFieldBoxOptions InputForm InputGrouping InputNamePacket InputNotebook InputPacket InputSettings InputStream InputString InputStringPacket InputToBoxFormPacket Insert InsertionPointObject InsertResults Inset Inset3DBox Inset3DBoxOptions InsetBox InsetBoxOptions Install InstallService InString Integer IntegerDigits IntegerExponent IntegerLength IntegerPart IntegerPartitions IntegerQ Integers IntegerString Integral Integrate Interactive InteractiveTradingChart Interlaced Interleaving InternallyBalancedDecomposition InterpolatingFunction InterpolatingPolynomial Interpolation InterpolationOrder InterpolationPoints InterpolationPrecision Interpretation InterpretationBox InterpretationBoxOptions InterpretationFunction ' +
+ 'InterpretTemplate InterquartileRange Interrupt InterruptSettings Intersection Interval IntervalIntersection IntervalMemberQ IntervalUnion Inverse InverseBetaRegularized InverseCDF InverseChiSquareDistribution InverseContinuousWaveletTransform InverseDistanceTransform InverseEllipticNomeQ InverseErf InverseErfc InverseFourier InverseFourierCosTransform InverseFourierSequenceTransform InverseFourierSinTransform InverseFourierTransform InverseFunction InverseFunctions InverseGammaDistribution InverseGammaRegularized InverseGaussianDistribution InverseGudermannian InverseHaversine InverseJacobiCD InverseJacobiCN InverseJacobiCS InverseJacobiDC InverseJacobiDN InverseJacobiDS InverseJacobiNC InverseJacobiND InverseJacobiNS InverseJacobiSC InverseJacobiSD InverseJacobiSN InverseLaplaceTransform InversePermutation InverseRadon InverseSeries InverseSurvivalFunction InverseWaveletTransform InverseWeierstrassP InverseZTransform Invisible InvisibleApplication InvisibleTimes IrreduciblePolynomialQ IsolatingInterval IsomorphicGraphQ IsotopeData Italic Item ItemBox ItemBoxOptions ItemSize ItemStyle ItoProcess ' +
+ 'JaccardDissimilarity JacobiAmplitude Jacobian JacobiCD JacobiCN JacobiCS JacobiDC JacobiDN JacobiDS JacobiNC JacobiND JacobiNS JacobiP JacobiSC JacobiSD JacobiSN JacobiSymbol JacobiZeta JankoGroupJ1 JankoGroupJ2 JankoGroupJ3 JankoGroupJ4 JarqueBeraALMTest JohnsonDistribution Join Joined JoinedCurve JoinedCurveBox JoinForm JordanDecomposition JordanModelDecomposition ' +
+ 'K KagiChart KaiserBesselWindow KaiserWindow KalmanEstimator KalmanFilter KarhunenLoeveDecomposition KaryTree KatzCentrality KCoreComponents KDistribution KelvinBei KelvinBer KelvinKei KelvinKer KendallTau KendallTauTest KernelExecute KernelMixtureDistribution KernelObject Kernels Ket Khinchin KirchhoffGraph KirchhoffMatrix KleinInvariantJ KnightTourGraph KnotData KnownUnitQ KolmogorovSmirnovTest KroneckerDelta KroneckerModelDecomposition KroneckerProduct KroneckerSymbol KuiperTest KumaraswamyDistribution Kurtosis KuwaharaFilter ' +
+ 'Label Labeled LabeledSlider LabelingFunction LabelStyle LaguerreL LambdaComponents LambertW LanczosWindow LandauDistribution Language LanguageCategory LaplaceDistribution LaplaceTransform Laplacian LaplacianFilter LaplacianGaussianFilter Large Larger Last Latitude LatitudeLongitude LatticeData LatticeReduce Launch LaunchKernels LayeredGraphPlot LayerSizeFunction LayoutInformation LCM LeafCount LeapYearQ LeastSquares LeastSquaresFilterKernel Left LeftArrow LeftArrowBar LeftArrowRightArrow LeftDownTeeVector LeftDownVector LeftDownVectorBar LeftRightArrow LeftRightVector LeftTee LeftTeeArrow LeftTeeVector LeftTriangle LeftTriangleBar LeftTriangleEqual LeftUpDownVector LeftUpTeeVector LeftUpVector LeftUpVectorBar LeftVector LeftVectorBar LegendAppearance Legended LegendFunction LegendLabel LegendLayout LegendMargins LegendMarkers LegendMarkerSize LegendreP LegendreQ LegendreType Length LengthWhile LerchPhi Less LessEqual LessEqualGreater LessFullEqual LessGreater LessLess LessSlantEqual LessTilde LetterCharacter LetterQ Level LeveneTest LeviCivitaTensor LevyDistribution Lexicographic LibraryFunction LibraryFunctionError LibraryFunctionInformation LibraryFunctionLoad LibraryFunctionUnload LibraryLoad LibraryUnload LicenseID LiftingFilterData LiftingWaveletTransform LightBlue LightBrown LightCyan Lighter LightGray LightGreen Lighting LightingAngle LightMagenta LightOrange LightPink LightPurple LightRed LightSources LightYellow Likelihood Limit LimitsPositioning LimitsPositioningTokens LindleyDistribution Line Line3DBox LinearFilter LinearFractionalTransform LinearModelFit LinearOffsetFunction LinearProgramming LinearRecurrence LinearSolve LinearSolveFunction LineBox LineBreak LinebreakAdjustments LineBreakChart LineBreakWithin LineColor LineForm LineGraph LineIndent LineIndentMaxFraction LineIntegralConvolutionPlot LineIntegralConvolutionScale LineLegend LineOpacity LineSpacing LineWrapParts LinkActivate LinkClose LinkConnect LinkConnectedQ LinkCreate LinkError LinkFlush LinkFunction LinkHost LinkInterrupt LinkLaunch LinkMode LinkObject LinkOpen LinkOptions LinkPatterns LinkProtocol LinkRead LinkReadHeld LinkReadyQ Links LinkWrite LinkWriteHeld LiouvilleLambda List Listable ListAnimate ListContourPlot ListContourPlot3D ListConvolve ListCorrelate ListCurvePathPlot ListDeconvolve ListDensityPlot Listen ListFourierSequenceTransform ListInterpolation ListLineIntegralConvolutionPlot ListLinePlot ListLogLinearPlot ListLogLogPlot ListLogPlot ListPicker ListPickerBox ListPickerBoxBackground ListPickerBoxOptions ListPlay ListPlot ListPlot3D ListPointPlot3D ListPolarPlot ListQ ListStreamDensityPlot ListStreamPlot ListSurfacePlot3D ListVectorDensityPlot ListVectorPlot ListVectorPlot3D ListZTransform Literal LiteralSearch LocalClusteringCoefficient LocalizeVariables LocationEquivalenceTest LocationTest Locator LocatorAutoCreate LocatorBox LocatorBoxOptions LocatorCentering LocatorPane LocatorPaneBox LocatorPaneBoxOptions ' +
+ 'LocatorRegion Locked Log Log10 Log2 LogBarnesG LogGamma LogGammaDistribution LogicalExpand LogIntegral LogisticDistribution LogitModelFit LogLikelihood LogLinearPlot LogLogisticDistribution LogLogPlot LogMultinormalDistribution LogNormalDistribution LogPlot LogRankTest LogSeriesDistribution LongEqual Longest LongestAscendingSequence LongestCommonSequence LongestCommonSequencePositions LongestCommonSubsequence LongestCommonSubsequencePositions LongestMatch LongForm Longitude LongLeftArrow LongLeftRightArrow LongRightArrow Loopback LoopFreeGraphQ LowerCaseQ LowerLeftArrow LowerRightArrow LowerTriangularize LowpassFilter LQEstimatorGains LQGRegulator LQOutputRegulatorGains LQRegulatorGains LUBackSubstitution LucasL LuccioSamiComponents LUDecomposition LyapunovSolve LyonsGroupLy ' +
+ 'MachineID MachineName MachineNumberQ MachinePrecision MacintoshSystemPageSetup Magenta Magnification Magnify MainSolve MaintainDynamicCaches Majority MakeBoxes MakeExpression MakeRules MangoldtLambda ManhattanDistance Manipulate Manipulator MannWhitneyTest MantissaExponent Manual Map MapAll MapAt MapIndexed MAProcess MapThread MarcumQ MardiaCombinedTest MardiaKurtosisTest MardiaSkewnessTest MarginalDistribution MarkovProcessProperties Masking MatchingDissimilarity MatchLocalNameQ MatchLocalNames MatchQ Material MathematicaNotation MathieuC MathieuCharacteristicA MathieuCharacteristicB MathieuCharacteristicExponent MathieuCPrime MathieuGroupM11 MathieuGroupM12 MathieuGroupM22 MathieuGroupM23 MathieuGroupM24 MathieuS MathieuSPrime MathMLForm MathMLText Matrices MatrixExp MatrixForm MatrixFunction MatrixLog MatrixPlot MatrixPower MatrixQ MatrixRank Max MaxBend MaxDetect MaxExtraBandwidths MaxExtraConditions MaxFeatures MaxFilter Maximize MaxIterations MaxMemoryUsed MaxMixtureKernels MaxPlotPoints MaxPoints MaxRecursion MaxStableDistribution MaxStepFraction MaxSteps MaxStepSize MaxValue MaxwellDistribution McLaughlinGroupMcL Mean MeanClusteringCoefficient MeanDegreeConnectivity MeanDeviation MeanFilter MeanGraphDistance MeanNeighborDegree MeanShift MeanShiftFilter Median MedianDeviation MedianFilter Medium MeijerG MeixnerDistribution MemberQ MemoryConstrained MemoryInUse Menu MenuAppearance MenuCommandKey MenuEvaluator MenuItem MenuPacket MenuSortingValue MenuStyle MenuView MergeDifferences Mesh MeshFunctions MeshRange MeshShading MeshStyle Message MessageDialog MessageList MessageName MessageOptions MessagePacket Messages MessagesNotebook MetaCharacters MetaInformation Method MethodOptions MexicanHatWavelet MeyerWavelet Min MinDetect MinFilter MinimalPolynomial MinimalStateSpaceModel Minimize Minors MinRecursion MinSize MinStableDistribution Minus MinusPlus MinValue Missing MissingDataMethod MittagLefflerE MixedRadix MixedRadixQuantity MixtureDistribution Mod Modal Mode Modular ModularLambda Module Modulus MoebiusMu Moment Momentary MomentConvert MomentEvaluate MomentGeneratingFunction Monday Monitor MonomialList MonomialOrder MonsterGroupM MorletWavelet MorphologicalBinarize MorphologicalBranchPoints MorphologicalComponents MorphologicalEulerNumber MorphologicalGraph MorphologicalPerimeter MorphologicalTransform Most MouseAnnotation MouseAppearance MouseAppearanceTag MouseButtons Mouseover MousePointerNote MousePosition MovingAverage MovingMedian MoyalDistribution MultiedgeStyle MultilaunchWarning MultiLetterItalics MultiLetterStyle MultilineFunction Multinomial MultinomialDistribution MultinormalDistribution MultiplicativeOrder Multiplicity Multiselection MultivariateHypergeometricDistribution MultivariatePoissonDistribution MultivariateTDistribution ' +
+ 'N NakagamiDistribution NameQ Names NamespaceBox Nand NArgMax NArgMin NBernoulliB NCache NDSolve NDSolveValue Nearest NearestFunction NeedCurrentFrontEndPackagePacket NeedCurrentFrontEndSymbolsPacket NeedlemanWunschSimilarity Needs Negative NegativeBinomialDistribution NegativeMultinomialDistribution NeighborhoodGraph Nest NestedGreaterGreater NestedLessLess NestedScriptRules NestList NestWhile NestWhileList NevilleThetaC NevilleThetaD NevilleThetaN NevilleThetaS NewPrimitiveStyle NExpectation Next NextPrime NHoldAll NHoldFirst NHoldRest NicholsGridLines NicholsPlot NIntegrate NMaximize NMaxValue NMinimize NMinValue NominalVariables NonAssociative NoncentralBetaDistribution NoncentralChiSquareDistribution NoncentralFRatioDistribution NoncentralStudentTDistribution NonCommutativeMultiply NonConstants None NonlinearModelFit NonlocalMeansFilter NonNegative NonPositive Nor NorlundB Norm Normal NormalDistribution NormalGrouping Normalize NormalizedSquaredEuclideanDistance NormalsFunction NormFunction Not NotCongruent NotCupCap NotDoubleVerticalBar Notebook NotebookApply NotebookAutoSave NotebookClose NotebookConvertSettings NotebookCreate NotebookCreateReturnObject NotebookDefault NotebookDelete NotebookDirectory NotebookDynamicExpression NotebookEvaluate NotebookEventActions NotebookFileName NotebookFind NotebookFindReturnObject NotebookGet NotebookGetLayoutInformationPacket NotebookGetMisspellingsPacket NotebookInformation NotebookInterfaceObject NotebookLocate NotebookObject NotebookOpen NotebookOpenReturnObject NotebookPath NotebookPrint NotebookPut NotebookPutReturnObject NotebookRead NotebookResetGeneratedCells Notebooks NotebookSave NotebookSaveAs NotebookSelection NotebookSetupLayoutInformationPacket NotebooksMenu NotebookWrite NotElement NotEqualTilde NotExists NotGreater NotGreaterEqual NotGreaterFullEqual NotGreaterGreater NotGreaterLess NotGreaterSlantEqual NotGreaterTilde NotHumpDownHump NotHumpEqual NotLeftTriangle NotLeftTriangleBar NotLeftTriangleEqual NotLess NotLessEqual NotLessFullEqual NotLessGreater NotLessLess NotLessSlantEqual NotLessTilde NotNestedGreaterGreater NotNestedLessLess NotPrecedes NotPrecedesEqual NotPrecedesSlantEqual NotPrecedesTilde NotReverseElement NotRightTriangle NotRightTriangleBar NotRightTriangleEqual NotSquareSubset NotSquareSubsetEqual NotSquareSuperset NotSquareSupersetEqual NotSubset NotSubsetEqual NotSucceeds NotSucceedsEqual NotSucceedsSlantEqual NotSucceedsTilde NotSuperset NotSupersetEqual NotTilde NotTildeEqual NotTildeFullEqual NotTildeTilde NotVerticalBar NProbability NProduct NProductFactors NRoots NSolve NSum NSumTerms Null NullRecords NullSpace NullWords Number NumberFieldClassNumber NumberFieldDiscriminant NumberFieldFundamentalUnits NumberFieldIntegralBasis NumberFieldNormRepresentatives NumberFieldRegulator NumberFieldRootsOfUnity NumberFieldSignature NumberForm NumberFormat NumberMarks NumberMultiplier NumberPadding NumberPoint NumberQ NumberSeparator ' +
+ 'NumberSigns NumberString Numerator NumericFunction NumericQ NuttallWindow NValues NyquistGridLines NyquistPlot ' +
+ 'O ObservabilityGramian ObservabilityMatrix ObservableDecomposition ObservableModelQ OddQ Off Offset OLEData On ONanGroupON OneIdentity Opacity Open OpenAppend Opener OpenerBox OpenerBoxOptions OpenerView OpenFunctionInspectorPacket Opening OpenRead OpenSpecialOptions OpenTemporary OpenWrite Operate OperatingSystem OptimumFlowData Optional OptionInspectorSettings OptionQ Options OptionsPacket OptionsPattern OptionValue OptionValueBox OptionValueBoxOptions Or Orange Order OrderDistribution OrderedQ Ordering Orderless OrnsteinUhlenbeckProcess Orthogonalize Out Outer OutputAutoOverwrite OutputControllabilityMatrix OutputControllableModelQ OutputForm OutputFormData OutputGrouping OutputMathEditExpression OutputNamePacket OutputResponse OutputSizeLimit OutputStream Over OverBar OverDot Overflow OverHat Overlaps Overlay OverlayBox OverlayBoxOptions Overscript OverscriptBox OverscriptBoxOptions OverTilde OverVector OwenT OwnValues ' +
+ 'PackingMethod PaddedForm Padding PadeApproximant PadLeft PadRight PageBreakAbove PageBreakBelow PageBreakWithin PageFooterLines PageFooters PageHeaderLines PageHeaders PageHeight PageRankCentrality PageWidth PairedBarChart PairedHistogram PairedSmoothHistogram PairedTTest PairedZTest PaletteNotebook PalettePath Pane PaneBox PaneBoxOptions Panel PanelBox PanelBoxOptions Paneled PaneSelector PaneSelectorBox PaneSelectorBoxOptions PaperWidth ParabolicCylinderD ParagraphIndent ParagraphSpacing ParallelArray ParallelCombine ParallelDo ParallelEvaluate Parallelization Parallelize ParallelMap ParallelNeeds ParallelProduct ParallelSubmit ParallelSum ParallelTable ParallelTry Parameter ParameterEstimator ParameterMixtureDistribution ParameterVariables ParametricFunction ParametricNDSolve ParametricNDSolveValue ParametricPlot ParametricPlot3D ParentConnect ParentDirectory ParentForm Parenthesize ParentList ParetoDistribution Part PartialCorrelationFunction PartialD ParticleData Partition PartitionsP PartitionsQ ParzenWindow PascalDistribution PassEventsDown PassEventsUp Paste PasteBoxFormInlineCells PasteButton Path PathGraph PathGraphQ Pattern PatternSequence PatternTest PauliMatrix PaulWavelet Pause PausedTime PDF PearsonChiSquareTest PearsonCorrelationTest PearsonDistribution PerformanceGoal PeriodicInterpolation Periodogram PeriodogramArray PermutationCycles PermutationCyclesQ PermutationGroup PermutationLength PermutationList PermutationListQ PermutationMax PermutationMin PermutationOrder PermutationPower PermutationProduct PermutationReplace Permutations PermutationSupport Permute PeronaMalikFilter Perpendicular PERTDistribution PetersenGraph PhaseMargins Pi Pick PIDData PIDDerivativeFilter PIDFeedforward PIDTune Piecewise PiecewiseExpand PieChart PieChart3D PillaiTrace PillaiTraceTest Pink Pivoting PixelConstrained PixelValue PixelValuePositions Placed Placeholder PlaceholderReplace Plain PlanarGraphQ Play PlayRange Plot Plot3D Plot3Matrix PlotDivision PlotJoined PlotLabel PlotLayout PlotLegends PlotMarkers PlotPoints PlotRange PlotRangeClipping PlotRangePadding PlotRegion PlotStyle Plus PlusMinus Pochhammer PodStates PodWidth Point Point3DBox PointBox PointFigureChart PointForm PointLegend PointSize PoissonConsulDistribution PoissonDistribution PoissonProcess PoissonWindow PolarAxes PolarAxesOrigin PolarGridLines PolarPlot PolarTicks PoleZeroMarkers PolyaAeppliDistribution PolyGamma Polygon Polygon3DBox Polygon3DBoxOptions PolygonBox PolygonBoxOptions PolygonHoleScale PolygonIntersections PolygonScale PolyhedronData PolyLog PolynomialExtendedGCD PolynomialForm PolynomialGCD PolynomialLCM PolynomialMod PolynomialQ PolynomialQuotient PolynomialQuotientRemainder PolynomialReduce PolynomialRemainder Polynomials PopupMenu PopupMenuBox PopupMenuBoxOptions PopupView PopupWindow Position Positive PositiveDefiniteMatrixQ PossibleZeroQ Postfix PostScript Power PowerDistribution PowerExpand PowerMod PowerModList ' +
+ 'PowerSpectralDensity PowersRepresentations PowerSymmetricPolynomial Precedence PrecedenceForm Precedes PrecedesEqual PrecedesSlantEqual PrecedesTilde Precision PrecisionGoal PreDecrement PredictionRoot PreemptProtect PreferencesPath Prefix PreIncrement Prepend PrependTo PreserveImageOptions Previous PriceGraphDistribution PrimaryPlaceholder Prime PrimeNu PrimeOmega PrimePi PrimePowerQ PrimeQ Primes PrimeZetaP PrimitiveRoot PrincipalComponents PrincipalValue Print PrintAction PrintForm PrintingCopies PrintingOptions PrintingPageRange PrintingStartingPageNumber PrintingStyleEnvironment PrintPrecision PrintTemporary Prism PrismBox PrismBoxOptions PrivateCellOptions PrivateEvaluationOptions PrivateFontOptions PrivateFrontEndOptions PrivateNotebookOptions PrivatePaths Probability ProbabilityDistribution ProbabilityPlot ProbabilityPr ProbabilityScalePlot ProbitModelFit ProcessEstimator ProcessParameterAssumptions ProcessParameterQ ProcessStateDomain ProcessTimeDomain Product ProductDistribution ProductLog ProgressIndicator ProgressIndicatorBox ProgressIndicatorBoxOptions Projection Prolog PromptForm Properties Property PropertyList PropertyValue Proportion Proportional Protect Protected ProteinData Pruning PseudoInverse Purple Put PutAppend Pyramid PyramidBox PyramidBoxOptions ' +
+ 'QBinomial QFactorial QGamma QHypergeometricPFQ QPochhammer QPolyGamma QRDecomposition QuadraticIrrationalQ Quantile QuantilePlot Quantity QuantityForm QuantityMagnitude QuantityQ QuantityUnit Quartics QuartileDeviation Quartiles QuartileSkewness QueueingNetworkProcess QueueingProcess QueueProperties Quiet Quit Quotient QuotientRemainder ' +
+ 'RadialityCentrality RadicalBox RadicalBoxOptions RadioButton RadioButtonBar RadioButtonBox RadioButtonBoxOptions Radon RamanujanTau RamanujanTauL RamanujanTauTheta RamanujanTauZ Random RandomChoice RandomComplex RandomFunction RandomGraph RandomImage RandomInteger RandomPermutation RandomPrime RandomReal RandomSample RandomSeed RandomVariate RandomWalkProcess Range RangeFilter RangeSpecification RankedMax RankedMin Raster Raster3D Raster3DBox Raster3DBoxOptions RasterArray RasterBox RasterBoxOptions Rasterize RasterSize Rational RationalFunctions Rationalize Rationals Ratios Raw RawArray RawBoxes RawData RawMedium RayleighDistribution Re Read ReadList ReadProtected Real RealBlockDiagonalForm RealDigits RealExponent Reals Reap Record RecordLists RecordSeparators Rectangle RectangleBox RectangleBoxOptions RectangleChart RectangleChart3D RecurrenceFilter RecurrenceTable RecurringDigitsForm Red Reduce RefBox ReferenceLineStyle ReferenceMarkers ReferenceMarkerStyle Refine ReflectionMatrix ReflectionTransform Refresh RefreshRate RegionBinarize RegionFunction RegionPlot RegionPlot3D RegularExpression Regularization Reinstall Release ReleaseHold ReliabilityDistribution ReliefImage ReliefPlot Remove RemoveAlphaChannel RemoveAsynchronousTask Removed RemoveInputStreamMethod RemoveOutputStreamMethod RemoveProperty RemoveScheduledTask RenameDirectory RenameFile RenderAll RenderingOptions RenewalProcess RenkoChart Repeated RepeatedNull RepeatedString Replace ReplaceAll ReplaceHeldPart ReplaceImageValue ReplaceList ReplacePart ReplacePixelValue ReplaceRepeated Resampling Rescale RescalingTransform ResetDirectory ResetMenusPacket ResetScheduledTask Residue Resolve Rest Resultant ResumePacket Return ReturnExpressionPacket ReturnInputFormPacket ReturnPacket ReturnTextPacket Reverse ReverseBiorthogonalSplineWavelet ReverseElement ReverseEquilibrium ReverseGraph ReverseUpEquilibrium RevolutionAxis RevolutionPlot3D RGBColor RiccatiSolve RiceDistribution RidgeFilter RiemannR RiemannSiegelTheta RiemannSiegelZ Riffle Right RightArrow RightArrowBar RightArrowLeftArrow RightCosetRepresentative RightDownTeeVector RightDownVector RightDownVectorBar RightTee RightTeeArrow RightTeeVector RightTriangle RightTriangleBar RightTriangleEqual RightUpDownVector RightUpTeeVector RightUpVector RightUpVectorBar RightVector RightVectorBar RiskAchievementImportance RiskReductionImportance RogersTanimotoDissimilarity Root RootApproximant RootIntervals RootLocusPlot RootMeanSquare RootOfUnityQ RootReduce Roots RootSum Rotate RotateLabel RotateLeft RotateRight RotationAction RotationBox RotationBoxOptions RotationMatrix RotationTransform Round RoundImplies RoundingRadius Row RowAlignments RowBackgrounds RowBox RowHeights RowLines RowMinHeight RowReduce RowsEqual RowSpacings RSolve RudvalisGroupRu Rule RuleCondition RuleDelayed RuleForm RulerUnits Run RunScheduledTask RunThrough RuntimeAttributes RuntimeOptions RussellRaoDissimilarity ' +
+ 'SameQ SameTest SampleDepth SampledSoundFunction SampledSoundList SampleRate SamplingPeriod SARIMAProcess SARMAProcess SatisfiabilityCount SatisfiabilityInstances SatisfiableQ Saturday Save Saveable SaveAutoDelete SaveDefinitions SawtoothWave Scale Scaled ScaleDivisions ScaledMousePosition ScaleOrigin ScalePadding ScaleRanges ScaleRangeStyle ScalingFunctions ScalingMatrix ScalingTransform Scan ScheduledTaskActiveQ ScheduledTaskData ScheduledTaskObject ScheduledTasks SchurDecomposition ScientificForm ScreenRectangle ScreenStyleEnvironment ScriptBaselineShifts ScriptLevel ScriptMinSize ScriptRules ScriptSizeMultipliers Scrollbars ScrollingOptions ScrollPosition Sec Sech SechDistribution SectionGrouping SectorChart SectorChart3D SectorOrigin SectorSpacing SeedRandom Select Selectable SelectComponents SelectedCells SelectedNotebook Selection SelectionAnimate SelectionCell SelectionCellCreateCell SelectionCellDefaultStyle SelectionCellParentStyle SelectionCreateCell SelectionDebuggerTag SelectionDuplicateCell SelectionEvaluate SelectionEvaluateCreateCell SelectionMove SelectionPlaceholder SelectionSetStyle SelectWithContents SelfLoops SelfLoopStyle SemialgebraicComponentInstances SendMail Sequence SequenceAlignment SequenceForm SequenceHold SequenceLimit Series SeriesCoefficient SeriesData SessionTime Set SetAccuracy SetAlphaChannel SetAttributes Setbacks SetBoxFormNamesPacket SetDelayed SetDirectory SetEnvironment SetEvaluationNotebook SetFileDate SetFileLoadingContext SetNotebookStatusLine SetOptions SetOptionsPacket SetPrecision SetProperty SetSelectedNotebook SetSharedFunction SetSharedVariable SetSpeechParametersPacket SetStreamPosition SetSystemOptions Setter SetterBar SetterBox SetterBoxOptions Setting SetValue Shading Shallow ShannonWavelet ShapiroWilkTest Share Sharpen ShearingMatrix ShearingTransform ShenCastanMatrix Short ShortDownArrow Shortest ShortestMatch ShortestPathFunction ShortLeftArrow ShortRightArrow ShortUpArrow Show ShowAutoStyles ShowCellBracket ShowCellLabel ShowCellTags ShowClosedCellArea ShowContents ShowControls ShowCursorTracker ShowGroupOpenCloseIcon ShowGroupOpener ShowInvisibleCharacters ShowPageBreaks ShowPredictiveInterface ShowSelection ShowShortBoxForm ShowSpecialCharacters ShowStringCharacters ShowSyntaxStyles ShrinkingDelay ShrinkWrapBoundingBox SiegelTheta SiegelTukeyTest Sign Signature SignedRankTest SignificanceLevel SignPadding SignTest SimilarityRules SimpleGraph SimpleGraphQ Simplify Sin Sinc SinghMaddalaDistribution SingleEvaluation SingleLetterItalics SingleLetterStyle SingularValueDecomposition SingularValueList SingularValuePlot SingularValues Sinh SinhIntegral SinIntegral SixJSymbol Skeleton SkeletonTransform SkellamDistribution Skewness SkewNormalDistribution Skip SliceDistribution Slider Slider2D Slider2DBox Slider2DBoxOptions SliderBox SliderBoxOptions SlideView Slot SlotSequence Small SmallCircle Smaller SmithDelayCompensator SmithWatermanSimilarity ' +
+ 'SmoothDensityHistogram SmoothHistogram SmoothHistogram3D SmoothKernelDistribution SocialMediaData Socket SokalSneathDissimilarity Solve SolveAlways SolveDelayed Sort SortBy Sound SoundAndGraphics SoundNote SoundVolume Sow Space SpaceForm Spacer Spacings Span SpanAdjustments SpanCharacterRounding SpanFromAbove SpanFromBoth SpanFromLeft SpanLineThickness SpanMaxSize SpanMinSize SpanningCharacters SpanSymmetric SparseArray SpatialGraphDistribution Speak SpeakTextPacket SpearmanRankTest SpearmanRho Spectrogram SpectrogramArray Specularity SpellingCorrection SpellingDictionaries SpellingDictionariesPath SpellingOptions SpellingSuggestionsPacket Sphere SphereBox SphericalBesselJ SphericalBesselY SphericalHankelH1 SphericalHankelH2 SphericalHarmonicY SphericalPlot3D SphericalRegion SpheroidalEigenvalue SpheroidalJoiningFactor SpheroidalPS SpheroidalPSPrime SpheroidalQS SpheroidalQSPrime SpheroidalRadialFactor SpheroidalS1 SpheroidalS1Prime SpheroidalS2 SpheroidalS2Prime Splice SplicedDistribution SplineClosed SplineDegree SplineKnots SplineWeights Split SplitBy SpokenString Sqrt SqrtBox SqrtBoxOptions Square SquaredEuclideanDistance SquareFreeQ SquareIntersection SquaresR SquareSubset SquareSubsetEqual SquareSuperset SquareSupersetEqual SquareUnion SquareWave StabilityMargins StabilityMarginsStyle StableDistribution Stack StackBegin StackComplete StackInhibit StandardDeviation StandardDeviationFilter StandardForm Standardize StandbyDistribution Star StarGraph StartAsynchronousTask StartingStepSize StartOfLine StartOfString StartScheduledTask StartupSound StateDimensions StateFeedbackGains StateOutputEstimator StateResponse StateSpaceModel StateSpaceRealization StateSpaceTransform StationaryDistribution StationaryWaveletPacketTransform StationaryWaveletTransform StatusArea StatusCentrality StepMonitor StieltjesGamma StirlingS1 StirlingS2 StopAsynchronousTask StopScheduledTask StrataVariables StratonovichProcess StreamColorFunction StreamColorFunctionScaling StreamDensityPlot StreamPlot StreamPoints StreamPosition Streams StreamScale StreamStyle String StringBreak StringByteCount StringCases StringCount StringDrop StringExpression StringForm StringFormat StringFreeQ StringInsert StringJoin StringLength StringMatchQ StringPosition StringQ StringReplace StringReplaceList StringReplacePart StringReverse StringRotateLeft StringRotateRight StringSkeleton StringSplit StringTake StringToStream StringTrim StripBoxes StripOnInput StripWrapperBoxes StrokeForm StructuralImportance StructuredArray StructuredSelection StruveH StruveL Stub StudentTDistribution Style StyleBox StyleBoxAutoDelete StyleBoxOptions StyleData StyleDefinitions StyleForm StyleKeyMapping StyleMenuListing StyleNameDialogSettings StyleNames StylePrint StyleSheetPath Subfactorial Subgraph SubMinus SubPlus SubresultantPolynomialRemainders ' +
+ 'SubresultantPolynomials Subresultants Subscript SubscriptBox SubscriptBoxOptions Subscripted Subset SubsetEqual Subsets SubStar Subsuperscript SubsuperscriptBox SubsuperscriptBoxOptions Subtract SubtractFrom SubValues Succeeds SucceedsEqual SucceedsSlantEqual SucceedsTilde SuchThat Sum SumConvergence Sunday SuperDagger SuperMinus SuperPlus Superscript SuperscriptBox SuperscriptBoxOptions Superset SupersetEqual SuperStar Surd SurdForm SurfaceColor SurfaceGraphics SurvivalDistribution SurvivalFunction SurvivalModel SurvivalModelFit SuspendPacket SuzukiDistribution SuzukiGroupSuz SwatchLegend Switch Symbol SymbolName SymletWavelet Symmetric SymmetricGroup SymmetricMatrixQ SymmetricPolynomial SymmetricReduction Symmetrize SymmetrizedArray SymmetrizedArrayRules SymmetrizedDependentComponents SymmetrizedIndependentComponents SymmetrizedReplacePart SynchronousInitialization SynchronousUpdating Syntax SyntaxForm SyntaxInformation SyntaxLength SyntaxPacket SyntaxQ SystemDialogInput SystemException SystemHelpPath SystemInformation SystemInformationData SystemOpen SystemOptions SystemsModelDelay SystemsModelDelayApproximate SystemsModelDelete SystemsModelDimensions SystemsModelExtract SystemsModelFeedbackConnect SystemsModelLabels SystemsModelOrder SystemsModelParallelConnect SystemsModelSeriesConnect SystemsModelStateFeedbackConnect SystemStub ' +
+ 'Tab TabFilling Table TableAlignments TableDepth TableDirections TableForm TableHeadings TableSpacing TableView TableViewBox TabSpacings TabView TabViewBox TabViewBoxOptions TagBox TagBoxNote TagBoxOptions TaggingRules TagSet TagSetDelayed TagStyle TagUnset Take TakeWhile Tally Tan Tanh TargetFunctions TargetUnits TautologyQ TelegraphProcess TemplateBox TemplateBoxOptions TemplateSlotSequence TemporalData Temporary TemporaryVariable TensorContract TensorDimensions TensorExpand TensorProduct TensorQ TensorRank TensorReduce TensorSymmetry TensorTranspose TensorWedge Tetrahedron TetrahedronBox TetrahedronBoxOptions TeXForm TeXSave Text Text3DBox Text3DBoxOptions TextAlignment TextBand TextBoundingBox TextBox TextCell TextClipboardType TextData TextForm TextJustification TextLine TextPacket TextParagraph TextRecognize TextRendering TextStyle Texture TextureCoordinateFunction TextureCoordinateScaling Therefore ThermometerGauge Thick Thickness Thin Thinning ThisLink ThompsonGroupTh Thread ThreeJSymbol Threshold Through Throw Thumbnail Thursday Ticks TicksStyle Tilde TildeEqual TildeFullEqual TildeTilde TimeConstrained TimeConstraint Times TimesBy TimeSeriesForecast TimeSeriesInvertibility TimeUsed TimeValue TimeZone Timing Tiny TitleGrouping TitsGroupT ToBoxes ToCharacterCode ToColor ToContinuousTimeModel ToDate ToDiscreteTimeModel ToeplitzMatrix ToExpression ToFileName Together Toggle ToggleFalse Toggler TogglerBar TogglerBox TogglerBoxOptions ToHeldExpression ToInvertibleTimeSeries TokenWords Tolerance ToLowerCase ToNumberField TooBig Tooltip TooltipBox TooltipBoxOptions TooltipDelay TooltipStyle Top TopHatTransform TopologicalSort ToRadicals ToRules ToString Total TotalHeight TotalVariationFilter TotalWidth TouchscreenAutoZoom TouchscreenControlPlacement ToUpperCase Tr Trace TraceAbove TraceAction TraceBackward TraceDepth TraceDialog TraceForward TraceInternal TraceLevel TraceOff TraceOn TraceOriginal TracePrint TraceScan TrackedSymbols TradingChart TraditionalForm TraditionalFunctionNotation TraditionalNotation TraditionalOrder TransferFunctionCancel TransferFunctionExpand TransferFunctionFactor TransferFunctionModel TransferFunctionPoles TransferFunctionTransform TransferFunctionZeros TransformationFunction TransformationFunctions TransformationMatrix TransformedDistribution TransformedField Translate TranslationTransform TransparentColor Transpose TreeForm TreeGraph TreeGraphQ TreePlot TrendStyle TriangleWave TriangularDistribution Trig TrigExpand TrigFactor TrigFactorList Trigger TrigReduce TrigToExp TrimmedMean True TrueQ TruncatedDistribution TsallisQExponentialDistribution TsallisQGaussianDistribution TTest Tube TubeBezierCurveBox TubeBezierCurveBoxOptions TubeBox TubeBSplineCurveBox TubeBSplineCurveBoxOptions Tuesday TukeyLambdaDistribution TukeyWindow Tuples TuranGraph TuringMachine ' +
+ 'Transparent ' +
+ 'UnateQ Uncompress Undefined UnderBar Underflow Underlined Underoverscript UnderoverscriptBox UnderoverscriptBoxOptions Underscript UnderscriptBox UnderscriptBoxOptions UndirectedEdge UndirectedGraph UndirectedGraphQ UndocumentedTestFEParserPacket UndocumentedTestGetSelectionPacket Unequal Unevaluated UniformDistribution UniformGraphDistribution UniformSumDistribution Uninstall Union UnionPlus Unique UnitBox UnitConvert UnitDimensions Unitize UnitRootTest UnitSimplify UnitStep UnitTriangle UnitVector Unprotect UnsameQ UnsavedVariables Unset UnsetShared UntrackedVariables Up UpArrow UpArrowBar UpArrowDownArrow Update UpdateDynamicObjects UpdateDynamicObjectsSynchronous UpdateInterval UpDownArrow UpEquilibrium UpperCaseQ UpperLeftArrow UpperRightArrow UpperTriangularize Upsample UpSet UpSetDelayed UpTee UpTeeArrow UpValues URL URLFetch URLFetchAsynchronous URLSave URLSaveAsynchronous UseGraphicsRange Using UsingFrontEnd ' +
+ 'V2Get ValidationLength Value ValueBox ValueBoxOptions ValueForm ValueQ ValuesData Variables Variance VarianceEquivalenceTest VarianceEstimatorFunction VarianceGammaDistribution VarianceTest VectorAngle VectorColorFunction VectorColorFunctionScaling VectorDensityPlot VectorGlyphData VectorPlot VectorPlot3D VectorPoints VectorQ Vectors VectorScale VectorStyle Vee Verbatim Verbose VerboseConvertToPostScriptPacket VerifyConvergence VerifySolutions VerifyTestAssumptions Version VersionNumber VertexAdd VertexCapacity VertexColors VertexComponent VertexConnectivity VertexCoordinateRules VertexCoordinates VertexCorrelationSimilarity VertexCosineSimilarity VertexCount VertexCoverQ VertexDataCoordinates VertexDegree VertexDelete VertexDiceSimilarity VertexEccentricity VertexInComponent VertexInDegree VertexIndex VertexJaccardSimilarity VertexLabeling VertexLabels VertexLabelStyle VertexList VertexNormals VertexOutComponent VertexOutDegree VertexQ VertexRenderingFunction VertexReplace VertexShape VertexShapeFunction VertexSize VertexStyle VertexTextureCoordinates VertexWeight Vertical VerticalBar VerticalForm VerticalGauge VerticalSeparator VerticalSlider VerticalTilde ViewAngle ViewCenter ViewMatrix ViewPoint ViewPointSelectorSettings ViewPort ViewRange ViewVector ViewVertical VirtualGroupData Visible VisibleCell VoigtDistribution VonMisesDistribution ' +
+ 'WaitAll WaitAsynchronousTask WaitNext WaitUntil WakebyDistribution WalleniusHypergeometricDistribution WaringYuleDistribution WatershedComponents WatsonUSquareTest WattsStrogatzGraphDistribution WaveletBestBasis WaveletFilterCoefficients WaveletImagePlot WaveletListPlot WaveletMapIndexed WaveletMatrixPlot WaveletPhi WaveletPsi WaveletScale WaveletScalogram WaveletThreshold WeaklyConnectedComponents WeaklyConnectedGraphQ WeakStationarity WeatherData WeberE Wedge Wednesday WeibullDistribution WeierstrassHalfPeriods WeierstrassInvariants WeierstrassP WeierstrassPPrime WeierstrassSigma WeierstrassZeta WeightedAdjacencyGraph WeightedAdjacencyMatrix WeightedData WeightedGraphQ Weights WelchWindow WheelGraph WhenEvent Which While White Whitespace WhitespaceCharacter WhittakerM WhittakerW WienerFilter WienerProcess WignerD WignerSemicircleDistribution WilksW WilksWTest WindowClickSelect WindowElements WindowFloating WindowFrame WindowFrameElements WindowMargins WindowMovable WindowOpacity WindowSelected WindowSize WindowStatusArea WindowTitle WindowToolbars WindowWidth With WolframAlpha WolframAlphaDate WolframAlphaQuantity WolframAlphaResult Word WordBoundary WordCharacter WordData WordSearch WordSeparators WorkingPrecision Write WriteString Wronskian ' +
+ 'XMLElement XMLObject Xnor Xor ' +
+ 'Yellow YuleDissimilarity ' +
+ 'ZernikeR ZeroSymmetric ZeroTest ZeroWidthTimes Zeta ZetaZero ZipfDistribution ZTest ZTransform ' +
+ '$Aborted $ActivationGroupID $ActivationKey $ActivationUserRegistered $AddOnsDirectory $AssertFunction $Assumptions $AsynchronousTask $BaseDirectory $BatchInput $BatchOutput $BoxForms $ByteOrdering $Canceled $CharacterEncoding $CharacterEncodings $CommandLine $CompilationTarget $ConditionHold $ConfiguredKernels $Context $ContextPath $ControlActiveSetting $CreationDate $CurrentLink $DateStringFormat $DefaultFont $DefaultFrontEnd $DefaultImagingDevice $DefaultPath $Display $DisplayFunction $DistributedContexts $DynamicEvaluation $Echo $Epilog $ExportFormats $Failed $FinancialDataSource $FormatType $FrontEnd $FrontEndSession $GeoLocation $HistoryLength $HomeDirectory $HTTPCookies $IgnoreEOF $ImagingDevices $ImportFormats $InitialDirectory $Input $InputFileName $InputStreamMethods $Inspector $InstallationDate $InstallationDirectory $InterfaceEnvironment $IterationLimit $KernelCount $KernelID $Language $LaunchDirectory $LibraryPath $LicenseExpirationDate $LicenseID $LicenseProcesses $LicenseServer $LicenseSubprocesses $LicenseType $Line $Linked $LinkSupported $LoadedFiles $MachineAddresses $MachineDomain $MachineDomains $MachineEpsilon $MachineID $MachineName $MachinePrecision $MachineType $MaxExtraPrecision $MaxLicenseProcesses $MaxLicenseSubprocesses $MaxMachineNumber $MaxNumber $MaxPiecewiseCases $MaxPrecision $MaxRootDegree $MessageGroups $MessageList $MessagePrePrint $Messages $MinMachineNumber $MinNumber $MinorReleaseNumber $MinPrecision $ModuleNumber $NetworkLicense $NewMessage $NewSymbol $Notebooks $NumberMarks $Off $OperatingSystem $Output $OutputForms $OutputSizeLimit $OutputStreamMethods $Packages $ParentLink $ParentProcessID $PasswordFile $PatchLevelID $Path $PathnameSeparator $PerformanceGoal $PipeSupported $Post $Pre $PreferencesDirectory $PrePrint $PreRead $PrintForms $PrintLiteral $ProcessID $ProcessorCount $ProcessorType $ProductInformation $ProgramName $RandomState $RecursionLimit $ReleaseNumber $RootDirectory $ScheduledTask $ScriptCommandLine $SessionID $SetParentLink $SharedFunctions $SharedVariables $SoundDisplay $SoundDisplayFunction $SuppressInputFormHeads $SynchronousEvaluation $SyntaxHandler $System $SystemCharacterEncoding $SystemID $SystemWordLength $TemporaryDirectory $TemporaryPrefix $TextStyle $TimedOut $TimeUnit $TimeZone $TopDirectory $TraceOff $TraceOn $TracePattern $TracePostAction $TracePreAction $Urgent $UserAddOnsDirectory $UserBaseDirectory $UserDocumentsDirectory $UserName $Version $VersionNumber',
+ contains: [
+ {
+ className: "comment",
+ begin: /\(\*/, end: /\*\)/
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'list',
+ begin: /\{/, end: /\}/,
+ illegal: /:/
+ }
+ ]
+ };
+};
+},{}],84:[function(require,module,exports){
+module.exports = function(hljs) {
+ var COMMON_CONTAINS = [
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'string',
+ begin: '\'', end: '\'',
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
+ }
+ ];
+ var TRANSPOSE = {
+ relevance: 0,
+ contains: [
+ {
+ className: 'operator', begin: /'['\.]*/
+ }
+ ]
+ };
+
+ return {
+ keywords: {
+ keyword:
+ 'break case catch classdef continue else elseif end enumerated events for function ' +
+ 'global if methods otherwise parfor persistent properties return spmd switch try while',
+ built_in:
+ 'sin sind sinh asin asind asinh cos cosd cosh acos acosd acosh tan tand tanh atan ' +
+ 'atand atan2 atanh sec secd sech asec asecd asech csc cscd csch acsc acscd acsch cot ' +
+ 'cotd coth acot acotd acoth hypot exp expm1 log log1p log10 log2 pow2 realpow reallog ' +
+ 'realsqrt sqrt nthroot nextpow2 abs angle complex conj imag real unwrap isreal ' +
+ 'cplxpair fix floor ceil round mod rem sign airy besselj bessely besselh besseli ' +
+ 'besselk beta betainc betaln ellipj ellipke erf erfc erfcx erfinv expint gamma ' +
+ 'gammainc gammaln psi legendre cross dot factor isprime primes gcd lcm rat rats perms ' +
+ 'nchoosek factorial cart2sph cart2pol pol2cart sph2cart hsv2rgb rgb2hsv zeros ones ' +
+ 'eye repmat rand randn linspace logspace freqspace meshgrid accumarray size length ' +
+ 'ndims numel disp isempty isequal isequalwithequalnans cat reshape diag blkdiag tril ' +
+ 'triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute ' +
+ 'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i inf nan ' +
+ 'isnan isinf isfinite j why compan gallery hadamard hankel hilb invhilb magic pascal ' +
+ 'rosser toeplitz vander wilkinson'
+ },
+ illegal: '(//|"|#|/\\*|\\s+/\\w+)',
+ contains: [
+ {
+ className: 'function',
+ beginKeywords: 'function', end: '$',
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)'
+ },
+ {
+ className: 'params',
+ begin: '\\[', end: '\\]'
+ }
+ ]
+ },
+ {
+ begin: /[a-zA-Z_][a-zA-Z_0-9]*'['\.]*/,
+ returnBegin: true,
+ relevance: 0,
+ contains: [
+ {begin: /[a-zA-Z_][a-zA-Z_0-9]*/, relevance: 0},
+ TRANSPOSE.contains[0]
+ ]
+ },
+ {
+ className: 'matrix',
+ begin: '\\[', end: '\\]',
+ contains: COMMON_CONTAINS,
+ relevance: 0,
+ starts: TRANSPOSE
+ },
+ {
+ className: 'cell',
+ begin: '\\{', end: /\}/,
+ contains: COMMON_CONTAINS,
+ relevance: 0,
+ illegal: /:/,
+ starts: TRANSPOSE
+ },
+ {
+ // transpose operators at the end of a function call
+ begin: /\)/,
+ relevance: 0,
+ starts: TRANSPOSE
+ },
+ {
+ className: 'comment',
+ begin: '\\%', end: '$'
+ }
+ ].concat(COMMON_CONTAINS)
+ };
+};
+},{}],85:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords:
+ 'int float string vector matrix if else switch case default while do for in break ' +
+ 'continue global proc return about abs addAttr addAttributeEditorNodeHelp addDynamic ' +
+ 'addNewShelfTab addPP addPanelCategory addPrefixToName advanceToNextDrivenKey ' +
+ 'affectedNet affects aimConstraint air alias aliasAttr align alignCtx alignCurve ' +
+ 'alignSurface allViewFit ambientLight angle angleBetween animCone animCurveEditor ' +
+ 'animDisplay animView annotate appendStringArray applicationName applyAttrPreset ' +
+ 'applyTake arcLenDimContext arcLengthDimension arclen arrayMapper art3dPaintCtx ' +
+ 'artAttrCtx artAttrPaintVertexCtx artAttrSkinPaintCtx artAttrTool artBuildPaintMenu ' +
+ 'artFluidAttrCtx artPuttyCtx artSelectCtx artSetPaintCtx artUserPaintCtx assignCommand ' +
+ 'assignInputDevice assignViewportFactories attachCurve attachDeviceAttr attachSurface ' +
+ 'attrColorSliderGrp attrCompatibility attrControlGrp attrEnumOptionMenu ' +
+ 'attrEnumOptionMenuGrp attrFieldGrp attrFieldSliderGrp attrNavigationControlGrp ' +
+ 'attrPresetEditWin attributeExists attributeInfo attributeMenu attributeQuery ' +
+ 'autoKeyframe autoPlace bakeClip bakeFluidShading bakePartialHistory bakeResults ' +
+ 'bakeSimulation basename basenameEx batchRender bessel bevel bevelPlus binMembership ' +
+ 'bindSkin blend2 blendShape blendShapeEditor blendShapePanel blendTwoAttr blindDataType ' +
+ 'boneLattice boundary boxDollyCtx boxZoomCtx bufferCurve buildBookmarkMenu ' +
+ 'buildKeyframeMenu button buttonManip CBG cacheFile cacheFileCombine cacheFileMerge ' +
+ 'cacheFileTrack camera cameraView canCreateManip canvas capitalizeString catch ' +
+ 'catchQuiet ceil changeSubdivComponentDisplayLevel changeSubdivRegion channelBox ' +
+ 'character characterMap characterOutlineEditor characterize chdir checkBox checkBoxGrp ' +
+ 'checkDefaultRenderGlobals choice circle circularFillet clamp clear clearCache clip ' +
+ 'clipEditor clipEditorCurrentTimeCtx clipSchedule clipSchedulerOutliner clipTrimBefore ' +
+ 'closeCurve closeSurface cluster cmdFileOutput cmdScrollFieldExecuter ' +
+ 'cmdScrollFieldReporter cmdShell coarsenSubdivSelectionList collision color ' +
+ 'colorAtPoint colorEditor colorIndex colorIndexSliderGrp colorSliderButtonGrp ' +
+ 'colorSliderGrp columnLayout commandEcho commandLine commandPort compactHairSystem ' +
+ 'componentEditor compositingInterop computePolysetVolume condition cone confirmDialog ' +
+ 'connectAttr connectControl connectDynamic connectJoint connectionInfo constrain ' +
+ 'constrainValue constructionHistory container containsMultibyte contextInfo control ' +
+ 'convertFromOldLayers convertIffToPsd convertLightmap convertSolidTx convertTessellation ' +
+ 'convertUnit copyArray copyFlexor copyKey copySkinWeights cos cpButton cpCache ' +
+ 'cpClothSet cpCollision cpConstraint cpConvClothToMesh cpForces cpGetSolverAttr cpPanel ' +
+ 'cpProperty cpRigidCollisionFilter cpSeam cpSetEdit cpSetSolverAttr cpSolver ' +
+ 'cpSolverTypes cpTool cpUpdateClothUVs createDisplayLayer createDrawCtx createEditor ' +
+ 'createLayeredPsdFile createMotionField createNewShelf createNode createRenderLayer ' +
+ 'createSubdivRegion cross crossProduct ctxAbort ctxCompletion ctxEditMode ctxTraverse ' +
+ 'currentCtx currentTime currentTimeCtx currentUnit curve curveAddPtCtx ' +
+ 'curveCVCtx curveEPCtx curveEditorCtx curveIntersect curveMoveEPCtx curveOnSurface ' +
+ 'curveSketchCtx cutKey cycleCheck cylinder dagPose date defaultLightListCheckBox ' +
+ 'defaultNavigation defineDataServer defineVirtualDevice deformer deg_to_rad delete ' +
+ 'deleteAttr deleteShadingGroupsAndMaterials deleteShelfTab deleteUI deleteUnusedBrushes ' +
+ 'delrandstr detachCurve detachDeviceAttr detachSurface deviceEditor devicePanel dgInfo ' +
+ 'dgdirty dgeval dgtimer dimWhen directKeyCtx directionalLight dirmap dirname disable ' +
+ 'disconnectAttr disconnectJoint diskCache displacementToPoly displayAffected ' +
+ 'displayColor displayCull displayLevelOfDetail displayPref displayRGBColor ' +
+ 'displaySmoothness displayStats displayString displaySurface distanceDimContext ' +
+ 'distanceDimension doBlur dolly dollyCtx dopeSheetEditor dot dotProduct ' +
+ 'doubleProfileBirailSurface drag dragAttrContext draggerContext dropoffLocator ' +
+ 'duplicate duplicateCurve duplicateSurface dynCache dynControl dynExport dynExpression ' +
+ 'dynGlobals dynPaintEditor dynParticleCtx dynPref dynRelEdPanel dynRelEditor ' +
+ 'dynamicLoad editAttrLimits editDisplayLayerGlobals editDisplayLayerMembers ' +
+ 'editRenderLayerAdjustment editRenderLayerGlobals editRenderLayerMembers editor ' +
+ 'editorTemplate effector emit emitter enableDevice encodeString endString endsWith env ' +
+ 'equivalent equivalentTol erf error eval evalDeferred evalEcho event ' +
+ 'exactWorldBoundingBox exclusiveLightCheckBox exec executeForEachObject exists exp ' +
+ 'expression expressionEditorListen extendCurve extendSurface extrude fcheck fclose feof ' +
+ 'fflush fgetline fgetword file fileBrowserDialog fileDialog fileExtension fileInfo ' +
+ 'filetest filletCurve filter filterCurve filterExpand filterStudioImport ' +
+ 'findAllIntersections findAnimCurves findKeyframe findMenuItem findRelatedSkinCluster ' +
+ 'finder firstParentOf fitBspline flexor floatEq floatField floatFieldGrp floatScrollBar ' +
+ 'floatSlider floatSlider2 floatSliderButtonGrp floatSliderGrp floor flow fluidCacheInfo ' +
+ 'fluidEmitter fluidVoxelInfo flushUndo fmod fontDialog fopen formLayout format fprint ' +
+ 'frameLayout fread freeFormFillet frewind fromNativePath fwrite gamma gauss ' +
+ 'geometryConstraint getApplicationVersionAsFloat getAttr getClassification ' +
+ 'getDefaultBrush getFileList getFluidAttr getInputDeviceRange getMayaPanelTypes ' +
+ 'getModifiers getPanel getParticleAttr getPluginResource getenv getpid glRender ' +
+ 'glRenderEditor globalStitch gmatch goal gotoBindPose grabColor gradientControl ' +
+ 'gradientControlNoAttr graphDollyCtx graphSelectContext graphTrackCtx gravity grid ' +
+ 'gridLayout group groupObjectsByName HfAddAttractorToAS HfAssignAS HfBuildEqualMap ' +
+ 'HfBuildFurFiles HfBuildFurImages HfCancelAFR HfConnectASToHF HfCreateAttractor ' +
+ 'HfDeleteAS HfEditAS HfPerformCreateAS HfRemoveAttractorFromAS HfSelectAttached ' +
+ 'HfSelectAttractors HfUnAssignAS hardenPointCurve hardware hardwareRenderPanel ' +
+ 'headsUpDisplay headsUpMessage help helpLine hermite hide hilite hitTest hotBox hotkey ' +
+ 'hotkeyCheck hsv_to_rgb hudButton hudSlider hudSliderButton hwReflectionMap hwRender ' +
+ 'hwRenderLoad hyperGraph hyperPanel hyperShade hypot iconTextButton iconTextCheckBox ' +
+ 'iconTextRadioButton iconTextRadioCollection iconTextScrollList iconTextStaticLabel ' +
+ 'ikHandle ikHandleCtx ikHandleDisplayScale ikSolver ikSplineHandleCtx ikSystem ' +
+ 'ikSystemInfo ikfkDisplayMethod illustratorCurves image imfPlugins inheritTransform ' +
+ 'insertJoint insertJointCtx insertKeyCtx insertKnotCurve insertKnotSurface instance ' +
+ 'instanceable instancer intField intFieldGrp intScrollBar intSlider intSliderGrp ' +
+ 'interToUI internalVar intersect iprEngine isAnimCurve isConnected isDirty isParentOf ' +
+ 'isSameObject isTrue isValidObjectName isValidString isValidUiName isolateSelect ' +
+ 'itemFilter itemFilterAttr itemFilterRender itemFilterType joint jointCluster jointCtx ' +
+ 'jointDisplayScale jointLattice keyTangent keyframe keyframeOutliner ' +
+ 'keyframeRegionCurrentTimeCtx keyframeRegionDirectKeyCtx keyframeRegionDollyCtx ' +
+ 'keyframeRegionInsertKeyCtx keyframeRegionMoveKeyCtx keyframeRegionScaleKeyCtx ' +
+ 'keyframeRegionSelectKeyCtx keyframeRegionSetKeyCtx keyframeRegionTrackCtx ' +
+ 'keyframeStats lassoContext lattice latticeDeformKeyCtx launch launchImageEditor ' +
+ 'layerButton layeredShaderPort layeredTexturePort layout layoutDialog lightList ' +
+ 'lightListEditor lightListPanel lightlink lineIntersection linearPrecision linstep ' +
+ 'listAnimatable listAttr listCameras listConnections listDeviceAttachments listHistory ' +
+ 'listInputDeviceAxes listInputDeviceButtons listInputDevices listMenuAnnotation ' +
+ 'listNodeTypes listPanelCategories listRelatives listSets listTransforms ' +
+ 'listUnselected listerEditor loadFluid loadNewShelf loadPlugin ' +
+ 'loadPluginLanguageResources loadPrefObjects localizedPanelLabel lockNode loft log ' +
+ 'longNameOf lookThru ls lsThroughFilter lsType lsUI Mayatomr mag makeIdentity makeLive ' +
+ 'makePaintable makeRoll makeSingleSurface makeTubeOn makebot manipMoveContext ' +
+ 'manipMoveLimitsCtx manipOptions manipRotateContext manipRotateLimitsCtx ' +
+ 'manipScaleContext manipScaleLimitsCtx marker match max memory menu menuBarLayout ' +
+ 'menuEditor menuItem menuItemToShelf menuSet menuSetPref messageLine min minimizeApp ' +
+ 'mirrorJoint modelCurrentTimeCtx modelEditor modelPanel mouse movIn movOut move ' +
+ 'moveIKtoFK moveKeyCtx moveVertexAlongDirection multiProfileBirailSurface mute ' +
+ 'nParticle nameCommand nameField namespace namespaceInfo newPanelItems newton nodeCast ' +
+ 'nodeIconButton nodeOutliner nodePreset nodeType noise nonLinear normalConstraint ' +
+ 'normalize nurbsBoolean nurbsCopyUVSet nurbsCube nurbsEditUV nurbsPlane nurbsSelect ' +
+ 'nurbsSquare nurbsToPoly nurbsToPolygonsPref nurbsToSubdiv nurbsToSubdivPref ' +
+ 'nurbsUVSet nurbsViewDirectionVector objExists objectCenter objectLayer objectType ' +
+ 'objectTypeUI obsoleteProc oceanNurbsPreviewPlane offsetCurve offsetCurveOnSurface ' +
+ 'offsetSurface openGLExtension openMayaPref optionMenu optionMenuGrp optionVar orbit ' +
+ 'orbitCtx orientConstraint outlinerEditor outlinerPanel overrideModifier ' +
+ 'paintEffectsDisplay pairBlend palettePort paneLayout panel panelConfiguration ' +
+ 'panelHistory paramDimContext paramDimension paramLocator parent parentConstraint ' +
+ 'particle particleExists particleInstancer particleRenderInfo partition pasteKey ' +
+ 'pathAnimation pause pclose percent performanceOptions pfxstrokes pickWalk picture ' +
+ 'pixelMove planarSrf plane play playbackOptions playblast plugAttr plugNode pluginInfo ' +
+ 'pluginResourceUtil pointConstraint pointCurveConstraint pointLight pointMatrixMult ' +
+ 'pointOnCurve pointOnSurface pointPosition poleVectorConstraint polyAppend ' +
+ 'polyAppendFacetCtx polyAppendVertex polyAutoProjection polyAverageNormal ' +
+ 'polyAverageVertex polyBevel polyBlendColor polyBlindData polyBoolOp polyBridgeEdge ' +
+ 'polyCacheMonitor polyCheck polyChipOff polyClipboard polyCloseBorder polyCollapseEdge ' +
+ 'polyCollapseFacet polyColorBlindData polyColorDel polyColorPerVertex polyColorSet ' +
+ 'polyCompare polyCone polyCopyUV polyCrease polyCreaseCtx polyCreateFacet ' +
+ 'polyCreateFacetCtx polyCube polyCut polyCutCtx polyCylinder polyCylindricalProjection ' +
+ 'polyDelEdge polyDelFacet polyDelVertex polyDuplicateAndConnect polyDuplicateEdge ' +
+ 'polyEditUV polyEditUVShell polyEvaluate polyExtrudeEdge polyExtrudeFacet ' +
+ 'polyExtrudeVertex polyFlipEdge polyFlipUV polyForceUV polyGeoSampler polyHelix ' +
+ 'polyInfo polyInstallAction polyLayoutUV polyListComponentConversion polyMapCut ' +
+ 'polyMapDel polyMapSew polyMapSewMove polyMergeEdge polyMergeEdgeCtx polyMergeFacet ' +
+ 'polyMergeFacetCtx polyMergeUV polyMergeVertex polyMirrorFace polyMoveEdge ' +
+ 'polyMoveFacet polyMoveFacetUV polyMoveUV polyMoveVertex polyNormal polyNormalPerVertex ' +
+ 'polyNormalizeUV polyOptUvs polyOptions polyOutput polyPipe polyPlanarProjection ' +
+ 'polyPlane polyPlatonicSolid polyPoke polyPrimitive polyPrism polyProjection ' +
+ 'polyPyramid polyQuad polyQueryBlindData polyReduce polySelect polySelectConstraint ' +
+ 'polySelectConstraintMonitor polySelectCtx polySelectEditCtx polySeparate ' +
+ 'polySetToFaceNormal polySewEdge polyShortestPathCtx polySmooth polySoftEdge ' +
+ 'polySphere polySphericalProjection polySplit polySplitCtx polySplitEdge polySplitRing ' +
+ 'polySplitVertex polyStraightenUVBorder polySubdivideEdge polySubdivideFacet ' +
+ 'polyToSubdiv polyTorus polyTransfer polyTriangulate polyUVSet polyUnite polyWedgeFace ' +
+ 'popen popupMenu pose pow preloadRefEd print progressBar progressWindow projFileViewer ' +
+ 'projectCurve projectTangent projectionContext projectionManip promptDialog propModCtx ' +
+ 'propMove psdChannelOutliner psdEditTextureFile psdExport psdTextureFile putenv pwd ' +
+ 'python querySubdiv quit rad_to_deg radial radioButton radioButtonGrp radioCollection ' +
+ 'radioMenuItemCollection rampColorPort rand randomizeFollicles randstate rangeControl ' +
+ 'readTake rebuildCurve rebuildSurface recordAttr recordDevice redo reference ' +
+ 'referenceEdit referenceQuery refineSubdivSelectionList refresh refreshAE ' +
+ 'registerPluginResource rehash reloadImage removeJoint removeMultiInstance ' +
+ 'removePanelCategory rename renameAttr renameSelectionList renameUI render ' +
+ 'renderGlobalsNode renderInfo renderLayerButton renderLayerParent ' +
+ 'renderLayerPostProcess renderLayerUnparent renderManip renderPartition ' +
+ 'renderQualityNode renderSettings renderThumbnailUpdate renderWindowEditor ' +
+ 'renderWindowSelectContext renderer reorder reorderDeformers requires reroot ' +
+ 'resampleFluid resetAE resetPfxToPolyCamera resetTool resolutionNode retarget ' +
+ 'reverseCurve reverseSurface revolve rgb_to_hsv rigidBody rigidSolver roll rollCtx ' +
+ 'rootOf rot rotate rotationInterpolation roundConstantRadius rowColumnLayout rowLayout ' +
+ 'runTimeCommand runup sampleImage saveAllShelves saveAttrPreset saveFluid saveImage ' +
+ 'saveInitialState saveMenu savePrefObjects savePrefs saveShelf saveToolSettings scale ' +
+ 'scaleBrushBrightness scaleComponents scaleConstraint scaleKey scaleKeyCtx sceneEditor ' +
+ 'sceneUIReplacement scmh scriptCtx scriptEditorInfo scriptJob scriptNode scriptTable ' +
+ 'scriptToShelf scriptedPanel scriptedPanelType scrollField scrollLayout sculpt ' +
+ 'searchPathArray seed selLoadSettings select selectContext selectCurveCV selectKey ' +
+ 'selectKeyCtx selectKeyframeRegionCtx selectMode selectPref selectPriority selectType ' +
+ 'selectedNodes selectionConnection separator setAttr setAttrEnumResource ' +
+ 'setAttrMapping setAttrNiceNameResource setConstraintRestPosition ' +
+ 'setDefaultShadingGroup setDrivenKeyframe setDynamic setEditCtx setEditor setFluidAttr ' +
+ 'setFocus setInfinity setInputDeviceMapping setKeyCtx setKeyPath setKeyframe ' +
+ 'setKeyframeBlendshapeTargetWts setMenuMode setNodeNiceNameResource setNodeTypeFlag ' +
+ 'setParent setParticleAttr setPfxToPolyCamera setPluginResource setProject ' +
+ 'setStampDensity setStartupMessage setState setToolTo setUITemplate setXformManip sets ' +
+ 'shadingConnection shadingGeometryRelCtx shadingLightRelCtx shadingNetworkCompare ' +
+ 'shadingNode shapeCompare shelfButton shelfLayout shelfTabLayout shellField ' +
+ 'shortNameOf showHelp showHidden showManipCtx showSelectionInTitle ' +
+ 'showShadingGroupAttrEditor showWindow sign simplify sin singleProfileBirailSurface ' +
+ 'size sizeBytes skinCluster skinPercent smoothCurve smoothTangentSurface smoothstep ' +
+ 'snap2to2 snapKey snapMode snapTogetherCtx snapshot soft softMod softModCtx sort sound ' +
+ 'soundControl source spaceLocator sphere sphrand spotLight spotLightPreviewPort ' +
+ 'spreadSheetEditor spring sqrt squareSurface srtContext stackTrace startString ' +
+ 'startsWith stitchAndExplodeShell stitchSurface stitchSurfacePoints strcmp ' +
+ 'stringArrayCatenate stringArrayContains stringArrayCount stringArrayInsertAtIndex ' +
+ 'stringArrayIntersector stringArrayRemove stringArrayRemoveAtIndex ' +
+ 'stringArrayRemoveDuplicates stringArrayRemoveExact stringArrayToString ' +
+ 'stringToStringArray strip stripPrefixFromName stroke subdAutoProjection ' +
+ 'subdCleanTopology subdCollapse subdDuplicateAndConnect subdEditUV ' +
+ 'subdListComponentConversion subdMapCut subdMapSewMove subdMatchTopology subdMirror ' +
+ 'subdToBlind subdToPoly subdTransferUVsToCache subdiv subdivCrease ' +
+ 'subdivDisplaySmoothness substitute substituteAllString substituteGeometry substring ' +
+ 'surface surfaceSampler surfaceShaderList swatchDisplayPort switchTable symbolButton ' +
+ 'symbolCheckBox sysFile system tabLayout tan tangentConstraint texLatticeDeformContext ' +
+ 'texManipContext texMoveContext texMoveUVShellContext texRotateContext texScaleContext ' +
+ 'texSelectContext texSelectShortestPathCtx texSmudgeUVContext texWinToolCtx text ' +
+ 'textCurves textField textFieldButtonGrp textFieldGrp textManip textScrollList ' +
+ 'textToShelf textureDisplacePlane textureHairColor texturePlacementContext ' +
+ 'textureWindow threadCount threePointArcCtx timeControl timePort timerX toNativePath ' +
+ 'toggle toggleAxis toggleWindowVisibility tokenize tokenizeList tolerance tolower ' +
+ 'toolButton toolCollection toolDropped toolHasOptions toolPropertyWindow torus toupper ' +
+ 'trace track trackCtx transferAttributes transformCompare transformLimits translator ' +
+ 'trim trunc truncateFluidCache truncateHairCache tumble tumbleCtx turbulence ' +
+ 'twoPointArcCtx uiRes uiTemplate unassignInputDevice undo undoInfo ungroup uniform unit ' +
+ 'unloadPlugin untangleUV untitledFileName untrim upAxis updateAE userCtx uvLink ' +
+ 'uvSnapshot validateShelfName vectorize view2dToolCtx viewCamera viewClipPlane ' +
+ 'viewFit viewHeadOn viewLookAt viewManip viewPlace viewSet visor volumeAxis vortex ' +
+ 'waitCursor warning webBrowser webBrowserPrefs whatIs window windowPref wire ' +
+ 'wireContext workspace wrinkle wrinkleContext writeTake xbmLangPathList xform',
+ illegal: '',
+ contains: [
+ hljs.C_NUMBER_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ begin: '`', end: '`',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ className: 'variable',
+ variants: [
+ {begin: '\\$\\d'},
+ {begin: '[\\$\\%\\@](\\^\\w\\b|#\\w+|[^\\s\\w{]|{\\w+}|\\w+)'},
+ {begin: '\\*(\\^\\w\\b|#\\w+|[^\\s\\w{]|{\\w+}|\\w+)', relevance: 0}
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ]
+ };
+};
+},{}],86:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: [
+ "environ vocabularies notations constructors definitions registrations theorems schemes requirements",
+ "begin end definition registration cluster existence pred func defpred deffunc theorem proof",
+ "let take assume then thus hence ex for st holds consider reconsider such that and in provided of as from",
+ "be being by means equals implies iff redefine define now not or attr is mode suppose per cases set",
+ "thesis contradiction scheme reserve struct",
+ "correctness compatibility coherence symmetry assymetry reflexivity irreflexivity",
+ "connectedness uniqueness commutativity idempotence involutiveness projectivity"
+ ].join(" "),
+ contains: [
+ {
+ className: "comment",
+ begin: "::", end: "$"
+ }
+ ]
+ };
+};
+},{}],87:[function(require,module,exports){
+module.exports = function(hljs) {
+ var NUMBER = {
+ variants: [
+ {
+ className: 'number',
+ begin: '[$][a-fA-F0-9]+'
+ },
+ hljs.NUMBER_MODE
+ ]
+ }
+
+ return {
+ case_insensitive: true,
+ keywords: {
+ keyword: 'public private property continue exit extern new try catch ' +
+ 'eachin not abstract final select case default const local global field ' +
+ 'end if then else elseif endif while wend repeat until forever for to step next return module inline throw',
+
+ built_in: 'DebugLog DebugStop Error Print ACos ACosr ASin ASinr ATan ATan2 ATan2r ATanr Abs Abs Ceil ' +
+ 'Clamp Clamp Cos Cosr Exp Floor Log Max Max Min Min Pow Sgn Sgn Sin Sinr Sqrt Tan Tanr Seed PI HALFPI TWOPI',
+
+ literal: 'true false null and or shl shr mod'
+ },
+ contains: [
+ {
+ className: 'comment',
+ begin: '#rem', end: '#end'
+ },
+ {
+ className: 'comment',
+ begin: "'", end: '$',
+ relevance: 0
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function method', end: '[(=:]|$',
+ illegal: /\n/,
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE,
+ ]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '$',
+ contains: [
+ {
+ beginKeywords: 'extends implements'
+ },
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ {
+ className: 'variable',
+ begin: '\\b(self|super)\\b'
+ },
+ {
+ className: 'preprocessor',
+ beginKeywords: 'import',
+ end: '$'
+ },
+ {
+ className: 'preprocessor',
+ begin: '\\s*#', end: '$',
+ keywords: 'if else elseif endif end then'
+ },
+ {
+ className: 'pi',
+ begin: '^\\s*strict\\b'
+ },
+ {
+ beginKeywords: 'alias', end: '=',
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
+ },
+ hljs.QUOTE_STRING_MODE,
+ NUMBER
+ ]
+ }
+};
+},{}],88:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VAR = {
+ className: 'variable',
+ variants: [
+ {begin: /\$\d+/},
+ {begin: /\$\{/, end: /}/},
+ {begin: '[\\$\\@]' + hljs.UNDERSCORE_IDENT_RE}
+ ]
+ };
+ var DEFAULT = {
+ endsWithParent: true,
+ lexemes: '[a-z/_]+',
+ keywords: {
+ built_in:
+ 'on off yes no true false none blocked debug info notice warn error crit ' +
+ 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
+ },
+ relevance: 0,
+ illegal: '=>',
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE, VAR],
+ variants: [
+ {begin: /"/, end: /"/},
+ {begin: /'/, end: /'/}
+ ]
+ },
+ {
+ className: 'url',
+ begin: '([a-z]+):/', end: '\\s', endsWithParent: true, excludeEnd: true,
+ contains: [VAR]
+ },
+ {
+ className: 'regexp',
+ contains: [hljs.BACKSLASH_ESCAPE, VAR],
+ variants: [
+ {begin: "\\s\\^", end: "\\s|{|;", returnEnd: true},
+ // regexp locations (~, ~*)
+ {begin: "~\\*?\\s+", end: "\\s|{|;", returnEnd: true},
+ // *.example.com
+ {begin: "\\*(\\.[a-z\\-]+)+"},
+ // sub.example.*
+ {begin: "([a-z\\-]+\\.)+\\*"}
+ ]
+ },
+ // IP
+ {
+ className: 'number',
+ begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
+ },
+ // units
+ {
+ className: 'number',
+ begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
+ relevance: 0
+ },
+ VAR
+ ]
+ };
+
+ return {
+ aliases: ['nginxconf'],
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {
+ begin: hljs.UNDERSCORE_IDENT_RE + '\\s', end: ';|{', returnBegin: true,
+ contains: [
+ {
+ className: 'title',
+ begin: hljs.UNDERSCORE_IDENT_RE,
+ starts: DEFAULT
+ }
+ ],
+ relevance: 0
+ }
+ ],
+ illegal: '[^\\s\\}]'
+ };
+};
+},{}],89:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword: 'addr and as asm bind block break|0 case|0 cast const|0 continue|0 converter discard distinct|10 div do elif else|0 end|0 enum|0 except export finally for from generic if|0 import|0 in include|0 interface is isnot|10 iterator|10 let|0 macro method|10 mixin mod nil not notin|10 object|0 of or out proc|10 ptr raise ref|10 return shl shr static template|10 try|0 tuple type|0 using|0 var|0 when while|0 with without xor yield',
+ literal: 'shared guarded stdin stdout stderr result|10 true false'
+ },
+ contains: [ {
+ className: 'decorator', // Actually pragma
+ begin: /{\./,
+ end: /\.}/,
+ relevance: 10
+ }, {
+ className: 'string',
+ begin: /[a-zA-Z]\w*"/,
+ end: /"/,
+ contains: [{begin: /""/}]
+ }, {
+ className: 'string',
+ begin: /([a-zA-Z]\w*)?"""/,
+ end: /"""/
+ }, {
+ className: 'string',
+ begin: /"/,
+ end: /"/,
+ illegal: /\n/,
+ contains: [{begin: /\\./}]
+ }, {
+ className: 'type',
+ begin: /\b[A-Z]\w+\b/,
+ relevance: 0
+ }, {
+ className: 'type',
+ begin: /\b(int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|float32|float64|bool|char|string|cstring|pointer|expr|stmt|void|auto|any|range|array|openarray|varargs|seq|set|clong|culong|cchar|cschar|cshort|cint|csize|clonglong|cfloat|cdouble|clongdouble|cuchar|cushort|cuint|culonglong|cstringarray|semistatic)\b/
+ }, {
+ className: 'number',
+ begin: /\b(0[xX][0-9a-fA-F][_0-9a-fA-F]*)('?[iIuU](8|16|32|64))?/,
+ relevance: 0
+ }, {
+ className: 'number',
+ begin: /\b(0o[0-7][_0-7]*)('?[iIuUfF](8|16|32|64))?/,
+ relevance: 0
+ }, {
+ className: 'number',
+ begin: /\b(0(b|B)[01][_01]*)('?[iIuUfF](8|16|32|64))?/,
+ relevance: 0
+ }, {
+ className: 'number',
+ begin: /\b(\d[_\d]*)('?[iIuUfF](8|16|32|64))?/,
+ relevance: 0
+ },
+ hljs.HASH_COMMENT_MODE
+ ]
+ }
+};
+},{}],90:[function(require,module,exports){
+module.exports = function(hljs) {
+ var NIX_KEYWORDS = {
+ keyword: 'rec with let in inherit assert if else then',
+ constant: 'true false or and null',
+ built_in:
+ 'import abort baseNameOf dirOf isNull builtins map removeAttrs throw toString derivation'
+ };
+ var ANTIQUOTE = {
+ className: 'subst',
+ begin: /\$\{/,
+ end: /\}/,
+ keywords: NIX_KEYWORDS
+ };
+ var ATTRS = {
+ className: 'variable',
+ // TODO: we have to figure out a way how to exclude \s*=
+ begin: /[a-zA-Z0-9-_]+(\s*=)/
+ };
+ var SINGLE_QUOTE = {
+ className: 'string',
+ begin: "''",
+ end: "''",
+ contains: [
+ ANTIQUOTE
+ ]
+ };
+ var DOUBLE_QUOTE = {
+ className: 'string',
+ begin: '"',
+ end: '"',
+ contains: [
+ ANTIQUOTE
+ ]
+ };
+ var EXPRESSIONS = [
+ hljs.NUMBER_MODE,
+ hljs.HASH_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ SINGLE_QUOTE,
+ DOUBLE_QUOTE,
+ ATTRS
+ ];
+ ANTIQUOTE.contains = EXPRESSIONS;
+ return {
+ aliases: ["nixos"],
+ keywords: NIX_KEYWORDS,
+ contains: EXPRESSIONS
+ };
+};
+},{}],91:[function(require,module,exports){
+module.exports = function(hljs) {
+ var CONSTANTS = {
+ className: 'symbol',
+ begin: '\\$(ADMINTOOLS|APPDATA|CDBURN_AREA|CMDLINE|COMMONFILES32|COMMONFILES64|COMMONFILES|COOKIES|DESKTOP|DOCUMENTS|EXEDIR|EXEFILE|EXEPATH|FAVORITES|FONTS|HISTORY|HWNDPARENT|INSTDIR|INTERNET_CACHE|LANGUAGE|LOCALAPPDATA|MUSIC|NETHOOD|OUTDIR|PICTURES|PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES32|PROGRAMFILES64|PROGRAMFILES|QUICKLAUNCH|RECENT|RESOURCES_LOCALIZED|RESOURCES|SENDTO|SMPROGRAMS|SMSTARTUP|STARTMENU|SYSDIR|TEMP|TEMPLATES|VIDEOS|WINDIR)'
+ };
+
+ var DEFINES = {
+ // ${defines}
+ className: 'constant',
+ begin: '\\$+{[a-zA-Z0-9_]+}'
+ };
+
+ var VARIABLES = {
+ // $variables
+ className: 'variable',
+ begin: '\\$+[a-zA-Z0-9_]+',
+ illegal: '\\(\\){}'
+ };
+
+ var LANGUAGES = {
+ // $(language_strings)
+ className: 'constant',
+ begin: '\\$+\\([a-zA-Z0-9_]+\\)'
+ };
+
+ var PARAMETERS = {
+ // command parameters
+ className: 'params',
+ begin: '(ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)'
+ };
+
+ var COMPILER ={
+ // !compiler_flags
+ className: 'constant',
+ begin: '\\!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversionsystem|ifdef|ifmacrodef|ifmacrondef|ifndef|if|include|insertmacro|macroend|macro|makensis|packhdr|searchparse|searchreplace|tempfile|undef|verbose|warning)'
+ };
+
+ return {
+ case_insensitive: false,
+ keywords: {
+ keyword:
+ 'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirText DirVar DirVerify EnableWindow EnumRegKey EnumRegValue Exch Exec ExecShell ExecWait ExpandEnvStrings File FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileReadUTF16LE FileReadWord FileSeek FileWrite FileWriteByte FileWriteUTF16LE FileWriteWord FindClose FindFirst FindNext FindWindow FlushINI FunctionEnd GetCurInstType GetCurrentAddress GetDlgItem GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal GetFullPathName GetFunctionAddress GetInstDirError GetLabelAddress GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfSilent InitPluginsDir InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText InstTypeSetText IntCmp IntCmpU IntFmt IntOp IsWindow LangString LicenseBkColor LicenseData LicenseForceSelection LicenseLangString LicenseText LoadLanguageFile LockWindow LogSet LogText ManifestDPIAware ManifestSupportedOS MessageBox MiscButtonText Name Nop OutFile Page PageCallbacks PageExEnd Pop Push Quit ReadEnvStr ReadINIStr ReadRegDWORD ReadRegStr Reboot RegDLL Rename RequestExecutionLevel ReserveFile Return RMDir SearchPath SectionEnd SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText SectionGroupEnd SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress SetCompressor SetCompressorDictSize SetCtlColors SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrorLevel SetErrors SetFileAttributes SetFont SetOutPath SetOverwrite SetPluginUnload SetRebootFlag SetRegView SetShellVarContext SetSilent ShowInstDetails ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCmpS StrCpy StrLen SubCaption SubSectionEnd Unicode UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText UninstPage UnRegDLL Var VIAddVersionKey VIFileVersion VIProductVersion WindowIcon WriteINIStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegStr WriteUninstaller XPStyle',
+ literal:
+ 'admin all auto both colored current false force hide highest lastused leave listonly none normal notset off on open print show silent silentlog smooth textonly true user '
+ },
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'string',
+ begin: '"', end: '"',
+ illegal: '\\n',
+ contains: [
+ { // $\n, $\r, $\t, $$
+ className: 'symbol',
+ begin: '\\$(\\\\(n|r|t)|\\$)'
+ },
+ CONSTANTS,
+ DEFINES,
+ VARIABLES,
+ LANGUAGES
+ ]
+ },
+ { // line comments
+ className: 'comment',
+ begin: ';', end: '$',
+ relevance: 0
+ },
+ {
+ className: 'function',
+ beginKeywords: 'Function PageEx Section SectionGroup SubSection', end: '$'
+ },
+ COMPILER,
+ DEFINES,
+ VARIABLES,
+ LANGUAGES,
+ PARAMETERS,
+ hljs.NUMBER_MODE,
+ { // plug::ins
+ className: 'literal',
+ begin: hljs.IDENT_RE + '::' + hljs.IDENT_RE
+ }
+ ]
+ };
+};
+},{}],92:[function(require,module,exports){
+module.exports = function(hljs) {
+ var OBJC_KEYWORDS = {
+ keyword:
+ 'int float while char export sizeof typedef const struct for union ' +
+ 'unsigned long volatile static bool mutable if do return goto void ' +
+ 'enum else break extern asm case short default double register explicit ' +
+ 'signed typename this switch continue wchar_t inline readonly assign ' +
+ 'readwrite self @synchronized id typeof ' +
+ 'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
+ 'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
+ '@private @protected @public @try @property @end @throw @catch @finally ' +
+ '@autoreleasepool @synthesize @dynamic @selector @optional @required',
+ literal:
+ 'false true FALSE TRUE nil YES NO NULL',
+ built_in:
+ 'NSString NSData NSDictionary CGRect CGPoint UIButton UILabel UITextView UIWebView MKMapView ' +
+ 'NSView NSViewController NSWindow NSWindowController NSSet NSUUID NSIndexSet ' +
+ 'UISegmentedControl NSObject UITableViewDelegate UITableViewDataSource NSThread ' +
+ 'UIActivityIndicator UITabbar UIToolBar UIBarButtonItem UIImageView NSAutoreleasePool ' +
+ 'UITableView BOOL NSInteger CGFloat NSException NSLog NSMutableString NSMutableArray ' +
+ 'NSMutableDictionary NSURL NSIndexPath CGSize UITableViewCell UIView UIViewController ' +
+ 'UINavigationBar UINavigationController UITabBarController UIPopoverController ' +
+ 'UIPopoverControllerDelegate UIImage NSNumber UISearchBar NSFetchedResultsController ' +
+ 'NSFetchedResultsChangeType UIScrollView UIScrollViewDelegate UIEdgeInsets UIColor ' +
+ 'UIFont UIApplication NSNotFound NSNotificationCenter NSNotification ' +
+ 'UILocalNotification NSBundle NSFileManager NSTimeInterval NSDate NSCalendar ' +
+ 'NSUserDefaults UIWindow NSRange NSArray NSError NSURLRequest NSURLConnection ' +
+ 'NSURLSession NSURLSessionDataTask NSURLSessionDownloadTask NSURLSessionUploadTask NSURLResponse' +
+ 'UIInterfaceOrientation MPMoviePlayerController dispatch_once_t ' +
+ 'dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
+ };
+ var LEXEMES = /[a-zA-Z@][a-zA-Z0-9_]*/;
+ var CLASS_KEYWORDS = '@interface @class @protocol @implementation';
+ return {
+ aliases: ['m', 'mm', 'objc', 'obj-c'],
+ keywords: OBJC_KEYWORDS, lexemes: LEXEMES,
+ illegal: '',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'string',
+ variants: [
+ {
+ begin: '@"', end: '"',
+ illegal: '\\n',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: '\'', end: '[^\\\\]\'',
+ illegal: '[^\\\\][^\']'
+ }
+ ]
+ },
+ {
+ className: 'preprocessor',
+ begin: '#',
+ end: '$',
+ contains: [
+ {
+ className: 'title',
+ variants: [
+ { begin: '\"', end: '\"' },
+ { begin: '<', end: '>' }
+ ]
+ }
+ ]
+ },
+ {
+ className: 'class',
+ begin: '(' + CLASS_KEYWORDS.split(' ').join('|') + ')\\b', end: '({|$)', excludeEnd: true,
+ keywords: CLASS_KEYWORDS, lexemes: LEXEMES,
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ {
+ className: 'variable',
+ begin: '\\.'+hljs.UNDERSCORE_IDENT_RE,
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],93:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['ml'],
+ keywords: {
+ keyword:
+ 'and as assert asr begin class constraint do done downto else end ' +
+ 'exception external false for fun function functor if in include ' +
+ 'inherit initializer land lazy let lor lsl lsr lxor match method ' +
+ 'mod module mutable new object of open or private rec ref sig struct ' +
+ 'then to true try type val virtual when while with parser value',
+ built_in:
+ 'bool char float int list unit array exn option int32 int64 nativeint ' +
+ 'format4 format6 lazy_t in_channel out_channel string'
+ },
+ illegal: /\/\//,
+ contains: [
+ {
+ className: 'string',
+ begin: '"""', end: '"""'
+ },
+ {
+ className: 'comment',
+ begin: '\\(\\*', end: '\\*\\)',
+ contains: ['self']
+ },
+ {
+ className: 'class',
+ beginKeywords: 'type', end: '\\(|=|$', excludeEnd: true,
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ {
+ className: 'annotation',
+ begin: '\\[<', end: '>\\]'
+ },
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
+ hljs.C_NUMBER_MODE
+ ]
+ }
+};
+},{}],94:[function(require,module,exports){
+module.exports = function(hljs) {
+ var OXYGENE_KEYWORDS = 'abstract add and array as asc aspect assembly async begin break block by case class concat const copy constructor continue '+
+ 'create default delegate desc distinct div do downto dynamic each else empty end ensure enum equals event except exit extension external false '+
+ 'final finalize finalizer finally flags for forward from function future global group has if implementation implements implies in index inherited '+
+ 'inline interface into invariants is iterator join locked locking loop matching method mod module namespace nested new nil not notify nullable of '+
+ 'old on operator or order out override parallel params partial pinned private procedure property protected public queryable raise read readonly '+
+ 'record reintroduce remove repeat require result reverse sealed select self sequence set shl shr skip static step soft take then to true try tuple '+
+ 'type union unit unsafe until uses using var virtual raises volatile where while with write xor yield await mapped deprecated stdcall cdecl pascal '+
+ 'register safecall overload library platform reference packed strict published autoreleasepool selector strong weak unretained';
+ var CURLY_COMMENT = {
+ className: 'comment',
+ begin: '{', end: '}',
+ relevance: 0
+ };
+ var PAREN_COMMENT = {
+ className: 'comment',
+ begin: '\\(\\*', end: '\\*\\)',
+ relevance: 10
+ };
+ var STRING = {
+ className: 'string',
+ begin: '\'', end: '\'',
+ contains: [{begin: '\'\''}]
+ };
+ var CHAR_STRING = {
+ className: 'string', begin: '(#\\d+)+'
+ };
+ var FUNCTION = {
+ className: 'function',
+ beginKeywords: 'function constructor destructor procedure method', end: '[:;]',
+ keywords: 'function constructor|10 destructor|10 procedure|10 method|10',
+ contains: [
+ hljs.TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ keywords: OXYGENE_KEYWORDS,
+ contains: [STRING, CHAR_STRING]
+ },
+ CURLY_COMMENT, PAREN_COMMENT
+ ]
+ };
+ return {
+ case_insensitive: true,
+ keywords: OXYGENE_KEYWORDS,
+ illegal: '("|\\$[G-Zg-z]|\\/\\*||=>|->)',
+ contains: [
+ CURLY_COMMENT, PAREN_COMMENT, hljs.C_LINE_COMMENT_MODE,
+ STRING, CHAR_STRING,
+ hljs.NUMBER_MODE,
+ FUNCTION,
+ {
+ className: 'class',
+ begin: '=\\bclass\\b', end: 'end;',
+ keywords: OXYGENE_KEYWORDS,
+ contains: [
+ STRING, CHAR_STRING,
+ CURLY_COMMENT, PAREN_COMMENT, hljs.C_LINE_COMMENT_MODE,
+ FUNCTION
+ ]
+ }
+ ]
+ };
+};
+},{}],95:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ subLanguage: 'xml', relevance: 0,
+ contains: [
+ {
+ className: 'comment',
+ begin: '^#', end: '$'
+ },
+ {
+ className: 'comment',
+ begin: '\\^rem{', end: '}',
+ relevance: 10,
+ contains: [
+ {
+ begin: '{', end: '}',
+ contains: ['self']
+ }
+ ]
+ },
+ {
+ className: 'preprocessor',
+ begin: '^@(?:BASE|USE|CLASS|OPTIONS)$',
+ relevance: 10
+ },
+ {
+ className: 'title',
+ begin: '@[\\w\\-]+\\[[\\w^;\\-]*\\](?:\\[[\\w^;\\-]*\\])?(?:.*)$'
+ },
+ {
+ className: 'variable',
+ begin: '\\$\\{?[\\w\\-\\.\\:]+\\}?'
+ },
+ {
+ className: 'keyword',
+ begin: '\\^[\\w\\-\\.\\:]+'
+ },
+ {
+ className: 'number',
+ begin: '\\^#[0-9a-fA-F]+'
+ },
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],96:[function(require,module,exports){
+module.exports = function(hljs) {
+ var PERL_KEYWORDS = 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
+ 'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
+ 'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq' +
+ 'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
+ 'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget' +
+ 'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
+ 'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
+ 'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
+ 'endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand ' +
+ 'mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink ' +
+ 'getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr ' +
+ 'untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link ' +
+ 'getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller ' +
+ 'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
+ 'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
+ 'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
+ 'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir' +
+ 'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
+ 'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when';
+ var SUBST = {
+ className: 'subst',
+ begin: '[$@]\\{', end: '\\}',
+ keywords: PERL_KEYWORDS
+ };
+ var METHOD = {
+ begin: '->{', end: '}'
+ // contains defined later
+ };
+ var VAR = {
+ className: 'variable',
+ variants: [
+ {begin: /\$\d/},
+ {begin: /[\$\%\@](\^\w\b|#\w+(\:\:\w+)*|{\w+}|\w+(\:\:\w*)*)/},
+ {begin: /[\$\%\@][^\s\w{]/, relevance: 0}
+ ]
+ };
+ var COMMENT = {
+ className: 'comment',
+ begin: '^(__END__|__DATA__)', end: '\\n$',
+ relevance: 5
+ };
+ var STRING_CONTAINS = [hljs.BACKSLASH_ESCAPE, SUBST, VAR];
+ var PERL_DEFAULT_CONTAINS = [
+ VAR,
+ hljs.HASH_COMMENT_MODE,
+ COMMENT,
+ {
+ className: 'comment',
+ begin: '^\\=\\w', end: '\\=cut', endsWithParent: true
+ },
+ METHOD,
+ {
+ className: 'string',
+ contains: STRING_CONTAINS,
+ variants: [
+ {
+ begin: 'q[qwxr]?\\s*\\(', end: '\\)',
+ relevance: 5
+ },
+ {
+ begin: 'q[qwxr]?\\s*\\[', end: '\\]',
+ relevance: 5
+ },
+ {
+ begin: 'q[qwxr]?\\s*\\{', end: '\\}',
+ relevance: 5
+ },
+ {
+ begin: 'q[qwxr]?\\s*\\|', end: '\\|',
+ relevance: 5
+ },
+ {
+ begin: 'q[qwxr]?\\s*\\<', end: '\\>',
+ relevance: 5
+ },
+ {
+ begin: 'qw\\s+q', end: 'q',
+ relevance: 5
+ },
+ {
+ begin: '\'', end: '\'',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: '"', end: '"'
+ },
+ {
+ begin: '`', end: '`',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ begin: '{\\w+}',
+ contains: [],
+ relevance: 0
+ },
+ {
+ begin: '\-?\\w+\\s*\\=\\>',
+ contains: [],
+ relevance: 0
+ }
+ ]
+ },
+ {
+ className: 'number',
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
+ relevance: 0
+ },
+ { // regexp container
+ begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
+ keywords: 'split return print reverse grep',
+ relevance: 0,
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ COMMENT,
+ {
+ className: 'regexp',
+ begin: '(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*',
+ relevance: 10
+ },
+ {
+ className: 'regexp',
+ begin: '(m|qr)?/', end: '/[a-z]*',
+ contains: [hljs.BACKSLASH_ESCAPE],
+ relevance: 0 // allows empty "//" which is a common comment delimiter in other languages
+ }
+ ]
+ },
+ {
+ className: 'sub',
+ beginKeywords: 'sub', end: '(\\s*\\(.*?\\))?[;{]',
+ relevance: 5
+ },
+ {
+ className: 'operator',
+ begin: '-\\w\\b',
+ relevance: 0
+ }
+ ];
+ SUBST.contains = PERL_DEFAULT_CONTAINS;
+ METHOD.contains = PERL_DEFAULT_CONTAINS;
+
+ return {
+ aliases: ['pl'],
+ keywords: PERL_KEYWORDS,
+ contains: PERL_DEFAULT_CONTAINS
+ };
+};
+},{}],97:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VARIABLE = {
+ className: 'variable', begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
+ };
+ var PREPROCESSOR = {
+ className: 'preprocessor', begin: /<\?(php)?|\?>/
+ };
+ var STRING = {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
+ variants: [
+ {
+ begin: 'b"', end: '"'
+ },
+ {
+ begin: 'b\'', end: '\''
+ },
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
+ ]
+ };
+ var NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
+ return {
+ aliases: ['php3', 'php4', 'php5', 'php6'],
+ case_insensitive: true,
+ keywords:
+ 'and include_once list abstract global private echo interface as static endswitch ' +
+ 'array null if endwhile or const for endforeach self var while isset public ' +
+ 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' +
+ 'return parent clone use __CLASS__ __LINE__ else break print eval new ' +
+ 'catch __METHOD__ case exception default die require __FUNCTION__ ' +
+ 'enddeclare final try switch continue endfor endif declare unset true false ' +
+ 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' +
+ 'yield finally',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.HASH_COMMENT_MODE,
+ {
+ className: 'comment',
+ begin: '/\\*', end: '\\*/',
+ contains: [
+ {
+ className: 'phpdoc',
+ begin: '\\s@[A-Za-z]+'
+ },
+ PREPROCESSOR
+ ]
+ },
+ {
+ className: 'comment',
+ begin: '__halt_compiler.+?;', endsWithParent: true,
+ keywords: '__halt_compiler', lexemes: hljs.UNDERSCORE_IDENT_RE
+ },
+ {
+ className: 'string',
+ begin: '<<<[\'"]?\\w+[\'"]?$', end: '^\\w+;',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ PREPROCESSOR,
+ VARIABLE,
+ {
+ // swallow class members to avoid parsing them as keywords
+ begin: /->+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: /[;{]/, excludeEnd: true,
+ illegal: '\\$|\\[|%',
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ contains: [
+ 'self',
+ VARIABLE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ STRING,
+ NUMBER
+ ]
+ }
+ ]
+ },
+ {
+ className: 'class',
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
+ illegal: /[:\(\$"]/,
+ contains: [
+ {beginKeywords: 'extends implements'},
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ {
+ beginKeywords: 'namespace', end: ';',
+ illegal: /[\.']/,
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
+ },
+ {
+ beginKeywords: 'use', end: ';',
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
+ },
+ {
+ begin: '=>' // No markup, just a relevance booster
+ },
+ STRING,
+ NUMBER
+ ]
+ };
+};
+},{}],98:[function(require,module,exports){
+module.exports = function(hljs) {
+ var backtickEscape = {
+ begin: '`[\\s\\S]',
+ relevance: 0
+ };
+ var dollarEscape = {
+ begin: '\\$\\$[\\s\\S]',
+ relevance: 0
+ };
+ var VAR = {
+ className: 'variable',
+ variants: [
+ {begin: /\$[\w\d][\w\d_:]*/}
+ ]
+ };
+ var QUOTE_STRING = {
+ className: 'string',
+ begin: /"/, end: /"/,
+ contains: [
+ backtickEscape,
+ VAR,
+ {
+ className: 'variable',
+ begin: /\$[A-z]/, end: /[^A-z]/
+ }
+ ]
+ };
+ var APOS_STRING = {
+ className: 'string',
+ begin: /'/, end: /'/
+ };
+
+ return {
+ aliases: ['ps'],
+ lexemes: /-?[A-z\.\-]+/,
+ case_insensitive: true,
+ keywords: {
+ keyword: 'if else foreach return function do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch',
+ literal: '$null $true $false',
+ built_in: 'Add-Content Add-History Add-Member Add-PSSnapin Clear-Content Clear-Item Clear-Item Property Clear-Variable Compare-Object ConvertFrom-SecureString Convert-Path ConvertTo-Html ConvertTo-SecureString Copy-Item Copy-ItemProperty Export-Alias Export-Clixml Export-Console Export-Csv ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-Content Get-Credential Get-Culture Get-Date Get-EventLog Get-ExecutionPolicy Get-Help Get-History Get-Host Get-Item Get-ItemProperty Get-Location Get-Member Get-PfxCertificate Get-Process Get-PSDrive Get-PSProvider Get-PSSnapin Get-Service Get-TraceSource Get-UICulture Get-Unique Get-Variable Get-WmiObject Group-Object Import-Alias Import-Clixml Import-Csv Invoke-Expression Invoke-History Invoke-Item Join-Path Measure-Command Measure-Object Move-Item Move-ItemProperty New-Alias New-Item New-ItemProperty New-Object New-PSDrive New-Service New-TimeSpan New-Variable Out-Default Out-File Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Remove-Item Remove-ItemProperty Remove-PSDrive Remove-PSSnapin Remove-Variable Rename-Item Rename-ItemProperty Resolve-Path Restart-Service Resume-Service Select-Object Select-String Set-Acl Set-Alias Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-Location Set-PSDebug Set-Service Set-TraceSource Set-Variable Sort-Object Split-Path Start-Service Start-Sleep Start-Transcript Stop-Process Stop-Service Stop-Transcript Suspend-Service Tee-Object Test-Path Trace-Command Update-FormatData Update-TypeData Where-Object Write-Debug Write-Error Write-Host Write-Output Write-Progress Write-Verbose Write-Warning',
+ operator: '-ne -eq -lt -gt -ge -le -not -like -notlike -match -notmatch -contains -notcontains -in -notin -replace'
+ },
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ hljs.NUMBER_MODE,
+ QUOTE_STRING,
+ APOS_STRING,
+ VAR
+ ]
+ };
+};
+},{}],99:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword: 'BufferedReader PVector PFont PImage PGraphics HashMap boolean byte char color ' +
+ 'double float int long String Array FloatDict FloatList IntDict IntList JSONArray JSONObject ' +
+ 'Object StringDict StringList Table TableRow XML ' +
+ // Java keywords
+ 'false synchronized int abstract float private char boolean static null if const ' +
+ 'for true while long throw strictfp finally protected import native final return void ' +
+ 'enum else break transient new catch instanceof byte super volatile case assert short ' +
+ 'package default double public try this switch continue throws protected public private',
+ constant: 'P2D P3D HALF_PI PI QUARTER_PI TAU TWO_PI',
+ variable: 'displayHeight displayWidth mouseY mouseX mousePressed pmouseX pmouseY key ' +
+ 'keyCode pixels focused frameCount frameRate height width',
+ title: 'setup draw',
+ built_in: 'size createGraphics beginDraw createShape loadShape PShape arc ellipse line point ' +
+ 'quad rect triangle bezier bezierDetail bezierPoint bezierTangent curve curveDetail curvePoint ' +
+ 'curveTangent curveTightness shape shapeMode beginContour beginShape bezierVertex curveVertex ' +
+ 'endContour endShape quadraticVertex vertex ellipseMode noSmooth rectMode smooth strokeCap ' +
+ 'strokeJoin strokeWeight mouseClicked mouseDragged mouseMoved mousePressed mouseReleased ' +
+ 'mouseWheel keyPressed keyPressedkeyReleased keyTyped print println save saveFrame day hour ' +
+ 'millis minute month second year background clear colorMode fill noFill noStroke stroke alpha ' +
+ 'blue brightness color green hue lerpColor red saturation modelX modelY modelZ screenX screenY ' +
+ 'screenZ ambient emissive shininess specular add createImage beginCamera camera endCamera frustum ' +
+ 'ortho perspective printCamera printProjection cursor frameRate noCursor exit loop noLoop popStyle ' +
+ 'pushStyle redraw binary boolean byte char float hex int str unbinary unhex join match matchAll nf ' +
+ 'nfc nfp nfs split splitTokens trim append arrayCopy concat expand reverse shorten sort splice subset ' +
+ 'box sphere sphereDetail createInput createReader loadBytes loadJSONArray loadJSONObject loadStrings ' +
+ 'loadTable loadXML open parseXML saveTable selectFolder selectInput beginRaw beginRecord createOutput ' +
+ 'createWriter endRaw endRecord PrintWritersaveBytes saveJSONArray saveJSONObject saveStream saveStrings ' +
+ 'saveXML selectOutput popMatrix printMatrix pushMatrix resetMatrix rotate rotateX rotateY rotateZ scale ' +
+ 'shearX shearY translate ambientLight directionalLight lightFalloff lights lightSpecular noLights normal ' +
+ 'pointLight spotLight image imageMode loadImage noTint requestImage tint texture textureMode textureWrap ' +
+ 'blend copy filter get loadPixels set updatePixels blendMode loadShader PShaderresetShader shader createFont ' +
+ 'loadFont text textFont textAlign textLeading textMode textSize textWidth textAscent textDescent abs ceil ' +
+ 'constrain dist exp floor lerp log mag map max min norm pow round sq sqrt acos asin atan atan2 cos degrees ' +
+ 'radians sin tan noise noiseDetail noiseSeed random randomGaussian randomSeed'
+ },
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],100:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ contains: [
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'built_in',
+ begin: '{', end: '}$',
+ excludeBegin: true, excludeEnd: true,
+ contains: [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE],
+ relevance: 0
+ },
+ {
+ className: 'filename',
+ begin: '[a-zA-Z_][\\da-zA-Z_]+\\.[\\da-zA-Z_]{1,3}', end: ':',
+ excludeEnd: true
+ },
+ {
+ className: 'header',
+ begin: '(ncalls|tottime|cumtime)', end: '$',
+ keywords: 'ncalls tottime|10 cumtime|10 filename',
+ relevance: 10
+ },
+ {
+ className: 'summary',
+ begin: 'function calls', end: '$',
+ contains: [hljs.C_NUMBER_MODE],
+ relevance: 10
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ {
+ className: 'function',
+ begin: '\\(', end: '\\)$',
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE
+ ],
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],101:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword: 'package import option optional required repeated group',
+ built_in: 'double float int32 int64 uint32 uint64 sint32 sint64 ' +
+ 'fixed32 fixed64 sfixed32 sfixed64 bool string bytes',
+ literal: 'true false'
+ },
+ contains: [
+ hljs.QUOTE_STRING_MODE,
+ hljs.NUMBER_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'message enum service', end: /\{/,
+ illegal: /\n/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
+ })
+ ]
+ },
+ {
+ className: 'function',
+ beginKeywords: 'rpc',
+ end: /;/, excludeEnd: true,
+ keywords: 'rpc returns'
+ },
+ {
+ className: 'constant',
+ begin: /^\s*[A-Z_]+/,
+ end: /\s*=/, excludeEnd: true
+ }
+ ]
+ };
+};
+},{}],102:[function(require,module,exports){
+module.exports = function(hljs) {
+ var PUPPET_TYPE_REFERENCE =
+ 'augeas computer cron exec file filebucket host interface k5login macauthorization mailalias maillist mcx mount nagios_command ' +
+ 'nagios_contact nagios_contactgroup nagios_host nagios_hostdependency nagios_hostescalation nagios_hostextinfo nagios_hostgroup nagios_service firewall ' +
+ 'nagios_servicedependency nagios_serviceescalation nagios_serviceextinfo nagios_servicegroup nagios_timeperiod notify package resources ' +
+ 'router schedule scheduled_task selboolean selmodule service ssh_authorized_key sshkey stage tidy user vlan yumrepo zfs zone zpool';
+
+ var PUPPET_ATTRIBUTES =
+ /* metaparameters */
+ 'alias audit before loglevel noop require subscribe tag ' +
+ /* normal attributes */
+ 'owner ensure group mode name|0 changes context force incl lens load_path onlyif provider returns root show_diff type_check ' +
+ 'en_address ip_address realname command environment hour monute month monthday special target weekday '+
+ 'creates cwd ogoutput refresh refreshonly tries try_sleep umask backup checksum content ctime force ignore ' +
+ 'links mtime purge recurse recurselimit replace selinux_ignore_defaults selrange selrole seltype seluser source ' +
+ 'souirce_permissions sourceselect validate_cmd validate_replacement allowdupe attribute_membership auth_membership forcelocal gid '+
+ 'ia_load_module members system host_aliases ip allowed_trunk_vlans description device_url duplex encapsulation etherchannel ' +
+ 'native_vlan speed principals allow_root auth_class auth_type authenticate_user k_of_n mechanisms rule session_owner shared options ' +
+ 'device fstype enable hasrestart directory present absent link atboot blockdevice device dump pass remounts poller_tag use ' +
+ 'message withpath adminfile allow_virtual allowcdrom category configfiles flavor install_options instance package_settings platform ' +
+ 'responsefile status uninstall_options vendor unless_system_user unless_uid binary control flags hasstatus manifest pattern restart running ' +
+ 'start stop allowdupe auths expiry gid groups home iterations key_membership keys managehome membership password password_max_age ' +
+ 'password_min_age profile_membership profiles project purge_ssh_keys role_membership roles salt shell uid baseurl cost descr enabled ' +
+ 'enablegroups exclude failovermethod gpgcheck gpgkey http_caching include includepkgs keepalive metadata_expire metalink mirrorlist ' +
+ 'priority protect proxy proxy_password proxy_username repo_gpgcheck s3_enabled skip_if_unavailable sslcacert sslclientcert sslclientkey ' +
+ 'sslverify mounted';
+
+ var PUPPET_KEYWORDS =
+ {
+ keyword:
+ /* language keywords */
+ 'and case class default define else elsif false if in import enherits node or true undef unless main settings $string ' + PUPPET_TYPE_REFERENCE,
+ literal:
+ PUPPET_ATTRIBUTES,
+
+ built_in:
+ /* core facts */
+ 'architecture augeasversion blockdevices boardmanufacturer boardproductname boardserialnumber cfkey dhcp_servers ' +
+ 'domain ec2_ ec2_userdata facterversion filesystems ldom fqdn gid hardwareisa hardwaremodel hostname id|0 interfaces '+
+ 'ipaddress ipaddress_ ipaddress6 ipaddress6_ iphostnumber is_virtual kernel kernelmajversion kernelrelease kernelversion ' +
+ 'kernelrelease kernelversion lsbdistcodename lsbdistdescription lsbdistid lsbdistrelease lsbmajdistrelease lsbminordistrelease ' +
+ 'lsbrelease macaddress macaddress_ macosx_buildversion macosx_productname macosx_productversion macosx_productverson_major ' +
+ 'macosx_productversion_minor manufacturer memoryfree memorysize netmask metmask_ network_ operatingsystem operatingsystemmajrelease '+
+ 'operatingsystemrelease osfamily partitions path physicalprocessorcount processor processorcount productname ps puppetversion '+
+ 'rubysitedir rubyversion selinux selinux_config_mode selinux_config_policy selinux_current_mode selinux_current_mode selinux_enforced '+
+ 'selinux_policyversion serialnumber sp_ sshdsakey sshecdsakey sshrsakey swapencrypted swapfree swapsize timezone type uniqueid uptime '+
+ 'uptime_days uptime_hours uptime_seconds uuid virtual vlans xendomains zfs_version zonenae zones zpool_version'
+ };
+
+ var COMMENT = {
+ className: 'comment',
+ begin: '#', end: '$'
+ };
+
+ var STRING = {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE],
+ variants: [
+ {begin: /'/, end: /'/},
+ {begin: /"/, end: /"/}
+ ]
+ };
+
+ var PUPPET_DEFAULT_CONTAINS = [
+ STRING,
+ COMMENT,
+ {
+ className: 'keyword',
+ beginKeywords: 'class', end: '$|;',
+ illegal: /=/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: '(::)?[A-Za-z_]\\w*(::\\w+)*'}),
+ COMMENT,
+ STRING
+ ]
+ },
+ {
+ className: 'keyword',
+ begin: '([a-zA-Z_(::)]+ *\\{)',
+ contains:[STRING, COMMENT],
+ relevance: 0
+ },
+ {
+ className: 'keyword',
+ begin: '(\\}|\\{)',
+ relevance: 0
+ },
+ {
+ className: 'function',
+ begin:'[a-zA-Z_]+\\s*=>'
+ },
+ {
+ className: 'constant',
+ begin: '(::)?(\\b[A-Z][a-z_]*(::)?)+',
+ relevance: 0
+ },
+ {
+ className: 'number',
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
+ relevance: 0
+ }
+ ];
+
+ return {
+ aliases: ['pp'],
+ keywords: PUPPET_KEYWORDS,
+ contains: PUPPET_DEFAULT_CONTAINS
+ }
+};
+},{}],103:[function(require,module,exports){
+module.exports = function(hljs) {
+ var PROMPT = {
+ className: 'prompt', begin: /^(>>>|\.\.\.) /
+ };
+ var STRING = {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE],
+ variants: [
+ {
+ begin: /(u|b)?r?'''/, end: /'''/,
+ contains: [PROMPT],
+ relevance: 10
+ },
+ {
+ begin: /(u|b)?r?"""/, end: /"""/,
+ contains: [PROMPT],
+ relevance: 10
+ },
+ {
+ begin: /(u|r|ur)'/, end: /'/,
+ relevance: 10
+ },
+ {
+ begin: /(u|r|ur)"/, end: /"/,
+ relevance: 10
+ },
+ {
+ begin: /(b|br)'/, end: /'/
+ },
+ {
+ begin: /(b|br)"/, end: /"/
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE
+ ]
+ };
+ var NUMBER = {
+ className: 'number', relevance: 0,
+ variants: [
+ {begin: hljs.BINARY_NUMBER_RE + '[lLjJ]?'},
+ {begin: '\\b(0o[0-7]+)[lLjJ]?'},
+ {begin: hljs.C_NUMBER_RE + '[lLjJ]?'}
+ ]
+ };
+ var PARAMS = {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ contains: ['self', PROMPT, NUMBER, STRING]
+ };
+ var FUNC_CLASS_PROTO = {
+ end: /:/,
+ illegal: /[${=;\n]/,
+ contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS]
+ };
+
+ return {
+ aliases: ['py', 'gyp'],
+ keywords: {
+ keyword:
+ 'and elif is global as in if from raise for except finally print import pass return ' +
+ 'exec else break not with class assert yield try while continue del or def lambda ' +
+ 'nonlocal|10 None True False',
+ built_in:
+ 'Ellipsis NotImplemented'
+ },
+ illegal: /(<\/|->|\?)/,
+ contains: [
+ PROMPT,
+ NUMBER,
+ STRING,
+ hljs.HASH_COMMENT_MODE,
+ hljs.inherit(FUNC_CLASS_PROTO, {className: 'function', beginKeywords: 'def', relevance: 10}),
+ hljs.inherit(FUNC_CLASS_PROTO, {className: 'class', beginKeywords: 'class'}),
+ {
+ className: 'decorator',
+ begin: /@/, end: /$/
+ },
+ {
+ begin: /\b(print|exec)\(/ // don’t highlight keywords-turned-functions in Python 3
+ }
+ ]
+ };
+};
+},{}],104:[function(require,module,exports){
+module.exports = function(hljs) {
+ var Q_KEYWORDS = {
+ keyword:
+ 'do while select delete by update from',
+ constant:
+ '0b 1b',
+ built_in:
+ 'neg not null string reciprocal floor ceiling signum mod xbar xlog and or each scan over prior mmu lsq inv md5 ltime gtime count first var dev med cov cor all any rand sums prds mins maxs fills deltas ratios avgs differ prev next rank reverse iasc idesc asc desc msum mcount mavg mdev xrank mmin mmax xprev rotate distinct group where flip type key til get value attr cut set upsert raze union inter except cross sv vs sublist enlist read0 read1 hopen hclose hdel hsym hcount peach system ltrim rtrim trim lower upper ssr view tables views cols xcols keys xkey xcol xasc xdesc fkeys meta lj aj aj0 ij pj asof uj ww wj wj1 fby xgroup ungroup ej save load rsave rload show csv parse eval min max avg wavg wsum sin cos tan sum',
+ typename:
+ '`float `double int `timestamp `timespan `datetime `time `boolean `symbol `char `byte `short `long `real `month `date `minute `second `guid'
+ };
+ return {
+ aliases:['k', 'kdb'],
+ keywords: Q_KEYWORDS,
+ lexemes: /\b(`?)[A-Za-z0-9_]+\b/,
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],105:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*';
+
+ return {
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ {
+ begin: IDENT_RE,
+ lexemes: IDENT_RE,
+ keywords: {
+ keyword:
+ 'function if in break next repeat else for return switch while try tryCatch|10 ' +
+ 'stop warning require library attach detach source setMethod setGeneric ' +
+ 'setGroupGeneric setClass ...|10',
+ literal:
+ 'NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 ' +
+ 'NA_complex_|10'
+ },
+ relevance: 0
+ },
+ {
+ // hex value
+ className: 'number',
+ begin: "0[xX][0-9a-fA-F]+[Li]?\\b",
+ relevance: 0
+ },
+ {
+ // explicit integer
+ className: 'number',
+ begin: "\\d+(?:[eE][+\\-]?\\d*)?L\\b",
+ relevance: 0
+ },
+ {
+ // number with trailing decimal
+ className: 'number',
+ begin: "\\d+\\.(?!\\d)(?:i\\b)?",
+ relevance: 0
+ },
+ {
+ // number
+ className: 'number',
+ begin: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",
+ relevance: 0
+ },
+ {
+ // number with leading decimal
+ className: 'number',
+ begin: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",
+ relevance: 0
+ },
+
+ {
+ // escaped identifier
+ begin: '`',
+ end: '`',
+ relevance: 0
+ },
+
+ {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE],
+ variants: [
+ {begin: '"', end: '"'},
+ {begin: "'", end: "'"}
+ ]
+ }
+ ]
+ };
+};
+},{}],106:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords:
+ 'ArchiveRecord AreaLightSource Atmosphere Attribute AttributeBegin AttributeEnd Basis ' +
+ 'Begin Blobby Bound Clipping ClippingPlane Color ColorSamples ConcatTransform Cone ' +
+ 'CoordinateSystem CoordSysTransform CropWindow Curves Cylinder DepthOfField Detail ' +
+ 'DetailRange Disk Displacement Display End ErrorHandler Exposure Exterior Format ' +
+ 'FrameAspectRatio FrameBegin FrameEnd GeneralPolygon GeometricApproximation Geometry ' +
+ 'Hider Hyperboloid Identity Illuminate Imager Interior LightSource ' +
+ 'MakeCubeFaceEnvironment MakeLatLongEnvironment MakeShadow MakeTexture Matte ' +
+ 'MotionBegin MotionEnd NuPatch ObjectBegin ObjectEnd ObjectInstance Opacity Option ' +
+ 'Orientation Paraboloid Patch PatchMesh Perspective PixelFilter PixelSamples ' +
+ 'PixelVariance Points PointsGeneralPolygons PointsPolygons Polygon Procedural Projection ' +
+ 'Quantize ReadArchive RelativeDetail ReverseOrientation Rotate Scale ScreenWindow ' +
+ 'ShadingInterpolation ShadingRate Shutter Sides Skew SolidBegin SolidEnd Sphere ' +
+ 'SubdivisionMesh Surface TextureCoordinates Torus Transform TransformBegin TransformEnd ' +
+ 'TransformPoints Translate TrimCurve WorldBegin WorldEnd',
+ illegal: '',
+ contains: [
+ hljs.HASH_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE
+ ]
+ };
+};
+},{}],107:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword:
+ 'float color point normal vector matrix while for if do return else break extern continue',
+ built_in:
+ 'abs acos ambient area asin atan atmosphere attribute calculatenormal ceil cellnoise ' +
+ 'clamp comp concat cos degrees depth Deriv diffuse distance Du Dv environment exp ' +
+ 'faceforward filterstep floor format fresnel incident length lightsource log match ' +
+ 'max min mod noise normalize ntransform opposite option phong pnoise pow printf ' +
+ 'ptlined radians random reflect refract renderinfo round setcomp setxcomp setycomp ' +
+ 'setzcomp shadow sign sin smoothstep specular specularbrdf spline sqrt step tan ' +
+ 'texture textureinfo trace transform vtransform xcomp ycomp zcomp'
+ },
+ illegal: '',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$'
+ },
+ {
+ className: 'shader',
+ beginKeywords: 'surface displacement light volume imager', end: '\\('
+ },
+ {
+ className: 'shading',
+ beginKeywords: 'illuminate illuminance gather', end: '\\('
+ }
+ ]
+ };
+};
+},{}],108:[function(require,module,exports){
+module.exports = function(hljs) {
+ var RUBY_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?';
+ var RUBY_KEYWORDS =
+ 'and false then defined module in return redo if BEGIN retry end for true self when ' +
+ 'next until do begin unless END rescue nil else break undef not super class case ' +
+ 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor';
+ var YARDOCTAG = {
+ className: 'yardoctag',
+ begin: '@[A-Za-z]+'
+ };
+ var IRB_OBJECT = {
+ className: 'value',
+ begin: '#<', end: '>'
+ };
+ var COMMENT = {
+ className: 'comment',
+ variants: [
+ {
+ begin: '#', end: '$',
+ contains: [YARDOCTAG]
+ },
+ {
+ begin: '^\\=begin', end: '^\\=end',
+ contains: [YARDOCTAG],
+ relevance: 10
+ },
+ {
+ begin: '^__END__', end: '\\n$'
+ }
+ ]
+ };
+ var SUBST = {
+ className: 'subst',
+ begin: '#\\{', end: '}',
+ keywords: RUBY_KEYWORDS
+ };
+ var STRING = {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
+ variants: [
+ {begin: /'/, end: /'/},
+ {begin: /"/, end: /"/},
+ {begin: /`/, end: /`/},
+ {begin: '%[qQwWx]?\\(', end: '\\)'},
+ {begin: '%[qQwWx]?\\[', end: '\\]'},
+ {begin: '%[qQwWx]?{', end: '}'},
+ {begin: '%[qQwWx]?<', end: '>'},
+ {begin: '%[qQwWx]?/', end: '/'},
+ {begin: '%[qQwWx]?%', end: '%'},
+ {begin: '%[qQwWx]?-', end: '-'},
+ {begin: '%[qQwWx]?\\|', end: '\\|'},
+ {
+ // \B in the beginning suppresses recognition of ?-sequences where ?
+ // is the last character of a preceding identifier, as in: `func?4`
+ begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/
+ }
+ ]
+ };
+ var PARAMS = {
+ className: 'params',
+ begin: '\\(', end: '\\)',
+ keywords: RUBY_KEYWORDS
+ };
+
+ var RUBY_DEFAULT_CONTAINS = [
+ STRING,
+ IRB_OBJECT,
+ COMMENT,
+ {
+ className: 'class',
+ beginKeywords: 'class module', end: '$|;',
+ illegal: /=/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),
+ {
+ className: 'inheritance',
+ begin: '<\\s*',
+ contains: [{
+ className: 'parent',
+ begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE
+ }]
+ },
+ COMMENT
+ ]
+ },
+ {
+ className: 'function',
+ beginKeywords: 'def', end: ' |$|;',
+ relevance: 0,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),
+ PARAMS,
+ COMMENT
+ ]
+ },
+ {
+ className: 'constant',
+ begin: '(::)?(\\b[A-Z]\\w*(::)?)+',
+ relevance: 0
+ },
+ {
+ className: 'symbol',
+ begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',
+ relevance: 0
+ },
+ {
+ className: 'symbol',
+ begin: ':',
+ contains: [STRING, {begin: RUBY_METHOD_RE}],
+ relevance: 0
+ },
+ {
+ className: 'number',
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
+ relevance: 0
+ },
+ {
+ className: 'variable',
+ begin: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'
+ },
+ { // regexp container
+ begin: '(' + hljs.RE_STARTERS_RE + ')\\s*',
+ contains: [
+ IRB_OBJECT,
+ COMMENT,
+ {
+ className: 'regexp',
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
+ illegal: /\n/,
+ variants: [
+ {begin: '/', end: '/[a-z]*'},
+ {begin: '%r{', end: '}[a-z]*'},
+ {begin: '%r\\(', end: '\\)[a-z]*'},
+ {begin: '%r!', end: '![a-z]*'},
+ {begin: '%r\\[', end: '\\][a-z]*'}
+ ]
+ }
+ ],
+ relevance: 0
+ }
+ ];
+ SUBST.contains = RUBY_DEFAULT_CONTAINS;
+ PARAMS.contains = RUBY_DEFAULT_CONTAINS;
+
+ var IRB_DEFAULT = [
+ {
+ begin: /^\s*=>/,
+ className: 'status',
+ starts: {
+ end: '$', contains: RUBY_DEFAULT_CONTAINS
+ }
+ },
+ {
+ className: 'prompt',
+ begin: /^\S[^=>\n]*>+/,
+ starts: {
+ end: '$', contains: RUBY_DEFAULT_CONTAINS
+ }
+ }
+ ];
+
+ return {
+ aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],
+ keywords: RUBY_KEYWORDS,
+ contains: [COMMENT].concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS)
+ };
+};
+},{}],109:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword: 'BILL_PERIOD BILL_START BILL_STOP RS_EFFECTIVE_START RS_EFFECTIVE_STOP RS_JURIS_CODE RS_OPCO_CODE ' +
+ 'INTDADDATTRIBUTE|5 INTDADDVMSG|5 INTDBLOCKOP|5 INTDBLOCKOPNA|5 INTDCLOSE|5 INTDCOUNT|5 ' +
+ 'INTDCOUNTSTATUSCODE|5 INTDCREATEMASK|5 INTDCREATEDAYMASK|5 INTDCREATEFACTORMASK|5 ' +
+ 'INTDCREATEHANDLE|5 INTDCREATEOVERRIDEDAYMASK|5 INTDCREATEOVERRIDEMASK|5 ' +
+ 'INTDCREATESTATUSCODEMASK|5 INTDCREATETOUPERIOD|5 INTDDELETE|5 INTDDIPTEST|5 INTDEXPORT|5 ' +
+ 'INTDGETERRORCODE|5 INTDGETERRORMESSAGE|5 INTDISEQUAL|5 INTDJOIN|5 INTDLOAD|5 INTDLOADACTUALCUT|5 ' +
+ 'INTDLOADDATES|5 INTDLOADHIST|5 INTDLOADLIST|5 INTDLOADLISTDATES|5 INTDLOADLISTENERGY|5 ' +
+ 'INTDLOADLISTHIST|5 INTDLOADRELATEDCHANNEL|5 INTDLOADSP|5 INTDLOADSTAGING|5 INTDLOADUOM|5 ' +
+ 'INTDLOADUOMDATES|5 INTDLOADUOMHIST|5 INTDLOADVERSION|5 INTDOPEN|5 INTDREADFIRST|5 INTDREADNEXT|5 ' +
+ 'INTDRECCOUNT|5 INTDRELEASE|5 INTDREPLACE|5 INTDROLLAVG|5 INTDROLLPEAK|5 INTDSCALAROP|5 INTDSCALE|5 ' +
+ 'INTDSETATTRIBUTE|5 INTDSETDSTPARTICIPANT|5 INTDSETSTRING|5 INTDSETVALUE|5 INTDSETVALUESTATUS|5 ' +
+ 'INTDSHIFTSTARTTIME|5 INTDSMOOTH|5 INTDSORT|5 INTDSPIKETEST|5 INTDSUBSET|5 INTDTOU|5 ' +
+ 'INTDTOURELEASE|5 INTDTOUVALUE|5 INTDUPDATESTATS|5 INTDVALUE|5 STDEV INTDDELETEEX|5 ' +
+ 'INTDLOADEXACTUAL|5 INTDLOADEXCUT|5 INTDLOADEXDATES|5 INTDLOADEX|5 INTDLOADEXRELATEDCHANNEL|5 ' +
+ 'INTDSAVEEX|5 MVLOAD|5 MVLOADACCT|5 MVLOADACCTDATES|5 MVLOADACCTHIST|5 MVLOADDATES|5 MVLOADHIST|5 ' +
+ 'MVLOADLIST|5 MVLOADLISTDATES|5 MVLOADLISTHIST|5 IF FOR NEXT DONE SELECT END CALL ABORT CLEAR CHANNEL FACTOR LIST NUMBER ' +
+ 'OVERRIDE SET WEEK DISTRIBUTIONNODE ELSE WHEN THEN OTHERWISE IENUM CSV INCLUDE LEAVE RIDER SAVE DELETE ' +
+ 'NOVALUE SECTION WARN SAVE_UPDATE DETERMINANT LABEL REPORT REVENUE EACH ' +
+ 'IN FROM TOTAL CHARGE BLOCK AND OR CSV_FILE RATE_CODE AUXILIARY_DEMAND ' +
+ 'UIDACCOUNT RS BILL_PERIOD_SELECT HOURS_PER_MONTH INTD_ERROR_STOP SEASON_SCHEDULE_NAME ' +
+ 'ACCOUNTFACTOR ARRAYUPPERBOUND CALLSTOREDPROC GETADOCONNECTION GETCONNECT GETDATASOURCE ' +
+ 'GETQUALIFIER GETUSERID HASVALUE LISTCOUNT LISTOP LISTUPDATE LISTVALUE PRORATEFACTOR RSPRORATE ' +
+ 'SETBINPATH SETDBMONITOR WQ_OPEN BILLINGHOURS DATE DATEFROMFLOAT DATETIMEFROMSTRING ' +
+ 'DATETIMETOSTRING DATETOFLOAT DAY DAYDIFF DAYNAME DBDATETIME HOUR MINUTE MONTH MONTHDIFF ' +
+ 'MONTHHOURS MONTHNAME ROUNDDATE SAMEWEEKDAYLASTYEAR SECOND WEEKDAY WEEKDIFF YEAR YEARDAY ' +
+ 'YEARSTR COMPSUM HISTCOUNT HISTMAX HISTMIN HISTMINNZ HISTVALUE MAXNRANGE MAXRANGE MINRANGE ' +
+ 'COMPIKVA COMPKVA COMPKVARFROMKQKW COMPLF IDATTR FLAG LF2KW LF2KWH MAXKW POWERFACTOR ' +
+ 'READING2USAGE AVGSEASON MAXSEASON MONTHLYMERGE SEASONVALUE SUMSEASON ACCTREADDATES ' +
+ 'ACCTTABLELOAD CONFIGADD CONFIGGET CREATEOBJECT CREATEREPORT EMAILCLIENT EXPBLKMDMUSAGE ' +
+ 'EXPMDMUSAGE EXPORT_USAGE FACTORINEFFECT GETUSERSPECIFIEDSTOP INEFFECT ISHOLIDAY RUNRATE ' +
+ 'SAVE_PROFILE SETREPORTTITLE USEREXIT WATFORRUNRATE TO TABLE ACOS ASIN ATAN ATAN2 BITAND CEIL ' +
+ 'COS COSECANT COSH COTANGENT DIVQUOT DIVREM EXP FABS FLOOR FMOD FREPM FREXPN LOG LOG10 MAX MAXN ' +
+ 'MIN MINNZ MODF POW ROUND ROUND2VALUE ROUNDINT SECANT SIN SINH SQROOT TAN TANH FLOAT2STRING ' +
+ 'FLOAT2STRINGNC INSTR LEFT LEN LTRIM MID RIGHT RTRIM STRING STRINGNC TOLOWER TOUPPER TRIM ' +
+ 'NUMDAYS READ_DATE STAGING',
+ built_in: 'IDENTIFIER OPTIONS XML_ELEMENT XML_OP XML_ELEMENT_OF DOMDOCCREATE DOMDOCLOADFILE DOMDOCLOADXML ' +
+ 'DOMDOCSAVEFILE DOMDOCGETROOT DOMDOCADDPI DOMNODEGETNAME DOMNODEGETTYPE DOMNODEGETVALUE DOMNODEGETCHILDCT ' +
+ 'DOMNODEGETFIRSTCHILD DOMNODEGETSIBLING DOMNODECREATECHILDELEMENT DOMNODESETATTRIBUTE ' +
+ 'DOMNODEGETCHILDELEMENTCT DOMNODEGETFIRSTCHILDELEMENT DOMNODEGETSIBLINGELEMENT DOMNODEGETATTRIBUTECT ' +
+ 'DOMNODEGETATTRIBUTEI DOMNODEGETATTRIBUTEBYNAME DOMNODEGETBYNAME'
+ },
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ { className: 'array',
+ begin: '\#[a-zA-Z\ \.]+'
+ }
+ ]
+ };
+};
+},{}],110:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['rs'],
+ keywords: {
+ keyword:
+ 'alignof as be box break const continue crate do else enum extern ' +
+ 'false fn for if impl in let loop match mod mut offsetof once priv ' +
+ 'proc pub pure ref return self sizeof static struct super trait true ' +
+ 'type typeof unsafe unsized use virtual while yield ' +
+ 'int i8 i16 i32 i64 ' +
+ 'uint u8 u32 u64 ' +
+ 'float f32 f64 ' +
+ 'str char bool',
+ built_in:
+ 'assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! ' +
+ 'debug_assert! debug_assert_eq! env! fail! file! format! format_args! ' +
+ 'include_bin! include_str! line! local_data_key! module_path! ' +
+ 'option_env! print! println! select! stringify! try! unimplemented! ' +
+ 'unreachable! vec! write! writeln!'
+ },
+ lexemes: hljs.IDENT_RE + '!?',
+ illegal: '',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
+ {
+ className: 'string',
+ begin: /r(#*)".*?"\1(?!#)/
+ },
+ {
+ className: 'string',
+ begin: /'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/
+ },
+ {
+ begin: /'[a-zA-Z_][a-zA-Z0-9_]*/
+ },
+ {
+ className: 'number',
+ begin: '\\b(0[xb][A-Za-z0-9_]+|[0-9_]+(\\.[0-9_]+)?([uif](8|16|32|64)?)?)',
+ relevance: 0
+ },
+ {
+ className: 'function',
+ beginKeywords: 'fn', end: '(\\(|<)', excludeEnd: true,
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
+ },
+ {
+ className: 'preprocessor',
+ begin: '#\\[', end: '\\]'
+ },
+ {
+ beginKeywords: 'type', end: '(=|<)',
+ contains: [hljs.UNDERSCORE_TITLE_MODE],
+ illegal: '\\S'
+ },
+ {
+ beginKeywords: 'trait enum', end: '({|<)',
+ contains: [hljs.UNDERSCORE_TITLE_MODE],
+ illegal: '\\S'
+ },
+ {
+ begin: hljs.IDENT_RE + '::'
+ },
+ {
+ begin: '->'
+ }
+ ]
+ };
+};
+},{}],111:[function(require,module,exports){
+module.exports = function(hljs) {
+
+ var ANNOTATION = {
+ className: 'annotation', begin: '@[A-Za-z]+'
+ };
+
+ var STRING = {
+ className: 'string',
+ begin: 'u?r?"""', end: '"""',
+ relevance: 10
+ };
+
+ var SYMBOL = {
+ className: 'symbol',
+ begin: '\'\\w[\\w\\d_]*(?!\')'
+ };
+
+ var TYPE = {
+ className: 'type',
+ begin: '\\b[A-Z][A-Za-z0-9_]*',
+ relevance: 0
+ };
+
+ var NAME = {
+ className: 'title',
+ begin: /[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/,
+ relevance: 0
+ }
+
+ var CLASS = {
+ className: 'class',
+ beginKeywords: 'class object trait type',
+ end: /[:={\[(\n;]/,
+ contains: [{className: 'keyword', beginKeywords: 'extends with', relevance: 10}, NAME]
+ };
+
+ var METHOD = {
+ className: 'function',
+ beginKeywords: 'def val',
+ end: /[:={\[(\n;]/,
+ contains: [NAME]
+ };
+
+ var JAVADOC = {
+ className: 'javadoc',
+ begin: '/\\*\\*', end: '\\*/',
+ contains: [{
+ className: 'javadoctag',
+ begin: '@[A-Za-z]+'
+ }],
+ relevance: 10
+ };
+
+ return {
+ keywords: {
+ literal: 'true false null',
+ keyword: 'type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit'
+ },
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ STRING,
+ hljs.QUOTE_STRING_MODE,
+ SYMBOL,
+ TYPE,
+ METHOD,
+ CLASS,
+ hljs.C_NUMBER_MODE,
+ ANNOTATION
+ ]
+ };
+};
+},{}],112:[function(require,module,exports){
+module.exports = function(hljs) {
+ var SCHEME_IDENT_RE = '[^\\(\\)\\[\\]\\{\\}",\'`;#|\\\\\\s]+';
+ var SCHEME_SIMPLE_NUMBER_RE = '(\\-|\\+)?\\d+([./]\\d+)?';
+ var SCHEME_COMPLEX_NUMBER_RE = SCHEME_SIMPLE_NUMBER_RE + '[+\\-]' + SCHEME_SIMPLE_NUMBER_RE + 'i';
+ var BUILTINS = {
+ built_in:
+ 'case-lambda call/cc class define-class exit-handler field import ' +
+ 'inherit init-field interface let*-values let-values let/ec mixin ' +
+ 'opt-lambda override protect provide public rename require ' +
+ 'require-for-syntax syntax syntax-case syntax-error unit/sig unless ' +
+ 'when with-syntax and begin call-with-current-continuation ' +
+ 'call-with-input-file call-with-output-file case cond define ' +
+ 'define-syntax delay do dynamic-wind else for-each if lambda let let* ' +
+ 'let-syntax letrec letrec-syntax map or syntax-rules \' * + , ,@ - ... / ' +
+ '; < <= = => > >= ` abs acos angle append apply asin assoc assq assv atan ' +
+ 'boolean? caar cadr call-with-input-file call-with-output-file ' +
+ 'call-with-values car cdddar cddddr cdr ceiling char->integer ' +
+ 'char-alphabetic? char-ci<=? char-ci char-ci=? char-ci>=? char-ci>? ' +
+ 'char-downcase char-lower-case? char-numeric? char-ready? char-upcase ' +
+ 'char-upper-case? char-whitespace? char<=? char char=? char>=? char>? ' +
+ 'char? close-input-port close-output-port complex? cons cos ' +
+ 'current-input-port current-output-port denominator display eof-object? ' +
+ 'eq? equal? eqv? eval even? exact->inexact exact? exp expt floor ' +
+ 'force gcd imag-part inexact->exact inexact? input-port? integer->char ' +
+ 'integer? interaction-environment lcm length list list->string ' +
+ 'list->vector list-ref list-tail list? load log magnitude make-polar ' +
+ 'make-rectangular make-string make-vector max member memq memv min ' +
+ 'modulo negative? newline not null-environment null? number->string ' +
+ 'number? numerator odd? open-input-file open-output-file output-port? ' +
+ 'pair? peek-char port? positive? procedure? quasiquote quote quotient ' +
+ 'rational? rationalize read read-char real-part real? remainder reverse ' +
+ 'round scheme-report-environment set! set-car! set-cdr! sin sqrt string ' +
+ 'string->list string->number string->symbol string-append string-ci<=? ' +
+ 'string-ci string-ci=? string-ci>=? string-ci>? string-copy ' +
+ 'string-fill! string-length string-ref string-set! string<=? string ' +
+ 'string=? string>=? string>? string? substring symbol->string symbol? ' +
+ 'tan transcript-off transcript-on truncate values vector ' +
+ 'vector->list vector-fill! vector-length vector-ref vector-set! ' +
+ 'with-input-from-file with-output-to-file write write-char zero?'
+ };
+
+ var SHEBANG = {
+ className: 'shebang',
+ begin: '^#!',
+ end: '$'
+ };
+
+ var LITERAL = {
+ className: 'literal',
+ begin: '(#t|#f|#\\\\' + SCHEME_IDENT_RE + '|#\\\\.)'
+ };
+
+ var NUMBER = {
+ className: 'number',
+ variants: [
+ { begin: SCHEME_SIMPLE_NUMBER_RE, relevance: 0 },
+ { begin: SCHEME_COMPLEX_NUMBER_RE, relevance: 0 },
+ { begin: '#b[0-1]+(/[0-1]+)?' },
+ { begin: '#o[0-7]+(/[0-7]+)?' },
+ { begin: '#x[0-9a-f]+(/[0-9a-f]+)?' }
+ ]
+ };
+
+ var STRING = hljs.QUOTE_STRING_MODE;
+
+ var REGULAR_EXPRESSION = {
+ className: 'regexp',
+ begin: '#[pr]x"',
+ end: '[^\\\\]"'
+ };
+
+ var COMMENT = {
+ className: 'comment',
+ variants: [
+ { begin: ';', end: '$', relevance: 0 },
+ { begin: '#\\|', end: '\\|#' }
+ ]
+ };
+
+ var IDENT = {
+ begin: SCHEME_IDENT_RE,
+ relevance: 0
+ };
+
+ var QUOTED_IDENT = {
+ className: 'variable',
+ begin: '\'' + SCHEME_IDENT_RE
+ };
+
+ var BODY = {
+ endsWithParent: true,
+ relevance: 0
+ };
+
+ var LIST = {
+ className: 'list',
+ variants: [
+ { begin: '\\(', end: '\\)' },
+ { begin: '\\[', end: '\\]' }
+ ],
+ contains: [
+ {
+ className: 'keyword',
+ begin: SCHEME_IDENT_RE,
+ lexemes: SCHEME_IDENT_RE,
+ keywords: BUILTINS
+ },
+ BODY
+ ]
+ };
+
+ BODY.contains = [LITERAL, NUMBER, STRING, COMMENT, IDENT, QUOTED_IDENT, LIST];
+
+ return {
+ illegal: /\S/,
+ contains: [SHEBANG, NUMBER, STRING, COMMENT, QUOTED_IDENT, LIST]
+ };
+};
+},{}],113:[function(require,module,exports){
+module.exports = function(hljs) {
+
+ var COMMON_CONTAINS = [
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'string',
+ begin: '\'|\"', end: '\'|\"',
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
+ }
+ ];
+
+ return {
+ aliases: ['sci'],
+ keywords: {
+ keyword: 'abort break case clear catch continue do elseif else endfunction end for function'+
+ 'global if pause return resume select try then while'+
+ '%f %F %t %T %pi %eps %inf %nan %e %i %z %s',
+ built_in: // Scilab has more than 2000 functions. Just list the most commons
+ 'abs and acos asin atan ceil cd chdir clearglobal cosh cos cumprod deff disp error'+
+ 'exec execstr exists exp eye gettext floor fprintf fread fsolve imag isdef isempty'+
+ 'isinfisnan isvector lasterror length load linspace list listfiles log10 log2 log'+
+ 'max min msprintf mclose mopen ones or pathconvert poly printf prod pwd rand real'+
+ 'round sinh sin size gsort sprintf sqrt strcat strcmps tring sum system tanh tan'+
+ 'type typename warning zeros matrix'
+ },
+ illegal: '("|#|/\\*|\\s+/\\w+)',
+ contains: [
+ {
+ className: 'function',
+ beginKeywords: 'function endfunction', end: '$',
+ keywords: 'function endfunction|10',
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)'
+ }
+ ]
+ },
+ {
+ className: 'transposed_variable',
+ begin: '[a-zA-Z_][a-zA-Z_0-9]*(\'+[\\.\']*|[\\.\']+)', end: '',
+ relevance: 0
+ },
+ {
+ className: 'matrix',
+ begin: '\\[', end: '\\]\'*[\\.\']*',
+ relevance: 0,
+ contains: COMMON_CONTAINS
+ },
+ {
+ className: 'comment',
+ begin: '//', end: '$'
+ }
+ ].concat(COMMON_CONTAINS)
+ };
+};
+},{}],114:[function(require,module,exports){
+module.exports = function(hljs) {
+ var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
+ var VARIABLE = {
+ className: 'variable',
+ begin: '(\\$' + IDENT_RE + ')\\b'
+ };
+ var FUNCTION = {
+ className: 'function',
+ begin: IDENT_RE + '\\(',
+ returnBegin: true,
+ excludeEnd: true,
+ end: '\\('
+ };
+ var HEXCOLOR = {
+ className: 'hexcolor', begin: '#[0-9A-Fa-f]+'
+ };
+ var DEF_INTERNALS = {
+ className: 'attribute',
+ begin: '[A-Z\\_\\.\\-]+', end: ':',
+ excludeEnd: true,
+ illegal: '[^\\s]',
+ starts: {
+ className: 'value',
+ endsWithParent: true, excludeEnd: true,
+ contains: [
+ FUNCTION,
+ HEXCOLOR,
+ hljs.CSS_NUMBER_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'important', begin: '!important'
+ }
+ ]
+ }
+ };
+ return {
+ case_insensitive: true,
+ illegal: '[=/|\']',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ FUNCTION,
+ {
+ className: 'id', begin: '\\#[A-Za-z0-9_-]+',
+ relevance: 0
+ },
+ {
+ className: 'class', begin: '\\.[A-Za-z0-9_-]+',
+ relevance: 0
+ },
+ {
+ className: 'attr_selector',
+ begin: '\\[', end: '\\]',
+ illegal: '$'
+ },
+ {
+ className: 'tag', // begin: IDENT_RE, end: '[,|\\s]'
+ begin: '\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b',
+ relevance: 0
+ },
+ {
+ className: 'pseudo',
+ begin: ':(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)'
+ },
+ {
+ className: 'pseudo',
+ begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
+ },
+ VARIABLE,
+ {
+ className: 'attribute',
+ begin: '\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b',
+ illegal: '[^\\s]'
+ },
+ {
+ className: 'value',
+ begin: '\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b'
+ },
+ {
+ className: 'value',
+ begin: ':', end: ';',
+ contains: [
+ FUNCTION,
+ VARIABLE,
+ HEXCOLOR,
+ hljs.CSS_NUMBER_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+ {
+ className: 'important', begin: '!important'
+ }
+ ]
+ },
+ {
+ className: 'at_rule',
+ begin: '@', end: '[{;]',
+ keywords: 'mixin include extend for if else each while charset import debug media page content font-face namespace warn',
+ contains: [
+ FUNCTION,
+ VARIABLE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+ HEXCOLOR,
+ hljs.CSS_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '\\s[A-Za-z0-9_.-]+',
+ relevance: 0
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],115:[function(require,module,exports){
+module.exports = function(hljs) {
+ var VAR_IDENT_RE = '[a-z][a-zA-Z0-9_]*';
+ var CHAR = {
+ className: 'char',
+ begin: '\\$.{1}'
+ };
+ var SYMBOL = {
+ className: 'symbol',
+ begin: '#' + hljs.UNDERSCORE_IDENT_RE
+ };
+ return {
+ aliases: ['st'],
+ keywords: 'self super nil true false thisContext', // only 6
+ contains: [
+ {
+ className: 'comment',
+ begin: '"', end: '"'
+ },
+ hljs.APOS_STRING_MODE,
+ {
+ className: 'class',
+ begin: '\\b[A-Z][A-Za-z0-9_]*',
+ relevance: 0
+ },
+ {
+ className: 'method',
+ begin: VAR_IDENT_RE + ':',
+ relevance: 0
+ },
+ hljs.C_NUMBER_MODE,
+ SYMBOL,
+ CHAR,
+ {
+ className: 'localvars',
+ // This looks more complicated than needed to avoid combinatorial
+ // explosion under V8. It effectively means `| var1 var2 ... |` with
+ // whitespace adjacent to `|` being optional.
+ begin: '\\|[ ]*' + VAR_IDENT_RE + '([ ]+' + VAR_IDENT_RE + ')*[ ]*\\|',
+ returnBegin: true, end: /\|/,
+ illegal: /\S/,
+ contains: [{begin: '(\\|[ ]*)?' + VAR_IDENT_RE}]
+ },
+ {
+ className: 'array',
+ begin: '\\#\\(', end: '\\)',
+ contains: [
+ hljs.APOS_STRING_MODE,
+ CHAR,
+ hljs.C_NUMBER_MODE,
+ SYMBOL
+ ]
+ }
+ ]
+ };
+};
+},{}],116:[function(require,module,exports){
+module.exports = function(hljs) {
+ var COMMENT_MODE = {
+ className: 'comment',
+ begin: '--', end: '$'
+ };
+ return {
+ case_insensitive: true,
+ illegal: /[<>]/,
+ contains: [
+ {
+ className: 'operator',
+ beginKeywords:
+ 'begin end start commit rollback savepoint lock alter create drop rename call '+
+ 'delete do handler insert load replace select truncate update set show pragma grant '+
+ 'merge describe use explain help declare prepare execute deallocate savepoint release '+
+ 'unlock purge reset change stop analyze cache flush optimize repair kill '+
+ 'install uninstall checksum restore check backup',
+ end: /;/, endsWithParent: true,
+ keywords: {
+ keyword:
+ 'abs absolute acos action add adddate addtime aes_decrypt aes_encrypt after aggregate all allocate alter ' +
+ 'analyze and any are as asc ascii asin assertion at atan atan2 atn2 authorization authors avg backup ' +
+ 'before begin benchmark between bin binlog bit_and bit_count bit_length bit_or bit_xor both by ' +
+ 'cache call cascade cascaded case cast catalog ceil ceiling chain change changed char_length ' +
+ 'character_length charindex charset check checksum checksum_agg choose close coalesce ' +
+ 'coercibility collate collation collationproperty column columns columns_updated commit compress concat ' +
+ 'concat_ws concurrent connect connection connection_id consistent constraint constraints continue ' +
+ 'contributors conv convert convert_tz corresponding cos cot count count_big crc32 create cross cume_dist ' +
+ 'curdate current current_date current_time current_timestamp current_user cursor curtime data database ' +
+ 'databases datalength date_add date_format date_sub dateadd datediff datefromparts datename ' +
+ 'datepart datetime2fromparts datetimeoffsetfromparts day dayname dayofmonth dayofweek dayofyear ' +
+ 'deallocate declare decode default deferrable deferred degrees delayed delete des_decrypt ' +
+ 'des_encrypt des_key_file desc describe descriptor diagnostics difference disconnect distinct ' +
+ 'distinctrow div do domain double drop dumpfile each else elt enclosed encode encrypt end end-exec ' +
+ 'engine engines eomonth errors escape escaped event eventdata events except exception exec execute ' +
+ 'exists exp explain export_set extended external extract fast fetch field fields find_in_set ' +
+ 'first first_value floor flush for force foreign format found found_rows from from_base64 ' +
+ 'from_days from_unixtime full function get get_format get_lock getdate getutcdate global go goto grant ' +
+ 'grants greatest group group_concat grouping grouping_id gtid_subset gtid_subtract handler having help ' +
+ 'hex high_priority hosts hour ident_current ident_incr ident_seed identified identity if ifnull ignore ' +
+ 'iif ilike immediate in index indicator inet6_aton inet6_ntoa inet_aton inet_ntoa infile initially inner ' +
+ 'innodb input insert install instr intersect into is is_free_lock is_ipv4 ' +
+ 'is_ipv4_compat is_ipv4_mapped is_not is_not_null is_used_lock isdate isnull isolation join key kill ' +
+ 'language last last_day last_insert_id last_value lcase lead leading least leaves left len lenght level ' +
+ 'like limit lines ln load load_file local localtime localtimestamp locate lock log log10 log2 logfile ' +
+ 'logs low_priority lower lpad ltrim make_set makedate maketime master master_pos_wait match matched max ' +
+ 'md5 medium merge microsecond mid min minute mod mode module month monthname mutex name_const names ' +
+ 'national natural nchar next no no_write_to_binlog not now nullif nvarchar oct ' +
+ 'octet_length of old_password on only open optimize option optionally or ord order outer outfile output ' +
+ 'pad parse partial partition password patindex percent_rank percentile_cont percentile_disc period_add ' +
+ 'period_diff pi plugin position pow power pragma precision prepare preserve primary prior privileges ' +
+ 'procedure procedure_analyze processlist profile profiles public publishingservername purge quarter ' +
+ 'query quick quote quotename radians rand read references regexp relative relaylog release ' +
+ 'release_lock rename repair repeat replace replicate reset restore restrict return returns reverse ' +
+ 'revoke right rlike rollback rollup round row row_count rows rpad rtrim savepoint schema scroll ' +
+ 'sec_to_time second section select serializable server session session_user set sha sha1 sha2 share ' +
+ 'show sign sin size slave sleep smalldatetimefromparts snapshot some soname soundex ' +
+ 'sounds_like space sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache ' +
+ 'sql_small_result sql_variant_property sqlstate sqrt square start starting status std ' +
+ 'stddev stddev_pop stddev_samp stdev stdevp stop str str_to_date straight_join strcmp string stuff ' +
+ 'subdate substr substring subtime subtring_index sum switchoffset sysdate sysdatetime sysdatetimeoffset ' +
+ 'system_user sysutcdatetime table tables tablespace tan temporary terminated tertiary_weights then time ' +
+ 'time_format time_to_sec timediff timefromparts timestamp timestampadd timestampdiff timezone_hour ' +
+ 'timezone_minute to to_base64 to_days to_seconds todatetimeoffset trailing transaction translation ' +
+ 'trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse ucase uncompress ' +
+ 'uncompressed_length unhex unicode uninstall union unique unix_timestamp unknown unlock update upgrade ' +
+ 'upped upper usage use user user_resources using utc_date utc_time utc_timestamp uuid uuid_short ' +
+ 'validate_password_strength value values var var_pop var_samp variables variance varp ' +
+ 'version view warnings week weekday weekofyear weight_string when whenever where with work write xml ' +
+ 'xor year yearweek zon',
+ literal:
+ 'true false null',
+ built_in:
+ 'array bigint binary bit blob boolean char character date dec decimal float int integer interval number ' +
+ 'numeric real serial smallint varchar varying int8 serial8 text'
+ },
+ contains: [
+ {
+ className: 'string',
+ begin: '\'', end: '\'',
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
+ },
+ {
+ className: 'string',
+ begin: '"', end: '"',
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '""'}]
+ },
+ {
+ className: 'string',
+ begin: '`', end: '`',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ hljs.C_NUMBER_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ COMMENT_MODE
+ ]
+ },
+ hljs.C_BLOCK_COMMENT_MODE,
+ COMMENT_MODE
+ ]
+ };
+};
+},{}],117:[function(require,module,exports){
+module.exports = function(hljs) {
+
+ var VARIABLE = {
+ className: 'variable',
+ begin: '\\$' + hljs.IDENT_RE
+ };
+
+ var HEX_COLOR = {
+ className: 'hexcolor',
+ begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})',
+ relevance: 10
+ };
+
+ var AT_KEYWORDS = [
+ 'charset',
+ 'css',
+ 'debug',
+ 'extend',
+ 'font-face',
+ 'for',
+ 'import',
+ 'include',
+ 'media',
+ 'mixin',
+ 'page',
+ 'warn',
+ 'while'
+ ];
+
+ var PSEUDO_SELECTORS = [
+ 'after',
+ 'before',
+ 'first-letter',
+ 'first-line',
+ 'active',
+ 'first-child',
+ 'focus',
+ 'hover',
+ 'lang',
+ 'link',
+ 'visited'
+ ];
+
+ var TAGS = [
+ 'a',
+ 'abbr',
+ 'address',
+ 'article',
+ 'aside',
+ 'audio',
+ 'b',
+ 'blockquote',
+ 'body',
+ 'button',
+ 'canvas',
+ 'caption',
+ 'cite',
+ 'code',
+ 'dd',
+ 'del',
+ 'details',
+ 'dfn',
+ 'div',
+ 'dl',
+ 'dt',
+ 'em',
+ 'fieldset',
+ 'figcaption',
+ 'figure',
+ 'footer',
+ 'form',
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6',
+ 'header',
+ 'hgroup',
+ 'html',
+ 'i',
+ 'iframe',
+ 'img',
+ 'input',
+ 'ins',
+ 'kbd',
+ 'label',
+ 'legend',
+ 'li',
+ 'mark',
+ 'menu',
+ 'nav',
+ 'object',
+ 'ol',
+ 'p',
+ 'q',
+ 'quote',
+ 'samp',
+ 'section',
+ 'span',
+ 'strong',
+ 'summary',
+ 'sup',
+ 'table',
+ 'tbody',
+ 'td',
+ 'textarea',
+ 'tfoot',
+ 'th',
+ 'thead',
+ 'time',
+ 'tr',
+ 'ul',
+ 'var',
+ 'video'
+ ];
+
+ var TAG_END = '[\\.\\s\\n\\[\\:,]';
+
+ var ATTRIBUTES = [
+ 'align-content',
+ 'align-items',
+ 'align-self',
+ 'animation',
+ 'animation-delay',
+ 'animation-direction',
+ 'animation-duration',
+ 'animation-fill-mode',
+ 'animation-iteration-count',
+ 'animation-name',
+ 'animation-play-state',
+ 'animation-timing-function',
+ 'auto',
+ 'backface-visibility',
+ 'background',
+ 'background-attachment',
+ 'background-clip',
+ 'background-color',
+ 'background-image',
+ 'background-origin',
+ 'background-position',
+ 'background-repeat',
+ 'background-size',
+ 'border',
+ 'border-bottom',
+ 'border-bottom-color',
+ 'border-bottom-left-radius',
+ 'border-bottom-right-radius',
+ 'border-bottom-style',
+ 'border-bottom-width',
+ 'border-collapse',
+ 'border-color',
+ 'border-image',
+ 'border-image-outset',
+ 'border-image-repeat',
+ 'border-image-slice',
+ 'border-image-source',
+ 'border-image-width',
+ 'border-left',
+ 'border-left-color',
+ 'border-left-style',
+ 'border-left-width',
+ 'border-radius',
+ 'border-right',
+ 'border-right-color',
+ 'border-right-style',
+ 'border-right-width',
+ 'border-spacing',
+ 'border-style',
+ 'border-top',
+ 'border-top-color',
+ 'border-top-left-radius',
+ 'border-top-right-radius',
+ 'border-top-style',
+ 'border-top-width',
+ 'border-width',
+ 'bottom',
+ 'box-decoration-break',
+ 'box-shadow',
+ 'box-sizing',
+ 'break-after',
+ 'break-before',
+ 'break-inside',
+ 'caption-side',
+ 'clear',
+ 'clip',
+ 'clip-path',
+ 'color',
+ 'column-count',
+ 'column-fill',
+ 'column-gap',
+ 'column-rule',
+ 'column-rule-color',
+ 'column-rule-style',
+ 'column-rule-width',
+ 'column-span',
+ 'column-width',
+ 'columns',
+ 'content',
+ 'counter-increment',
+ 'counter-reset',
+ 'cursor',
+ 'direction',
+ 'display',
+ 'empty-cells',
+ 'filter',
+ 'flex',
+ 'flex-basis',
+ 'flex-direction',
+ 'flex-flow',
+ 'flex-grow',
+ 'flex-shrink',
+ 'flex-wrap',
+ 'float',
+ 'font',
+ 'font-family',
+ 'font-feature-settings',
+ 'font-kerning',
+ 'font-language-override',
+ 'font-size',
+ 'font-size-adjust',
+ 'font-stretch',
+ 'font-style',
+ 'font-variant',
+ 'font-variant-ligatures',
+ 'font-weight',
+ 'height',
+ 'hyphens',
+ 'icon',
+ 'image-orientation',
+ 'image-rendering',
+ 'image-resolution',
+ 'ime-mode',
+ 'inherit',
+ 'initial',
+ 'justify-content',
+ 'left',
+ 'letter-spacing',
+ 'line-height',
+ 'list-style',
+ 'list-style-image',
+ 'list-style-position',
+ 'list-style-type',
+ 'margin',
+ 'margin-bottom',
+ 'margin-left',
+ 'margin-right',
+ 'margin-top',
+ 'marks',
+ 'mask',
+ 'max-height',
+ 'max-width',
+ 'min-height',
+ 'min-width',
+ 'nav-down',
+ 'nav-index',
+ 'nav-left',
+ 'nav-right',
+ 'nav-up',
+ 'none',
+ 'normal',
+ 'object-fit',
+ 'object-position',
+ 'opacity',
+ 'order',
+ 'orphans',
+ 'outline',
+ 'outline-color',
+ 'outline-offset',
+ 'outline-style',
+ 'outline-width',
+ 'overflow',
+ 'overflow-wrap',
+ 'overflow-x',
+ 'overflow-y',
+ 'padding',
+ 'padding-bottom',
+ 'padding-left',
+ 'padding-right',
+ 'padding-top',
+ 'page-break-after',
+ 'page-break-before',
+ 'page-break-inside',
+ 'perspective',
+ 'perspective-origin',
+ 'pointer-events',
+ 'position',
+ 'quotes',
+ 'resize',
+ 'right',
+ 'tab-size',
+ 'table-layout',
+ 'text-align',
+ 'text-align-last',
+ 'text-decoration',
+ 'text-decoration-color',
+ 'text-decoration-line',
+ 'text-decoration-style',
+ 'text-indent',
+ 'text-overflow',
+ 'text-rendering',
+ 'text-shadow',
+ 'text-transform',
+ 'text-underline-position',
+ 'top',
+ 'transform',
+ 'transform-origin',
+ 'transform-style',
+ 'transition',
+ 'transition-delay',
+ 'transition-duration',
+ 'transition-property',
+ 'transition-timing-function',
+ 'unicode-bidi',
+ 'vertical-align',
+ 'visibility',
+ 'white-space',
+ 'widows',
+ 'width',
+ 'word-break',
+ 'word-spacing',
+ 'word-wrap',
+ 'z-index'
+ ];
+
+ // illegals
+ var ILLEGAL = [
+ '\\{',
+ '\\}',
+ '\\?',
+ '(\\bReturn\\b)', // monkey
+ '(\\bEnd\\b)', // monkey
+ '(\\bend\\b)', // vbscript
+ ';', // sql
+ '#\\s', // markdown
+ '\\*\\s', // markdown
+ '===\\s' // markdown
+ ];
+
+ return {
+ aliases: ['styl'],
+ case_insensitive: false,
+ illegal: '(' + ILLEGAL.join('|') + ')',
+ keywords: 'if else for in',
+ contains: [
+
+ // strings
+ hljs.QUOTE_STRING_MODE,
+ hljs.APOS_STRING_MODE,
+
+ // comments
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+
+ // hex colors
+ HEX_COLOR,
+
+ // class tag
+ {
+ begin: '\\.[a-zA-Z][a-zA-Z0-9_-]*' + TAG_END,
+ returnBegin: true,
+ contains: [
+ {className: 'class', begin: '\\.[a-zA-Z][a-zA-Z0-9_-]*'}
+ ]
+ },
+
+ // id tag
+ {
+ begin: '\\#[a-zA-Z][a-zA-Z0-9_-]*' + TAG_END,
+ returnBegin: true,
+ contains: [
+ {className: 'id', begin: '\\#[a-zA-Z][a-zA-Z0-9_-]*'}
+ ]
+ },
+
+ // tags
+ {
+ begin: '\\b(' + TAGS.join('|') + ')' + TAG_END,
+ returnBegin: true,
+ contains: [
+ {className: 'tag', begin: '\\b[a-zA-Z][a-zA-Z0-9_-]*'}
+ ]
+ },
+
+ // psuedo selectors
+ {
+ className: 'pseudo',
+ begin: '&?:?:\\b(' + PSEUDO_SELECTORS.join('|') + ')' + TAG_END
+ },
+
+ // @ keywords
+ {
+ className: 'at_rule',
+ begin: '\@(' + AT_KEYWORDS.join('|') + ')\\b'
+ },
+
+ // variables
+ VARIABLE,
+
+ // dimension
+ hljs.CSS_NUMBER_MODE,
+
+ // number
+ hljs.NUMBER_MODE,
+
+ // functions
+ // - only from beginning of line + whitespace
+ {
+ className: 'function',
+ begin: '\\b[a-zA-Z][a-zA-Z0-9_\-]*\\(.*\\)',
+ illegal: '[\\n]',
+ returnBegin: true,
+ contains: [
+ {className: 'title', begin: '\\b[a-zA-Z][a-zA-Z0-9_\-]*'},
+ {
+ className: 'params',
+ begin: /\(/,
+ end: /\)/,
+ contains: [
+ HEX_COLOR,
+ VARIABLE,
+ hljs.APOS_STRING_MODE,
+ hljs.CSS_NUMBER_MODE,
+ hljs.NUMBER_MODE,
+ hljs.QUOTE_STRING_MODE
+ ]
+ }
+ ]
+ },
+
+ // attributes
+ // - only from beginning of line + whitespace
+ // - must have whitespace after it
+ {
+ className: 'attribute',
+ begin: '\\b(' + ATTRIBUTES.reverse().join('|') + ')\\b'
+ }
+ ]
+ };
+};
+},{}],118:[function(require,module,exports){
+module.exports = function(hljs) {
+ var SWIFT_KEYWORDS = {
+ keyword: 'class deinit enum extension func import init let protocol static ' +
+ 'struct subscript typealias var break case continue default do ' +
+ 'else fallthrough if in for return switch where while as dynamicType ' +
+ 'is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ ' +
+ '__LINE__ associativity didSet get infix inout left mutating none ' +
+ 'nonmutating operator override postfix precedence prefix right set '+
+ 'unowned unowned safe unsafe weak willSet',
+ literal: 'true false nil',
+ built_in: 'abs advance alignof alignofValue assert bridgeFromObjectiveC ' +
+ 'bridgeFromObjectiveCUnconditional bridgeToObjectiveC ' +
+ 'bridgeToObjectiveCUnconditional c contains count countElements ' +
+ 'countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump ' +
+ 'encodeBitsAsWords enumerate equal false filter find getBridgedObjectiveCType ' +
+ 'getVaList indices insertionSort isBridgedToObjectiveC ' +
+ 'isBridgedVerbatimToObjectiveC isUniquelyReferenced join ' +
+ 'lexicographicalCompare map max maxElement min minElement nil numericCast ' +
+ 'partition posix print println quickSort reduce reflect reinterpretCast ' +
+ 'reverse roundUpToAlignment sizeof sizeofValue sort split startsWith strideof ' +
+ 'strideofValue swap swift toString transcode true underestimateCount ' +
+ 'unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer ' +
+ 'withUnsafePointerToObject withUnsafePointers withVaList'
+ };
+
+ var TYPE = {
+ className: 'type',
+ begin: '\\b[A-Z][\\w\']*',
+ relevance: 0
+ };
+ var BLOCK_COMMENT = {
+ className: 'comment',
+ begin: '/\\*', end: '\\*/',
+ contains: [hljs.PHRASAL_WORDS_MODE, 'self']
+ };
+ var SUBST = {
+ className: 'subst',
+ begin: /\\\(/, end: '\\)',
+ keywords: SWIFT_KEYWORDS,
+ contains: [] // assigned later
+ };
+ var NUMBERS = {
+ className: 'number',
+ begin: '\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b',
+ relevance: 0
+ };
+ var QUOTE_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, {
+ contains: [SUBST, hljs.BACKSLASH_ESCAPE]
+ });
+ SUBST.contains = [NUMBERS];
+
+ return {
+ keywords: SWIFT_KEYWORDS,
+ contains: [
+ QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ BLOCK_COMMENT,
+ TYPE,
+ NUMBERS,
+ {
+ className: 'func',
+ beginKeywords: 'func', end: '{', excludeEnd: true,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ begin: /[A-Za-z$_][0-9A-Za-z$_]*/,
+ illegal: /\(/
+ }),
+ {
+ className: 'generics',
+ begin: /\, end: /\>/,
+ illegal: /\>/
+ },
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ keywords: SWIFT_KEYWORDS,
+ contains: [
+ 'self',
+ NUMBERS,
+ QUOTE_STRING_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {begin: ':'} // relevance booster
+ ],
+ illegal: /["']/
+ }
+ ],
+ illegal: /\[|%/
+ },
+ {
+ className: 'class',
+ keywords: 'struct protocol class extension enum',
+ begin: '(struct|protocol|class(?! (func|var))|extension|enum)',
+ end: '\\{',
+ excludeEnd: true,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: /[A-Za-z$_][0-9A-Za-z$_]*/})
+ ]
+ },
+ {
+ className: 'preprocessor', // @attributes
+ begin: '(@assignment|@class_protocol|@exported|@final|@lazy|@noreturn|' +
+ '@NSCopying|@NSManaged|@objc|@optional|@required|@auto_closure|' +
+ '@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|' +
+ '@infix|@prefix|@postfix)'
+ },
+ ]
+ };
+};
+},{}],119:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['tk'],
+ keywords: 'after append apply array auto_execok auto_import auto_load auto_mkindex ' +
+ 'auto_mkindex_old auto_qualify auto_reset bgerror binary break catch cd chan clock ' +
+ 'close concat continue dde dict encoding eof error eval exec exit expr fblocked ' +
+ 'fconfigure fcopy file fileevent filename flush for foreach format gets glob global ' +
+ 'history http if incr info interp join lappend|10 lassign|10 lindex|10 linsert|10 list ' +
+ 'llength|10 load lrange|10 lrepeat|10 lreplace|10 lreverse|10 lsearch|10 lset|10 lsort|10 '+
+ 'mathfunc mathop memory msgcat namespace open package parray pid pkg::create pkg_mkIndex '+
+ 'platform platform::shell proc puts pwd read refchan regexp registry regsub|10 rename '+
+ 'return safe scan seek set socket source split string subst switch tcl_endOfWord '+
+ 'tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter '+
+ 'tcl_wordBreakBefore tcltest tclvars tell time tm trace unknown unload unset update '+
+ 'uplevel upvar variable vwait while',
+ contains: [
+ {
+ className: 'comment',
+ variants: [
+ {begin: ';[ \\t]*#', end: '$'},
+ {begin: '^[ \\t]*#', end: '$'}
+ ]
+ },
+ {
+ beginKeywords: 'proc',
+ end: '[\\{]',
+ excludeEnd: true,
+ contains: [
+ {
+ className: 'symbol',
+ begin: '[ \\t\\n\\r]+(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
+ end: '[ \\t\\n\\r]',
+ endsWithParent: true,
+ excludeEnd: true,
+ }
+ ]
+ },
+ {
+ className: 'variable',
+ excludeEnd: true,
+ variants: [
+ {
+ begin: '\\$(\\{)?(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*\\(([a-zA-Z0-9_])*\\)',
+ end: '[^a-zA-Z0-9_\\}\\$]',
+ },
+ {
+ begin: '\\$(\\{)?(::)?[a-zA-Z_]((::)?[a-zA-Z0-9_])*',
+ end: '(\\))?[^a-zA-Z0-9_\\}\\$]',
+ },
+ ]
+ },
+ {
+ className: 'string',
+ contains: [hljs.BACKSLASH_ESCAPE],
+ variants: [
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
+ ]
+ },
+ {
+ className: 'number',
+ variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]
+ },
+ ]
+ }
+};
+},{}],120:[function(require,module,exports){
+module.exports = function(hljs) {
+ var COMMAND1 = {
+ className: 'command',
+ begin: '\\\\[a-zA-Zа-яА-я]+[\\*]?'
+ };
+ var COMMAND2 = {
+ className: 'command',
+ begin: '\\\\[^a-zA-Zа-яА-я0-9]'
+ };
+ var SPECIAL = {
+ className: 'special',
+ begin: '[{}\\[\\]\\~]',
+ relevance: 0
+ };
+
+ return {
+ contains: [
+ { // parameter
+ begin: '\\\\[a-zA-Zа-яА-я]+[\\*]? *= *-?\\d*\\.?\\d+(pt|pc|mm|cm|in|dd|cc|ex|em)?',
+ returnBegin: true,
+ contains: [
+ COMMAND1, COMMAND2,
+ {
+ className: 'number',
+ begin: ' *=', end: '-?\\d*\\.?\\d+(pt|pc|mm|cm|in|dd|cc|ex|em)?',
+ excludeBegin: true
+ }
+ ],
+ relevance: 10
+ },
+ COMMAND1, COMMAND2,
+ SPECIAL,
+ {
+ className: 'formula',
+ begin: '\\$\\$', end: '\\$\\$',
+ contains: [COMMAND1, COMMAND2, SPECIAL],
+ relevance: 0
+ },
+ {
+ className: 'formula',
+ begin: '\\$', end: '\\$',
+ contains: [COMMAND1, COMMAND2, SPECIAL],
+ relevance: 0
+ },
+ {
+ className: 'comment',
+ begin: '%', end: '$',
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],121:[function(require,module,exports){
+module.exports = function(hljs) {
+ var BUILT_IN_TYPES = 'bool byte i16 i32 i64 double string binary';
+ return {
+ keywords: {
+ keyword:
+ 'namespace const typedef struct enum service exception void oneway set list map required optional',
+ built_in:
+ BUILT_IN_TYPES,
+ literal:
+ 'true false'
+ },
+ contains: [
+ hljs.QUOTE_STRING_MODE,
+ hljs.NUMBER_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'class',
+ beginKeywords: 'struct enum service exception', end: /\{/,
+ illegal: /\n/,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {
+ starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
+ })
+ ]
+ },
+ {
+ className: 'stl_container',
+ begin: '\\b(set|list|map)\\s*<', end: '>',
+ keywords: BUILT_IN_TYPES,
+ contains: ['self']
+ }
+ ]
+ };
+};
+},{}],122:[function(require,module,exports){
+module.exports = function(hljs) {
+
+ var PARAMS = {
+ className: 'params',
+ begin: '\\(', end: '\\)'
+ };
+
+
+ var FUNCTION_NAMES = 'attribute block constant cycle date dump include ' +
+ 'max min parent random range source template_from_string';
+
+ var FUNCTIONS = {
+ className: 'function',
+ beginKeywords: FUNCTION_NAMES,
+ relevance: 0,
+ contains: [
+ PARAMS
+ ]
+ };
+
+ var FILTER = {
+ className: 'filter',
+ begin: /\|[A-Za-z]+\:?/,
+ keywords:
+ 'abs batch capitalize convert_encoding date date_modify default ' +
+ 'escape first format join json_encode keys last length lower ' +
+ 'merge nl2br number_format raw replace reverse round slice sort split ' +
+ 'striptags title trim upper url_encode',
+ contains: [
+ FUNCTIONS
+ ]
+ };
+
+
+ return {
+ aliases: ['craftcms'],
+ case_insensitive: true,
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ className: 'template_comment',
+ begin: /\{#/, end: /#}/
+ },
+
+ {
+ className: 'template_tag',
+ begin: /\{%/, end: /%}/,
+ keywords:
+ 'autoescape block do embed extends filter flush for ' +
+ 'if import include maro sandbox set spaceless use ' +
+ 'verbatim',
+ contains: [FILTER,FUNCTIONS]
+ },
+ {
+ className: 'variable',
+ begin: /\{\{/, end: /}}/,
+ contains: [FILTER,FUNCTIONS]
+ }
+ ]
+ };
+};
+},{}],123:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['ts'],
+ keywords: {
+ keyword:
+ 'in if for while finally var new function|0 do return void else break catch ' +
+ 'instanceof with throw case default try this switch continue typeof delete ' +
+ 'let yield const class public private get set super interface extends' +
+ 'static constructor implements enum export import declare',
+ literal:
+ 'true false null undefined NaN Infinity',
+ built_in:
+ 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' +
+ 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' +
+ 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' +
+ 'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
+ 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
+ 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
+ 'module console window document any number boolean string void',
+ },
+ contains: [
+ {
+ className: 'pi',
+ begin: /^\s*('|")use strict('|")/,
+ relevance: 0
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_NUMBER_MODE,
+ { // "value" container
+ begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
+ keywords: 'return throw case',
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.REGEXP_MODE,
+ { // E4X
+ begin: /, end: />;/,
+ relevance: 0,
+ subLanguage: 'xml'
+ }
+ ],
+ relevance: 0
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function', end: /\{/, excludeEnd: true,
+ contains: [
+ hljs.inherit(hljs.TITLE_MODE, {begin: /[A-Za-z$_][0-9A-Za-z$_]*/}),
+ {
+ className: 'params',
+ begin: /\(/, end: /\)/,
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE
+ ],
+ illegal: /["'\(]/
+ }
+ ],
+ illegal: /\[|%/,
+ relevance: 0 // () => {} is more typical in TypeScript
+ },
+ {
+ className: 'constructor',
+ beginKeywords: 'constructor', end: /\{/, excludeEnd: true,
+ relevance: 10
+ },
+ {
+ className: 'module',
+ beginKeywords: 'module', end: /\{/, excludeEnd: true,
+ },
+ {
+ className: 'interface',
+ beginKeywords: 'interface', end: /\{/, excludeEnd: true,
+ },
+ {
+ begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
+ },
+ {
+ begin: '\\.' + hljs.IDENT_RE, relevance: 0 // hack: prevents detection of keywords after dots
+ }
+ ]
+ };
+};
+},{}],124:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ keywords: {
+ keyword:
+ // Value types
+ 'char uchar unichar int uint long ulong short ushort int8 int16 int32 int64 uint8 ' +
+ 'uint16 uint32 uint64 float double bool struct enum string void ' +
+ // Reference types
+ 'weak unowned owned ' +
+ // Modifiers
+ 'async signal static abstract interface override ' +
+ // Control Structures
+ 'while do for foreach else switch case break default return try catch ' +
+ // Visibility
+ 'public private protected internal ' +
+ // Other
+ 'using new this get set const stdout stdin stderr var',
+ built_in:
+ 'DBus GLib CCode Gee Object',
+ literal:
+ 'false true null'
+ },
+ contains: [
+ {
+ className: 'class',
+ beginKeywords: 'class interface delegate namespace', end: '{', excludeEnd: true,
+ illegal: '[^,:\\n\\s\\.]',
+ contains: [
+ hljs.UNDERSCORE_TITLE_MODE
+ ]
+ },
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ {
+ className: 'string',
+ begin: '"""', end: '"""',
+ relevance: 5
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '^#', end: '$',
+ relevance: 2
+ },
+ {
+ className: 'constant',
+ begin: ' [A-Z_]+ ',
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],125:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['vb'],
+ case_insensitive: true,
+ keywords: {
+ keyword:
+ 'addhandler addressof alias and andalso aggregate ansi as assembly auto binary by byref byval ' + /* a-b */
+ 'call case catch class compare const continue custom declare default delegate dim distinct do ' + /* c-d */
+ 'each equals else elseif end enum erase error event exit explicit finally for friend from function ' + /* e-f */
+ 'get global goto group handles if implements imports in inherits interface into is isfalse isnot istrue ' + /* g-i */
+ 'join key let lib like loop me mid mod module mustinherit mustoverride mybase myclass ' + /* j-m */
+ 'namespace narrowing new next not notinheritable notoverridable ' + /* n */
+ 'of off on operator option optional or order orelse overloads overridable overrides ' + /* o */
+ 'paramarray partial preserve private property protected public ' + /* p */
+ 'raiseevent readonly redim rem removehandler resume return ' + /* r */
+ 'select set shadows shared skip static step stop structure strict sub synclock ' + /* s */
+ 'take text then throw to try unicode until using when where while widening with withevents writeonly xor', /* t-x */
+ built_in:
+ 'boolean byte cbool cbyte cchar cdate cdec cdbl char cint clng cobj csbyte cshort csng cstr ctype ' + /* b-c */
+ 'date decimal directcast double gettype getxmlnamespace iif integer long object ' + /* d-o */
+ 'sbyte short single string trycast typeof uinteger ulong ushort', /* s-u */
+ literal:
+ 'true false nothing'
+ },
+ illegal: '//|{|}|endif|gosub|variant|wend', /* reserved deprecated keywords */
+ contains: [
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}),
+ {
+ className: 'comment',
+ begin: '\'', end: '$', returnBegin: true,
+ contains: [
+ {
+ className: 'xmlDocTag',
+ begin: '\'\'\'|'
+ },
+ {
+ className: 'xmlDocTag',
+ begin: '?', end: '>'
+ }
+ ]
+ },
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'preprocessor',
+ begin: '#', end: '$',
+ keywords: 'if else elseif end region externalsource'
+ }
+ ]
+ };
+};
+},{}],126:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ subLanguage: 'xml', subLanguageMode: 'continuous',
+ contains: [
+ {
+ begin: '<%', end: '%>',
+ subLanguage: 'vbscript'
+ }
+ ]
+ };
+};
+},{}],127:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ aliases: ['vbs'],
+ case_insensitive: true,
+ keywords: {
+ keyword:
+ 'call class const dim do loop erase execute executeglobal exit for each next function ' +
+ 'if then else on error option explicit new private property let get public randomize ' +
+ 'redim rem select case set stop sub while wend with end to elseif is or xor and not ' +
+ 'class_initialize class_terminate default preserve in me byval byref step resume goto',
+ built_in:
+ 'lcase month vartype instrrev ubound setlocale getobject rgb getref string ' +
+ 'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' +
+ 'conversions csng timevalue second year space abs clng timeserial fixs len asc ' +
+ 'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' +
+ 'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' +
+ 'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' +
+ 'strcomp int createobject loadpicture tan formatnumber mid scriptenginebuildversion ' +
+ 'scriptengine split scriptengineminorversion cint sin datepart ltrim sqr ' +
+ 'scriptenginemajorversion time derived eval date formatpercent exp inputbox left ascw ' +
+ 'chrw regexp server response request cstr err',
+ literal:
+ 'true false null nothing empty'
+ },
+ illegal: '//',
+ contains: [
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}),
+ {
+ className: 'comment',
+ begin: /'/, end: /$/,
+ relevance: 0
+ },
+ hljs.C_NUMBER_MODE
+ ]
+ };
+};
+},{}],128:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ case_insensitive: true,
+ keywords: {
+ keyword:
+ 'abs access after alias all and architecture array assert attribute begin block ' +
+ 'body buffer bus case component configuration constant context cover disconnect ' +
+ 'downto default else elsif end entity exit fairness file for force function generate ' +
+ 'generic group guarded if impure in inertial inout is label library linkage literal ' +
+ 'loop map mod nand new next nor not null of on open or others out package port ' +
+ 'postponed procedure process property protected pure range record register reject ' +
+ 'release rem report restrict restrict_guarantee return rol ror select sequence ' +
+ 'severity shared signal sla sll sra srl strong subtype then to transport type ' +
+ 'unaffected units until use variable vmode vprop vunit wait when while with xnor xor',
+ typename:
+ 'boolean bit character severity_level integer time delay_length natural positive ' +
+ 'string bit_vector file_open_kind file_open_status std_ulogic std_ulogic_vector ' +
+ 'std_logic std_logic_vector unsigned signed boolean_vector integer_vector ' +
+ 'real_vector time_vector'
+ },
+ illegal: '{',
+ contains: [
+ hljs.C_BLOCK_COMMENT_MODE, // VHDL-2008 block commenting.
+ {
+ className: 'comment',
+ begin: '--', end: '$'
+ },
+ hljs.QUOTE_STRING_MODE,
+ hljs.C_NUMBER_MODE,
+ {
+ className: 'literal',
+ begin: '\'(U|X|0|1|Z|W|L|H|-)\'',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ },
+ {
+ className: 'attribute',
+ begin: '\'[A-Za-z](_?[A-Za-z0-9])*',
+ contains: [hljs.BACKSLASH_ESCAPE]
+ }
+ ]
+ }; // return
+};
+},{}],129:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ lexemes: /[!#@\w]+/,
+ keywords: {
+ keyword: //ex command
+ // express version except: ! & * < = > !! # @ @@
+ 'N|0 P|0 X|0 a|0 ab abc abo al am an|0 ar arga argd arge argdo argg argl argu as au aug aun b|0 bN ba bad bd be bel bf bl bm bn bo bp br brea breaka breakd breakl bro bufdo buffers bun bw c|0 cN cNf ca cabc caddb cad caddf cal cat cb cc ccl cd ce cex cf cfir cgetb cgete cg changes chd che checkt cl cla clo cm cmapc cme cn cnew cnf cno cnorea cnoreme co col colo com comc comp con conf cope '+
+ 'cp cpf cq cr cs cst cu cuna cunme cw d|0 delm deb debugg delc delf dif diffg diffo diffp diffpu diffs diffthis dig di dl dell dj dli do doautoa dp dr ds dsp e|0 ea ec echoe echoh echom echon el elsei em en endfo endf endt endw ene ex exe exi exu f|0 files filet fin fina fini fir fix fo foldc foldd folddoc foldo for fu g|0 go gr grepa gu gv ha h|0 helpf helpg helpt hi hid his i|0 ia iabc if ij il im imapc '+
+ 'ime ino inorea inoreme int is isp iu iuna iunme j|0 ju k|0 keepa kee keepj lN lNf l|0 lad laddb laddf la lan lat lb lc lch lcl lcs le lefta let lex lf lfir lgetb lgete lg lgr lgrepa lh ll lla lli lmak lm lmapc lne lnew lnf ln loadk lo loc lockv lol lope lp lpf lr ls lt lu lua luad luaf lv lvimgrepa lw m|0 ma mak map mapc marks mat me menut mes mk mks mksp mkv mkvie mod mz mzf nbc nb nbs n|0 new nm nmapc nme nn nnoreme noa no noh norea noreme norm nu nun nunme ol o|0 om omapc ome on ono onoreme opt ou ounme ow p|0 '+
+ 'profd prof pro promptr pc ped pe perld po popu pp pre prev ps pt ptN ptf ptj ptl ptn ptp ptr pts pu pw py3 python3 py3d py3f py pyd pyf q|0 quita qa r|0 rec red redi redr redraws reg res ret retu rew ri rightb rub rubyd rubyf rund ru rv s|0 sN san sa sal sav sb sbN sba sbf sbl sbm sbn sbp sbr scrip scripte scs se setf setg setl sf sfir sh sim sig sil sl sla sm smap smapc sme sn sni sno snor snoreme sor '+
+ 'so spelld spe spelli spellr spellu spellw sp spr sre st sta startg startr star stopi stj sts sun sunm sunme sus sv sw sy synti sync t|0 tN tabN tabc tabdo tabe tabf tabfir tabl tabm tabnew '+
+ 'tabn tabo tabp tabr tabs tab ta tags tc tcld tclf te tf th tj tl tm tn to tp tr try ts tu u|0 undoj undol una unh unl unlo unm unme uns up v|0 ve verb vert vim vimgrepa vi viu vie vm vmapc vme vne vn vnoreme vs vu vunme windo w|0 wN wa wh wi winc winp wn wp wq wqa ws wu wv x|0 xa xmapc xm xme xn xnoreme xu xunme y|0 z|0 ~ '+
+ // full version
+ 'Next Print append abbreviate abclear aboveleft all amenu anoremenu args argadd argdelete argedit argglobal arglocal argument ascii autocmd augroup aunmenu buffer bNext ball badd bdelete behave belowright bfirst blast bmodified bnext botright bprevious brewind break breakadd breakdel breaklist browse bunload '+
+ 'bwipeout change cNext cNfile cabbrev cabclear caddbuffer caddexpr caddfile call catch cbuffer cclose center cexpr cfile cfirst cgetbuffer cgetexpr cgetfile chdir checkpath checktime clist clast close cmap cmapclear cmenu cnext cnewer cnfile cnoremap cnoreabbrev cnoremenu copy colder colorscheme command comclear compiler continue confirm copen cprevious cpfile cquit crewind cscope cstag cunmap '+
+ 'cunabbrev cunmenu cwindow delete delmarks debug debuggreedy delcommand delfunction diffupdate diffget diffoff diffpatch diffput diffsplit digraphs display deletel djump dlist doautocmd doautoall deletep drop dsearch dsplit edit earlier echo echoerr echohl echomsg else elseif emenu endif endfor '+
+ 'endfunction endtry endwhile enew execute exit exusage file filetype find finally finish first fixdel fold foldclose folddoopen folddoclosed foldopen function global goto grep grepadd gui gvim hardcopy help helpfind helpgrep helptags highlight hide history insert iabbrev iabclear ijump ilist imap '+
+ 'imapclear imenu inoremap inoreabbrev inoremenu intro isearch isplit iunmap iunabbrev iunmenu join jumps keepalt keepmarks keepjumps lNext lNfile list laddexpr laddbuffer laddfile last language later lbuffer lcd lchdir lclose lcscope left leftabove lexpr lfile lfirst lgetbuffer lgetexpr lgetfile lgrep lgrepadd lhelpgrep llast llist lmake lmap lmapclear lnext lnewer lnfile lnoremap loadkeymap loadview '+
+ 'lockmarks lockvar lolder lopen lprevious lpfile lrewind ltag lunmap luado luafile lvimgrep lvimgrepadd lwindow move mark make mapclear match menu menutranslate messages mkexrc mksession mkspell mkvimrc mkview mode mzscheme mzfile nbclose nbkey nbsart next nmap nmapclear nmenu nnoremap '+
+ 'nnoremenu noautocmd noremap nohlsearch noreabbrev noremenu normal number nunmap nunmenu oldfiles open omap omapclear omenu only onoremap onoremenu options ounmap ounmenu ownsyntax print profdel profile promptfind promptrepl pclose pedit perl perldo pop popup ppop preserve previous psearch ptag ptNext '+
+ 'ptfirst ptjump ptlast ptnext ptprevious ptrewind ptselect put pwd py3do py3file python pydo pyfile quit quitall qall read recover redo redir redraw redrawstatus registers resize retab return rewind right rightbelow ruby rubydo rubyfile rundo runtime rviminfo substitute sNext sandbox sargument sall saveas sbuffer sbNext sball sbfirst sblast sbmodified sbnext sbprevious sbrewind scriptnames scriptencoding '+
+ 'scscope set setfiletype setglobal setlocal sfind sfirst shell simalt sign silent sleep slast smagic smapclear smenu snext sniff snomagic snoremap snoremenu sort source spelldump spellgood spellinfo spellrepall spellundo spellwrong split sprevious srewind stop stag startgreplace startreplace '+
+ 'startinsert stopinsert stjump stselect sunhide sunmap sunmenu suspend sview swapname syntax syntime syncbind tNext tabNext tabclose tabedit tabfind tabfirst tablast tabmove tabnext tabonly tabprevious tabrewind tag tcl tcldo tclfile tearoff tfirst throw tjump tlast tmenu tnext topleft tprevious '+'trewind tselect tunmenu undo undojoin undolist unabbreviate unhide unlet unlockvar unmap unmenu unsilent update vglobal version verbose vertical vimgrep vimgrepadd visual viusage view vmap vmapclear vmenu vnew '+
+ 'vnoremap vnoremenu vsplit vunmap vunmenu write wNext wall while winsize wincmd winpos wnext wprevious wqall wsverb wundo wviminfo xit xall xmapclear xmap xmenu xnoremap xnoremenu xunmap xunmenu yank',
+ built_in: //built in func
+ 'abs acos add and append argc argidx argv asin atan atan2 browse browsedir bufexists buflisted bufloaded bufname bufnr bufwinnr byte2line byteidx call ceil changenr char2nr cindent clearmatches col complete complete_add complete_check confirm copy cos cosh count cscope_connection cursor '+
+ 'deepcopy delete did_filetype diff_filler diff_hlID empty escape eval eventhandler executable exists exp expand extend feedkeys filereadable filewritable filter finddir findfile float2nr floor fmod fnameescape fnamemodify foldclosed foldclosedend foldlevel foldtext foldtextresult foreground function '+
+ 'garbagecollect get getbufline getbufvar getchar getcharmod getcmdline getcmdpos getcmdtype getcwd getfontname getfperm getfsize getftime getftype getline getloclist getmatches getpid getpos getqflist getreg getregtype gettabvar gettabwinvar getwinposx getwinposy getwinvar glob globpath has has_key '+
+ 'haslocaldir hasmapto histadd histdel histget histnr hlexists hlID hostname iconv indent index input inputdialog inputlist inputrestore inputsave inputsecret insert invert isdirectory islocked items join keys len libcall libcallnr line line2byte lispindent localtime log log10 luaeval map maparg mapcheck '+
+ 'match matchadd matcharg matchdelete matchend matchlist matchstr max min mkdir mode mzeval nextnonblank nr2char or pathshorten pow prevnonblank printf pumvisible py3eval pyeval range readfile reltime reltimestr remote_expr remote_foreground remote_peek remote_read remote_send remove rename repeat '+
+ 'resolve reverse round screenattr screenchar screencol screenrow search searchdecl searchpair searchpairpos searchpos server2client serverlist setbufvar setcmdpos setline setloclist setmatches setpos setqflist setreg settabvar settabwinvar setwinvar sha256 shellescape shiftwidth simplify sin '+
+ 'sinh sort soundfold spellbadword spellsuggest split sqrt str2float str2nr strchars strdisplaywidth strftime stridx string strlen strpart strridx strtrans strwidth submatch substitute synconcealed synID synIDattr '+
+ 'synIDtrans synstack system tabpagebuflist tabpagenr tabpagewinnr tagfiles taglist tan tanh tempname tolower toupper tr trunc type undofile undotree values virtcol visualmode wildmenumode winbufnr wincol winheight winline winnr winrestcmd winrestview winsaveview winwidth writefile xor'
+ },
+ illegal: /[{:]/,
+ contains: [
+ hljs.NUMBER_MODE,
+ hljs.APOS_STRING_MODE,
+ {
+ className: 'string',
+ // quote with escape, comment as quote
+ begin: /"((\\")|[^"\n])*("|\n)/
+ },
+ {
+ className: 'variable',
+ begin: /[bwtglsav]:[\w\d_]*/
+ },
+ {
+ className: 'function',
+ beginKeywords: 'function function!', end: '$',
+ relevance: 0,
+ contains: [
+ hljs.TITLE_MODE,
+ {
+ className: 'params',
+ begin: '\\(', end: '\\)'
+ }
+ ]
+ }
+ ]
+ };
+};
+},{}],130:[function(require,module,exports){
+module.exports = function(hljs) {
+ return {
+ case_insensitive: true,
+ lexemes: '\\.?' + hljs.IDENT_RE,
+ keywords: {
+ keyword:
+ 'lock rep repe repz repne repnz xaquire xrelease bnd nobnd ' +
+ 'aaa aad aam aas adc add and arpl bb0_reset bb1_reset bound bsf bsr bswap bt btc btr bts call cbw cdq cdqe clc cld cli clts cmc cmp cmpsb cmpsd cmpsq cmpsw cmpxchg cmpxchg486 cmpxchg8b cmpxchg16b cpuid cpu_read cpu_write cqo cwd cwde daa das dec div dmint emms enter equ f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne fcmovnu fcmovu fcom fcomi fcomip fcomp fcompp fcos fdecstp fdisi fdiv fdivp fdivr fdivrp femms feni ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisttp fisub fisubr fld fld1 fldcw fldenv fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni fninit fnop fnsave fnstcw fnstenv fnstsw fpatan fprem fprem1 fptan frndint frstor fsave fscale fsetpm fsin fsincos fsqrt fst fstcw fstenv fstp fstsw fsub fsubp fsubr fsubrp ftst fucom fucomi fucomip fucomp fucompp fxam fxch fxtract fyl2x fyl2xp1 hlt ibts icebp idiv imul in inc incbin insb insd insw int int01 int1 int03 int3 into invd invpcid invlpg invlpga iret iretd iretq iretw jcxz jecxz jrcxz jmp jmpe lahf lar lds lea leave les lfence lfs lgdt lgs lidt lldt lmsw loadall loadall286 lodsb lodsd lodsq lodsw loop loope loopne loopnz loopz lsl lss ltr mfence monitor mov movd movq movsb movsd movsq movsw movsx movsxd movzx mul mwait neg nop not or out outsb outsd outsw packssdw packsswb packuswb paddb paddd paddsb paddsiw paddsw paddusb paddusw paddw pand pandn pause paveb pavgusb pcmpeqb pcmpeqd pcmpeqw pcmpgtb pcmpgtd pcmpgtw pdistib pf2id pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pmachriw pmaddwd pmagw pmulhriw pmulhrwa pmulhrwc pmulhw pmullw pmvgezb pmvlzb pmvnzb pmvzb pop popa popad popaw popf popfd popfq popfw por prefetch prefetchw pslld psllq psllw psrad psraw psrld psrlq psrlw psubb psubd psubsb psubsiw psubsw psubusb psubusw psubw punpckhbw punpckhdq punpckhwd punpcklbw punpckldq punpcklwd push pusha pushad pushaw pushf pushfd pushfq pushfw pxor rcl rcr rdshr rdmsr rdpmc rdtsc rdtscp ret retf retn rol ror rdm rsdc rsldt rsm rsts sahf sal salc sar sbb scasb scasd scasq scasw sfence sgdt shl shld shr shrd sidt sldt skinit smi smint smintold smsw stc std sti stosb stosd stosq stosw str sub svdc svldt svts swapgs syscall sysenter sysexit sysret test ud0 ud1 ud2b ud2 ud2a umov verr verw fwait wbinvd wrshr wrmsr xadd xbts xchg xlatb xlat xor cmove cmovz cmovne cmovnz cmova cmovnbe cmovae cmovnb cmovb cmovnae cmovbe cmovna cmovg cmovnle cmovge cmovnl cmovl cmovnge cmovle cmovng cmovc cmovnc cmovo cmovno cmovs cmovns cmovp cmovpe cmovnp cmovpo je jz jne jnz ja jnbe jae jnb jb jnae jbe jna jg jnle jge jnl jl jnge jle jng jc jnc jo jno js jns jpo jnp jpe jp sete setz setne setnz seta setnbe setae setnb setnc setb setnae setcset setbe setna setg setnle setge setnl setl setnge setle setng sets setns seto setno setpe setp setpo setnp addps addss andnps andps cmpeqps cmpeqss cmpleps cmpless cmpltps cmpltss cmpneqps cmpneqss cmpnleps cmpnless cmpnltps cmpnltss cmpordps cmpordss cmpunordps cmpunordss cmpps cmpss comiss cvtpi2ps cvtps2pi cvtsi2ss cvtss2si cvttps2pi cvttss2si divps divss ldmxcsr maxps maxss minps minss movaps movhps movlhps movlps movhlps movmskps movntps movss movups mulps mulss orps rcpps rcpss rsqrtps rsqrtss shufps sqrtps sqrtss stmxcsr subps subss ucomiss unpckhps unpcklps xorps fxrstor fxrstor64 fxsave fxsave64 xgetbv xsetbv xsave xsave64 xsaveopt xsaveopt64 xrstor xrstor64 prefetchnta prefetcht0 prefetcht1 prefetcht2 maskmovq movntq pavgb pavgw pextrw pinsrw pmaxsw pmaxub pminsw pminub pmovmskb pmulhuw psadbw pshufw pf2iw pfnacc pfpnacc pi2fw pswapd maskmovdqu clflush movntdq movnti movntpd movdqa movdqu movdq2q movq2dq paddq pmuludq pshufd pshufhw pshuflw pslldq psrldq psubq punpckhqdq punpcklqdq addpd addsd andnpd andpd cmpeqpd cmpeqsd cmplepd cmplesd cmpltpd cmpltsd cmpneqpd cmpneqsd cmpnlepd cmpnlesd cmpnltpd cmpnltsd cmpordpd cmpordsd cmpunordpd cmpunordsd cmppd comisd cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtps2dq cvtps2pd cvtsd2si cvtsd2ss cvtsi2sd cvtss2sd cvttpd2pi cvttpd2dq cvttps2dq cvttsd2si divpd divsd maxpd maxsd minpd minsd movapd movhpd movlpd movmskpd movupd mulpd mulsd orpd shufpd sqrtpd sqrtsd subpd subsd ucomisd unpckhpd unpcklpd xorpd addsubpd addsubps haddpd haddps hsubpd hsubps lddqu movddup movshdup movsldup clgi stgi vmcall vmclear vmfunc vmlaunch vmload vmmcall vmptrld vmptrst vmread vmresume vmrun vmsave vmwrite vmxoff vmxon invept invvpid pabsb pabsw pabsd palignr phaddw phaddd phaddsw phsubw phsubd phsubsw pmaddubsw pmulhrsw pshufb psignb psignw psignd extrq insertq movntsd movntss lzcnt blendpd blendps blendvpd blendvps dppd dpps extractps insertps movntdqa mpsadbw packusdw pblendvb pblendw pcmpeqq pextrb pextrd pextrq phminposuw pinsrb pinsrd pinsrq pmaxsb pmaxsd pmaxud pmaxuw pminsb pminsd pminud pminuw pmovsxbw pmovsxbd pmovsxbq pmovsxwd pmovsxwq pmovsxdq pmovzxbw pmovzxbd pmovzxbq pmovzxwd pmovzxwq pmovzxdq pmuldq pmulld ptest roundpd roundps roundsd roundss crc32 pcmpestri pcmpestrm pcmpistri pcmpistrm pcmpgtq popcnt getsec pfrcpv pfrsqrtv movbe aesenc aesenclast aesdec aesdeclast aesimc aeskeygenassist vaesenc vaesenclast vaesdec vaesdeclast vaesimc vaeskeygenassist vaddpd vaddps vaddsd vaddss vaddsubpd vaddsubps vandpd vandps vandnpd vandnps vblendpd vblendps vblendvpd vblendvps vbroadcastss vbroadcastsd vbroadcastf128 vcmpeq_ospd vcmpeqpd vcmplt_ospd vcmpltpd vcmple_ospd vcmplepd vcmpunord_qpd vcmpunordpd vcmpneq_uqpd vcmpneqpd vcmpnlt_uspd vcmpnltpd vcmpnle_uspd vcmpnlepd vcmpord_qpd vcmpordpd vcmpeq_uqpd vcmpnge_uspd vcmpngepd vcmpngt_uspd vcmpngtpd vcmpfalse_oqpd vcmpfalsepd vcmpneq_oqpd vcmpge_ospd vcmpgepd vcmpgt_ospd vcmpgtpd vcmptrue_uqpd vcmptruepd vcmplt_oqpd vcmple_oqpd vcmpunord_spd vcmpneq_uspd vcmpnlt_uqpd vcmpnle_uqpd vcmpord_spd vcmpeq_uspd vcmpnge_uqpd vcmpngt_uqpd vcmpfalse_ospd vcmpneq_ospd vcmpge_oqpd vcmpgt_oqpd vcmptrue_uspd vcmppd vcmpeq_osps vcmpeqps vcmplt_osps vcmpltps vcmple_osps vcmpleps vcmpunord_qps vcmpunordps vcmpneq_uqps vcmpneqps vcmpnlt_usps vcmpnltps vcmpnle_usps vcmpnleps vcmpord_qps vcmpordps vcmpeq_uqps vcmpnge_usps vcmpngeps vcmpngt_usps vcmpngtps vcmpfalse_oqps vcmpfalseps vcmpneq_oqps vcmpge_osps vcmpgeps vcmpgt_osps vcmpgtps vcmptrue_uqps vcmptrueps vcmplt_oqps vcmple_oqps vcmpunord_sps vcmpneq_usps vcmpnlt_uqps vcmpnle_uqps vcmpord_sps vcmpeq_usps vcmpnge_uqps vcmpngt_uqps vcmpfalse_osps vcmpneq_osps vcmpge_oqps vcmpgt_oqps vcmptrue_usps vcmpps vcmpeq_ossd vcmpeqsd vcmplt_ossd vcmpltsd vcmple_ossd vcmplesd vcmpunord_qsd vcmpunordsd vcmpneq_uqsd vcmpneqsd vcmpnlt_ussd vcmpnltsd vcmpnle_ussd vcmpnlesd vcmpord_qsd vcmpordsd vcmpeq_uqsd vcmpnge_ussd vcmpngesd vcmpngt_ussd vcmpngtsd vcmpfalse_oqsd vcmpfalsesd vcmpneq_oqsd vcmpge_ossd vcmpgesd vcmpgt_ossd vcmpgtsd vcmptrue_uqsd vcmptruesd vcmplt_oqsd vcmple_oqsd vcmpunord_ssd vcmpneq_ussd vcmpnlt_uqsd vcmpnle_uqsd vcmpord_ssd vcmpeq_ussd vcmpnge_uqsd vcmpngt_uqsd vcmpfalse_ossd vcmpneq_ossd vcmpge_oqsd vcmpgt_oqsd vcmptrue_ussd vcmpsd vcmpeq_osss vcmpeqss vcmplt_osss vcmpltss vcmple_osss vcmpless vcmpunord_qss vcmpunordss vcmpneq_uqss vcmpneqss vcmpnlt_usss vcmpnltss vcmpnle_usss vcmpnless vcmpord_qss vcmpordss vcmpeq_uqss vcmpnge_usss vcmpngess vcmpngt_usss vcmpngtss vcmpfalse_oqss vcmpfalsess vcmpneq_oqss vcmpge_osss vcmpgess vcmpgt_osss vcmpgtss vcmptrue_uqss vcmptruess vcmplt_oqss vcmple_oqss vcmpunord_sss vcmpneq_usss vcmpnlt_uqss vcmpnle_uqss vcmpord_sss vcmpeq_usss vcmpnge_uqss vcmpngt_uqss vcmpfalse_osss vcmpneq_osss vcmpge_oqss vcmpgt_oqss vcmptrue_usss vcmpss vcomisd vcomiss vcvtdq2pd vcvtdq2ps vcvtpd2dq vcvtpd2ps vcvtps2dq vcvtps2pd vcvtsd2si vcvtsd2ss vcvtsi2sd vcvtsi2ss vcvtss2sd vcvtss2si vcvttpd2dq vcvttps2dq vcvttsd2si vcvttss2si vdivpd vdivps vdivsd vdivss vdppd vdpps vextractf128 vextractps vhaddpd vhaddps vhsubpd vhsubps vinsertf128 vinsertps vlddqu vldqqu vldmxcsr vmaskmovdqu vmaskmovps vmaskmovpd vmaxpd vmaxps vmaxsd vmaxss vminpd vminps vminsd vminss vmovapd vmovaps vmovd vmovq vmovddup vmovdqa vmovqqa vmovdqu vmovqqu vmovhlps vmovhpd vmovhps vmovlhps vmovlpd vmovlps vmovmskpd vmovmskps vmovntdq vmovntqq vmovntdqa vmovntpd vmovntps vmovsd vmovshdup vmovsldup vmovss vmovupd vmovups vmpsadbw vmulpd vmulps vmulsd vmulss vorpd vorps vpabsb vpabsw vpabsd vpacksswb vpackssdw vpackuswb vpackusdw vpaddb vpaddw vpaddd vpaddq vpaddsb vpaddsw vpaddusb vpaddusw vpalignr vpand vpandn vpavgb vpavgw vpblendvb vpblendw vpcmpestri vpcmpestrm vpcmpistri vpcmpistrm vpcmpeqb vpcmpeqw vpcmpeqd vpcmpeqq vpcmpgtb vpcmpgtw vpcmpgtd vpcmpgtq vpermilpd vpermilps vperm2f128 vpextrb vpextrw vpextrd vpextrq vphaddw vphaddd vphaddsw vphminposuw vphsubw vphsubd vphsubsw vpinsrb vpinsrw vpinsrd vpinsrq vpmaddwd vpmaddubsw vpmaxsb vpmaxsw vpmaxsd vpmaxub vpmaxuw vpmaxud vpminsb vpminsw vpminsd vpminub vpminuw vpminud vpmovmskb vpmovsxbw vpmovsxbd vpmovsxbq vpmovsxwd vpmovsxwq vpmovsxdq vpmovzxbw vpmovzxbd vpmovzxbq vpmovzxwd vpmovzxwq vpmovzxdq vpmulhuw vpmulhrsw vpmulhw vpmullw vpmulld vpmuludq vpmuldq vpor vpsadbw vpshufb vpshufd vpshufhw vpshuflw vpsignb vpsignw vpsignd vpslldq vpsrldq vpsllw vpslld vpsllq vpsraw vpsrad vpsrlw vpsrld vpsrlq vptest vpsubb vpsubw vpsubd vpsubq vpsubsb vpsubsw vpsubusb vpsubusw vpunpckhbw vpunpckhwd vpunpckhdq vpunpckhqdq vpunpcklbw vpunpcklwd vpunpckldq vpunpcklqdq vpxor vrcpps vrcpss vrsqrtps vrsqrtss vroundpd vroundps vroundsd vroundss vshufpd vshufps vsqrtpd vsqrtps vsqrtsd vsqrtss vstmxcsr vsubpd vsubps vsubsd vsubss vtestps vtestpd vucomisd vucomiss vunpckhpd vunpckhps vunpcklpd vunpcklps vxorpd vxorps vzeroall vzeroupper pclmullqlqdq pclmulhqlqdq pclmullqhqdq pclmulhqhqdq pclmulqdq vpclmullqlqdq vpclmulhqlqdq vpclmullqhqdq vpclmulhqhqdq vpclmulqdq vfmadd132ps vfmadd132pd vfmadd312ps vfmadd312pd vfmadd213ps vfmadd213pd vfmadd123ps vfmadd123pd vfmadd231ps vfmadd231pd vfmadd321ps vfmadd321pd vfmaddsub132ps vfmaddsub132pd vfmaddsub312ps vfmaddsub312pd vfmaddsub213ps vfmaddsub213pd vfmaddsub123ps vfmaddsub123pd vfmaddsub231ps vfmaddsub231pd vfmaddsub321ps vfmaddsub321pd vfmsub132ps vfmsub132pd vfmsub312ps vfmsub312pd vfmsub213ps vfmsub213pd vfmsub123ps vfmsub123pd vfmsub231ps vfmsub231pd vfmsub321ps vfmsub321pd vfmsubadd132ps vfmsubadd132pd vfmsubadd312ps vfmsubadd312pd vfmsubadd213ps vfmsubadd213pd vfmsubadd123ps vfmsubadd123pd vfmsubadd231ps vfmsubadd231pd vfmsubadd321ps vfmsubadd321pd vfnmadd132ps vfnmadd132pd vfnmadd312ps vfnmadd312pd vfnmadd213ps vfnmadd213pd vfnmadd123ps vfnmadd123pd vfnmadd231ps vfnmadd231pd vfnmadd321ps vfnmadd321pd vfnmsub132ps vfnmsub132pd vfnmsub312ps vfnmsub312pd vfnmsub213ps vfnmsub213pd vfnmsub123ps vfnmsub123pd vfnmsub231ps vfnmsub231pd vfnmsub321ps vfnmsub321pd vfmadd132ss vfmadd132sd vfmadd312ss vfmadd312sd vfmadd213ss vfmadd213sd vfmadd123ss vfmadd123sd vfmadd231ss vfmadd231sd vfmadd321ss vfmadd321sd vfmsub132ss vfmsub132sd vfmsub312ss vfmsub312sd vfmsub213ss vfmsub213sd vfmsub123ss vfmsub123sd vfmsub231ss vfmsub231sd vfmsub321ss vfmsub321sd vfnmadd132ss vfnmadd132sd vfnmadd312ss vfnmadd312sd vfnmadd213ss vfnmadd213sd vfnmadd123ss vfnmadd123sd vfnmadd231ss vfnmadd231sd vfnmadd321ss vfnmadd321sd vfnmsub132ss vfnmsub132sd vfnmsub312ss vfnmsub312sd vfnmsub213ss vfnmsub213sd vfnmsub123ss vfnmsub123sd vfnmsub231ss vfnmsub231sd vfnmsub321ss vfnmsub321sd rdfsbase rdgsbase rdrand wrfsbase wrgsbase vcvtph2ps vcvtps2ph adcx adox rdseed clac stac xstore xcryptecb xcryptcbc xcryptctr xcryptcfb xcryptofb montmul xsha1 xsha256 llwpcb slwpcb lwpval lwpins vfmaddpd vfmaddps vfmaddsd vfmaddss vfmaddsubpd vfmaddsubps vfmsubaddpd vfmsubaddps vfmsubpd vfmsubps vfmsubsd vfmsubss vfnmaddpd vfnmaddps vfnmaddsd vfnmaddss vfnmsubpd vfnmsubps vfnmsubsd vfnmsubss vfrczpd vfrczps vfrczsd vfrczss vpcmov vpcomb vpcomd vpcomq vpcomub vpcomud vpcomuq vpcomuw vpcomw vphaddbd vphaddbq vphaddbw vphadddq vphaddubd vphaddubq vphaddubw vphaddudq vphadduwd vphadduwq vphaddwd vphaddwq vphsubbw vphsubdq vphsubwd vpmacsdd vpmacsdqh vpmacsdql vpmacssdd vpmacssdqh vpmacssdql vpmacsswd vpmacssww vpmacswd vpmacsww vpmadcsswd vpmadcswd vpperm vprotb vprotd vprotq vprotw vpshab vpshad vpshaq vpshaw vpshlb vpshld vpshlq vpshlw vbroadcasti128 vpblendd vpbroadcastb vpbroadcastw vpbroadcastd vpbroadcastq vpermd vpermpd vpermps vpermq vperm2i128 vextracti128 vinserti128 vpmaskmovd vpmaskmovq vpsllvd vpsllvq vpsravd vpsrlvd vpsrlvq vgatherdpd vgatherqpd vgatherdps vgatherqps vpgatherdd vpgatherqd vpgatherdq vpgatherqq xabort xbegin xend xtest andn bextr blci blcic blsi blsic blcfill blsfill blcmsk blsmsk blsr blcs bzhi mulx pdep pext rorx sarx shlx shrx tzcnt tzmsk t1mskc valignd valignq vblendmpd vblendmps vbroadcastf32x4 vbroadcastf64x4 vbroadcasti32x4 vbroadcasti64x4 vcompresspd vcompressps vcvtpd2udq vcvtps2udq vcvtsd2usi vcvtss2usi vcvttpd2udq vcvttps2udq vcvttsd2usi vcvttss2usi vcvtudq2pd vcvtudq2ps vcvtusi2sd vcvtusi2ss vexpandpd vexpandps vextractf32x4 vextractf64x4 vextracti32x4 vextracti64x4 vfixupimmpd vfixupimmps vfixupimmsd vfixupimmss vgetexppd vgetexpps vgetexpsd vgetexpss vgetmantpd vgetmantps vgetmantsd vgetmantss vinsertf32x4 vinsertf64x4 vinserti32x4 vinserti64x4 vmovdqa32 vmovdqa64 vmovdqu32 vmovdqu64 vpabsq vpandd vpandnd vpandnq vpandq vpblendmd vpblendmq vpcmpltd vpcmpled vpcmpneqd vpcmpnltd vpcmpnled vpcmpd vpcmpltq vpcmpleq vpcmpneqq vpcmpnltq vpcmpnleq vpcmpq vpcmpequd vpcmpltud vpcmpleud vpcmpnequd vpcmpnltud vpcmpnleud vpcmpud vpcmpequq vpcmpltuq vpcmpleuq vpcmpnequq vpcmpnltuq vpcmpnleuq vpcmpuq vpcompressd vpcompressq vpermi2d vpermi2pd vpermi2ps vpermi2q vpermt2d vpermt2pd vpermt2ps vpermt2q vpexpandd vpexpandq vpmaxsq vpmaxuq vpminsq vpminuq vpmovdb vpmovdw vpmovqb vpmovqd vpmovqw vpmovsdb vpmovsdw vpmovsqb vpmovsqd vpmovsqw vpmovusdb vpmovusdw vpmovusqb vpmovusqd vpmovusqw vpord vporq vprold vprolq vprolvd vprolvq vprord vprorq vprorvd vprorvq vpscatterdd vpscatterdq vpscatterqd vpscatterqq vpsraq vpsravq vpternlogd vpternlogq vptestmd vptestmq vptestnmd vptestnmq vpxord vpxorq vrcp14pd vrcp14ps vrcp14sd vrcp14ss vrndscalepd vrndscaleps vrndscalesd vrndscaless vrsqrt14pd vrsqrt14ps vrsqrt14sd vrsqrt14ss vscalefpd vscalefps vscalefsd vscalefss vscatterdpd vscatterdps vscatterqpd vscatterqps vshuff32x4 vshuff64x2 vshufi32x4 vshufi64x2 kandnw kandw kmovw knotw kortestw korw kshiftlw kshiftrw kunpckbw kxnorw kxorw vpbroadcastmb2q vpbroadcastmw2d vpconflictd vpconflictq vplzcntd vplzcntq vexp2pd vexp2ps vrcp28pd vrcp28ps vrcp28sd vrcp28ss vrsqrt28pd vrsqrt28ps vrsqrt28sd vrsqrt28ss vgatherpf0dpd vgatherpf0dps vgatherpf0qpd vgatherpf0qps vgatherpf1dpd vgatherpf1dps vgatherpf1qpd vgatherpf1qps vscatterpf0dpd vscatterpf0dps vscatterpf0qpd vscatterpf0qps vscatterpf1dpd vscatterpf1dps vscatterpf1qpd vscatterpf1qps prefetchwt1 bndmk bndcl bndcu bndcn bndmov bndldx bndstx sha1rnds4 sha1nexte sha1msg1 sha1msg2 sha256rnds2 sha256msg1 sha256msg2 hint_nop0 hint_nop1 hint_nop2 hint_nop3 hint_nop4 hint_nop5 hint_nop6 hint_nop7 hint_nop8 hint_nop9 hint_nop10 hint_nop11 hint_nop12 hint_nop13 hint_nop14 hint_nop15 hint_nop16 hint_nop17 hint_nop18 hint_nop19 hint_nop20 hint_nop21 hint_nop22 hint_nop23 hint_nop24 hint_nop25 hint_nop26 hint_nop27 hint_nop28 hint_nop29 hint_nop30 hint_nop31 hint_nop32 hint_nop33 hint_nop34 hint_nop35 hint_nop36 hint_nop37 hint_nop38 hint_nop39 hint_nop40 hint_nop41 hint_nop42 hint_nop43 hint_nop44 hint_nop45 hint_nop46 hint_nop47 hint_nop48 hint_nop49 hint_nop50 hint_nop51 hint_nop52 hint_nop53 hint_nop54 hint_nop55 hint_nop56 hint_nop57 hint_nop58 hint_nop59 hint_nop60 hint_nop61 hint_nop62 hint_nop63',
+ literal:
+ // Instruction pointer
+ 'ip eip rip ' +
+ // 8-bit registers
+ 'al ah bl bh cl ch dl dh sil dil bpl spl r8b r9b r10b r11b r12b r13b r14b r15b ' +
+ // 16-bit registers
+ 'ax bx cx dx si di bp sp r8w r9w r10w r11w r12w r13w r14w r15w ' +
+ // 32-bit registers
+ 'eax ebx ecx edx esi edi ebp esp eip r8d r9d r10d r11d r12d r13d r14d r15d ' +
+ // 64-bit registers
+ 'rax rbx rcx rdx rsi rdi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 ' +
+ // Segment registers
+ 'cs ds es fs gs ss ' +
+ // Floating point stack registers
+ 'st st0 st1 st2 st3 st4 st5 st6 st7 ' +
+ // MMX Registers
+ 'mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 ' +
+ // SSE registers
+ 'xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 xmm8 xmm9 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 ' +
+ 'xmm16 xmm17 xmm18 xmm19 xmm20 xmm21 xmm22 xmm23 xmm24 xmm25 xmm26 xmm27 xmm28 xmm29 xmm30 xmm31 ' +
+ // AVX registers
+ 'ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 ymm9 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ' +
+ 'ymm16 ymm17 ymm18 ymm19 ymm20 ymm21 ymm22 ymm23 ymm24 ymm25 ymm26 ymm27 ymm28 ymm29 ymm30 ymm31 ' +
+ // AVX-512F registers
+ 'zmm0 zmm1 zmm2 zmm3 zmm4 zmm5 zmm6 zmm7 zmm8 zmm9 zmm10 zmm11 zmm12 zmm13 zmm14 zmm15 ' +
+ 'zmm16 zmm17 zmm18 zmm19 zmm20 zmm21 zmm22 zmm23 zmm24 zmm25 zmm26 zmm27 zmm28 zmm29 zmm30 zmm31 ' +
+ // AVX-512F mask registers
+ 'k0 k1 k2 k3 k4 k5 k6 k7 ' +
+ // Bound (MPX) register
+ 'bnd0 bnd1 bnd2 bnd3 ' +
+ // Special register
+ 'cr0 cr1 cr2 cr3 cr4 cr8 dr0 dr1 dr2 dr3 dr8 tr3 tr4 tr5 tr6 tr7 ' +
+ // NASM altreg package
+ 'r0 r1 r2 r3 r4 r5 r6 r7 r0b r1b r2b r3b r4b r5b r6b r7b ' +
+ 'r0w r1w r2w r3w r4w r5w r6w r7w r0d r1d r2d r3d r4d r5d r6d r7d ' +
+ 'r0h r1h r2h r3h ' +
+ 'r0l r1l r2l r3l r4l r5l r6l r7l r8l r9l r10l r11l r12l r13l r14l r15l',
+
+ pseudo:
+ 'db dw dd dq dt ddq do dy dz ' +
+ 'resb resw resd resq rest resdq reso resy resz ' +
+ 'incbin equ times',
+
+ preprocessor:
+ '%define %xdefine %+ %undef %defstr %deftok %assign %strcat %strlen %substr %rotate %elif %else %endif ' +
+ '%ifmacro %ifctx %ifidn %ifidni %ifid %ifnum %ifstr %iftoken %ifempty %ifenv %error %warning %fatal %rep ' +
+ '%endrep %include %push %pop %repl %pathsearch %depend %use %arg %stacksize %local %line %comment %endcomment ' +
+ '.nolist ' +
+ 'byte word dword qword nosplit rel abs seg wrt strict near far a32 ptr ' +
+ '__FILE__ __LINE__ __SECT__ __BITS__ __OUTPUT_FORMAT__ __DATE__ __TIME__ __DATE_NUM__ __TIME_NUM__ ' +
+ '__UTC_DATE__ __UTC_TIME__ __UTC_DATE_NUM__ __UTC_TIME_NUM__ __PASS__ struc endstruc istruc at iend ' +
+ 'align alignb sectalign daz nodaz up down zero default option assume public ',
+
+ built_in:
+ 'bits use16 use32 use64 default section segment absolute extern global common cpu float ' +
+ '__utf16__ __utf16le__ __utf16be__ __utf32__ __utf32le__ __utf32be__ ' +
+ '__float8__ __float16__ __float32__ __float64__ __float80m__ __float80e__ __float128l__ __float128h__ ' +
+ '__Infinity__ __QNaN__ __SNaN__ Inf NaN QNaN SNaN float8 float16 float32 float64 float80m float80e ' +
+ 'float128l float128h __FLOAT_DAZ__ __FLOAT_ROUND__ __FLOAT__'
+ },
+ contains: [
+ {
+ className: 'comment',
+ begin: ';',
+ end: '$',
+ relevance: 0
+ },
+ // Float number and x87 BCD
+ {
+ className: 'number',
+ begin: '\\b(?:([0-9][0-9_]*)?\\.[0-9_]*(?:[eE][+-]?[0-9_]+)?|(0[Xx])?[0-9][0-9_]*\\.?[0-9_]*(?:[pP](?:[+-]?[0-9_]+)?)?)\\b',
+ relevance: 0
+ },
+ // Hex number in $
+ {
+ className: 'number',
+ begin: '\\$[0-9][0-9A-Fa-f]*',
+ relevance: 0
+ },
+ // Number in H,X,D,T,Q,O,B,Y suffix
+ {
+ className: 'number',
+ begin: '\\b(?:[0-9A-Fa-f][0-9A-Fa-f_]*[HhXx]|[0-9][0-9_]*[DdTt]?|[0-7][0-7_]*[QqOo]|[0-1][0-1_]*[BbYy])\\b'
+ },
+ // Number in H,X,D,T,Q,O,B,Y prefix
+ {
+ className: 'number',
+ begin: '\\b(?:0[HhXx][0-9A-Fa-f_]+|0[DdTt][0-9_]+|0[QqOo][0-7_]+|0[BbYy][0-1_]+)\\b'
+ },
+ // Double quote string
+ hljs.QUOTE_STRING_MODE,
+ // Single-quoted string
+ {
+ className: 'string',
+ begin: '\'',
+ end: '[^\\\\]\'',
+ relevance: 0
+ },
+ // Backquoted string
+ {
+ className: 'string',
+ begin: '`',
+ end: '[^\\\\]`',
+ relevance: 0
+ },
+ // Section name
+ {
+ className: 'string',
+ begin: '\\.[A-Za-z0-9]+',
+ relevance: 0
+ },
+ // Global label and local label
+ {
+ className: 'label',
+ begin: '^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)',
+ relevance: 0
+ },
+ // Macro-local label
+ {
+ className: 'label',
+ begin: '^\\s*%%[A-Za-z0-9_$#@~.?]*:',
+ relevance: 0
+ },
+ // Macro parameter
+ {
+ className: 'argument',
+ begin: '%[0-9]+',
+ relevance: 0
+ },
+ // Macro parameter
+ {
+ className: 'built_in',
+ begin: '%!\S+',
+ relevance: 0
+ }
+ ]
+ };
+};
+},{}],131:[function(require,module,exports){
+module.exports = function(hljs) {
+ var BUILTIN_MODULES = 'ObjectLoader Animate MovieCredits Slides Filters Shading Materials LensFlare Mapping VLCAudioVideo StereoDecoder PointCloud NetworkAccess RemoteControl RegExp ChromaKey Snowfall NodeJS Speech Charts';
+
+ var XL_KEYWORDS = {
+ keyword: 'if then else do while until for loop import with is as where when by data constant',
+ literal: 'true false nil',
+ type: 'integer real text name boolean symbol infix prefix postfix block tree',
+ built_in: 'in mod rem and or xor not abs sign floor ceil sqrt sin cos tan asin acos atan exp expm1 log log2 log10 log1p pi at',
+ module: BUILTIN_MODULES,
+ id: 'text_length text_range text_find text_replace contains page slide basic_slide title_slide title subtitle fade_in fade_out fade_at clear_color color line_color line_width texture_wrap texture_transform texture scale_?x scale_?y scale_?z? translate_?x translate_?y translate_?z? rotate_?x rotate_?y rotate_?z? rectangle circle ellipse sphere path line_to move_to quad_to curve_to theme background contents locally time mouse_?x mouse_?y mouse_buttons'
+ };
+
+ var XL_CONSTANT = {
+ className: 'constant',
+ begin: '[A-Z][A-Z_0-9]+',
+ relevance: 0
+ };
+ var XL_VARIABLE = {
+ className: 'variable',
+ begin: '([A-Z][a-z_0-9]+)+',
+ relevance: 0
+ };
+ var XL_ID = {
+ className: 'id',
+ begin: '[a-z][a-z_0-9]+',
+ relevance: 0
+ };
+
+ var DOUBLE_QUOTE_TEXT = {
+ className: 'string',
+ begin: '"', end: '"', illegal: '\\n'
+ };
+ var SINGLE_QUOTE_TEXT = {
+ className: 'string',
+ begin: '\'', end: '\'', illegal: '\\n'
+ };
+ var LONG_TEXT = {
+ className: 'string',
+ begin: '<<', end: '>>'
+ };
+ var BASED_NUMBER = {
+ className: 'number',
+ begin: '[0-9]+#[0-9A-Z_]+(\\.[0-9-A-Z_]+)?#?([Ee][+-]?[0-9]+)?',
+ relevance: 10
+ };
+ var IMPORT = {
+ className: 'import',
+ beginKeywords: 'import', end: '$',
+ keywords: {
+ keyword: 'import',
+ module: BUILTIN_MODULES
+ },
+ relevance: 0,
+ contains: [DOUBLE_QUOTE_TEXT]
+ };
+ var FUNCTION_DEFINITION = {
+ className: 'function',
+ begin: '[a-z].*->'
+ };
+ return {
+ aliases: ['tao'],
+ lexemes: /[a-zA-Z][a-zA-Z0-9_?]*/,
+ keywords: XL_KEYWORDS,
+ contains: [
+ hljs.C_LINE_COMMENT_MODE,
+ hljs.C_BLOCK_COMMENT_MODE,
+ DOUBLE_QUOTE_TEXT,
+ SINGLE_QUOTE_TEXT,
+ LONG_TEXT,
+ FUNCTION_DEFINITION,
+ IMPORT,
+ XL_CONSTANT,
+ XL_VARIABLE,
+ XL_ID,
+ BASED_NUMBER,
+ hljs.NUMBER_MODE
+ ]
+ };
+};
+},{}],132:[function(require,module,exports){
+module.exports = function(hljs) {
+ var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
+ var PHP = {
+ begin: /<\?(php)?(?!\w)/, end: /\?>/,
+ subLanguage: 'php', subLanguageMode: 'continuous'
+ };
+ var TAG_INTERNALS = {
+ endsWithParent: true,
+ illegal: /,
+ relevance: 0,
+ contains: [
+ PHP,
+ {
+ className: 'attribute',
+ begin: XML_IDENT_RE,
+ relevance: 0
+ },
+ {
+ begin: '=',
+ relevance: 0,
+ contains: [
+ {
+ className: 'value',
+ contains: [PHP],
+ variants: [
+ {begin: /"/, end: /"/},
+ {begin: /'/, end: /'/},
+ {begin: /[^\s\/>]+/}
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ return {
+ aliases: ['html', 'xhtml', 'rss', 'atom', 'xsl', 'plist'],
+ case_insensitive: true,
+ contains: [
+ {
+ className: 'doctype',
+ begin: '',
+ relevance: 10,
+ contains: [{begin: '\\[', end: '\\]'}]
+ },
+ {
+ className: 'comment',
+ begin: '',
+ relevance: 10
+ },
+ {
+ className: 'cdata',
+ begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
+ relevance: 10
+ },
+ {
+ className: 'tag',
+ /*
+ The lookahead pattern (?=...) ensures that 'begin' only matches
+ '', returnEnd: true,
+ subLanguage: 'css'
+ }
+ },
+ {
+ className: 'tag',
+ // See the comment in the ",returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:"",returnEnd:!0,subLanguage:"javascript"}},b,{className:"pi",begin:/<\?\w+/,end:/\?>/,relevance:10},{className:"tag",begin:"?",end:"/?>",contains:[{className:"title",begin:/[^ \/><\n\t]+/,relevance:0},c]}]}}},{}],133:[function(a,b){function c(a){return this instanceof c?void(this.options=a||{}):new c(a)}function d(){return"\n"}c.prototype.code=function(a){return"\n\n"+a+"\n\n"},c.prototype.blockquote=function(a){return" "+a+"\n"},c.prototype.html=function(a){return a},c.prototype.heading=function(a){return a},c.prototype.hr=function(){return"\n\n"},c.prototype.list=function(a){return a},c.prototype.listitem=function(a){return" "+a+"\n"},c.prototype.paragraph=function(a){return"\n"+a+"\n"},c.prototype.table=function(a,b){return"\n"+a+"\n"+b+"\n\n"},c.prototype.tablerow=function(a){return a+"\n"},c.prototype.tablecell=function(a){return a+" "},c.prototype.strong=function(a){return a},c.prototype.em=function(a){return a},c.prototype.codespan=function(a){return a},c.prototype.br=function(){return"\n\n"},c.prototype.del=function(a){return a},c.prototype.link=function(a,b,c){return[b,c].filter(Boolean).join(" ")},c.prototype.image=function(a,b,c){return[b,c].filter(Boolean).join(" ")},c.prototype.footnote=function(a,b){return"\n"+b+"\n"},c.prototype.math=d,c.prototype.reffn=d,b.exports=c},{}],134:[function(b,c,d){(function(b){(function(){function b(a){this.tokens=[],this.tokens.links={},this.options=a||m.defaults,this.rules=n.normal,this.options.gfm&&(this.rules=this.options.tables?n.tables:n.gfm),this.options.mathjax||(this.rules.math=k)}function e(a,b){if(this.options=b||m.defaults,this.links=a,this.rules=o.normal,this.renderer=this.options.renderer||new f,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?o.breaks:o.gfm:this.options.pedantic&&(this.rules=o.pedantic),this.options.mathjax||(this.rules.math=k)}function f(a){this.options=a||{}}function g(a){this.tokens=[],this.token=null,this.options=a||m.defaults,this.options.renderer=this.options.renderer||new f,this.renderer=this.options.renderer,this.renderer.options=this.options}function h(a,b){return a.replace(b?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function i(a){return a.replace(/&([#\w]+);/g,function(a,b){return b=b.toLowerCase(),"colon"===b?":":"#"===b.charAt(0)?String.fromCharCode("x"===b.charAt(1)?parseInt(b.substring(2),16):+b.substring(1)):""})}function j(a,b){return a=a.source,b=b||"",function c(d,e){return d?(e=e.source||e,e=e.replace(/(^|[^\[])\^/g,"$1"),a=a.replace(d,e),c):new RegExp(a,b)}}function k(){}function l(a){for(var b,c,d=1;d..
"+h(k.message+"",!0)+"";throw k}}var n={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:k,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:k,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,footnote:/^\[\^([^\]]+)\]: ([^\n]+)/,table:k,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def|math))+)\n*/,text:/^[^\n]+/,math:/^ *(\${2,}) *([\s\S]+?)\s*\1 *(?:\n+|$)/};n.bullet=/(?:[*+-]|\d+\.)/,n.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,n.item=j(n.item,"gm")(/bull/g,n.bullet)(),n.list=j(n.list)(/bull/g,n.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+n.def.source+")")("footnote",n.footnote)(),n.blockquote=j(n.blockquote)("def",n.def)(),n._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",n.html=j(n.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/
'+(c?a:h(a,!0))+"\n\n":""+(c?a:h(a,!0))+"\n"},f.prototype.blockquote=function(a){return"\n"+a+"\n"},f.prototype.html=function(a){return a},f.prototype.heading=function(a,b,c){var d=/({#)(.+)(})/g.exec(c);return"
"+a+"
\n"},f.prototype.table=function(a,b){return""+a+""},f.prototype.br=function(){return this.options.xhtml?"\n'+a+". "+b+' ↩\n\n'},f.prototype.link=function(a,b,c){if(this.options.sanitize){try{var d=decodeURIComponent(i(a)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===d.indexOf("javascript:"))return""}var f='"+c+""},f.prototype.image=function(a,b,c){var d='
c?Sd(0,d+c):Td(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function wc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++cf;){var h=f+g>>>1;d(a[h]) 1?arguments:arguments[0],b=-1,c=a?ac(me(a,"length")):0,d=nd(0>c?0:c);++b 2?gb(a,17,p(arguments,2),null,b):gb(a,1,null,null,b)}function Jc(a){for(var b=arguments.length>1?_(arguments,!0,!1,1):ub(a),c=-1,d=b.length;++c 2?gb(b,19,p(arguments,2),null,a):gb(b,3,null,null,a)}function Lc(){for(var a=arguments,b=a.length;b--;)if(!Db(a[b]))throw new wd;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Mc(a,b){return b="number"==typeof b?b:+b||a.length,gb(a,4,null,null,null,b)}function Nc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!Db(a))throw new wd;if(b=Sd(0,b)||0,c===!0){var n=!0;m=!1}else Eb(c)&&(n=c.leading,l="maxWait"in c&&(Sd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(oe()-g);if(0>=c){e&&Dd(e);var l=j;e=i=j=r,l&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))}else i=Jd(o,c)},p=function(){i&&Dd(i),e=i=j=r,(m||l!==b)&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))};return function(){if(d=arguments,g=oe(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k),r=0>=q;r?(e&&(e=Dd(e)),k=g,f=a.apply(h,d)):e||(e=Jd(p,q))}return r&&i?i=Dd(i):i||b===l||(i=Jd(o,b)),c&&(r=!0,f=a.apply(h,d)),!r||i||e||(d=h=null),f}}function Oc(a){if(!Db(a))throw new wd;var b=p(arguments,1);return Jd(function(){a.apply(r,b)},1)}function Pc(a,b){if(!Db(a))throw new wd;var c=p(arguments,2);return Jd(function(){a.apply(r,c)},b)}function Qc(a,b){if(!Db(a))throw new wd;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return Hd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Rc(a){var b,c;if(!Db(a))throw new wd;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Sc(a){return gb(a,16,p(arguments,1))}function Tc(a){return gb(a,32,null,p(arguments,1))}function Uc(a,b,c){var d=!0,e=!0;if(!Db(a))throw new wd;return c===!1?d=!1:Eb(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e,Nc(a,b,W)}function Vc(a,b){return gb(b,16,[a])}function Wc(a){return function(){return a}}function Xc(a,b,c){var d=typeof a;if(null==a||"function"==d)return t(a,b,c);if("object"!=d)return bd(a);var e=_d(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Eb(g)?function(b){for(var c=e.length,d=!1;c--&&(d=ab(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Yc(a){return null==a?"":vd(a).replace(de,hb)}function Zc(a){return a}function $c(a,d,e){var f=!0,g=d&&ub(d);d&&(e||g.length)||(null==e&&(e=d),h=c,d=a,a=b,g=ub(d)),e===!1?f=!1:Eb(e)&&"chain"in e&&(f=e.chain);var h=a,i=Db(h);Yb(g,function(b){var c=a[b]=d[b];i&&(h.prototype[b]=function(){var b=this.__chain__,d=this.__wrapped__,e=[d];Id.apply(e,arguments);var g=c.apply(a,e);if(f||b){if(d===g&&Eb(g))return this;g=new h(g),g.__chain__=b}return g})})}function _c(){return a._=zd,this}function ad(){}function bd(a){return function(b){return b[a]}}function cd(a,b,c){var d=null==a,e=null==b;if(null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0,c||a%1||b%1){var f=Vd();return Td(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b)}return cb(a,b)}function dd(a,b){if(a){var c=a[b];return Db(c)?a[b]():c}}function ed(a,c,d){var e=b.templateSettings;a=vd(a||""),d=fe({},d,e);var f,g=fe({},d.imports,e.imports),h=_d(g),i=Rb(g),j=0,l=d.interpolate||H,m="__p += '",n=ud((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(J,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=qd(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return c?s(c):(s.source=m,s)}function fd(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=nd(a);for(b=t(b,c,1);++d/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:b}},Nd||(s=function(){function b(){}return function(c){if(Eb(c)){b.prototype=c;var d=new b;b.prototype=null}return d||a.Object()}}());var Yd=Md?function(a,b){X.value=b,Md(a,"__bindData__",X)}:ad,Zd=Od||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ad.call(a)==N||!1},$d=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)Hd.call(c,b)&&d.push(b);return d},_d=Rd?function(a){return Eb(a)?Rd(a):[]}:$d,ae={"&":"&","<":"<",">":">",'"':""","'":"'"},be=wb(ae),ce=ud("("+_d(be).join("|")+")","g"),de=ud("["+_d(ae).join("")+"]","g"),ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=t(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof d]&&d&&!d.nodeType&&d,ab=Y[typeof c]&&c&&!c.nodeType&&c,bb=ab&&ab.exports===_&&_,cb=Y[typeof b]&&b;!cb||cb.global!==cb&&cb.window!==cb||($=cb);var db=q();"function"==typeof a&&"object"==typeof a.amd&&a.amd?($._=db,a(function(){return db})):_&&ab?bb?(ab.exports=db)._=db:_._=db:$._=db}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[4])(4)})}(); \ No newline at end of file diff --git a/lib/generate/config.js b/lib/generate/config.js new file mode 100644 index 0000000000..7ec0741de7 --- /dev/null +++ b/lib/generate/config.js @@ -0,0 +1,105 @@ +var _ = require('lodash'); +var path = require('path'); + +// Default configuration for gitbook +var CONFIG = { + // Folders to use for output + // Caution: it overrides the value from the command line + // It's not advised this option in the book.json + "output": null, + + // Generator to use for building + // Caution: it overrides the value from the command line + // It's not advised this option in the book.json + "generator": "site", + + // Configuration file to use + "configFile": "book", + + // Book title and description (defaults are extracted from the README) + "title": null, + "description": null, + + // For ebook format, the extension to use for generation (default is detected from output extension) + // "epub", "pdf", "mobi" + // Caution: it overrides the value from the command line + // It's not advised this option in the book.json + "extension": null, + + // Plugins list, can contain "-name" for removing default plugins + "plugins": [], + + // Global configuration for plugins + "pluginsConfig": { + "fontSettings": { + "theme": null, //"sepia", "night" or "white", + "family": "sans",// "serif" or "sans", + "size": 2 // 1 - 4 + } + }, + + // Variables for templating + "variables": {}, + + // Set another theme with your own layout + // It's recommended to use plugins or add more options for default theme, though + // See https://github.com/GitbookIO/gitbook/issues/209 + "theme": path.resolve(__dirname, '../../theme'), + + // Links in template (null: default, false: remove, string: new value) + "links": { + // Custom links at top of sidebar + "sidebar": { + //"Custom link name": "https://customlink.com" + }, + + // Sharing links + "sharing": { + "google": null, + "facebook": null, + "twitter": null, + "weibo": null, + "all": null + } + }, + + + // Options for PDF generation + "pdf": { + // Add toc at the end of the file + "toc": true, + + // Add page numbers to the bottom of every page + "pageNumbers": false, + + // Font size for the file content + "fontSize": 12, + + // Paper size for the pdf + // Choices are [u’a0’, u’a1’, u’a2’, u’a3’, u’a4’, u’a5’, u’a6’, u’b0’, u’b1’, u’b2’, u’b3’, u’b4’, u’b5’, u’b6’, u’legal’, u’letter’] + "paperSize": "a4", + + // Margin (in pts) + // Note: 72 pts equals 1 inch + "margin": { + "right": 62, + "left": 62, + "top": 36, + "bottom": 36 + }, + + //Header HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_. + "headerTemplate": "", + + //Footer HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_. + "footerTemplate": "" + } +}; + +module.exports = { + CONFIG: CONFIG, + defaults: function(options) { + return _.merge(options || {}, CONFIG, _.defaults); + } +} + diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js new file mode 100644 index 0000000000..bc39e156dd --- /dev/null +++ b/lib/generate/ebook/index.js @@ -0,0 +1,86 @@ +var util = require("util"); +var path = require("path"); +var Q = require("q"); +var _ = require("lodash"); +var exec = require('child_process').exec; + +var fs = require('graceful-fs'); +var parse = require("../../parse"); +var BaseGenerator = require("../page"); +var stringUtils = require("../../utils/string"); + +var Generator = function() { + BaseGenerator.apply(this, arguments); +}; +util.inherits(Generator, BaseGenerator); + +Generator.prototype.finish = function() { + var that = this; + + return BaseGenerator.prototype.finish.apply(this) + .then(function() { + var d = Q.defer(); + var format = that.options.extension || path.extname(that.options.output).replace("\.", "") || "pdf"; + + if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) { + that.options.cover = path.join(that.options.output, "cover.jpg"); + } + + var _options = { + "--cover": that.options.cover, + "--title": that.options.title, + "--comments": that.options.description, + "--authors": that.options.author, + "--publisher": "GitBook", + "--chapter": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]", + "--chapter-mark": "pagebreak", + "--page-breaks-before": "/", + "--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]", + "--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]", + "--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]", + "--no-chapters-in-toc": true, + "--max-levels": "1", + "--breadth-first": true + }; + + if (format == "pdf") { + var pdfOptions = that.options.pdf; + + _.extend(_options, { + "--margin-left": String(pdfOptions.margin.left), + "--margin-right": String(pdfOptions.margin.right), + "--margin-top": String(pdfOptions.margin.top), + "--margin-bottom": String(pdfOptions.margin.bottom), + "--pdf-default-font-size": String(pdfOptions.fontSize), + "--pdf-mono-font-size": String(pdfOptions.fontSize), + "--paper-size": String(pdfOptions.paperSize), + "--pdf-page-numbers": Boolean(pdfOptions.pageNumbers), + "--pdf-header-template": String(pdfOptions.headerTemplate), + "--pdf-footer-template": String(pdfOptions.footerTemplate) + }); + } + + var command = [ + "ebook-convert", + path.join(that.options.output, "SUMMARY.html"), + path.join(that.options.output, "index."+format), + stringUtils.optionsToShellArgs(_options) + ].join(" "); + + exec(command, function (error, stdout, stderr) { + if (error) { + if (error.code == 127) { + error.message = "Need to install ebook-convert from Calibre"; + } else { + error.message = error.message + " "+stdout; + } + return d.reject(error); + } + d.resolve(); + }); + + return d.promise; + }); +}; + +module.exports = Generator; diff --git a/lib/generate/fs.js b/lib/generate/fs.js new file mode 100644 index 0000000000..4c232e723f --- /dev/null +++ b/lib/generate/fs.js @@ -0,0 +1,78 @@ +var Q = require("q"); +var fs = require('graceful-fs'); +var fsExtra = require("fs-extra"); +var Ignore = require("fstream-ignore"); + +var getFiles = function(path) { + var d = Q.defer(); + + // Our list of files + var files = []; + + var ig = Ignore({ + path: path, + ignoreFiles: ['.ignore', '.gitignore', '.bookignore'] + }); + + // Add extra rules to ignore common folders + ig.addIgnoreRules([ + // Skip Git stuff + '.git/', + '.gitignore', + + // Skip OS X meta data + '.DS_Store', + + // Skip stuff installed by plugins + 'node_modules', + + // Skip book outputs + '*.pdf', + '*.epub', + '*.mobi', + + // Skip config files + '.ignore', + '.bookignore', + 'book.json', + ], '__custom_stuff'); + + // Push each file to our list + ig.on('child', function (c) { + files.push( + c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '') + ); + }); + + ig.on('end', function() { + // Normalize paths on Windows + if(process.platform === 'win32') { + return d.resolve(files.map(function(file) { + return file.replace(/\\/g, '/'); + })); + } + + // Simply return paths otherwise + return d.resolve(files); + }); + + ig.on('error', d.reject); + + return d.promise; +}; + +module.exports = { + list: getFiles, + readFile: Q.denodeify(fs.readFile), + writeFile: Q.denodeify(fs.writeFile), + mkdirp: Q.denodeify(fsExtra.mkdirp), + copy: Q.denodeify(fsExtra.copy), + remove: Q.denodeify(fsExtra.remove), + symlink: Q.denodeify(fsExtra.symlink), + exists: function(path) { + var d = Q.defer(); + fs.exists(path, d.resolve); + return d.promise; + }, + readFileSync: fs.readFileSync.bind(fs) +}; diff --git a/lib/generate/generator.js b/lib/generate/generator.js new file mode 100644 index 0000000000..4791c986c8 --- /dev/null +++ b/lib/generate/generator.js @@ -0,0 +1,87 @@ +var _ = require("lodash"); +var path = require("path"); +var Q = require("q"); +var fs = require("./fs"); + +var Plugin = require("./plugin"); + +var BaseGenerator = function(options) { + this.options = options; + + // Base for assets in plugins + this.pluginAssetsBase = "book"; + + this.options.plugins = Plugin.normalizeNames(this.options.plugins); + this.options.plugins = _.union(this.options.plugins, this.options.defaultsPlugins); + this.plugins = []; +}; + +BaseGenerator.prototype.callHook = function(name, data) { + return this.plugins.hook(name, data); +}; + +// Sets up generator +BaseGenerator.prototype.load = function() { + return this.loadPlugins(); +}; + +BaseGenerator.prototype.loadPlugins = function() { + var that = this; + + return Plugin.fromList(this.options.plugins, this.options.input, this, { + assetsBase: this.pluginAssetsBase + }) + .then(function(_plugins) { + that.plugins = _plugins; + + return that.callHook("init"); + }); +}; + +BaseGenerator.prototype.convertFile = function(content, input) { + return Q.reject(new Error("Could not convert "+input)); +}; + +BaseGenerator.prototype.transferFile = function(input) { + return fs.copy( + path.join(this.options.input, input), + path.join(this.options.output, input) + ); +}; + +BaseGenerator.prototype.transferFolder = function(input) { + return fs.mkdirp( + path.join(this.options.output, input) + ); +}; + +BaseGenerator.prototype.copyCover = function() { + var that = this; + + return Q.all([ + fs.copy(path.join(this.options.input, "cover.jpg"), path.join(this.options.output, "cover.jpg")), + fs.copy(path.join(this.options.input, "cover_small.jpg"), path.join(this.options.output, "cover_small.jpg")) + ]) + .fail(function() { + // If orignally from multi-lang, try copy from originalInput + if (!that.options.originalInput) return; + + return Q.all([ + fs.copy(path.join(that.options.originalInput, "cover.jpg"), path.join(that.options.output, "cover.jpg")), + fs.copy(path.join(that.options.originalInput, "cover_small.jpg"), path.join(that.options.output, "cover_small.jpg")) + ]); + }) + .fail(function(err) { + return Q(); + }); +}; + +BaseGenerator.prototype.langsIndex = function(langs) { + return Q.reject(new Error("Langs index is not supported in this generator")); +}; + +BaseGenerator.prototype.finish = function() { + return Q.reject(new Error("Could not finish generation")); +}; + +module.exports = BaseGenerator; diff --git a/lib/generate/index.js b/lib/generate/index.js new file mode 100644 index 0000000000..2118c46edb --- /dev/null +++ b/lib/generate/index.js @@ -0,0 +1,378 @@ +var Q = require("q"); +var _ = require("lodash"); +var path = require("path"); +var tmp = require('tmp'); + +var swig = require('./template'); +var fs = require("./fs"); +var parse = require("../parse"); +var Plugin = require("./plugin"); +var defaultConfig = require("./config"); + +var generators = { + "site": require("./site"), + "page": require("./page"), + "ebook": require("./ebook"), + "json": require("./json") +}; + +var defaultDescription = "Book generated using GitBook"; + + +var containsFiles = function(dir, files) { + return Q.all(_.map(files, function(file) { + return fs.exists(path.join(dir, file)); + })) + .then(_.all); +}; + +// Test if generator exists +var checkGenerator = function(options) { + if (!generators[options.generator]) { + return Q.reject(new Error("Invalid generator (availables are: "+_.keys(generators).join(", ")+")")); + } + return Q(); +}; + +// Create the generator and load plugins +var loadGenerator = function(options) { + return checkGenerator(options) + .then(function() { + var generator = new generators[options.generator](options); + + return generator.load() + .then(_.constant(generator)); + }); +}; + + + +var generate = function(options) { + // Set defaults to options + options = defaultConfig.defaults(options); + + // Validate options + if (!options.input) { + return Q.reject(new Error("Need option input (book input directory)")); + } + + // Check files to get folder type (book, multilanguage book or neither) + return checkGenerator(options) + + // Read config file + .then(function() { + try { + var _config = require(path.resolve(options.input, options.configFile)); + + options = _.merge(options, _.omit(_config, 'input', 'configFile', 'defaultsPlugins')); + } + catch(err) { + // No config file: not a big deal + return Q(); + } + }) + + // Read readme + .then(function() { + return fs.readFile(path.join(options.input, "README.md"), "utf-8") + .then(function(_readme) { + _readme = parse.readme(_readme); + + options.title = options.title || _readme.title; + options.description = options.description || _readme.description || defaultDescription; + }); + }) + + // Detect multi-languages book + .then(function() { + return containsFiles(options.input, ['LANGS.md']) + }) + + .then(function(isMultiLang) { + // Multi language book + if(isMultiLang) { + return generateMultiLang(options); + } + + // Book + return generateBook(options); + }); +}; + + +var generateMultiLang = function(options) { + var langsSummary; + options.output = options.output || path.join(options.input, "_book"); + + return checkGenerator(options) + + // Multi-languages book + .then(function() { + return fs.readFile(path.join(options.input, "LANGS.md"), "utf-8") + }) + + // Clean output folder + .then(function(_langsSummary) { + langsSummary = _langsSummary; + return fs.remove(options.output); + }) + .then(function() { + return fs.mkdirp(options.output); + }) + + // Generate sub-books + .then(function() { + options.langsSummary = parse.langs(langsSummary); + + // Generated a book for each valid entry + return _.reduce(options.langsSummary.list, function(prev, entry) { + return prev.then(function() { + return generate(_.extend({}, options, { + input: path.join(options.input, entry.path), + output: path.join(options.output, entry.path), + originalInput: options.input, + originalOutput: options.output + })); + }) + }, Q()); + }) + + .then(function() { + return loadGenerator(options); + }) + + // Generate languages index + .then(function(generator) { + return generator.langsIndex(options.langsSummary); + }) + + // Copy cover file + .then(function() { + return Q.all([ + fs.copy(path.join(options.input, "cover.jpg"), path.join(options.output, "cover.jpg")), + fs.copy(path.join(options.input, "cover_small.jpg"), path.join(options.output, "cover_small.jpg")) + ]) + .fail(function() { + return Q(); + }) + }) + + // Return options to caller + .then(_.constant(options)); +}; + +/* + * Use a specific generator to convert a gitbook to a site/pdf/ebook/ + * output is always a folder + */ +var generateBook = function(options) { + var files; + + options.output = options.output || path.join(options.input, "_book"); + + // Check if it's a book + return containsFiles(options.input, ['SUMMARY.md', 'README.md']) + + // Fail if not a book + .then(function(isBook) { + if(!isBook) { + return Q.reject(new Error("Invalid gitbook repository, need SUMMARY.md and README.md")); + } + }) + + // Clean output folder + .then(function() { + return fs.remove(options.output); + }) + + .then(function() { + return fs.mkdirp(options.output); + }) + + // List all files in the repository + .then(function() { + return fs.list(options.input) + .then(function(_files) { + files = _files; + }); + }) + + .then(function() { + return loadGenerator(options); + }) + + // Convert files + .then(function(generator) { + // Generate the book + return Q() + + // Get summary + .then(function() { + var summary = { + path: path.join(options.input, "SUMMARY.md") + }; + + var _callHook = function(name) { + return generator.callHook(name, summary) + .then(function(_summary) { + summary = _summary; + return summary; + }); + }; + + return fs.readFile(summary.path, "utf-8") + .then(function(_content) { + summary.content = _content; + return _callHook("summary:before"); + }) + .then(function() { + summary.content = parse.summary(summary.content); + return _callHook("summary:after"); + }) + .then(function() { + options.summary = summary.content; + options.navigation = parse.navigation(options.summary); + }); + }) + + // Read glossary + .then(function() { + var glossary = {}; + + var _callHook = function(name) { + return generator.callHook(name, glossary) + .then(function(_glossary) { + glossary = _glossary; + return glossary; + }); + }; + + return fs.readFile(path.join(options.input, "GLOSSARY.md"), "utf-8") + .fail(function() { + return ""; + }) + .then(function(_content) { + glossary.content = _content; + return _callHook("glossary:before"); + }) + .then(function() { + glossary.content = parse.glossary(glossary.content); + return _callHook("glossary:after"); + }) + .then(function() { + options.glossary = glossary.content; + }); + }) + + // Skip processing some files + .then(function() { + files = _.filter(files, function (file) { + return !( + file === 'SUMMARY.md' || + file === 'GLOSSARY.md' + ); + }); + }) + + // Copy file and replace markdown file + .then(function() { + return Q.all( + _.chain(files) + .map(function(file) { + if (!file) return; + + if (file[file.length -1] == "/") { + return Q(generator.transferFolder(file)); + } else if (path.extname(file) == ".md" && options.navigation[file] != null) { + return fs.readFile(path.join(options.input, file), "utf-8") + .then(function(content) { + return Q(generator.convertFile(content, file)); + }); + } else { + return Q(generator.transferFile(file)); + } + }) + .value() + ); + }) + + // Finish generation + .then(function() { + return generator.finish(); + }) + .then(function() { + return generator.callHook("finish"); + }); + }) + + // Return all options + .then(function() { + return options; + }); +}; + +/* + * Extract files from generate output in a temporary folder + */ +var generateFile = function(options) { + options = _.defaults(options || {}, { + input: null, + output: null, + extension: null + }); + + return Q.nfcall(tmp.dir) + .then(function(tmpDir) { + return generate( + _.extend({}, + options, + { + output: tmpDir + }) + ) + .then(function(_options) { + var ext = options.extension; + var outputFile = options.output || path.resolve(options.input, "book."+ext); + + var copyFile = function(lang) { + var _outputFile = outputFile; + var _tmpDir = tmpDir; + + if (lang) { + _outputFile = _outputFile.slice(0, -path.extname(_outputFile).length)+"_"+lang+path.extname(_outputFile); + _tmpDir = path.join(_tmpDir, lang); + } + + return fs.copy( + path.join(_tmpDir, "index."+ext), + _outputFile + ); + }; + + // Multi-langs book + return Q() + .then(function() { + if (_options.langsSummary) { + return Q.all( + _.map(_options.langsSummary.list, function(lang) { + return copyFile(lang.lang); + }) + ); + } else { + return copyFile(); + } + }) + .then(function() { + return fs.remove(tmpDir); + }); + }); + }); +}; + +module.exports = { + generators: generators, + folder: generate, + file: generateFile, + book: generateBook, + Plugin: Plugin, +}; diff --git a/lib/generate/init.js b/lib/generate/init.js new file mode 100644 index 0000000000..705e6e7581 --- /dev/null +++ b/lib/generate/init.js @@ -0,0 +1,69 @@ +var Q = require('q'); +var _ = require('lodash'); + +var path = require('path'); + +var fs = require('./fs'); +var parse = require('../parse'); + + +// Extract paths out of a summary +function paths(summary) { + return _.reduce(summary.chapters, function(accu, chapter) { + return accu.concat( + _.filter([chapter.path].concat(_.pluck(chapter.articles, 'path'))) + ); + }, []); +} + +// Get the parent folders out of a group of files +function folders(files) { + return _.chain(files) + .map(function(file) { + return path.dirname(file); + }) + .uniq() + .value(); +} + +function initDir(dir) { + return fs.readFile(path.join(dir, 'SUMMARY.md'), 'utf8') + .then(function(src) { + // Parse summary + return parse.summary(src); + }) + .then(function(summary) { + // Extract paths from summary + return paths(summary); + }) + .then(function(paths) { + // Convert to absolute paths + return _.map(paths, function(file) { + return path.resolve(file); + }); + }) + .then(function(files) { + // Create folders + return Q.all(_.map(folders(files), function(folder) { + return fs.mkdirp(folder); + })) + .then(_.constant(files)); + }) + .then(function(files) { + // Create files that don't exist + return Q.all(_.map(files, function(file) { + return fs.exists(file) + .then(function(exists) { + if(exists) return; + return fs.writeFile(file, ''); + }); + })); + }) + .fail(function(err) { + console.error(err.stack); + }); +} + + +// Exports +module.exports = initDir; diff --git a/lib/generate/json/index.js b/lib/generate/json/index.js new file mode 100644 index 0000000000..a252ed3c46 --- /dev/null +++ b/lib/generate/json/index.js @@ -0,0 +1,77 @@ +var util = require("util"); +var path = require("path"); +var Q = require("q"); +var _ = require("lodash"); + +var fs = require("../fs"); +var parse = require("../../parse"); +var BaseGenerator = require("../generator"); + + +var Generator = function() { + BaseGenerator.apply(this, arguments); +}; +util.inherits(Generator, BaseGenerator); + +Generator.prototype.transferFile = function(input) { + // ignore +}; + +Generator.prototype.convertFile = function(content, input) { + var that = this; + var json = { + progress: parse.progress(this.options.navigation, input) + }; + + return Q() + .then(function() { + return parse.page(content, { + dir: path.dirname(input) || '/' + }); + }) + .then(function(parsed) { + json.lexed = parsed.lexed; + json.sections = parsed.sections; + }) + .then(function() { + return fs.writeFile( + path.join(that.options.output, input.replace(".md", ".json")), + JSON.stringify(json, null, 4) + ); + }); +}; + +// Generate languages index +// Contains the first languages readme and langs infos +Generator.prototype.langsIndex = function(langs) { + var that = this; + + if (langs.list.length == 0) return Q.reject("Need at least one language"); + + var mainLang = _.first(langs.list).lang; + console.log("Main language is", mainLang); + + return Q() + .then(function() { + return fs.readFile( + path.join(that.options.output, mainLang, "README.json") + ); + }) + .then(function(content) { + var json = JSON.parse(content); + _.extend(json, { + langs: langs.list + }); + + return fs.writeFile( + path.join(that.options.output, "README.json"), + JSON.stringify(json, null, 4) + ); + }); +}; + +Generator.prototype.finish = function() { + // ignore +}; + +module.exports = Generator; diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js new file mode 100644 index 0000000000..8e44187dd0 --- /dev/null +++ b/lib/generate/page/index.js @@ -0,0 +1,73 @@ +var _ = require("lodash"); +var util = require("util"); +var path = require("path"); +var Q = require("q"); +var swig = require("../template"); + +var fs = require("../fs"); +var parse = require("../../parse"); +var BaseGenerator = require("../site"); + +var Generator = function() { + BaseGenerator.apply(this, arguments); + + // Base for assets in plugins + this.pluginAssetsBase = "ebook"; + + // List of pages content + this.pages = {}; +}; +util.inherits(Generator, BaseGenerator); + +Generator.prototype.loadTemplates = function() { + this.template = swig.compileFile( + this.plugins.template("ebook:page") || path.resolve(this.options.theme, 'templates/ebook/page.html') + ); + this.summaryTemplate = swig.compileFile( + this.plugins.template("ebook:sumary") || path.resolve(this.options.theme, 'templates/ebook/summary.html') + ); +}; + +// Generate table of contents +Generator.prototype.writeToc = function() { + var that = this; + var basePath = "."; + + return this._writeTemplate(this.summaryTemplate, { + toc: parse.progress(this.options.navigation, "README.md").chapters, + basePath: basePath, + staticBase: path.join(basePath, "gitbook"), + }, path.join(this.options.output, "SUMMARY.html")); +}; + +Generator.prototype.finish = function() { + var that = this; + var basePath = "."; + var output = path.join(this.options.output, "index.html"); + + var progress = parse.progress(this.options.navigation, "README.md"); + + return Q() + + // Write table of contents + .then(function() { + return that.writeToc(); + }) + + // Copy cover + .then(function() { + return that.copyCover(); + }) + + // Copy assets + .then(function() { + return that.copyAssets(); + }); +}; + +// Generate languages index +Generator.prototype.langsIndex = function(langs) { + return Q(); +}; + +module.exports = Generator; diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js new file mode 100644 index 0000000000..9d740a53f7 --- /dev/null +++ b/lib/generate/plugin.js @@ -0,0 +1,284 @@ +var _ = require("lodash"); +var Q = require("q"); +var semver = require("semver"); +var path = require("path"); +var url = require("url"); +var fs = require("./fs"); +var resolve = require('resolve'); + +var pkg = require("../../package.json"); + +var RESOURCES = ["js", "css"]; + +var Plugin = function(name, root, generator) { + this.name = name; + this.root = root; + this.packageInfos = {}; + this.infos = {}; + this.generator = generator; + + // Bind methods + _.bindAll(this); + + _.each([ + "gitbook-plugin-"+name, + "gitbook-theme-"+name, + "gitbook-"+name, + name, + ], function(_name) { + if (this.load(_name, __dirname)) return false; + if (this.load(_name, path.resolve(root))) return false; + }, this); +}; + +// Load from a name +Plugin.prototype.load = function(name, baseDir) { + try { + var res = resolve.sync(name+"/package.json", { basedir: baseDir }); + + this.baseDir = path.dirname(res); + this.packageInfos = require(res); + this.infos = require(resolve.sync(name, { basedir: baseDir })); + this.name = name; + + return true; + } catch (e) { + return false; + } +}; + +Plugin.prototype.normalizeResource = function(resource) { + // Parse the resource path + var parsed = url.parse(resource); + + // This is a remote resource + // so we will simply link to using it's URL + if (parsed.protocol) { + return { + "url": resource + }; + } + + // This will be copied over from disk + // and shipped with the book's build + return { "path": this.name+"/"+resource }; +}; + +// Return resources +Plugin.prototype._getResources = function(base) { + base = base || "book"; + var book = this.infos[base]; + + // Nothing specified, fallback to default + if (!book) { + return Q({}); + } + + // Dynamic function + if(typeof book === "function") { + // Call giving it the context of our generator + return Q().then(book.bind(this.generator)); + } + + // Plain data object + return Q(_.cloneDeep(book)); +}; + +// Normalize resources and return them +Plugin.prototype.getResources = function(base) { + var that = this; + + return this._getResources(base) + .then(function(resources) { + + _.each(RESOURCES, function(resourceType) { + resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource); + }); + + return resources; + }); +}; + +// Test if it's a valid plugin +Plugin.prototype.isValid = function() { + return ( + this.packageInfos && + this.packageInfos.name && + this.packageInfos.engines && + this.packageInfos.engines.gitbook && + semver.satisfies(pkg.version, this.packageInfos.engines.gitbook) + ); +}; + +// Resolve file path +Plugin.prototype.resolveFile = function(filename) { + return path.resolve(this.baseDir, filename); +}; + +// Resolve file path +Plugin.prototype.callHook = function(name, data) { + // Our generator will be the context to apply + var context = this.generator; + + var hookFunc = this.infos.hooks? this.infos.hooks[name] : null; + data = data || {}; + + if (!hookFunc) return Q(data); + + return Q() + .then(function() { + return hookFunc.apply(context, [data]); + }); +}; + +// Copy plugin assets fodler +Plugin.prototype.copyAssets = function(out, options) { + var that = this; + options = _.defaults(options || {}, { + base: "book" + }); + + return this.getResources(options.base) + .get('assets') + .then(function(assets) { + // Assets are undefined + if(!assets) return false; + + return fs.copy( + that.resolveFile(assets), + out + ).then(_.constant(true)); + }, _.constant(false)); +}; + + +// Normalize a list of plugin name to use +Plugin.normalizeNames = function(names) { + // Normalize list to an array + names = _.isString(names) ? names.split(",") : (names || []); + + // List plugins to remove + var toremove = _.chain(names) + .filter(function(name) { + return name.length > 0 && name[0] == "-"; + }) + .map(function(name) { + return name.slice(1); + }) + .value(); + + // Merge with defaults + names = _.chain(names) + .concat(Plugin.defaults) + .uniq() + .value(); + + // Remove plugins starting with + names = _.filter(names, function(name) { + return !_.contains(toremove, name) && !(name.length > 0 && name[0] == "-"); + }); + + return names; +}; + +// Extract data from a list of plugin +Plugin.fromList = function(names, root, generator, options) { + options = _.defaults(options || {}, { + assetsBase: "book" + }); + + var failed = []; + + // Load plugins + var plugins = _.map(names, function(name) { + var plugin = new Plugin(name, root, generator); + if (!plugin.isValid()) failed.push(name); + return plugin; + }); + + if (_.size(failed) > 0) return Q.reject(new Error("Error loading plugins: "+failed.join(","))); + + // The raw resources extracted from each plugin + var pluginResources; + + // Get resources of plugins + return Q.all(_.map(plugins, function(plugin) { + return plugin.getResources(options.assetsBase); + })) + // Extract resources out + // css, js, etc ... + .then(function(resources) { + pluginResources = resources; + // Group by resource types + return _.chain(RESOURCES) + .map(function(resourceType) { + // Get resources from all the plugins for this current type + return [ + // Key + resourceType, + // Value + _.chain(resources) + .pluck(resourceType) + .compact() + .flatten() + .value() + ]; + }) + .object() + .value(); + }) + // Extract html snippets + .then(function(resources) { + // Map of html resources by name added by each plugin + resources.html = pluginResources.reduce(function(accu, resource) { + var html = (resource && resource.html) || {}; + _.each(html, function(code, key) { + // Turn into function if not one already + if (!_.isFunction(code)) code = _.constant(code); + // Append + accu[key] = (accu[key] || []).concat([code]); + }); + + return accu; + }, {}); + + return resources; + }) + // Return big multi-plugin object + .then(function(resources) { + return { + 'list': plugins, + 'resources': resources, + 'hook': function(name, data) { + return _.reduce(plugins, function(prev, plugin) { + return prev.then(function(ret) { + return plugin.callHook(name, ret); + }); + }, Q(data)); + }, + 'template': function(name) { + var withTpl = _.find(plugins, function(plugin) { + return ( + plugin.infos.templates && + plugin.infos.templates[name] + ); + }); + + if (!withTpl) return null; + return withTpl.resolveFile(withTpl.infos.templates[name]); + }, + 'html': function(tag, context, options) { + return _.map(resources.html[tag] || [], function(code) { + return code.call(context, options); + }).join("\n"); + } + }; + }); +}; + +// Default plugins +Plugin.defaults = [ + "mathjax" +]; + +module.exports = Plugin; diff --git a/lib/generate/site/glossary_indexer.js b/lib/generate/site/glossary_indexer.js new file mode 100644 index 0000000000..46ac9a4d7e --- /dev/null +++ b/lib/generate/site/glossary_indexer.js @@ -0,0 +1,101 @@ +var _ = require("lodash"); +var kramed = require('kramed'); +var textRenderer = require('kramed-text-renderer'); + +var entryId = require('../../parse/glossary').entryId; + + +function Indexer(glossary) { + if(!(this instanceof Indexer)) { + return new Indexer(glossary); + } + + _.bindAll(this); + + this.glossary = glossary || []; + + this.glossaryTerms = _.pluck(this.glossary, "id"); + + // Regex for searching for terms through body + this.termsRegex = new RegExp( + // Match any of the terms + "("+ + this.glossaryTerms.map(regexEscape).join('|') + + ")", + + // Flags + "gi" + ); + + // page url => terms + this.idx = { + /* + "a/b.html": ["one word", "second word"] + */ + }; + + // term => page urls + this.invertedIdx = { + /* + "word1": ["page1.html", "page2.html"] + */ + }; + + // Use text renderer + this.renderer = textRenderer(); +} + +Indexer.prototype.text = function(nodes) { + // Copy section + var section = _.toArray(nodes); + + // kramed's Render expects this, we don't use it yet + section.links = {}; + + var options = _.extend({}, kramed.defaults, { + renderer: this.renderer + }); + + return kramed.parser(section, options); +}; + +// Add page to glossary index +Indexer.prototype.add = function(sections, url) { + if(!(this.glossary && this.glossary.length > 0)) { + return; + } + + var textblob = + _.where(sections, { type: 'normal' }) + .map(this.text) + .join('\n'); + + var matches = _(textblob.match(this.termsRegex) || []) + .map(entryId) + .uniq() + .value(); + + // Add idx for book + this.idx[url] = matches; + + // Add to inverted idx + matches.forEach(function(match) { + if(!this.invertedIdx[match]) { + this.invertedIdx[match] = []; + } + this.invertedIdx[match].push(url); + }.bind(this)); +}; + +// Dump index as a string +Indexer.prototype.dump = function() { + return JSON.stringify(this.idx); +}; + + +function regexEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); +} + +// Exports +module.exports = Indexer; diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js new file mode 100644 index 0000000000..4d8803ee56 --- /dev/null +++ b/lib/generate/site/index.js @@ -0,0 +1,293 @@ +var util = require("util"); +var path = require("path"); +var Q = require("q"); +var _ = require("lodash"); +var swig = require("../template"); + +var fs = require("../fs"); +var parse = require("../../parse"); +var BaseGenerator = require("../generator"); +var links = require("../../utils/links"); +var indexer = require('./search_indexer'); +var glossaryIndexer = require('./glossary_indexer'); + + +var Generator = function() { + BaseGenerator.apply(this, arguments); + + // Attach methods to instance + _.bindAll(this); + + this.revision = Date.now(); + this.indexer = indexer(); +}; +util.inherits(Generator, BaseGenerator); + +// Add template loading to load +Generator.prototype.load = function() { + var that = this; + + return BaseGenerator.prototype.load.apply(this) + .then(function() { + return that.loadTemplates(); + }); +}; + +// Load all templates +Generator.prototype.loadTemplates = function() { + this.template = swig.compileFile( + this.plugins.template("site:page") || path.resolve(this.options.theme, 'templates/book/page.html') + ); + this.langsTemplate = swig.compileFile( + this.plugins.template("site:langs") || path.resolve(this.options.theme, 'templates/book/langs.html') + ); + this.glossaryTemplate = swig.compileFile( + this.plugins.template("site:glossary") || path.resolve(this.options.theme, 'templates/book/glossary.html') + ); +}; + +// Generate a template +Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) { + var that = this; + + interpolate = interpolate || _.identity; + return Q() + .then(function(sections) { + return tpl(_.extend({ + revision: that.revision, + + title: that.options.title, + description: that.options.description, + + glossary: that.options.glossary, + + summary: that.options.summary, + allNavigation: that.options.navigation, + + plugins: that.plugins, + pluginsConfig: JSON.stringify(that.options.pluginsConfig), + htmlSnippet: _.partialRight(that.plugins.html, that, options), + + options: that.options + }, options)); + }) + .then(interpolate) + .then(function(html) { + return fs.writeFile( + output, + html + ); + }); +}; + +Generator.prototype.indexPage = function(lexed, pagePath) { + // Setup glossary indexer if not yet setup + if(!this.glossaryIndexer) { + this.glossaryIndexer = glossaryIndexer(this.options.glossary); + } + + this.indexer.add(lexed, pagePath); + this.glossaryIndexer.add(lexed, pagePath); + return Q(); +}; + +// Convert a markdown file into a normalized data set +Generator.prototype.prepareFile = function(content, _input) { + var that = this; + + var input = path.join(this.options.input, _input); + + var page = { + path: _input, + rawPath: input, + content: content, + progress: parse.progress(this.options.navigation, _input) + }; + + var _callHook = function(name) { + return that.callHook(name, page) + .then(function(_page) { + page = _page; + return page; + }); + }; + + return Q() + .then(function() { + // Send content to plugins + return _callHook("page:before"); + }) + .then(function() { + // Lex, parse includes and get + // Get HTML generated sections + return parse.page(page.content, { + // Local files path + dir: path.dirname(_input) || '/', + + // Output directory + outdir: path.dirname(_input) || '/', + + // Includer for templating + includer: parse.includer(that.options.variables, [ + path.dirname(_input) || '/', + path.join(that.options.input, '_includes'), + ], path.join, fs.readFileSync) + }); + }) + .then(function(parsed) { + page.lexed = parsed.lexed; + page.sections = parsed.sections; + + // Use plugin hook + return _callHook("page"); + }) + .then(function() { + return page; + }); +}; + +// Convert a markdown file to html +Generator.prototype.convertFile = function(content, _input) { + var that = this; + + var _output = _input.replace(".md", ".html"); + if (_output == "README.html") _output = "index.html"; + var output = path.join(this.options.output, _output); + var basePath = path.relative(path.dirname(output), this.options.output) || "."; + + // Bug fix for issue #493 which would occur when relative-links are 2-level or more deep in win32 + if (process.platform === 'win32') { + basePath = basePath.replace(/\\/g, '/'); + } + + return this.prepareFile(content, _input) + .then(function(page) { + // Index page in search + return that.indexPage(page.lexed, _output).thenResolve(page); + }) + .then(function(page) { + // Write file + return that._writeTemplate(that.template, { + progress: page.progress, + + _input: page.path, + content: page.sections, + + basePath: basePath, + staticBase: links.join(basePath, "gitbook"), + }, output, function(html) { + page.content = html; + + return that.callHook("page:after", page).get("content") + }); + }); +}; + +// Generate languages index +Generator.prototype.langsIndex = function(langs) { + var that = this; + var basePath = "."; + + return this._writeTemplate(this.langsTemplate, { + langs: langs.list, + + basePath: basePath, + staticBase: path.join(basePath, "gitbook"), + }, path.join(this.options.output, "index.html")) + .then(function() { + // Copy assets + return that.copyAssets(); + }); +}; + +// Generate glossary +Generator.prototype.writeGlossary = function() { + var that = this; + var basePath = "."; + + // No glossary + if (!this.glossaryIndexer) return Q(); + + // Transform the glossary to get term, description, files + var glossary = _.chain(this.glossaryIndexer.invertedIdx) + .map(function(links, id) { + var term = _.find(that.options.glossary, { 'id': id }); + + return { + id: id, + name: term.name, + description: term.description, + files: _.chain(links) + .map(function(link) { + var name = link.slice(0, -5); + + if (name == "index") { + name = "README"; + } + return that.options.navigation[name+".md"]; + }) + .sortBy("percent") + .value() + } + }) + .sortBy("name") + .value(); + + return this._writeTemplate(this.glossaryTemplate, { + glossaryIndex: glossary, + basePath: basePath, + staticBase: path.join(basePath, "gitbook"), + }, path.join(this.options.output, "GLOSSARY.html")); +}; + +// Copy assets +Generator.prototype.copyAssets = function() { + var that = this; + + // Copy gitbook assets + return fs.copy( + path.join(that.options.theme, "assets"), + path.join(that.options.output, "gitbook") + ) + + // Copy plugins assets + .then(function() { + return Q.all( + _.map(that.plugins.list, function(plugin) { + var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name); + return plugin.copyAssets(pluginAssets, { + base: that.pluginAssetsBase + }); + }) + ); + }); +}; + +// Dump search index to disk +Generator.prototype.writeSearchIndex = function() { + return fs.writeFile( + path.join(this.options.output, 'search_index.json'), + this.indexer.dump() + ); +}; + +// Dump glossary index to disk +Generator.prototype.writeGlossaryIndex = function() { + if (!this.glossaryIndexer) return Q(); + + return fs.writeFile( + path.join(this.options.output, 'glossary_index.json'), + JSON.stringify(this.options.glossary) + ); +}; + + +Generator.prototype.finish = function() { + return this.copyAssets() + .then(this.copyCover) + .then(this.writeGlossary) + .then(this.writeGlossaryIndex) + .then(this.writeSearchIndex); +}; + +module.exports = Generator; diff --git a/lib/generate/site/search_indexer.js b/lib/generate/site/search_indexer.js new file mode 100644 index 0000000000..7cfe29a06f --- /dev/null +++ b/lib/generate/site/search_indexer.js @@ -0,0 +1,71 @@ +var Q = require("q"); +var _ = require("lodash"); + +var lunr = require('lunr'); +var kramed = require('kramed'); +var textRenderer = require('kramed-text-renderer'); + + +function Indexer() { + if(!(this instanceof Indexer)) { + return new Indexer(); + } + + _.bindAll(this); + + // Setup lunr index + this.idx = lunr(function () { + this.ref('url'); + + this.field('title', { boost: 10 }); + this.field('body'); + }); + + this.renderer = textRenderer(); +} + +Indexer.prototype.text = function(nodes) { + // Copy section + var section = _.toArray(nodes); + + // kramed's Render expects this, we don't use it yet + section.links = {}; + + var options = _.extend({}, kramed.defaults, { + renderer: this.renderer + }); + + return kramed.parser(section, options); +}; + +Indexer.prototype.addSection = function(path, section) { + var url = [path, section.id].join('#'); + + var title = this.text( + _.filter(section, {'type': 'heading'}) + ); + + var body = this.text( + _.omit(section, {'type': 'heading'}) + ); + + // Add to lunr index + this.idx.add({ + url: url, + title: title, + body: body, + }); +}; + +Indexer.prototype.add = function(lexedPage, url) { + var sections = lexedPage; + + _.map(sections, _.partial(this.addSection, url)); +}; + +Indexer.prototype.dump = function() { + return JSON.stringify(this.idx); +}; + +// Exports +module.exports = Indexer; diff --git a/lib/generate/template.js b/lib/generate/template.js new file mode 100644 index 0000000000..acfa580de2 --- /dev/null +++ b/lib/generate/template.js @@ -0,0 +1,52 @@ +var path = require("path"); +var swig = require('swig'); +var hljs = require('highlight.js'); + +var links = require('../utils/').links; +var pkg = require('../../package.json'); + +swig.setDefaults({ + locals: { + gitbook: { + version: pkg.version + } + } +}); + +// Swig filter for returning the count of lines in a code section +swig.setFilter('lines', function(content) { + return content.split('\n').length; +}); + +// Swig filter for returning a link to the associated html file of a markdown file +swig.setFilter('mdLink', function(link) { + var link = link.replace(".md", ".html"); + if (link == "README.html") link = "index.html"; + return link; +}); + +// Swig filter: highlight coloration +swig.setFilter('code', function(code, lang) { + try { + return hljs.highlight(lang, code).value; + } catch(e) { + return hljs.highlightAuto(code).value; + } +}); + +// Convert a level into a deep level +swig.setFilter('lvl', function(lvl) { + return lvl.split(".").length; +}); + +// Join path +swig.setFilter('pathJoin', function(base, _path) { + return links.join(base, _path); +}); + +// Is a link an absolute link +swig.setFilter('isExternalLink', function(link) { + return links.isExternal(link); +}); + +module.exports = swig; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000000..ba240cefb6 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,5 @@ +module.exports = { + parse: require('./parse/'), + generate: require('./generate/') +}; + diff --git a/lib/parse/glossary.js b/lib/parse/glossary.js new file mode 100644 index 0000000000..549e9fda53 --- /dev/null +++ b/lib/parse/glossary.js @@ -0,0 +1,48 @@ +var _ = require('lodash'); +var kramed = require('kramed'); + +// Get all the pairs of header + paragraph in a list of nodes +function groups(nodes) { + // A list of next nodes + var next = nodes.slice(1).concat(null); + + return _.reduce(nodes, function(accu, node, idx) { + // Skip + if(!( + node.type === 'heading' && + (next[idx] && next[idx].type === 'paragraph') + )) { + return accu; + } + + // Add group + accu.push([ + node, + next[idx] + ]); + + return accu; + }, []); +} + +function parseGlossary(src) { + var nodes = kramed.lexer(src); + + return groups(nodes) + .map(function(pair) { + // Simplify each group to a simple object with name/description + return { + name: pair[0].text, + id: entryId(pair[0].text), + description: pair[1].text, + }; + }); +} + +// Normalizes a glossary entry's name to create an ID +function entryId(name) { + return name.toLowerCase(); +} + +module.exports = parseGlossary; +module.exports.entryId = entryId; diff --git a/lib/parse/include.js b/lib/parse/include.js new file mode 100644 index 0000000000..483b18494e --- /dev/null +++ b/lib/parse/include.js @@ -0,0 +1,12 @@ +var _ = require('lodash'); + +module.exports = function(markdown, includer) { + // Memoized include function (to cache lookups) + var _include = _.memoize(includer); + + return markdown.replace(/{{([\s\S]+?)}}/g, function(match, key) { + // If fails leave content as is + key = key.trim(); + return _include(key) || match; + }); +}; diff --git a/lib/parse/includer.js b/lib/parse/includer.js new file mode 100644 index 0000000000..f7f20e05f1 --- /dev/null +++ b/lib/parse/includer.js @@ -0,0 +1,15 @@ +// Return a fs inclduer +module.exports = function(ctx, folders, resolveFile, readFile) { + return function(name) { + return ctx[name] || + folders.map(function(folder) { + // Try including snippet from FS + try { + var fname = resolveFile(folder, name); + // Trim trailing newlines/space of imported snippets + return readFile(fname, 'utf8').trimRight(); + } catch(err) {} + }) + .filter(Boolean)[0]; + } +}; diff --git a/lib/parse/index.js b/lib/parse/index.js new file mode 100644 index 0000000000..23471af0c2 --- /dev/null +++ b/lib/parse/index.js @@ -0,0 +1,11 @@ +module.exports = { + summary: require('./summary'), + glossary: require('./glossary'), + langs: require('./langs'), + page: require('./page'), + lex: require('./lex'), + progress: require('./progress'), + navigation: require('./navigation'), + readme: require('./readme'), + includer: require('./includer') +}; diff --git a/lib/parse/is_exercise.js b/lib/parse/is_exercise.js new file mode 100644 index 0000000000..74ed753961 --- /dev/null +++ b/lib/parse/is_exercise.js @@ -0,0 +1,17 @@ +var _ = require('lodash'); + +function isExercise(nodes) { + var codeType = { type: 'code' }; + + // Number of code nodes in section + var len = _.filter(nodes, codeType).length; + + return ( + // Got 3 or 4 code blocks + (len === 3 || len === 4) && + // Ensure all nodes are at the end + _.all(_.last(nodes, len), codeType) + ); +} + +module.exports = isExercise; diff --git a/lib/parse/is_quiz.js b/lib/parse/is_quiz.js new file mode 100644 index 0000000000..3322ff0c00 --- /dev/null +++ b/lib/parse/is_quiz.js @@ -0,0 +1,87 @@ +var _ = require('lodash'); + +function isQuizNode(node) { + return (/^[(\[][ x][)\]]/).test(node.text || node); +} + +function isTableQuestion(nodes) { + var block = questionBlock(nodes); + return ( + block.length === 1 && + block[0].type === 'table' && + _.all(block[0].cells[0].slice(1), isQuizNode) + ); +} + +function isListQuestion(nodes) { + var block = questionBlock(nodes); + // Counter of when we go in and out of lists + var inlist = 0; + // Number of lists we found + var lists = 0; + // Elements found outside a list + var outsiders = 0; + // Ensure that we have nothing except lists + _.each(block, function(node) { + if(node.type === 'list_start') { + inlist++; + } else if(node.type === 'list_end') { + inlist--; + lists++; + } else if(inlist === 0) { + // Found non list_start or list_end whilst outside a list + outsiders++; + } + }); + return lists > 0 && outsiders === 0; +} + +function isQuestion(nodes) { + return isListQuestion(nodes) || isTableQuestion(nodes); +} + +// Remove (optional) paragraph header node and blockquote +function questionBlock(nodes) { + return nodes.slice( + nodes[0].type === 'paragraph' ? 1 : 0, + _.findIndex(nodes, { type: 'blockquote_start' }) + ); +} + +function splitQuestions(nodes) { + // Represents nodes in current question + var buffer = []; + return _.reduce(nodes, function(accu, node) { + // Add node to buffer + buffer.push(node); + + // Flush buffer once we hit the end of a question + if(node.type === 'blockquote_end') { + accu.push(buffer); + // Clear buffer + buffer = []; + } + + return accu; + }, []); +} + +function isQuiz(nodes) { + // Extract potential questions + var questions = splitQuestions( + // Skip quiz title if there + nodes.slice( + (nodes[0] && nodes[0].type) === 'paragraph' ? 1 : 0 + ) + ); + + // Nothing that looks like questions + if(questions.length === 0) { + return false; + } + + // Ensure all questions are correctly structured + return _.all(questions, isQuestion); +} + +module.exports = isQuiz; diff --git a/lib/parse/langs.js b/lib/parse/langs.js new file mode 100644 index 0000000000..01b7c8c8c4 --- /dev/null +++ b/lib/parse/langs.js @@ -0,0 +1,25 @@ +var _ = require("lodash"); +var parseEntries = require("./summary").entries; + + +var parseLangs = function(content) { + var entries = parseEntries(content); + + return { + list: _.chain(entries) + .filter(function(entry) { + return Boolean(entry.path); + }) + .map(function(entry) { + return { + title: entry.title, + path: entry.path, + lang: entry.path.replace("/", "") + }; + }) + .value() + }; +}; + + +module.exports = parseLangs; \ No newline at end of file diff --git a/lib/parse/lex.js b/lib/parse/lex.js new file mode 100644 index 0000000000..3391acfde7 --- /dev/null +++ b/lib/parse/lex.js @@ -0,0 +1,79 @@ +var _ = require('lodash'); +var kramed = require('kramed'); + +var isExercise = require('./is_exercise'); +var isQuiz = require('./is_quiz'); + +// Split a page up into sections (lesson, exercises, ...) +function splitSections(nodes) { + var section = []; + + return _.reduce(nodes, function(sections, el) { + if(el.type === 'hr') { + sections.push(section); + section = []; + } else { + section.push(el); + } + + return sections; + }, []).concat([section]); // Add remaining nodes +} + +// What is the type of this section +function sectionType(nodes, idx) { + if(isExercise(nodes)) { + return 'exercise'; + } else if(isQuiz(nodes)) { + return 'quiz'; + } + + return 'normal'; +} + +// Generate a uniqueId to identify this section in our code +function sectionId(section, idx) { + return _.uniqueId('gitbook_'); +} + +function lexPage(src) { + // Lex file + var nodes = kramed.lexer(src); + + return _.chain(splitSections(nodes)) + .map(function(section, idx) { + // Detect section type + section.type = sectionType(section, idx); + return section; + }) + .map(function(section, idx) { + // Give each section an ID + section.id = sectionId(section, idx); + return section; + + }) + .filter(function(section) { + return !_.isEmpty(section); + }) + .reduce(function(sections, section) { + var last = _.last(sections); + + // Merge normal sections together + if(last && last.type === section.type && last.type === 'normal') { + last.push.apply(last, [{'type': 'hr'}].concat(section)); + } else { + // Add to list of sections + sections.push(section); + } + + return sections; + }, []) + .map(function(section) { + section.links = nodes.links; + return section; + }) + .value(); +} + +// Exports +module.exports = lexPage; diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js new file mode 100644 index 0000000000..ae4eb9d287 --- /dev/null +++ b/lib/parse/navigation.js @@ -0,0 +1,64 @@ +var _ = require('lodash'); + +// Cleans up an article/chapter object +// remove 'articles' attributes +function clean(obj) { + return obj && _.omit(obj, ['articles']); +} + +function flattenChapters(chapters) { + return _.reduce(chapters, function(accu, chapter) { + return accu.concat([clean(chapter)].concat(flattenChapters(chapter.articles))); + }, []); +} + +// Returns from a summary a map of +/* + { + "file/path.md": { + prev: ..., + next: ..., + }, + ... + } +*/ +function navigation(summary, files) { + // Support single files as well as list + files = _.isArray(files) ? files : (_.isString(files) ? [files] : null); + + // List of all navNodes + // Flatten chapters, then add in default README node if ndeeded etc ... + var navNodes = flattenChapters(summary.chapters); + var prevNodes = [null].concat(navNodes.slice(0, -1)); + var nextNodes = navNodes.slice(1).concat([null]); + + // Mapping of prev/next for a give path + var mapping = _.chain(_.zip(navNodes, prevNodes, nextNodes)) + .map(function(nodes) { + var current = nodes[0], prev = nodes[1], next = nodes[2]; + + // Skip if no path + if(!current.path) return null; + + return [current.path, { + title: current.title, + prev: prev, + next: next, + level: current.level, + }]; + }) + .filter() + .object() + .value(); + + // Filter for only files we want + if(files) { + return _.pick(mapping, files); + } + + return mapping; +} + + +// Exports +module.exports = navigation; diff --git a/lib/parse/page.js b/lib/parse/page.js new file mode 100644 index 0000000000..ca7441fd07 --- /dev/null +++ b/lib/parse/page.js @@ -0,0 +1,160 @@ +var _ = require('lodash'); +var kramed = require('kramed'); +var hljs = require('highlight.js'); + +var lex = require('./lex'); +var renderer = require('./renderer'); + +var include = require('./include'); +var lnormalize = require('../utils/lang').normalize; + + + +// Render a section using our custom renderer +function render(section, _options) { + // Copy section + var links = section.links || {}; + section = _.toArray(section); + section.links = links; + + // Build options using defaults and our custom renderer + var options = _.extend({}, kramed.defaults, { + renderer: renderer(null, _options), + + // Synchronous highlighting with highlight.js + highlight: function (code, lang) { + if(!lang) return code; + + // Normalize lang + lang = lnormalize(lang); + + try { + return hljs.highlight(lang, code).value; + } catch(e) { } + + return code; + } + }); + + return kramed.parser(section, options); +} + +function quizQuestion(node) { + if (node.text) { + node.text = node.text.replace(/^([\[(])x([\])])/, "$1 $2"); + } else { + return node.replace(/^([\[(])x([\])])/, "$1 $2"); + } +} + +function parsePage(src, options) { + options = options || {}; + + // Lex if not already lexed + var parsed = { + lexed: (_.isArray(src) ? page.content : lex(include(src, options.includer || function() { return undefined; }))) + }; + parsed.sections = parsed.lexed.map(function(section) { + // Transform given type + if(section.type === 'exercise') { + var nonCodeNodes = _.reject(section, { + 'type': 'code' + }); + + var codeNodes = _.filter(section, { + 'type': 'code' + }); + + // Languages in code blocks + var langs = _.pluck(codeNodes, 'lang').map(lnormalize); + + // Check that they are all the same + var validLangs = _.all(_.map(langs, function(lang) { + return lang && lang === langs[0]; + })); + + // Main language + var lang = validLangs ? langs[0] : null; + + return { + id: section.id, + type: section.type, + content: render(nonCodeNodes, options), + lang: lang, + code: { + base: codeNodes[0].text, + solution: codeNodes[1].text, + validation: codeNodes[2].text, + // Context is optional + context: codeNodes[3] ? codeNodes[3].text : null, + } + }; + } else if (section.type === 'quiz') { + var quiz = [], question, foundFeedback = false; + var nonQuizNodes = section[0].type === 'paragraph' && section[1].type !== 'list_start' ? [section[0]] : []; + var quizNodes = section.slice(0); + quizNodes.splice(0, nonQuizNodes.length); + + for (var i = 0; i < quizNodes.length; i++) { + var node = quizNodes[i]; + + if (question && (((node.type === 'list_end' || node.type === 'blockquote_end') && i === quizNodes.length - 1) + || node.type === 'table' || (node.type === 'paragraph' && !foundFeedback))) { + quiz.push({ + base: render(question.questionNodes, options), + solution: render(question.solutionNodes, options), + feedback: render(question.feedbackNodes, options) + }); + } + + if (node.type === 'table' || (node.type === 'paragraph' && !foundFeedback)) { + question = { questionNodes: [], solutionNodes: [], feedbackNodes: [] }; + } + + if (node.type === 'blockquote_start') { + foundFeedback = true; + } else if (node.type === 'blockquote_end') { + foundFeedback = false; + } + + if (node.type === 'table') { + question.solutionNodes.push(_.cloneDeep(node)); + node.cells = node.cells.map(function(row) { + return row.map(quizQuestion); + }); + question.questionNodes.push(node); + } else if (!/blockquote/.test(node.type)) { + if (foundFeedback) { + question.feedbackNodes.push(node); + } else if (node.type === 'paragraph' || node.type === 'text'){ + question.solutionNodes.push(_.cloneDeep(node)); + quizQuestion(node); + question.questionNodes.push(node); + } else { + question.solutionNodes.push(node); + question.questionNodes.push(node); + } + } + } + + return { + id: section.id, + type: section.type, + content: render(nonQuizNodes, options), + quiz: quiz + }; + } + + // Render normal pages + return { + id: section.id, + type: section.type, + content: render(section, options) + }; + }); + + return parsed; +} + +// Exports +module.exports = parsePage; diff --git a/lib/parse/progress.js b/lib/parse/progress.js new file mode 100644 index 0000000000..10a06d2b4e --- /dev/null +++ b/lib/parse/progress.js @@ -0,0 +1,47 @@ +var _ = require("lodash"); + +// Returns from a navigation and a current file, a snapshot of current detailed state +var calculProgress = function(navigation, current) { + var n = _.size(navigation); + var percent = 0, prevPercent = 0, currentChapter = null; + var done = true; + + var chapters = _.chain(navigation) + .map(function(nav, path) { + nav.path = path; + return nav; + }) + .map(function(nav, i) { + // Calcul percent + nav.percent = (i * 100) / Math.max((n - 1), 1); + + // Is it done + nav.done = done; + if (nav.path == current) { + currentChapter = nav; + percent = nav.percent; + done = false; + } else if (done) { + prevPercent = nav.percent; + } + + return nav; + }) + .value(); + + return { + // Previous percent + prevPercent: prevPercent, + + // Current percent + percent: percent, + + // List of chapter with progress + chapters: chapters, + + // Current chapter + current: currentChapter + }; +} + +module.exports = calculProgress; \ No newline at end of file diff --git a/lib/parse/readme.js b/lib/parse/readme.js new file mode 100644 index 0000000000..9d8f5527c3 --- /dev/null +++ b/lib/parse/readme.js @@ -0,0 +1,45 @@ +var _ = require('lodash'); +var kramed = require('kramed'); +var textRenderer = require('kramed-text-renderer'); + +function extractFirstNode(nodes, nType) { + return _.chain(nodes) + .filter(function(node) { + return node.type == nType; + }) + .pluck("text") + .first() + .value(); +} + + +function parseReadme(src) { + var nodes, title, description; + var renderer = textRenderer(); + + // Parse content + nodes = kramed.lexer(src); + + title = extractFirstNode(nodes, "heading") || ''; + description = extractFirstNode(nodes, "paragraph") || ''; + + var convert = _.compose( + function(text) { + return _.unescape(text.replace(/(\r\n|\n|\r)/gm, "")); + }, + function(text) { + return kramed.parse(text, _.extend({}, kramed.defaults, { + renderer: renderer + })); + } + ); + + return { + title: convert(title), + description: convert(description) + }; +} + + +// Exports +module.exports = parseReadme; diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js new file mode 100644 index 0000000000..5b6a79d8d9 --- /dev/null +++ b/lib/parse/renderer.js @@ -0,0 +1,141 @@ +var url = require('url'); +var _ = require('lodash'); +var inherits = require('util').inherits; +var links = require('../utils').links; +var kramed = require('kramed'); + +var rendererId = 0; + +function GitBookRenderer(options, extra_options) { + if(!(this instanceof GitBookRenderer)) { + return new GitBookRenderer(options, extra_options); + } + GitBookRenderer.super_.call(this, options); + + this._extra_options = extra_options; + this.quizRowId = 0; + this.id = rendererId++; + this.quizIndex = 0; +} +inherits(GitBookRenderer, kramed.Renderer); + +GitBookRenderer.prototype._unsanitized = function(href) { + var prot = ''; + try { + prot = decodeURIComponent(unescape(href)) + .replace(/[^\w:]/g, '') + .toLowerCase(); + + } catch (e) { + return true; + } + + if(prot.indexOf('javascript:') === 0) { + return true; + } + + return false; +}; + +GitBookRenderer.prototype.link = function(href, title, text) { + // Our "fixed" href + var _href = href; + + // Don't build if it looks malicious + if (this.options.sanitize && this._unsanitized(href)) { + return text; + } + + // Parsed version of the url + var parsed = url.parse(href); + var o = this._extra_options; + var extname = parsed.path? _.last(parsed.path.split(".")) : ""; + + // Relative link, rewrite it to point to github repo + if(links.isRelative(_href) && extname == "md") { + _href = links.toAbsolute(_href, o.dir || "./", o.outdir || "./"); + _href = _href.replace(".md", ".html"); + } + + // Generate HTML for link + var out = '' + text + ''; + return out; +}; + +GitBookRenderer.prototype.image = function(href, title, text) { + // Our "fixed" href + var _href = href; + + // Parsed version of the url + var parsed = url.parse(href); + + // Options + var o = this._extra_options; + + // Relative image, rewrite it depending output + if(links.isRelative(href) && o && o.dir && o.outdir) { + // o.dir: directory parent of the file currently in rendering process + // o.outdir: directory parent from the html output + + _href = links.toAbsolute(_href, o.dir, o.outdir); + } + + return GitBookRenderer.super_.prototype.image.call(this, _href, title, text); +}; + +GitBookRenderer.prototype.tablerow = function(content) { + this.quizRowId += 1; + return GitBookRenderer.super_.prototype.tablerow(content); +}; + +var fieldRegex = /^([(\[])([ x])[\])]/; +GitBookRenderer.prototype._createCheckboxAndRadios = function(text) { + var match = fieldRegex.exec(text); + if (!match) { + return text; + } + //fix radio input uncheck failed + var quizFieldName='quiz-row-' + this.id + '-' + this.quizRowId ; + var quizIdentifier = quizFieldName + '-' + this.quizIndex++; + var field = "" : "'/>"; + var splittedText = text.split(fieldRegex); + var length = splittedText.length; + var label = ''; + return text.replace(fieldRegex, field).replace(splittedText[length - 1], label); +}; + +GitBookRenderer.prototype.tablecell = function(content, flags) { + return GitBookRenderer.super_.prototype.tablecell(this._createCheckboxAndRadios(content), flags); +}; + +GitBookRenderer.prototype.listitem = function(text) { + return GitBookRenderer.super_.prototype.listitem(this._createCheckboxAndRadios(text)); +}; + +GitBookRenderer.prototype.code = function(code, lang, escaped) { + return GitBookRenderer.super_.prototype.code.call( + this, + code, + lang, + escaped + ); +}; + +GitBookRenderer.prototype.heading = function(text, level, raw) { + var id = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w -]+/g, '').replace(/ /g, '-'); + return ' ' + text + ' \n'; +}; + +// Exports +module.exports = GitBookRenderer; diff --git a/lib/parse/summary.js b/lib/parse/summary.js new file mode 100644 index 0000000000..21eadd1ef5 --- /dev/null +++ b/lib/parse/summary.js @@ -0,0 +1,148 @@ +var _ = require('lodash'); +var kramed = require('kramed'); + + +// Utility function for splitting a list into groups +function splitBy(list, starter, ender) { + var starts = 0; + var ends = 0; + var group = []; + + // Groups + return _.reduce(list, function(groups, value) { + // Ignore start and end delimiters in resulted groups + if(starter(value)) { + starts++; + } else if(ender(value)) { + ends++; + } + + // Add current value to group + group.push(value); + + // We've got a matching + if(starts === ends && starts !== 0) { + // Add group to end groups + // (remove starter and ender token) + groups.push(group.slice(1, -1)); + + // Reset group + group = []; + } + + return groups; + }, []); +} + +function listSplit(nodes, start_type, end_type) { + return splitBy(nodes, function(el) { + return el.type === start_type; + }, function(el) { + return el.type === end_type; + }); +} + +// Get the biggest list +// out of a list of kramed nodes +function filterList(nodes) { + return _.chain(nodes) + .toArray() + .rest(function(el) { + // Get everything after list_start + return el.type !== 'list_start'; + }) + .reverse() + .rest(function(el) { + // Get everything after list_end (remember we're reversed) + return el.type !== 'list_end'; + }) + .reverse() + .value().slice(1, -1); +} + +// Parses an Article or Chapter title +// supports extracting links +function parseTitle(src, nums) { + // Check if it's a link + var matches = kramed.InlineLexer.rules.link.exec(src); + + var level = nums.join('.'); + + // Not a link, return plain text + if(!matches) { + return { + title: src, + level: level, + path: null, + }; + } + + return { + title: matches[1], + level: level, + + // Normalize path + // 1. Convert Window's "\" to "/" + // 2. Remove leading "/" if exists + path: matches[2].replace(/\\/g, '/').replace(/^\/+/, ''), + }; +} + +function parseChapter(nodes, nums) { + // Convert single number to an array + nums = _.isArray(nums) ? nums : [nums]; + + return _.extend(parseTitle(_.first(nodes).text, nums), { + articles: _.map(listSplit(filterList(nodes), 'list_item_start', 'list_item_end'), function(nodes, i) { + return parseChapter(nodes, nums.concat(i + 1)); + }) + }); +} + +function defaultChapterList(chapterList) { + var first = _.first(chapterList); + + // Check if introduction node was specified in SUMMARY.md + if (first) { + var chapter = parseChapter(first, [0]); + + // Already have README node, we're good to go + if(chapter.path === 'README.md') { + return chapterList; + } + } + + // It wasn't specified, so add in default + return [ + [ { type: 'text', text: '[Introduction](README.md)' } ] + ].concat(chapterList); +} + +function listGroups(src) { + var nodes = kramed.lexer(src); + + // Get out groups of lists + return listSplit( + filterList(nodes), + 'list_item_start', 'list_item_end' + ); +} + +function parseSummary(src) { + // Split out chapter sections + var chapters = defaultChapterList(listGroups(src)) + .map(parseChapter); + + return { + chapters: chapters + }; +} + +function parseEntries (src) { + return listGroups(src).map(parseChapter); +} + + +// Exports +module.exports = parseSummary; +module.exports.entries = parseEntries; diff --git a/lib/utils/index.js b/lib/utils/index.js new file mode 100644 index 0000000000..dbc40876e1 --- /dev/null +++ b/lib/utils/index.js @@ -0,0 +1,4 @@ +module.exports = { + lang: require('./lang'), + links: require('./links') +}; diff --git a/lib/utils/lang.js b/lib/utils/lang.js new file mode 100644 index 0000000000..9da737bbae --- /dev/null +++ b/lib/utils/lang.js @@ -0,0 +1,19 @@ +var MAP = { + 'py': 'python', + 'js': 'javascript', + 'rb': 'ruby', + 'csharp': 'cs', +}; + +function normalize(lang) { + if(!lang) { return null; } + + var lower = lang.toLowerCase(); + return MAP[lower] || lower; +} + +// Exports +module.exports = { + normalize: normalize, + MAP: MAP +}; diff --git a/lib/utils/links.js b/lib/utils/links.js new file mode 100644 index 0000000000..b4d2fb7228 --- /dev/null +++ b/lib/utils/links.js @@ -0,0 +1,60 @@ +var url = require('url'); +var path = require('path'); + +// Is the link an external link +var isExternal = function(href) { + try { + return Boolean(url.parse(href).protocol); + } catch(err) { } + + return false; +}; + +// Return true if the link is relative +var isRelative = function(href) { + try { + var parsed = url.parse(href); + + return !parsed.protocol && parsed.path && parsed.path[0] != '/'; + } catch(err) {} + + return true; +}; + +// Relative to absolute path +// dir: directory parent of the file currently in rendering process +// outdir: directory parent from the html output + +var toAbsolute = function(_href, dir, outdir) { + // Absolute file in source + _href = path.join(dir, _href); + + // make it relative to output + _href = path.relative(outdir, _href); + + if (process.platform === 'win32') { + _href = _href.replace(/\\/g, '/'); + } + + return _href; +}; + +// Join links + +var join = function() { + var _href = path.join.apply(path, arguments); + + if (process.platform === 'win32') { + _href = _href.replace(/\\/g, '/'); + } + + return _href; +}; + + +module.exports = { + isRelative: isRelative, + isExternal: isExternal, + toAbsolute: toAbsolute, + join: join +}; diff --git a/lib/utils/string.js b/lib/utils/string.js new file mode 100644 index 0000000000..54c4c66d95 --- /dev/null +++ b/lib/utils/string.js @@ -0,0 +1,26 @@ +var _ = require("lodash"); + +function escapeShellArg(arg) { + var ret = ''; + + ret = arg.replace(/"/g, '\\"'); + + return "\"" + ret + "\""; +} + +function optionsToShellArgs(options) { + return _.chain(options) + .map(function(value, key) { + if (value == null || value === false) return null; + if (value === true) return key; + return key+"="+escapeShellArg(value); + }) + .compact() + .value() + .join(" "); +} + +module.exports = { + escapeShellArg: escapeShellArg, + optionsToShellArgs: optionsToShellArgs +}; diff --git a/package.json b/package.json index bf3f46eedd..d73d3f5fdc 100644 --- a/package.json +++ b/package.json @@ -1,64 +1,72 @@ { "name": "gitbook", - "version": "0.1.0", - "engines": { - "node": "^22.3.0" + "version": "1.3.1", + "homepage": "http://www.gitbook.io/", + "description": "Library and cmd utility to generate GitBooks", + "main": "lib/index.js", + "dependencies": { + "q": "1.0.1", + "lodash": "2.4.1", + "kramed": "0.4.3", + "kramed-text-renderer": "0.2.1", + "lunr": "0.5.2", + "swig": "1.3.2", + "send": "0.2.0", + "fstream-ignore": "0.0.7", + "commander": "2.2.0", + "graceful-fs": "3.0.2", + "fs-extra": "0.10.0", + "highlight.js": "8.3.0", + "tmp": "0.0.23", + "semver": "2.2.1", + "gaze": "~0.5.1", + "resolve": "0.6.3", + "tiny-lr-fork": "0.0.5", + "gitbook-plugin": "0.0.2", + "gitbook-plugin-mathjax": "0.0.6", + "gitbook-plugin-livereload": "0.0.1", + "gitbook-plugin-exercises": "1.0.0", + "gitbook-plugin-quizzes": "1.0.0" }, "devDependencies": { - "@biomejs/biome": "^1.9.4", - "@changesets/cli": "^2.29.7", - "turbo": "^2.5.8", - "vercel": "^39.4.2" + "mocha": "1.18.2", + "grunt": "~0.4.2", + "grunt-cli": "0.1.11", + "grunt-contrib-copy": "0.5.0", + "grunt-contrib-less": "~0.5.0", + "grunt-contrib-requirejs": "0.4.1", + "grunt-bower-install-simple": "0.9.2", + "grunt-browserify": "3.1.0", + "grunt-contrib-uglify": "0.6.0" }, - "packageManager": "bun@1.3.0", - "overrides": { - "@codemirror/state": "6.4.1", - "@types/react": "catalog:", - "@types/react-dom": "catalog:", - "react": "catalog:", - "react-dom": "catalog:", - "esbuild": "0.24.2" - }, - "private": true, "scripts": { - "dev": "turbo run dev --concurrency 20", - "build": "turbo run build", - "clean-deps": "rm -rf node_modules && rm -rf packages/*/node_modules", - "typecheck": "turbo run typecheck", - "format": "biome check --write ./", - "format:check": "biome check --diagnostic-level=error ./", - "unit": "turbo run unit", - "e2e": "turbo run e2e", - "e2e-customers": "turbo run e2e-customers", - "changeset": "changeset", - "changeset-version": "changeset version && bun run format && bun update", - "release": "turbo run release && bun run publish-all-packages", - "publish-all-packages": "for dir in packages/*; do (cd \"$dir\" && bun publish || true); done && changeset tag", - "download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local", - "clean": "turbo run clean" + "test": "export TESTING=true; mocha --reporter list" }, - "workspaces": { - "packages": ["packages/*"], - "catalog": { - "@tsconfig/strictest": "^2.0.6", - "@tsconfig/node20": "^20.1.6", - "@gitbook/api": "0.150.0", - "@scalar/api-client-react": "^1.3.46", - "@types/react": "^19.0.0", - "@types/react-dom": "^19.0.0", - "assert-never": "^1.4.0", - "bidc": "^0.0.2", - "bun-types": "^1.1.20", - "classnames": "^2.5.1", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "tsdown": "^0.15.6", - "typescript": "^5.5.3", - "usehooks-ts": "^3.1.1" - } + "bin": { + "gitbook": "./bin/gitbook.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/GitbookIO/gitbook.git" }, - "patchedDependencies": { - "decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch", - "@vercel/next@4.4.2": "patches/@vercel%2Fnext@4.4.2.patch" - } + "keywords": [ + "git", + "book", + "gitbook" + ], + "author": "FriendCode", + "license": "Apache 2", + "bugs": { + "url": "https://github.com/GitbookIO/gitbook/issues" + }, + "contributors": [ + { + "name": "Aaron O'Mullan", + "email": "aaron.omullan@gmail.com" + }, + { + "name": "Samy Pessé", + "email": "samypesse@gmail.com" + } + ] } diff --git a/packages/browser-types/.gitignore b/packages/browser-types/.gitignore deleted file mode 100644 index 849ddff3b7..0000000000 --- a/packages/browser-types/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/packages/browser-types/CHANGELOG.md b/packages/browser-types/CHANGELOG.md deleted file mode 100644 index 88ea1950a8..0000000000 --- a/packages/browser-types/CHANGELOG.md +++ /dev/null @@ -1,29 +0,0 @@ -# @gitbook/browser-types - -## 0.1.2 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles -- Updated dependencies [6142d6b] - - @gitbook/icons@0.3.3 - -## 0.1.1 - -### Patch Changes - -- 295f03d: Republish packages -- Updated dependencies [295f03d] - - @gitbook/icons@0.3.2 - -## 0.1.0 - -### Minor Changes - -- cbc71a5: First version of the public package for typing script integrations. - -### Patch Changes - -- 854c448: Custom assistants followup -- Updated dependencies [25e2b40] - - @gitbook/icons@0.3.0 diff --git a/packages/browser-types/README.md b/packages/browser-types/README.md deleted file mode 100644 index b2846c9d0e..0000000000 --- a/packages/browser-types/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gitbook/browser-types` - -Typescript types for the global variables available in a GitBook website. These types can be used by integrations embedding scripts. diff --git a/packages/browser-types/package.json b/packages/browser-types/package.json deleted file mode 100644 index 89f8b7a4e2..0000000000 --- a/packages/browser-types/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@gitbook/browser-types", - "description": "Typescript types for the global variables available in a GitBook website. These types can be used by integrations embedding scripts.", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "version": "0.1.2", - "dependencies": { - "@gitbook/api": "catalog:", - "@gitbook/icons": "workspace:" - }, - "devDependencies": { - "bun-types": "catalog:", - "tsdown": "catalog:", - "typescript": "catalog:" - }, - "scripts": { - "build": "tsdown", - "typecheck": "tsc --noEmit", - "dev": "bun run build -- --watch ./src" - }, - "files": ["dist", "README.md", "CHANGELOG.md"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/browser-types/src/index.ts b/packages/browser-types/src/index.ts deleted file mode 100644 index cb625250ea..0000000000 --- a/packages/browser-types/src/index.ts +++ /dev/null @@ -1,84 +0,0 @@ -import type { AIToolCallResult, AIToolDefinition } from '@gitbook/api'; -import type { IconName } from '@gitbook/icons'; - -export type GitBookIntegrationEvent = 'load' | 'unload'; - -export type GitBookIntegrationEventCallback = (...args: any[]) => void; - -export type GitBookIntegrationTool = AIToolDefinition & { - /** - * Confirmation action to be displayed to the user before executing the tool. - */ - confirmation?: { - icon?: IconName; - label: string; - }; - - /** - * Callback when the tool is executed. - * The input is provided by the AI assistant following the input schema of the tool. - */ - execute: (input: object) => Promise >; -}; - -export type GitBookAssistant = { - /** - * Name of the assistant displayed in the UI. - */ - label: string; - - /** - * Icon of the assistant displayed in the UI. - * Any FontAwesome icon name is supported. - * @example 'sparkle' - */ - icon: string; - - /** - * Callback when the assistant is opened. - */ - open: (query?: string) => void; - - /** - * Whether to display the triggers for this assistant in the UI. - * @default true - */ - ui?: boolean; -}; - -export type GitBookGlobal = { - /** - * Register an event listener. - */ - addEventListener: ( - type: GitBookIntegrationEvent, - func: GitBookIntegrationEventCallback - ) => void; - - /** - * Remove an event listener. - */ - removeEventListener: ( - type: GitBookIntegrationEvent, - func: GitBookIntegrationEventCallback - ) => void; - - /** - * Register a custom tool to be exposed to the AI assistant. - */ - registerTool: (tool: GitBookIntegrationTool) => void; - - /** - * Register a custom assistant to be available on the site. - */ - registerAssistant: (assistant: GitBookAssistant) => () => void; -}; - -declare global { - interface Window { - /** - * Global `window.GitBook` object accessible by integrations. - */ - GitBook?: GitBookGlobal; - } -} diff --git a/packages/browser-types/tsconfig.json b/packages/browser-types/tsconfig.json deleted file mode 100644 index c0b0f93266..0000000000 --- a/packages/browser-types/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noUncheckedIndexedAccess": true, - "noEmit": false, - "declaration": true, - "outDir": "dist", - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react-jsx", - "incremental": true, - "types": [ - "bun-types" // add Bun global - ] - }, - "include": ["src/**/*.ts", "src/**/*.tsx"], - "exclude": ["node_modules"] -} diff --git a/packages/cache-tags/.gitignore b/packages/cache-tags/.gitignore deleted file mode 100644 index 849ddff3b7..0000000000 --- a/packages/cache-tags/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/packages/cache-tags/CHANGELOG.md b/packages/cache-tags/CHANGELOG.md deleted file mode 100644 index 5c41b9b0fb..0000000000 --- a/packages/cache-tags/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# @gitbook/cache-tags - -## 0.3.3 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles - -## 0.3.2 - -### Patch Changes - -- 295f03d: Republish packages - -## 0.3.1 - -### Patch Changes - -- 77397ca: Fix version of @gitbook/api referenced in package.json - -## 0.3.0 - -### Minor Changes - -- 116575c: Improve typing of getComputedContentSourceCacheTags to match latest API specification - -## 0.2.0 - -### Minor Changes - -- f32bf1f: Export function `getCacheTagForURL` to easily get the cache tag for a URL. - -## 0.1.0 - -### Minor Changes - -- 05ffd0e: Initial version of the package diff --git a/packages/cache-tags/README.md b/packages/cache-tags/README.md deleted file mode 100644 index 14fc5c9431..0000000000 --- a/packages/cache-tags/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gitbook/cache-tags` - -Utility to generate cache tags for GitBook Open. \ No newline at end of file diff --git a/packages/cache-tags/package.json b/packages/cache-tags/package.json deleted file mode 100644 index a246b261fc..0000000000 --- a/packages/cache-tags/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@gitbook/cache-tags", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "version": "0.3.3", - "dependencies": { - "@gitbook/api": "catalog:", - "assert-never": "catalog:" - }, - "devDependencies": { - "bun-types": "catalog:", - "tsdown": "catalog:", - "typescript": "catalog:" - }, - "scripts": { - "build": "tsdown", - "typecheck": "tsc --noEmit", - "dev": "bun run build -- --watch ./src" - }, - "files": ["dist", "README.md", "CHANGELOG.md"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/cache-tags/src/index.ts b/packages/cache-tags/src/index.ts deleted file mode 100644 index 072d7f00ad..0000000000 --- a/packages/cache-tags/src/index.ts +++ /dev/null @@ -1,201 +0,0 @@ -import type { ComputedContentSource } from '@gitbook/api'; -import assertNever from 'assert-never'; - -/** - * Get a stringified cache tag for a given object. - */ -export function getCacheTag( - spec: /** - * All data related to a user - * @deprecated - in v2, no tag as this is an immutable data - */ - | { - tag: 'user'; - user: string; - } - /** - * All data related to a space - */ - | { - tag: 'space'; - space: string; - } - /** - * All data related to an integration. - */ - | { - tag: 'integration'; - integration: string; - } - /** - * All data related to a change request - */ - | { - tag: 'change-request'; - space: string; - changeRequest: string; - } - /** - * Immutable data related to a revision - * @deprecated - in v2, no tag as this is an immutable data - */ - | { - tag: 'revision'; - space: string; - revision: string; - } - /** - * Immutable data related to a document - * @deprecated - in v2, no tag as this is an immutable data - */ - | { - tag: 'document'; - space: string; - document: string; - } - /** - * Immutable data related to a computed document - * @deprecated - in v2, no tag as this is an immutable data - */ - | { - tag: 'computed-document'; - space: string; - sourceType: string; - } - /** - * All data related to the URL of a content - */ - | { - tag: 'url'; - hostname: string; - } - /** - * All data related to a site - */ - | { - tag: 'site'; - site: string; - } - /** - * All data related to an OpenAPI spec - */ - | { - tag: 'openapi'; - organization: string; - openAPISpec: string; - } - /** - * All data related to a translation - */ - | { - tag: 'translation'; - organization: string; - translation: string; - } -): string { - switch (spec.tag) { - case 'user': - return `user:${spec.user}`; - case 'url': - return `url:${spec.hostname}`; - case 'space': - return `space:${spec.space}`; - case 'change-request': - return `space:${spec.space}:change-request:${spec.changeRequest}`; - case 'revision': - return `space:${spec.space}:revision:${spec.revision}`; - case 'document': - return `space:${spec.space}:document:${spec.document}`; - case 'computed-document': - return `space:${spec.space}:computed-document:${spec.sourceType}`; - case 'site': - return `site:${spec.site}`; - case 'integration': - return `integration:${spec.integration}`; - case 'openapi': - return `organization:${spec.organization}:openapi:${spec.openAPISpec}`; - case 'translation': - return `organization:${spec.organization}:translation:${spec.translation}`; - default: - assertNever(spec); - } -} - -/** - * Get the tags for a computed content source. - */ -export function getComputedContentSourceCacheTags( - inContext: { - spaceId: string; - organizationId: string; - }, - source: ComputedContentSource -) { - const tags: string[] = []; - - if (!('dependencies' in source)) { - return tags; - } - - // We add the dependencies as tags, to ensure that the computed content is invalidated - // when the dependencies are updated. - const dependencies = Object.values(source.dependencies ?? {}); - if (dependencies.length > 0) { - dependencies.forEach((dependency) => { - switch (dependency.ref.kind) { - case 'space': - tags.push( - getCacheTag({ - tag: 'space', - space: dependency.ref.space, - }) - ); - break; - case 'openapi': - tags.push( - getCacheTag({ - tag: 'openapi', - organization: inContext.organizationId, - openAPISpec: dependency.ref.spec, - }) - ); - break; - case 'translation': - tags.push( - getCacheTag({ - tag: 'translation', - organization: inContext.organizationId, - translation: dependency.ref.translation, - }) - ); - break; - default: - // Do not throw for unknown dependency types - // as it might mean we are lagging behind the API version - break; - } - }); - } else { - // Push a dummy tag, as the v1 is only using the first tag - tags.push( - getCacheTag({ - tag: 'computed-document', - space: inContext.spaceId, - sourceType: source.type, - }) - ); - } - - // We invalidate the computed content when a new version of the integration is deployed. - if (source.type.startsWith('integration:')) { - const integration = source.type.split(':')[1]!; - tags.push( - getCacheTag({ - tag: 'integration', - integration, - }) - ); - } - - return tags; -} diff --git a/packages/cache-tags/tsconfig.json b/packages/cache-tags/tsconfig.json deleted file mode 100644 index c0b0f93266..0000000000 --- a/packages/cache-tags/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noUncheckedIndexedAccess": true, - "noEmit": false, - "declaration": true, - "outDir": "dist", - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react-jsx", - "incremental": true, - "types": [ - "bun-types" // add Bun global - ] - }, - "include": ["src/**/*.ts", "src/**/*.tsx"], - "exclude": ["node_modules"] -} diff --git a/packages/colors/.gitignore b/packages/colors/.gitignore deleted file mode 100644 index 849ddff3b7..0000000000 --- a/packages/colors/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/packages/colors/CHANGELOG.md b/packages/colors/CHANGELOG.md deleted file mode 100644 index de55f82138..0000000000 --- a/packages/colors/CHANGELOG.md +++ /dev/null @@ -1,55 +0,0 @@ -# @gitbook/colors - -## 0.4.2 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles - -## 0.4.1 - -### Patch Changes - -- 295f03d: Republish packages - -## 0.4.0 - -### Minor Changes - -- 17dd382: Add `original` background color step - -### Patch Changes - -- 193d591: Fix return type for `colorContrast` - -## 0.3.3 - -### Patch Changes - -- c3f6b8c: Update chroma ratio per step -- 5e975ab: Fix code highlighting for HTTP -- f7a3470: Change lightness check for color step 9 to allow input colors with a higher-than-needed contrast - -## 0.3.2 - -### Patch Changes - -- cdffd7c: Desaturate text colors by decreasing chroma for the last steps of the color scale - -## 0.3.1 - -### Patch Changes - -- fb90eb0: Reduce chroma of first color scale step - -## 0.3.0 - -### Minor Changes - -- 4f0a772: Override tint lightness if supplied color is out of bounds - -## 0.2.0 - -### Minor Changes - -- 445baaa: Initial release diff --git a/packages/colors/README.md b/packages/colors/README.md deleted file mode 100644 index cadefb7bbf..0000000000 --- a/packages/colors/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gitbook/colors` - -A set of default colors and transformation functions used throughout the GitBook Open and app. diff --git a/packages/colors/package.json b/packages/colors/package.json deleted file mode 100644 index af4b32d87a..0000000000 --- a/packages/colors/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@gitbook/colors", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "version": "0.4.2", - "devDependencies": { - "bun-types": "catalog:", - "tsdown": "catalog:", - "typescript": "catalog:" - }, - "scripts": { - "build": "tsdown", - "typecheck": "tsc --noEmit", - "dev": "bun run build -- --watch ./src" - }, - "files": ["dist", "README.md", "CHANGELOG.md"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/colors/src/colors.ts b/packages/colors/src/colors.ts deleted file mode 100644 index 7562febf63..0000000000 --- a/packages/colors/src/colors.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Default primary color throughout the GitBook ecosystem. - */ -export const DEFAULT_PRIMARY_COLOR = '#346DDB'; - -/** - * The darkest color that exists in GitBook, used as the relative minimum of every generated color scale. - */ -export const DARK_BASE = '#1D1D1D'; - -/** - * The lightest color that exists in GitBook, used as the relative maximum of every generated color scale. - */ -export const LIGHT_BASE = '#FFFFFF'; - -/** - * Used as the basis of all UI elements that are not colored by the primary color. Neutral gray by default, overridden by site customization. - */ -export const DEFAULT_TINT_COLOR = '#787878'; - -/** - * Used for informational messages and neutral alerts. - */ -export const DEFAULT_HINT_INFO_COLOR = '#787878'; - -/** - * Used for showing important information or non-critical warnings. - */ -export const DEFAULT_HINT_WARNING_COLOR = '#FE9A00'; - -/** - * Used for destructive actions or raising attention to critical information. - */ -export const DEFAULT_HINT_DANGER_COLOR = '#FB2C36'; - -/** - * Used for showing positive actions or achievements. - */ -export const DEFAULT_HINT_SUCCESS_COLOR = '#00C950'; diff --git a/packages/colors/src/index.ts b/packages/colors/src/index.ts deleted file mode 100644 index 3ae4e1ad64..0000000000 --- a/packages/colors/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './colors'; -export * from './transformations'; diff --git a/packages/colors/src/transformations.ts b/packages/colors/src/transformations.ts deleted file mode 100644 index d7950792cc..0000000000 --- a/packages/colors/src/transformations.ts +++ /dev/null @@ -1,445 +0,0 @@ -import { DARK_BASE, DEFAULT_TINT_COLOR, LIGHT_BASE } from './colors'; - -type ColorShades = { - [key: string]: string; -}; - -type RGBColor = [number, number, number]; -type OKLABColor = { L: number; A: number; B: number }; -type OKLCHColor = { L: number; C: number; H: number }; - -const D65 = [95.047, 100.0, 108.883] as const; // Reference white (D65) - -export enum ColorCategory { - backgrounds = 'backgrounds', - components = 'components', - borders = 'borders', - accents = 'accents', - text = 'text', -} - -type ColorSubScale = { - [key: string]: number | string; -}; - -/** - * Main color scale object. - * - * Each `ColorCategory` can be in/excluded in Tailwind's utility classes generation. - * Each subitem maps a semantic name within that category to a step in the scale. - */ -export const scale: Record = { - [ColorCategory.backgrounds]: { - /** Base background */ - base: 1, - /** Accent background */ - subtle: 2, - }, - [ColorCategory.components]: { - /** Component background */ - DEFAULT: 3, - /** Component hover background */ - hover: 4, - /** Component active background */ - active: 5, - }, - [ColorCategory.borders]: { - /** Subtle borders, separators */ - subtle: 6, - /** Element border, focus rings */ - DEFAULT: 7, - /** Element hover border */ - hover: 8, - }, - [ColorCategory.accents]: { - /** Solid backgrounds */ - solid: 9, - /** Hovered solid backgrounds */ - 'solid-hover': 10, - /** Original color */ - original: 'original', - }, - [ColorCategory.text]: { - /** Very low-contrast text - * Caution: this contrast does not meet accessiblity guidelines. - * Always check if you need to include a mitigating contrast-more style for users who need it. */ - subtle: 9, - /** Low-contrast text */ - DEFAULT: 11, - /** High-contrast text */ - strong: 12, - }, -}; - -/** - * The mix of foreground and background for every step in a colour scale. - * 0: 100% of the background color's luminosity, white in light mode - * 1: 100% of the foreground color's luminosity, black in light mode - */ -export const colorMixMapping = { - // bgs |components |borders |solid |text - light: [0, 0.02, 0.03, 0.05, 0.07, 0.1, 0.15, 0.2, 0.5, 0.55, 0.6, 1], - dark: [0, 0.03, 0.08, 0.1, 0.13, 0.15, 0.2, 0.25, 0.5, 0.55, 0.75, 1], -}; - -/** - * Convert a hex color to an RGB color. - */ -export function hexToRgb(hex: string): string { - const [r, g, b] = hexToRgbArray(hex); - // Return the RGB values separated by spaces - return `${r} ${g} ${b}`; -} - -/** - * Convert a hex color to a RGBA color. - */ -export function hexToRgba(hex: string, alpha: number): string { - const [r, g, b] = hexToRgbArray(hex); - // Return the RGBA values separated by spaces - return `rgba(${r}, ${g}, ${b}, ${alpha})`; -} - -/** - * Generate Tailwind-compatible shades from a single color - * @param {string} hex The hex code to generate shades from - * @param {boolean} halfShades Generate additional shades, e.g. at 150 - * @returns {{[key: number]: string}} - */ -export function shadesOfColor(hex: string, halfShades = false) { - const baseColor = hex; - - const shades = [ - 50, - 100, - 200, - 300, - 400, - 500, - 600, - 700, - 800, - 900, - ...(halfShades ? [150, 250, 350, 450, 550, 650, 750, 850] : []), - ].sort(); - - const result: ColorShades = {}; - - for (const shade of shades) { - const key = shade.toString(); - - if (shade === 500) { - result[key] = hex; - continue; - } - - let shadeIndex = shade; - const isDarkShade = shadeIndex > 500; - if (isDarkShade) { - shadeIndex -= 500; - } - - const percentage = shadeIndex / 500; - const startColor = isDarkShade ? DARK_BASE : baseColor; - const endColor = isDarkShade ? baseColor : LIGHT_BASE; - - result[key] = getColor(percentage, hexToRgbArray(startColor), hexToRgbArray(endColor)); - } - - return result; -} - -export type ColorScaleOptions = { - /** If set to `true`, inverts the scale (so 1 is black instead of white) and uses `colorMixMapping.dark` with different mix ratios per step. */ - darkMode?: boolean; - - /** Define a custom background color to use. If left undefined, the global `light`/`dark` values (in `colors.ts`) will be used. */ - background?: string; - - /** Define a custom foreground color to use. If left undefined, the global `light`/`dark` values (in `colors.ts`) will be used. */ - foreground?: string; - - mix?: { - /** If set to a hex code, this color will be additionally mixed into the generated scale according to `mix.ratio`. */ - color: string; - - /** Define a custom mix ratio to mix the `mix` color with. If left undefined, the default ratio will be used. */ - ratio: number; - }; -}; - -/** - * Generate a [Radix-like](https://www.radix-ui.com/colors/docs/palette-composition/understanding-the-scale) colour scale based of a hex colour. - * @param {string} hex The hex code to generate shades from - * @param {object} options - */ -export function colorScale( - hex: string, - { - darkMode = false, - background = darkMode ? DARK_BASE : LIGHT_BASE, - foreground = darkMode ? LIGHT_BASE : DARK_BASE, - mix, - }: ColorScaleOptions = {} -) { - const baseColor = rgbToOklch(hexToRgbArray(hex)); - const mixColor = mix?.color ? rgbToOklch(hexToRgbArray(mix.color)) : null; - const foregroundColor = rgbToOklch(hexToRgbArray(foreground)); - const backgroundColor = rgbToOklch(hexToRgbArray(background)); - let mapping = darkMode ? colorMixMapping.dark : colorMixMapping.light; - - if (mixColor && mix?.ratio && mix.ratio > 0) { - // If defined, we mix in a (tiny) bit of the mix color with the base color. - baseColor.L = mixColor.L * mix.ratio + baseColor.L * (1 - mix.ratio); - baseColor.C = mixColor.C * mix.ratio + baseColor.C * (1 - mix.ratio); - baseColor.H = mix.color === DEFAULT_TINT_COLOR ? baseColor.H : mixColor.H; - } - - if ( - (darkMode && baseColor.L < backgroundColor.L) || - (!darkMode && baseColor.L > backgroundColor.L) - ) { - // If the supplied color is outside of our lightness bounds, use the supplied color's lightness. - // This is mostly used to allow darker-than-dark backgrounds for brands that specifically want that look. - const difference = (backgroundColor.L - baseColor.L) / backgroundColor.L; - backgroundColor.L = baseColor.L; - // At the edges of the scale, the subtle lightness changes stop being perceptible. We need to amp up our mapping to still stand out. - const amplifier = 1; - mapping = mapping.map((step, index) => - index < 9 ? step + step * amplifier * difference : step - ); - } - - const result = []; - - for (let index = 0; index < mapping.length; index++) { - const step = mapping[index]!; - const targetL = foregroundColor.L * step + backgroundColor.L * (1 - step); - - if ( - index === 8 && - !mix && - (darkMode ? targetL - baseColor.L < 0.2 : baseColor.L - targetL < 0.2) - ) { - // Original colour is close enough to target, so let's use the original colour as step 9. - result.push(hex); - continue; - } - - const chromaRatio = (() => { - switch (index) { - // Step 9 and 10 have max chroma, meaning they are fully saturated. - case 8: - case 9: - return 1; - // Step 11 and 12 have a reduced chroma - case 10: - return 0.4; - case 11: - return 0.1; - default: - return index * 0.05; - } - })(); - - const shade = { - L: targetL, // Blend lightness - C: baseColor.C * chromaRatio, - H: baseColor.H, // Maintain the hue from the base color - }; - - const newHex = rgbArrayToHex(oklchToRgb(shade)); - - result.push(newHex); - } - - return result; -} - -/** - * Convert a hex color to an RGB color set. - */ -export function hexToRgbArray(hex: string): RGBColor { - const originalHex = hex; - - let value = hex.replace('#', ''); - if (hex.length === 3) value = value + value; - - const r = value.substring(0, 2); - const g = value.substring(2, 4); - const b = value.substring(4, 6); - - const rgb = [r, g, b].map((channel) => { - try { - const channelInt = Number.parseInt(channel, 16); - if (channelInt < 0 || channelInt > 255) throw new Error(); - return channelInt; - } catch { - throw new Error(`Invalid hex color provided: ${originalHex}`); - } - }); - - return rgb as RGBColor; -} - -/** - * Convert a RGB color set to a hex color. - */ -export function rgbArrayToHex(rgb: RGBColor): string { - return `#${rgb - .map((channel) => { - const component = channel.toString(16); - if (component.length === 1) return `0${component}`; - return component; - }) - .join('')}`; -} - -export function getColor(percentage: number, start: RGBColor, end: RGBColor) { - const rgb = end.map((channel, index) => { - return Math.round(channel + percentage * (start[index]! - channel)); - }); - - return rgbArrayToHex(rgb as RGBColor); -} - -// Utility constants and helper functions -export function rgbToLinear(rgb: RGBColor): [number, number, number] { - return rgb.map((v) => { - const scaled = v / 255; - return scaled <= 0.04045 ? scaled / 12.92 : ((scaled + 0.055) / 1.055) ** 2.4; - }) as [number, number, number]; -} - -export function linearToRgb(linear: [number, number, number]): RGBColor { - return linear.map((v) => { - const scaled = v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055; - return Math.round(Math.max(0, Math.min(1, scaled)) * 255); - }) as RGBColor; -} - -export function rgbToOklab(rgb: RGBColor): OKLABColor { - const [r, g, b] = rgbToLinear(rgb); - - const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b; - const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b; - const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b; - - const lRoot = Math.cbrt(l); - const mRoot = Math.cbrt(m); - const sRoot = Math.cbrt(s); - - return { - L: 0.2104542553 * lRoot + 0.793617785 * mRoot - 0.0040720468 * sRoot, - A: 1.9779984951 * lRoot - 2.428592205 * mRoot + 0.4505937099 * sRoot, - B: 0.0259040371 * lRoot + 0.7827717662 * mRoot - 0.808675766 * sRoot, - }; -} - -export function oklabToRgb(oklab: OKLABColor): RGBColor { - const { L, A, B } = oklab; - - const lRoot = L + 0.3963377774 * A + 0.2158037573 * B; - const mRoot = L - 0.1055613458 * A - 0.0638541728 * B; - const sRoot = L - 0.0894841775 * A - 1.291485548 * B; - - const l = lRoot ** 3; - const m = mRoot ** 3; - const s = sRoot ** 3; - - const r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s; - const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s; - const b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s; - - return linearToRgb([r, g, b]); -} - -export function oklabToOklch(oklab: OKLABColor): OKLCHColor { - const { L, A, B } = oklab; - const C = Math.sqrt(A ** 2 + B ** 2); - const H = (Math.atan2(B, A) * 180) / Math.PI; - return { L, C, H: H < 0 ? H + 360 : H }; -} - -export function oklchToOklab(oklch: OKLCHColor): OKLABColor { - const { L, C, H } = oklch; - const rad = (H * Math.PI) / 180; - return { - L, - A: C * Math.cos(rad), - B: C * Math.sin(rad), - }; -} - -export function rgbToOklch(rgb: RGBColor): OKLCHColor { - return oklabToOklch(rgbToOklab(rgb)); -} - -export function oklchToRgb(oklch: OKLCHColor): RGBColor { - return oklabToRgb(oklchToOklab(oklch)); -} - -export function rgbToXyz(rgb: RGBColor): [number, number, number] { - const [r, g, b] = rgbToLinear(rgb); - return [ - (r * 0.4124564 + g * 0.3575761 + b * 0.1804375) * 100, - (r * 0.2126729 + g * 0.7151522 + b * 0.072175) * 100, - (r * 0.0193339 + g * 0.119192 + b * 0.9503041) * 100, - ]; -} - -export function xyzToLab65(xyz: [number, number, number]): { - L: number; - A: number; - B: number; -} { - const [x, y, z] = xyz.map((v, i) => { - const scaled = v / D65[i]!; - return scaled > 0.008856 ? Math.cbrt(scaled) : 7.787 * scaled + 16 / 116; - }); - - return { - L: 116 * y! - 16, - A: 500 * (x! - y!), - B: 200 * (y! - z!), - }; -} - -export function rgbTolab65(rgb: RGBColor): { L: number; A: number; B: number } { - return xyzToLab65(rgbToXyz(rgb)); -} - -/* - Delta Phi Star perceptual lightness contrast by Andrew Somers: - https://github.com/Myndex/deltaphistar -*/ -export const PHI = 0.5 + Math.sqrt(1.25); - -export function dpsContrast(a: RGBColor, b: RGBColor) { - const dps = Math.abs(rgbTolab65(a).L ** PHI - rgbTolab65(b).L ** PHI); - const contrast = dps ** (1 / PHI) * Math.SQRT2 - 40; - return contrast < 7.5 ? 0 : contrast; -} - -export function colorContrast( - background: string, - foreground: string[] = [LIGHT_BASE, DARK_BASE] -): string { - const bg = hexToRgbArray(background); - - const best: { color?: RGBColor; contrast: number } = { - color: undefined, - contrast: 0, - }; - for (const color of foreground) { - const c = hexToRgbArray(color); - - const contrast = dpsContrast(c, bg); - if (contrast > best.contrast) { - best.color = c; - best.contrast = contrast; - } - } - - return best.color ? rgbArrayToHex(best.color) : foreground[0] || LIGHT_BASE; -} diff --git a/packages/colors/tsconfig.json b/packages/colors/tsconfig.json deleted file mode 100644 index c0b0f93266..0000000000 --- a/packages/colors/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noUncheckedIndexedAccess": true, - "noEmit": false, - "declaration": true, - "outDir": "dist", - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react-jsx", - "incremental": true, - "types": [ - "bun-types" // add Bun global - ] - }, - "include": ["src/**/*.ts", "src/**/*.tsx"], - "exclude": ["node_modules"] -} diff --git a/packages/embed/.gitignore b/packages/embed/.gitignore deleted file mode 100644 index 836fb463de..0000000000 --- a/packages/embed/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist/ -standalone/ diff --git a/packages/embed/CHANGELOG.md b/packages/embed/CHANGELOG.md deleted file mode 100644 index 41822424ce..0000000000 --- a/packages/embed/CHANGELOG.md +++ /dev/null @@ -1,41 +0,0 @@ -# @gitbook/embed - -## 0.1.4 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles -- Updated dependencies [6142d6b] - - @gitbook/icons@0.3.3 - -## 0.1.3 - -### Patch Changes - -- 295f03d: Republish packages -- Updated dependencies [295f03d] - - @gitbook/icons@0.3.2 - -## 0.1.2 - -### Patch Changes - -- 7508674: Fix bundling of packages - -## 0.1.1 - -### Patch Changes - -- 6f368b5: Fix embed assistant window width on small screens - -## 0.1.0 - -### Minor Changes - -- 81a6bd7: Improve API to control the GitBook embed - -### Patch Changes - -- 8927e8f: Initial version of the embed SDK. -- Updated dependencies [25e2b40] - - @gitbook/icons@0.3.0 diff --git a/packages/embed/README.md b/packages/embed/README.md deleted file mode 100644 index 45efed3ac8..0000000000 --- a/packages/embed/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# `@gitbook/embed` - -Embed the GitBook Docs Assistant in your product or website. - -# Usage - -## As a script from your docs site - -All GitBook docs site includes a script to easily embed the docs assistant as a widget on your website. - -The script is served at `https://docs.company.com/~gitbook/embed/script.js`. - -You can find the embed script from your docs site settings, or you can copy the following and replace the `docs.company.com` by your docs site hostname. - -```html - - -``` - -## As a package from NPM - -Install the package: `npm install @gitbook/embed` and import it in your web application: - -```tsx -import { createGitBook } from '@gitbook/embed'; - -const gitbook = createGitBook({ - siteURL: 'https://docs.company.com' -}); - -const iframe = document.createElement('iframe'); -iframe.src = gitbook.getFrameURL(); - -const frame = gitbook.createFrame(iframe); -``` - -## As React components - -After installing the NPM package, you can import prebuilt React components: - -```tsx -import { GitBookProvider, GitBookAssistantFrame } from '@gitbook/embed/react'; - - - -``` diff --git a/packages/embed/package.json b/packages/embed/package.json deleted file mode 100644 index a266c985ec..0000000000 --- a/packages/embed/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@gitbook/embed", - "description": "Embeddable components for GitBook", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "./react": { - "types": "./dist/react/index.d.ts", - "default": "./dist/react/index.js" - } - }, - "sideEffects": false, - "version": "0.1.4", - "dependencies": { - "@gitbook/api": "catalog:", - "@gitbook/icons": "workspace:", - "bidc": "catalog:" - }, - "peerDependencies": { - "react": "*" - }, - "devDependencies": { - "@types/react": "catalog:", - "tsdown": "catalog:", - "typescript": "catalog:", - "react": "catalog:" - }, - "scripts": { - "build": "bun run build-lib && bun run build-standalone", - "build-lib": "tsdown", - "build-standalone": "bun build src/standalone/index.ts --bundle --minify --outdir=standalone", - "clean": "rm -rf ./dist", - "typecheck": "tsc --noEmit", - "dev": "bun run build -- --watch ./src" - }, - "files": ["dist", "README.md", "CHANGELOG.md"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/embed/src/client/createGitBook.ts b/packages/embed/src/client/createGitBook.ts deleted file mode 100644 index bcd57a0961..0000000000 --- a/packages/embed/src/client/createGitBook.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { type GitBookFrameClient, createGitBookFrame } from './createGitBookFrame'; - -export type CreateGitBookOptions = { - /** - * URL of the GitBook site to embed. - */ - siteURL: string; -}; - -export type GetFrameURLOptions = { - /** - * Authentication to use for the frame. - */ - visitor?: { - /** - * Signed JWT token for Adaptive Content or Visitor Authentication to use. - */ - token?: string; - - /** - * Unsigned claims to pass to the frame. - * You can use these claims in dynamic expressions using `visitor.claims.unsigned.- `. - */ - unsignedClaims?: Record ; - }; -}; - -export type GitBookClient = { - /** - * Get the URL for a GitBook frame. - */ - getFrameURL: (options: GetFrameURLOptions) => string; - /** - * Create a new GitBook frame. - */ - createFrame: (iframe: HTMLIFrameElement) => GitBookFrameClient; -}; - -export function createGitBook(options: CreateGitBookOptions) { - const client: GitBookClient = { - getFrameURL: (frameOptions) => { - const url = new URL(options.siteURL); - url.pathname = `${url.pathname.endsWith('/') ? url.pathname : `${url.pathname}/`}~gitbook/embed/assistant`; - - if (frameOptions.visitor?.token) { - url.searchParams.set('token', frameOptions.visitor.token); - } - - if (frameOptions.visitor?.unsignedClaims) { - Object.entries(frameOptions.visitor.unsignedClaims).forEach(([key, value]) => { - url.searchParams.set(`visitor.${key}`, String(value)); - }); - } - - return url.toString(); - }, - createFrame: (iframe) => createGitBookFrame(iframe), - }; - - return client; -} diff --git a/packages/embed/src/client/createGitBookFrame.ts b/packages/embed/src/client/createGitBookFrame.ts deleted file mode 100644 index baaabf647c..0000000000 --- a/packages/embed/src/client/createGitBookFrame.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { createChannel } from 'bidc'; -import type { - FrameToParentMessage, - GitBookEmbeddableConfiguration, - ParentToFrameMessage, -} from './protocol'; - -export type GitBookFrameClient = { - /** - * Navigate to a page by its path. - */ - navigateToPage: (path: string) => void; - - /** - * Navigate to the assistant. - */ - navigateToAssistant: () => void; - - /** - * Post a message to the chat. - */ - postUserMessage: (message: string) => void; - - /** - * Clear the chat. - */ - clearChat: () => void; - - /** - * Set the placeholder settings. - */ - configure: (settings: Partial ) => void; - - /** - * Register an event listener. - */ - on: (event: string, listener: (...args: any[]) => void) => () => void; -}; - -/** - * Create a client to communicate with the GitBook Assistant frame. - */ -export function createGitBookFrame(iframe: HTMLIFrameElement): GitBookFrameClient { - if (!iframe.contentWindow) { - throw new Error('Iframe must have a content window'); - } - const channel = createChannel(iframe.contentWindow); - - channel.receive((message: FrameToParentMessage) => { - console.log('[gitbook:embed] received message', message); - if (message.type === 'close') { - const listeners = events.get('close') || []; - if (listeners) { - listeners.forEach((listener) => listener()); - } - } - }); - - const sendToFrame = (message: ParentToFrameMessage) => { - console.log('[gitbook:embed] send message', message); - channel.send(message); - }; - - const events = new Map void>>(); - - const configuration: GitBookEmbeddableConfiguration = { - buttons: [], - welcomeMessage: '', - suggestions: [], - tools: [], - }; - - return { - navigateToPage: (pagePath) => { - sendToFrame({ type: 'navigateToPage', pagePath }); - }, - navigateToAssistant: () => { - sendToFrame({ type: 'navigateToAssistant' }); - }, - postUserMessage: (message) => sendToFrame({ type: 'postUserMessage', message }), - configure: (settings) => { - Object.assign(configuration, settings); - sendToFrame({ type: 'configure', settings: configuration }); - }, - clearChat: () => sendToFrame({ type: 'clearChat' }), - on: (event, listener) => { - const listeners = events.get(event) || []; - listeners.push(listener); - events.set(event, listeners); - return () => { - events.set( - event, - listeners.filter((l) => l !== listener) - ); - }; - }, - }; -} diff --git a/packages/embed/src/client/index.ts b/packages/embed/src/client/index.ts deleted file mode 100644 index 27098d5b3a..0000000000 --- a/packages/embed/src/client/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './createGitBook'; -export * from './createGitBookFrame'; -export * from './protocol'; diff --git a/packages/embed/src/client/protocol.ts b/packages/embed/src/client/protocol.ts deleted file mode 100644 index f19b400e37..0000000000 --- a/packages/embed/src/client/protocol.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { AIToolCallResult, AIToolDefinition } from '@gitbook/api'; -import type { IconName } from '@gitbook/icons'; - -/** - * Custom tool definition to be passed to the AI assistant. - */ -export type GitBookToolDefinition = AIToolDefinition & { - /** - * Confirmation action to be displayed to the user before executing the tool. - */ - confirmation?: { - icon?: IconName; - label: string; - }; - - /** - * Callback when the tool is executed. - * The input is provided by the AI assistant following the input schema of the tool. - */ - execute: (input: object) => Promise >; -}; - -/** - * Custom button definition to be passed to the embeddable GitBook. - */ -export type GitBookEmbeddableButtonDefinition = { - /** - * Icon to be displayed in the button. - */ - icon: IconName; - - /** - * Label to be displayed in the button. - */ - label: string; - - /** - * Callback when the button is clicked. - */ - onClick: () => void | Promise ; -}; - -/** - * Overall configuration for the layout of the embeddable GitBook. - */ -export type GitBookEmbeddableConfiguration = { - /** - * Buttons to be displayed in the header of the embeddable GitBook. - */ - buttons: GitBookEmbeddableButtonDefinition[]; - - /** Message to be displayed in the welcome page. */ - welcomeMessage: string; - - /** Suggestions of questions to be displayed in the welcome page. */ - suggestions: string[]; - - /** Tools to be provided to the assistant. */ - tools: GitBookToolDefinition[]; -}; - -/** - * Messages sent from the parent to the frame. - */ -export type ParentToFrameMessage = - | { - type: 'postUserMessage'; - message: string; - } - | { - type: 'clearChat'; - } - | { - type: 'configure'; - settings: GitBookEmbeddableConfiguration; - } - | { - type: 'navigateToPage'; - pagePath: string; - } - | { - type: 'navigateToAssistant'; - }; - -/** - * Messages sent from the frame to the parent. - */ -export type FrameToParentMessage = { - type: 'close'; -}; diff --git a/packages/embed/src/index.ts b/packages/embed/src/index.ts deleted file mode 100644 index 4f1cce44fa..0000000000 --- a/packages/embed/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './client'; diff --git a/packages/embed/src/react/GitBookFrame.tsx b/packages/embed/src/react/GitBookFrame.tsx deleted file mode 100644 index cd0d8f65d6..0000000000 --- a/packages/embed/src/react/GitBookFrame.tsx +++ /dev/null @@ -1,53 +0,0 @@ -'use client'; - -import { useEffect, useMemo, useRef, useState } from 'react'; -import type { - GetFrameURLOptions, - GitBookEmbeddableConfiguration, - GitBookFrameClient, -} from '../client'; -import { useGitBook } from './GitBookProvider'; - -export type GitBookFrameProps = { - className?: string; -} & GetFrameURLOptions & - GitBookEmbeddableConfiguration; - -/** - * Render a frame with the GitBook Assistant in it. - */ -export function GitBookFrame(props: GitBookFrameProps) { - const { className, visitor, buttons, welcomeMessage, suggestions, tools } = props; - - const frameRef = useRef (null); - const gitbook = useGitBook(); - const [gitbookFrame, setGitbookFrame] = useState (null); - - const frameURL = useMemo(() => gitbook.getFrameURL({ visitor }), [gitbook, visitor]); - - useEffect(() => { - if (frameRef.current) { - setGitbookFrame(gitbook.createFrame(frameRef.current)); - } - }, [gitbook]); - - useEffect(() => { - gitbookFrame?.configure({ - buttons, - welcomeMessage, - suggestions, - tools, - }); - }, [gitbookFrame, buttons, welcomeMessage, suggestions, tools]); - - return ( - - ); -} diff --git a/packages/embed/src/react/GitBookProvider.tsx b/packages/embed/src/react/GitBookProvider.tsx deleted file mode 100644 index f7ab7b94f2..0000000000 --- a/packages/embed/src/react/GitBookProvider.tsx +++ /dev/null @@ -1,36 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { type CreateGitBookOptions, createGitBook } from '../client'; -import { GitBookContext } from './context'; - -/** - * Provider for the GitBook client. - */ -export function GitBookProvider(props: React.PropsWithChildren ) { - const { siteURL, children } = props; - - const options = React.useMemo( - () => ({ - siteURL, - }), - [siteURL] - ); - - const client = React.useMemo(() => createGitBook(options), [options]); - - return {children} ; -} - -/** - * Hook to access the GitBook client. - */ -export function useGitBook() { - const context = React.useContext(GitBookContext); - - if (!context) { - throw new Error('This component must be used within a'); - } - - return context; -} diff --git a/packages/embed/src/react/context.ts b/packages/embed/src/react/context.ts deleted file mode 100644 index b0c872c59f..0000000000 --- a/packages/embed/src/react/context.ts +++ /dev/null @@ -1,6 +0,0 @@ -'use client'; - -import * as React from 'react'; -import type { GitBookClient } from '../client'; - -export const GitBookContext = React.createContext (null); diff --git a/packages/embed/src/react/index.ts b/packages/embed/src/react/index.ts deleted file mode 100644 index ff70bb4618..0000000000 --- a/packages/embed/src/react/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './GitBookProvider'; -export * from './GitBookFrame'; diff --git a/packages/embed/src/standalone/index.ts b/packages/embed/src/standalone/index.ts deleted file mode 100644 index e9c7135b54..0000000000 --- a/packages/embed/src/standalone/index.ts +++ /dev/null @@ -1,178 +0,0 @@ -import './style.css'; - -import { - type CreateGitBookOptions, - type GetFrameURLOptions, - type GitBookClient, - type GitBookEmbeddableConfiguration, - type GitBookFrameClient, - createGitBook, -} from '../client'; - -export type GitBook = () => void; - -type StandaloneCalls = - // Initialize the widget - | ['init', CreateGitBookOptions, GetFrameURLOptions] - // Unload the widget - | ['unload'] - // Show the widget - | ['show'] - // Hide the widget - | ['hide'] - // Open the window - | ['open'] - // Close the window - | ['close'] - // Toggle the window - | ['toggle'] - // Post a user message - | ['postUserMessage', string] - // Clear the chat - | ['clearChat'] - // Configure the embed - | ['configure', Partial ] - // Navigate to a page - | ['navigateToPage', string] - // Navigate to the assistant - | ['navigateToAssistant']; - -export type GitBookStandalone = ((...args: StandaloneCalls) => void) & { - q?: StandaloneCalls[]; -}; - -const widgetButton = document.createElement('button'); -widgetButton.id = 'gitbook-widget-button'; -widgetButton.addEventListener('click', () => { - GitBook('toggle'); -}); -widgetButton.innerHTML = ` - - -`; - -const widgetWindow = document.createElement('div'); -widgetWindow.id = 'gitbook-widget-window'; -widgetWindow.classList.add('hidden'); - -document.body.appendChild(widgetButton); -document.body.appendChild(widgetWindow); - -let widgetIframe: HTMLIFrameElement | undefined; -let _client: GitBookClient | undefined; -let _frame: GitBookFrameClient | undefined; -let frameOptions: GetFrameURLOptions | undefined; -let frameConfiguration: GitBookEmbeddableConfiguration = { - buttons: [], - welcomeMessage: '', - suggestions: [], - tools: [], -}; - -function getClient() { - if (!_client) { - throw new Error( - 'GitBook client not initialized. Call GitBook("init", { siteURL: "..." }) first.' - ); - } - return _client; -} - -function getIframe() { - if (!widgetIframe || !_frame) { - const client = getClient(); - - widgetIframe?.remove(); - widgetIframe = document.createElement('iframe'); - widgetIframe.id = 'gitbook-widget-iframe'; - widgetIframe.src = client.getFrameURL({ - ...frameOptions, - }); - widgetWindow.appendChild(widgetIframe); - - _frame = client.createFrame(widgetIframe); - } - return { iframe: widgetIframe, frame: _frame }; -} - -const GitBook = (...args: StandaloneCalls) => { - switch (args[0]) { - case 'init': - if (_client) { - throw new Error( - 'GitBook client already initialized. Call GitBook("unload") first.' - ); - } - _client = createGitBook(args[1]); - frameOptions = args[2]; - break; - case 'unload': - _client = undefined; - _frame = undefined; - widgetIframe?.remove(); - widgetWindow.classList.add('hidden'); - break; - case 'show': - widgetButton.classList.remove('hidden'); - break; - case 'hide': - widgetButton.classList.add('hidden'); - break; - case 'open': - widgetWindow.classList.remove('hidden'); - widgetButton.classList.add('open'); - getIframe(); - break; - case 'toggle': - widgetWindow.classList.toggle('hidden'); - widgetButton.classList.toggle('open'); - getIframe(); - break; - case 'close': - widgetWindow.classList.add('hidden'); - widgetButton.classList.remove('open'); - break; - case 'postUserMessage': - getIframe().frame.postUserMessage(args[1]); - break; - case 'configure': - frameConfiguration = { - ...frameConfiguration, - ...args[1], - }; - getIframe().frame.configure({ - ...frameConfiguration, - buttons: [ - ...frameConfiguration.buttons, - - // Always include a close button - { - icon: 'close', - label: 'Close', - onClick: () => { - GitBook('close'); - }, - }, - ], - }); - break; - case 'clearChat': - getIframe().frame.clearChat(); - break; - case 'navigateToPage': - getIframe().frame.navigateToPage(args[1]); - break; - case 'navigateToAssistant': - getIframe().frame.navigateToAssistant(); - break; - } -}; - -// @ts-expect-error - GitBook is not defined in the global scope -const precalls = (window.GitBook as GitBookStandalone | undefined)?.q ?? []; - -// @ts-expect-error - GitBook is not defined in the global scope -window.GitBook = GitBook; -precalls.forEach((call) => GitBook(...call)); - -GitBook('configure', {}); diff --git a/packages/embed/src/standalone/style.css b/packages/embed/src/standalone/style.css deleted file mode 100644 index 9f69a1548e..0000000000 --- a/packages/embed/src/standalone/style.css +++ /dev/null @@ -1,171 +0,0 @@ -:root { - --gitbook-widget-top: 1rem; - --gitbook-widget-bottom: 1rem; - --gitbook-widget-right: 1rem; - --gitbook-widget-left: 1rem; - - --gitbook-widget-button-height: 46px; - - --gitbook-widget-radius: .5rem; - --gitbook-widget-text-size: 1rem; - --gitbook-widget-text-color: #656973; - --gitbook-widget-border-color: #e5e5e5; - - --gitbook-widget-background-translucent: rgba(255, 255, 255, 0.9); - --gitbook-widget-background-translucent-hover: rgba(250, 250, 250, 0.9); - --gitbook-widget-background-solid: #FFFFFF; - --gitbook-widget-background-solid-hover: #FBFBFB; - - --gitbook-widget-icon-size: 1.25rem; - - --gitbook-widget-window-width: 28rem; /* 448px */ - --gitbook-widget-window-height: 40rem; /* 640px */ - --gitbook-widget-window-spacing: .5rem; /* Spacing between the button and the window */ - --gitbook-widget-window-bottom: calc(var(--gitbook-widget-bottom) + var(--gitbook-widget-button-height) + var(--gitbook-widget-window-spacing)); - - --gitbook-widget-transition-duration-fast: 0.2s; - --gitbook-widget-transition-duration-slow: 0.5s; - --gitbook-widget-easing: cubic-bezier(0.25, 1, 0.5, 1); - --gitbook-widget-easing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1); -} - -* { - box-sizing: border-box; -} - -/* Button */ -#gitbook-widget-button { - position: fixed; - bottom: var(--gitbook-widget-bottom); - right: var(--gitbook-widget-right); - height: var(--gitbook-widget-button-height); - z-index: 9999; - - display: flex; - align-items: center; - flex-direction: row-reverse; - gap: .5rem; - padding: .75rem 1rem; - - border-radius: 100px; - border: 1px solid var(--gitbook-widget-border-color); - background-color: var(--gitbook-widget-background-translucent); - backdrop-filter: blur(16px); - - font-size: var(--gitbook-widget-text-size); - color: var(--gitbook-widget-text-color); - - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05), 0 1px 2px -1px rgba(0,0,0,0.05); - transition: all var(--gitbook-widget-transition-duration-fast) var(--gitbook-widget-easing); - - cursor:pointer; - animation: gitbook-widget-present var(--gitbook-widget-transition-duration-slow) var(--gitbook-widget-easing-bounce); -} - -#gitbook-widget-button:hover, #gitbook-widget-button:focus-visible { - background-color: var(--gitbook-widget-background-translucent-hover); -} -#gitbook-widget-button:hover, #gitbook-widget-button:focus-visible { - transform: translateY(-1px); - box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1); -} -#gitbook-widget-button:active { - transform: translateY(0); - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05), 0 1px 2px -1px rgba(0,0,0,0.05); -} - -@media (prefers-contrast: more) { - #gitbook-widget-button { - background-color: var(--gitbook-widget-background-solid); - } - #gitbook-widget-button:hover, #gitbook-widget-button:focus-visible { - background-color: var(--gitbook-widget-background-solid-hover); - } -} - -#gitbook-widget-button.hidden { - display: none; -} - -#gitbook-widget-button.open { - padding: .75rem; - gap: 0; -} - -/* Button: Icon */ -#gitbook-widget-button-icon { - width: var(--gitbook-widget-icon-size); - height: var(--gitbook-widget-icon-size); - mask-image: url("https://static-2v.gitbook.com/~gitbook/static/icons/svgs/custom-icons/gitbook-assistant.svg?v=2"); - mask-size: contain; - mask-repeat: no-repeat; - mask-position: center; - background-color: currentColor; -} - -#gitbook-widget-button.open #gitbook-widget-button-icon { - mask-image: url('https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/close.svg?v=2&token=a463935e93'); -} - -/* Button: Label */ -#gitbook-widget-button.open #gitbook-widget-button-label { - display: none; -} - -/* Window */ -#gitbook-widget-window { - position: fixed; - bottom: var(--gitbook-widget-window-bottom); - right: var(--gitbook-widget-right); - z-index: 9998; - width: calc(min(var(--gitbook-widget-window-width), calc(100vw - var(--gitbook-widget-right) - var(--gitbook-widget-left)))); - height: calc(min(var(--gitbook-widget-window-height), calc(100vh - var(--gitbook-widget-window-bottom) - var(--gitbook-widget-top)))); - background-color: var(--gitbook-widget-background-solid); - border: 1px solid var(--gitbook-widget-border-color); - border-radius: var(--gitbook-widget-radius); - box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - overflow: hidden; - transition-property: transform, opacity, display; - transition-duration: var(--gitbook-widget-transition-duration-slow); - transition-timing-function: var(--gitbook-widget-easing-bounce); - transform-origin: bottom right; - transition-behavior: allow-discrete; -} - -@starting-style { - #gitbook-widget-window { - opacity: 0; - transform: scale(0.9); - } -} - -body:has(#gitbook-widget-button.hidden) #gitbook-widget-window { - bottom: var(--gitbook-widget-bottom); -} - -#gitbook-widget-window.hidden { - transition-property: transform, opacity, display; - transition-duration: var(--gitbook-widget-transition-duration-fast); - transition-timing-function: var(--gitbook-widget-easing); - transition-behavior: allow-discrete; - display: none; - opacity: 0; - transform: scale(0.9); -} - -#gitbook-widget-iframe { - width: 100%; - height: 100%; - border: none; -} - -@keyframes gitbook-widget-present { - from { - opacity: 0; - transform: scale(0.9); - } - to { - opacity: 1; - transform: scale(1); - } -} \ No newline at end of file diff --git a/packages/embed/tsconfig.json b/packages/embed/tsconfig.json deleted file mode 100644 index 37ff331113..0000000000 --- a/packages/embed/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": false, - "declaration": true, - "outDir": "dist", - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react-jsx", - "incremental": true, - "types": [] - }, - "include": ["src/**/*.ts", "src/**/*.tsx"], - "exclude": ["node_modules"] -} diff --git a/packages/embed/tsdown.config.ts b/packages/embed/tsdown.config.ts deleted file mode 100644 index 5b409e4eba..0000000000 --- a/packages/embed/tsdown.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineConfig } from 'tsdown'; - -export default defineConfig([ - { - entry: 'src/index.ts', - outDir: 'dist', - }, - { - entry: 'src/react/index.ts', - outDir: 'dist/react', - unbundle: true, - }, -]); diff --git a/packages/emoji-codepoints/.gitignore b/packages/emoji-codepoints/.gitignore deleted file mode 100644 index 849ddff3b7..0000000000 --- a/packages/emoji-codepoints/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/packages/emoji-codepoints/CHANGELOG.md b/packages/emoji-codepoints/CHANGELOG.md deleted file mode 100644 index 110fe4dbce..0000000000 --- a/packages/emoji-codepoints/CHANGELOG.md +++ /dev/null @@ -1,25 +0,0 @@ -# @gitbook/emoji-codepoints - -## 0.2.2 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles - -## 0.2.1 - -### Patch Changes - -- 295f03d: Republish packages - -## 0.2.0 - -### Minor Changes - -- 57adb3e: Second release to fix publishing with changeset - -## 0.1.0 - -### Minor Changes - -- 5f8a8fe: Initial release diff --git a/packages/emoji-codepoints/build.ts b/packages/emoji-codepoints/build.ts deleted file mode 100644 index 4883ecb51d..0000000000 --- a/packages/emoji-codepoints/build.ts +++ /dev/null @@ -1,27 +0,0 @@ -import fs from 'node:fs'; -import path from 'node:path'; -import emojisRaws from 'emoji-assets/emoji.json'; - -interface EmojiData { - code_points: { - base: string; - fully_qualified: string; - }; -} - -const emojis = emojisRaws as Record ; -const output: Record = {}; - -Object.entries(emojis).forEach(([key, value]) => { - const emoji = value.code_points?.fully_qualified; - if (emoji && key !== emoji) { - output[key] = emoji; - } else if (!emoji) { - } -}); - -fs.mkdirSync(path.resolve(__dirname, 'dist'), { recursive: true }); -fs.writeFileSync( - path.resolve(__dirname, 'dist/index.ts'), - `export const emojiCodepoints: Record = ${JSON.stringify(output, null, 4)};` -); diff --git a/packages/emoji-codepoints/package.json b/packages/emoji-codepoints/package.json deleted file mode 100644 index e92df2ce7a..0000000000 --- a/packages/emoji-codepoints/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@gitbook/emoji-codepoints", - "description": "Optimized mapping of codepoints to the fully qualified emoji codepoints", - "version": "0.2.2", - "private": true, - "exports": "./dist/index.ts", - "sideEffects": false, - "devDependencies": { - "emoji-assets": "^9.0.0" - }, - "scripts": { - "generate": "bun ./build.ts", - "clean": "rm -rf ./dist" - } -} diff --git a/packages/expr/.gitignore b/packages/expr/.gitignore deleted file mode 100644 index 53c37a1660..0000000000 --- a/packages/expr/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist \ No newline at end of file diff --git a/packages/expr/CHANGELOG.md b/packages/expr/CHANGELOG.md deleted file mode 100644 index 7f7bf9065b..0000000000 --- a/packages/expr/CHANGELOG.md +++ /dev/null @@ -1,47 +0,0 @@ -# @gitbook/expr - -## 1.2.3 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles - -## 1.2.2 - -### Patch Changes - -- 295f03d: Republish packages - -## 1.2.1 - -### Patch Changes - -- a629900: Add dev script for @gitbook/expr - -## 1.2.0 - -### Minor Changes - -- 6da3655: Fix exports in gitbook/expr package.json - -## 1.1.1 - -### Patch Changes - -- 3548fa6: Fix eval-estree-expr named import - -## 1.1.0 - -### Minor Changes - -- e1ff17e: Fix bundling of gitbook/expr package - -### Patch Changes - -- 8ff1e3b: Add support for every/some array methods - -## 1.0.0 - -### Major Changes - -- ada195d: Publish gitbook/expr package to help evaluate user defined expressions. diff --git a/packages/expr/README.md b/packages/expr/README.md deleted file mode 100644 index ab6c82baa5..0000000000 --- a/packages/expr/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gitbook/expr` - -Safely evaluate & parse user-defined GitBook expressions. diff --git a/packages/expr/package.json b/packages/expr/package.json deleted file mode 100644 index 9a3101d96b..0000000000 --- a/packages/expr/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@gitbook/expr", - "description": "Safely evaluate & parse user-defined GitBook expressions.", - "version": "1.2.3", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "dependencies": { - "acorn": "^8.14.0", - "acorn-loose": "8.4.0", - "acorn-walk": "^8.3.4", - "assert-never": "catalog:", - "escodegen": "^2.1.0", - "eval-estree-expression": "github:jonschlinkert/eval-estree-expression#9cf28d2" - }, - "devDependencies": { - "@tsconfig/strictest": "catalog:", - "@tsconfig/node20": "catalog:", - "@types/escodegen": "^0.0.10", - "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", - "bun-types": "catalog:", - "tsdown": "catalog:", - "typescript": "catalog:" - }, - "scripts": { - "build": "tsdown", - "typecheck": "tsc --noEmit", - "unit": "bun test", - "clean": "rm -rf ./dist", - "dev": "bun run build -- --watch ./src" - }, - "files": ["dist", "README.md", "CHANGELOG.md"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/expr/src/__tests__/autocomplete.test.ts b/packages/expr/src/__tests__/autocomplete.test.ts deleted file mode 100644 index 321407c4d4..0000000000 --- a/packages/expr/src/__tests__/autocomplete.test.ts +++ /dev/null @@ -1,889 +0,0 @@ -import { describe, expect, it } from 'bun:test'; - -import { ExpressionRuntime } from '../runtime'; -import { - SymbolArray, - SymbolBoolean, - SymbolNumber, - SymbolObject, - SymbolString, - SymbolType, - SymbolsTable, -} from '../symbols'; -import { - type AutocompleteSuggestions, - type AutocompleteSymbolSuggestion, - SUPPORTED_BINARY_OPERATORS, - SUPPORTED_CONDITIONAL_OPERATORS, - SUPPORTED_LOGICAL_OPERATORS, -} from '../types'; - -describe('autocomplete', () => { - const runtime = new ExpressionRuntime(); - const visitorClaimsHelloArraySymbol = SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }); - const symbols = { - visitor: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: visitorClaimsHelloArraySymbol, - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - }, - methods: [], - }), - }; - const context = new SymbolsTable(symbols); - const SCENARIOS: Array<{ - expressionWithCursor: string; - expectedSuggestions: AutocompleteSuggestions; - }> = [ - { - expressionWithCursor: 'visit ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - }, - methods: [], - }), - ref: 'visitor', - parentRef: undefined, - childrenRefs: ['visitor.claims'], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor. ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - ref: 'visitor.claims', - parentRef: 'visitor', - childrenRefs: [ - 'visitor.claims.key', - 'visitor.claims.flags', - 'visitor.claims.hello', - 'visitor.claims.role', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims. ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolString({ name: 'key' }), - ref: 'visitor.claims.key', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.key.length', - 'visitor.claims.key.at', - 'visitor.claims.key.endsWith', - 'visitor.claims.key.includes', - ], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - ref: 'visitor.claims.flags', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.flags.FLAG1', - 'visitor.claims.flags.FLAG2', - 'visitor.claims.flags.FLAG3', - 'visitor.claims.flags.FLAG4', - ], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - ref: 'visitor.claims.hello', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.hello.length', - 'visitor.claims.hello.at', - 'visitor.claims.hello.includes', - 'visitor.claims.hello.some', - 'visitor.claims.hello.every', - ], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - ref: 'visitor.claims.role', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.role.length', - 'visitor.claims.role.at', - 'visitor.claims.role.endsWith', - 'visitor.claims.role.includes', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.ke ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolString({ name: 'key' }), - ref: 'visitor.claims.key', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.key.length', - 'visitor.claims.key.at', - 'visitor.claims.key.endsWith', - 'visitor.claims.key.includes', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.h ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - ref: 'visitor.claims.hello', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.hello.length', - 'visitor.claims.hello.at', - 'visitor.claims.hello.includes', - 'visitor.claims.hello.some', - 'visitor.claims.hello.every', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.hello. ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolNumber({ - name: 'length', - description: `The length data property of an Array instance represents the number of elements in that array. - The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length', - }), - ref: 'visitor.claims.hello.length', - parentRef: 'visitor.claims.hello', - childrenRefs: [], - }, - }, - ...visitorClaimsHelloArraySymbol.methods.map ( - (method) => ({ - type: 'symbol', - symbol: { - definition: method, - ref: `visitor.claims.hello.${method.name}`, - parentRef: 'visitor.claims.hello', - childrenRefs: [], - }, - }) - ), - ], - }, - { - expressionWithCursor: 'visitor.claims.f ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - ref: 'visitor.claims.flags', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.flags.FLAG1', - 'visitor.claims.flags.FLAG2', - 'visitor.claims.flags.FLAG3', - 'visitor.claims.flags.FLAG4', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.fl ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - ref: 'visitor.claims.flags', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.flags.FLAG1', - 'visitor.claims.flags.FLAG2', - 'visitor.claims.flags.FLAG3', - 'visitor.claims.flags.FLAG4', - ], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags. ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG1' }), - ref: 'visitor.claims.flags.FLAG1', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG2' }), - ref: 'visitor.claims.flags.FLAG2', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG3' }), - ref: 'visitor.claims.flags.FLAG3', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG4' }), - ref: 'visitor.claims.flags.FLAG4', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FL ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG1' }), - ref: 'visitor.claims.flags.FLAG1', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG2' }), - ref: 'visitor.claims.flags.FLAG2', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG3' }), - ref: 'visitor.claims.flags.FLAG3', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - { - type: 'symbol', - symbol: { - definition: SymbolBoolean({ name: 'FLAG4' }), - ref: 'visitor.claims.flags.FLAG4', - parentRef: 'visitor.claims.flags', - childrenRefs: [], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.key ', - expectedSuggestions: [...SUPPORTED_BINARY_OPERATORS].map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ', - expectedSuggestions: [ - ...[...SUPPORTED_BINARY_OPERATORS, ...SUPPORTED_LOGICAL_OPERATORS].filter((op) => - ['==', '!=', '===', '!==', '&&', '||'].includes(op.operator) - ), - ...SUPPORTED_CONDITIONAL_OPERATORS, - ].map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 = ', - expectedSuggestions: SUPPORTED_BINARY_OPERATORS.filter((op) => - ['==', '==='].includes(op.operator) - ).map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == ', - expectedSuggestions: SUPPORTED_BINARY_OPERATORS.filter( - (op) => op.operator === '===' - ).map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ! ', - expectedSuggestions: SUPPORTED_BINARY_OPERATORS.filter((op) => - ['!=', '!=='].includes(op.operator) - ).map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 != ', - expectedSuggestions: SUPPORTED_BINARY_OPERATORS.filter( - (op) => op.operator === '!==' - ).map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: true }, - }, - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: false }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == t ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: true }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == tr ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: true }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == true ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == f ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: false }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == fa ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: false }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == non ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == false ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.role == ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'admin' }, - }, - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'editor' }, - }, - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'reader' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == ad ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'admin' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == admin ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'admin' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == "ad ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'admin' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == "admin ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'admin' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == "admin" ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.role == edit ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'editor' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == "edit ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'editor' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == editor ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.String, data: 'editor' }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.role == "editor" ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.hello == ', - expectedSuggestions: [], - }, - { - expressionWithCursor: 'visitor.claims.hello[1] == ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { - kind: 'in-array', - srcSymbol: visitorClaimsHelloArraySymbol, - matchedLiteralString: '', - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.hello[1] == "test ', - expectedSuggestions: [ - { - type: 'literal-value', - value: { - kind: 'in-array', - srcSymbol: visitorClaimsHelloArraySymbol, - matchedLiteralString: '"test', - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 == true ', - expectedSuggestions: [ - ...SUPPORTED_LOGICAL_OPERATORS.filter((op) => ['&&', '||'].includes(op.operator)), - ...SUPPORTED_CONDITIONAL_OPERATORS, - ].map((op) => ({ - type: 'operator', - ...op, - })), - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 !== true && v ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - }, - methods: [], - }), - ref: 'visitor', - parentRef: undefined, - childrenRefs: ['visitor.claims'], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ? ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - }, - methods: [], - }), - ref: 'visitor', - parentRef: undefined, - childrenRefs: ['visitor.claims'], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ? visit ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - role: SymbolString({ - name: 'role', - enum: ['admin', 'editor', 'reader'], - }), - }, - methods: [], - }), - }, - methods: [], - }), - ref: 'visitor', - parentRef: undefined, - childrenRefs: ['visitor.claims'], - }, - }, - ], - }, - { - expressionWithCursor: 'visitor.claims.flags.FLAG1 ? visitor.claims.fl ', - expectedSuggestions: [ - { - type: 'symbol', - symbol: { - definition: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolBoolean({ name: 'FLAG1' }), - FLAG2: SymbolBoolean({ name: 'FLAG2' }), - FLAG3: SymbolBoolean({ name: 'FLAG3' }), - FLAG4: SymbolBoolean({ name: 'FLAG4' }), - }, - methods: [], - }), - ref: 'visitor.claims.flags', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.flags.FLAG1', - 'visitor.claims.flags.FLAG2', - 'visitor.claims.flags.FLAG3', - 'visitor.claims.flags.FLAG4', - ], - }, - }, - ], - }, - ]; - it.each(SCENARIOS)( - 'should provide matching suggestion for expression with cursor: $expressionWithCursor', - ({ expressionWithCursor, expectedSuggestions }) => { - const { expression, cursorOffset } = extractCursorPosition( - expressionWithCursor, - ' ' - ); - const { suggestions } = runtime.autocomplete(expression, cursorOffset, context); - expect(suggestions).toStrictEqual(expectedSuggestions); - } - ); -}); - -function extractCursorPosition( - expressionWithCursor: string, - cursorPlaceholder: string -): { expression: string; cursorOffset: number } { - const cursorOffset = expressionWithCursor.indexOf(cursorPlaceholder); - if (cursorOffset === -1) { - throw new Error( - `Cursor position (${cursorPlaceholder}) not found in the expression string.` - ); - } - - const expression = expressionWithCursor.replace(cursorPlaceholder, ''); - return { expression, cursorOffset }; -} diff --git a/packages/expr/src/__tests__/input-values.test.ts b/packages/expr/src/__tests__/input-values.test.ts deleted file mode 100644 index f36af0fadb..0000000000 --- a/packages/expr/src/__tests__/input-values.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { describe, expect, it } from 'bun:test'; - -import { inferDefaultInputValuesFromObjectJSONSchema } from '../input-values'; - -describe('inferDefaultInputValuesFromObjectJSONSchema', () => { - it('should infer properly the default input value based on the JSON schema of an object', () => { - const defaultInputValues = inferDefaultInputValuesFromObjectJSONSchema({ - type: 'object', - properties: { - claims: { - type: 'object', - properties: { - key: { - type: 'string', - }, - flags: { - type: 'object', - properties: { - FLAG1: { type: 'string' }, - FLAG2: { type: 'string' }, - FLAG3: { type: 'string' }, - }, - }, - isAlphaUser: { - type: 'boolean', - }, - hello: { - type: 'string', - enum: ['enumValue1', 'enumValue2', 'enumValue3'], - }, - }, - }, - }, - }); - expect(defaultInputValues).toMatchObject({ - claims: { - key: 'default', - flags: { - FLAG1: 'default', - FLAG2: 'default', - FLAG3: 'default', - }, - isAlphaUser: true, - hello: 'enumValue1', - }, - }); - }); -}); diff --git a/packages/expr/src/__tests__/runtime.test.ts b/packages/expr/src/__tests__/runtime.test.ts deleted file mode 100644 index fbc648be13..0000000000 --- a/packages/expr/src/__tests__/runtime.test.ts +++ /dev/null @@ -1,178 +0,0 @@ -import { describe, expect, it } from 'bun:test'; - -import { ExpressionError } from '../errors'; -import { ExpressionRuntime } from '../runtime'; -import type { Logger } from '../types'; - -const SILENT_LOGGER: Logger = { - debug: () => {}, - info: () => {}, - error: () => {}, -}; - -describe('ExpressionRuntime', () => { - const runtime = new ExpressionRuntime(SILENT_LOGGER); - - describe('evaluate', () => { - it.each([ - { - scenario: 'simple condition', - condition: 'isBetaUser === true', - inputs: { isBetaUser: false }, - expectedResult: false, - }, - { - scenario: 'simple condition with multiple inputs variables', - condition: 'useProductA && !isBetaUser', - inputs: { - useProductA: true, - isBetaUser: false, - }, - expectedResult: true, - }, - { - scenario: 'condition with objects in inputs variables', - condition: 'products.includes("productA") && userSegments.alpha', - inputs: { - products: ['productA', 'productB'], - userSegments: { - alpha: true, - beta: false, - }, - }, - expectedResult: true, - }, - { - scenario: 'array method', - condition: 'reviews.every(review => !!review.status)', - inputs: { reviews: [{ status: 'approved' }, { status: 'approved' }] }, - expectedResult: true, - }, - { - scenario: 'array every', - condition: 'reviews.every(review => review.status === "approved")', - inputs: { reviews: [{ status: 'approved' }, { status: 'approved' }] }, - expectedResult: true, - }, - { - scenario: 'array map', - condition: '[1, 2, 3].map(n => n * x)', - inputs: { x: 2 }, - expectedResult: [2, 4, 6], - }, - ])( - 'should properly evaluate/safeEvaluate a valid conditional expression: $scenario', - ({ condition, inputs, expectedResult }) => { - expect(runtime.evaluate(condition, inputs)).toEqual(expectedResult); - expect(runtime.safeEvaluate(condition, inputs).value).toEqual(expectedResult); - } - ); - - const INVALID_EXPRESSSIONS = [ - { - scenario: 'invalid syntax', - condition: 't}=d', - inputs: {}, - }, - { - scenario: 'non conditional expression', - condition: 'const a = 1;', - inputs: {}, - }, - { - scenario: 'unsafe expression', - condition: 'while (1) {}', - inputs: {}, - }, - { - scenario: 'unsafe expression', - condition: '[1, 2, 3].map(() => { while (1) {}})', - inputs: {}, - }, - ]; - - it.each(INVALID_EXPRESSSIONS)( - 'should return an object with the error for non conditional expression or syntax errors when using safeEvaluate is on (default): $scenario', - ({ condition, inputs }) => { - const result = runtime.safeEvaluate(condition, inputs); - expect(result.value).toBeUndefined(); - expect(result.error instanceof ExpressionError).toBe(true); - } - ); - - it.each(INVALID_EXPRESSSIONS)( - 'should throw an error when using evaluate with invalid expressions', - ({ condition, inputs }) => { - expect(() => runtime.evaluate(condition, inputs)).toThrowError(ExpressionError); - } - ); - }); - - describe('parse', () => { - it('should produce a valid ESTree compatible AST node for conditional expressions', () => { - const ast = runtime.parse('isBetaUser === true'); - - expect(ast.result).toEqual({ - type: 'BinaryExpression', - start: 0, - end: 19, - loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 19 } }, - left: { - type: 'Identifier', - start: 0, - end: 10, - loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 10 } }, - name: 'isBetaUser', - }, - operator: '===', - right: { - type: 'Literal', - start: 15, - end: 19, - loc: { start: { line: 1, column: 15 }, end: { line: 1, column: 19 } }, - value: true, - raw: 'true', - }, - }); - }); - - it.each([ - { - scenario: 'invalid syntax', - condition: 't}=d', - }, - { - scenario: 'non conditional expression', - condition: 'const a = 1;', - }, - ])( - 'should throw an error for non conditional expressions or syntax errors: $scenario', - ({ condition }) => { - expect(() => runtime.parse(condition)).toThrowError(ExpressionError); - } - ); - }); - - describe.skip('generate', () => { - it.each([ - { - scenario: 'simple condition', - condition: 'isBetaUser === true', - }, - { - scenario: 'simple condition with multiple inputs variables', - condition: 'useProductA && !isBetaUser', - }, - { - scenario: 'condition with objects in inputs variables', - condition: 'products.includes("productA") && userSegments.alpha', - }, - ])( - 'should produce the original expression using an AST node produced by parse: $scenario', - ({ condition }) => { - const { result } = runtime.parse(condition); - expect(runtime.generate(result)).toStrictEqual(condition); - } - ); - }); -}); diff --git a/packages/expr/src/__tests__/template.test.ts b/packages/expr/src/__tests__/template.test.ts deleted file mode 100644 index 56a3e70bc4..0000000000 --- a/packages/expr/src/__tests__/template.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { describe, expect, it } from 'bun:test'; - -import { ExpressionRuntime, parseTemplate } from '../'; - -describe('template expressions', () => { - it('should parse template into parts', () => { - const parts = parseTemplate('Hello {{ user.name }}!'); - expect(parts).toEqual([ - { type: 'text', value: 'Hello ', start: 0, end: 6 }, - { type: 'expression', value: 'user.name', start: 8, end: 19 }, - { type: 'text', value: '!', start: 21, end: 22 }, - ]); - }); - - it('should parse template starting with an expression', () => { - const parts = parseTemplate('{{ user.name }} is cool'); - expect(parts).toEqual([ - { type: 'expression', value: 'user.name', start: 2, end: 13 }, - { type: 'text', value: ' is cool', start: 15, end: 23 }, - ]); - }); - - it('should parse template without expressions', () => { - const parts = parseTemplate('Hello world'); - expect(parts).toEqual([{ type: 'text', value: 'Hello world', start: 0, end: 11 }]); - }); - - it('should evaluate template', () => { - const runtime = new ExpressionRuntime(); - const result = runtime.evaluateTemplate('Hello {{ user.name }}!', { - user: { name: 'John' }, - }); - expect(result).toBe('Hello John!'); - }); -}); diff --git a/packages/expr/src/autocomplete.ts b/packages/expr/src/autocomplete.ts deleted file mode 100644 index e87791f1b1..0000000000 --- a/packages/expr/src/autocomplete.ts +++ /dev/null @@ -1,568 +0,0 @@ -import type { - Node as AcornNode, - AnyNode, - BinaryExpression, - Expression, - Identifier, - Literal, - MemberExpression, - PrivateIdentifier, - Super, -} from 'acorn'; -import { isDummy } from 'acorn-loose'; -import * as walk from 'acorn-walk'; - -import assertNever from 'assert-never'; - -import { type ExtractSymbolDef, SymbolType, SymbolsTable } from './symbols'; -import { - type AutocompleteLiteralValueSuggestion, - type AutocompleteOperatorSuggestion, - type AutocompleteSuggestions, - type AutocompleteSymbolSuggestion, - type DirectLiteralValueSuggestion, - type ExpressionParserResult, - type Logger, - SUPPORTED_BINARY_OPERATORS, - SUPPORTED_CONDITIONAL_OPERATORS, - SUPPORTED_LOGICAL_OPERATORS, -} from './types'; - -interface ExpressionParser { - parse(expr: string, options: { loose?: boolean }): ExpressionParserResult; -} - -export class AutoComplete { - #parser: ExpressionParser; - #logger: Logger; - - constructor(parser: ExpressionParser, logger: Logger = console) { - this.#parser = parser; - this.#logger = logger; - } - - /** - * Generates autocomplete suggestions based on the input expression and cursor offset position. - */ - public getSuggestions( - expr: string, - cursorOffset: number, - context: SymbolsTable - ): AutocompleteSuggestions { - if (!expr.length) { - return []; - } - - try { - const { result, invalidNodes } = this.#parser.parse(expr, { loose: true }); - - // Locate the node at the cursor position. - const nodeAtCursorFound = walk.findNodeAround(result, cursorOffset, (_type, node) => - isNodeAtCursor(node, cursorOffset) - ); - - if (!nodeAtCursorFound) { - // When we can't find one we might be in the boundary of the program/expression. - // We could possibly be in a whitespace at the end of the expression or in a situation where the parsed - // tree may contain 2 top level ExpressionStatement (second one returned as invalid node by the parser). - // - // In this case we want to provide operators as suggestions and refine the search of the "cursor" node to either: - // - using the end position of the whole expression AST (e.g white space at the very end of the expression string) - // - or using the second top level ExpressionStatement node found by the parser as the cursor is at the end of that node. - if (cursorOffset > result.end) { - const ast = invalidNodes.length > 0 ? invalidNodes[0]?.expression : result; - - if (!ast) { - return []; - } - - const lastNodeFound = walk.findNodeAround(ast, ast.end, (_type, node) => - isNodeAtCursor(node, ast.end) - ); - if (!lastNodeFound) { - return []; - } - const { node } = lastNodeFound; - - if (!isAnyNode(node)) { - throw Error(`Unexpected node type ${node.type}`); - } - - return this.getOperatorSuggestionsForNode(ast, node, result.end, context); - } - return []; - } - - const { node } = nodeAtCursorFound; - - if (!isAnyNode(node)) { - throw Error(`Unexpected node type ${node.type}`); - } - - return this.getSuggestionsForNode(result, node, expr, cursorOffset, context); - } catch (error) { - this.#logger.error('Error while computing autocomplete suggestions', error); - return []; - } - } - - /** - * Provides autocomplete suggestions for a specific node in the AST. - */ - private getSuggestionsForNode( - ast: Expression, - node: AnyNode, - expr: string, - cursorOffset: number, - context: SymbolsTable - ): AutocompleteSuggestions { - // When the node is an identifier look up the parent to get more context for the suggestions. - let inferNode: AnyNode = node; - if (node.type === 'Identifier' || node.type === 'Literal') { - const parent = findParentNode(node, ast); - inferNode = - parent && - !['ExpressionStatement', 'LogicalExpression', 'ConditionalExpression'].includes( - parent.type - ) - ? parent - : node; - } - - switch (inferNode.type) { - case 'Identifier': - case 'MemberExpression': { - const pathParts = this.getSymbolsPathPartsForMemberExpressionNode( - inferNode, - cursorOffset - ); - - // Fetch suggestions from the symbol table - const candidatesKeys = context.getMatchingSymbolsKeys(pathParts); - - const suggestions: AutocompleteSymbolSuggestion[] = []; - for (const candidate of candidatesKeys) { - const symbolInfo = context.getSymbolInfo(candidate); - if (symbolInfo) { - suggestions.push({ type: 'symbol', symbol: symbolInfo }); - } - } - - if (suggestions.length === 1) { - const lastPathSegment = pathParts.at(-1)?.replace(/\*$/, ''); - - // Return no suggestion when the only match is an exact match of the - // typed token. - return lastPathSegment !== suggestions[0]?.symbol.definition.name - ? suggestions - : []; - } - - return suggestions; - } - case 'AssignmentExpression': - case 'UnaryExpression': { - // Provide suggestions for binary or logical operators based on the parsed operator - // of the partial expression (e.g suggest "==" when typing "=" (parsed as AssignmentExpression)). - return this.getOperatorSuggestionsForNode(ast, inferNode, cursorOffset, context); - } - case 'BinaryExpression': { - const { left, right } = inferNode; - - const isOperatorBinaryOp = SUPPORTED_BINARY_OPERATORS.some( - (op) => op.operator === inferNode.operator - ); - - const operatorIndex = expr.indexOf(inferNode.operator, left.end); - const operatorOffset = operatorIndex + inferNode.operator.length; - const isCursorAfterOperator = cursorOffset > operatorOffset; - - const shouldSuggestValues = - isCursorAfterOperator && - isOperatorBinaryOp && - isNodeAtCursor(right, cursorOffset); - - if (shouldSuggestValues) { - return this.getLiteralValueSuggestionsForNode(inferNode, cursorOffset, context); - } - - // Provide suggestions for binary operators based on the parsed operator - return this.getOperatorSuggestionsForNode(ast, inferNode, cursorOffset, context); - } - case 'ConditionalExpression': { - const { consequent, alternate } = inferNode; - - if (isNodeAtCursor(consequent, cursorOffset)) { - return this.getSuggestionsForNode(ast, consequent, expr, cursorOffset, context); - } - - if (isNodeAtCursor(alternate, cursorOffset)) { - return this.getSuggestionsForNode(ast, alternate, expr, cursorOffset, context); - } - } - } - - return []; - } - - /** - * Return a path corresponding to the MemberExpression node that can be used to lookup matching symbols in the symbol table. - */ - private getSymbolsPathPartsForMemberExpressionNode( - node: MemberExpression | Identifier, - cursorOffset: number, - options?: { withWildcardMatches: boolean } - ): string[] { - const withWildcardMatches = options?.withWildcardMatches ?? true; - const pathParts: string[] = []; - - switch (node.type) { - case 'MemberExpression': - { - const memberProperty = node.property; - - // Only support identifier or literal expressions as member properties. - if (!isSupportedMemberProperty(memberProperty)) { - return []; - } - - // Push the path part corresponding to the member property (e.g b in a.b or a['b']) - const propertyPathPart = this.getSymbolsPathPartFromMemberProperty( - memberProperty, - cursorOffset - ); - - if (propertyPathPart) { - pathParts.push( - withWildcardMatches ? `${propertyPathPart}*` : propertyPathPart - ); - } - - // Go through the parent(s) in the chain and add their path parts as well - let parent: Expression | Super | undefined = node.object; - while (parent) { - const parentProperty = 'property' in parent ? parent.property : parent; - - // Only support identifier or literal expressions as parent property. - const parentPropertyPathPart = isSupportedMemberProperty(parentProperty) - ? this.getSymbolsPathPartFromMemberProperty( - parentProperty, - cursorOffset - ) - : undefined; - - if (parentPropertyPathPart) { - pathParts.unshift(parentPropertyPathPart); - } - - parent = 'object' in parent ? parent.object : undefined; - } - } - break; - case 'Identifier': { - const propertyPathPart = this.getSymbolsPathPartFromMemberProperty( - node, - cursorOffset - ); - if (propertyPathPart) { - pathParts.push(withWildcardMatches ? `${propertyPathPart}*` : propertyPathPart); - } - break; - } - default: - assertNever(node); - } - - return pathParts; - } - - /** - * Return a part of a symbol path corresponding to a MemberExpression node property. - */ - private getSymbolsPathPartFromMemberProperty( - node: Identifier | Literal, - cursorOffset: number - ): string { - switch (node.type) { - case 'Identifier': { - if (isDummy(node)) { - return '*'; - } - - return isNodeAtCursor(node, cursorOffset) - ? node.name.slice(0, cursorOffset) - : node.name; - } - case 'Literal': { - if (isDummy(node) || !node.value) { - return '*'; - } - const value = String(node.value); - return isNodeAtCursor(node, cursorOffset) ? value.slice(0, cursorOffset) : value; - } - default: - assertNever(node); - } - } - - /** - * Provides autocomplete literal value suggestions for a specific node in the AST. - */ - private getLiteralValueSuggestionsForNode( - node: BinaryExpression, - cursorOffset: number, - context: SymbolsTable - ): Array { - const { left, right } = node; - - if (left.type !== 'MemberExpression' && left.type !== 'Identifier') { - return []; - } - - if (right.type !== 'Identifier' && right.type !== 'Literal') { - return []; - } - - const leftSymbolPath = this.getSymbolsPathPartsForMemberExpressionNode(left, cursorOffset, { - withWildcardMatches: false, - }); - - const isLeftComputedMember = left.type === 'MemberExpression' && left.computed; - const leftSymbolInfo = context.getSymbolInfo( - isLeftComputedMember ? leftSymbolPath.slice(0, -1) : leftSymbolPath - ); - - if (!leftSymbolInfo) { - return []; - } - - switch (leftSymbolInfo.definition.type) { - case SymbolType.Boolean: { - const suggestions: DirectLiteralValueSuggestion[] = [ - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: true }, - }, - { - type: 'literal-value', - value: { kind: 'direct', type: SymbolType.Boolean, data: false }, - }, - ]; - - return isDummy(right) - ? suggestions - : suggestions.filter((literalValue) => { - const literalValueString = String(literalValue.value.data); - const rightNodeValue = - right.type === 'Identifier' ? right.name : (right.raw ?? ''); - return ( - literalValueString !== rightNodeValue && - literalValueString.startsWith(rightNodeValue) - ); - }); - } - case SymbolType.String: { - if (!leftSymbolInfo.definition.enum) { - return []; - } - - const rightNodeValue = (() => { - if (right.type === 'Identifier') { - return right.name; - } - - const nodeValue = right.raw ?? ''; - if (/^(['"])(.*)\1$/.test(nodeValue)) { - return null; - } - - return nodeValue.replaceAll(/["']/g, ''); - })(); - - if (rightNodeValue === null) { - return []; - } - - const suggestions = isDummy(right) - ? leftSymbolInfo.definition.enum - : leftSymbolInfo.definition.enum.filter((enumValue) => - enumValue.startsWith(rightNodeValue) - ); - - return suggestions.map((value) => ({ - type: 'literal-value', - value: { - kind: 'direct', - type: SymbolType.String, - data: value, - }, - })); - } - case SymbolType.Array: { - // Only return a literal in array value suggestion when the left hand side of the binary expression - // is computed, e.g myArray[1] - return isLeftComputedMember - ? [ - { - type: 'literal-value', - value: { - kind: 'in-array', - srcSymbol: leftSymbolInfo.definition, - matchedLiteralString: !isDummy(right) - ? right.type === 'Identifier' - ? right.name - : (right.raw ?? '') - : '', - }, - }, - ] - : []; - } - default: - return []; - } - } - - /** - * Provides autocomplete operator suggestions for a specific node in the AST. - */ - private getOperatorSuggestionsForNode( - ast: Expression, - node: AnyNode, - cursorOffset: number, - context: SymbolsTable - ): Array { - if (node.type === 'Literal') { - const parent = findParentNode(node, ast); - - if (parent?.type === 'BinaryExpression') { - return [...SUPPORTED_LOGICAL_OPERATORS, ...SUPPORTED_CONDITIONAL_OPERATORS].map( - (op) => ({ - type: 'operator', - ...op, - }) - ); - } - - const literalSymbol = SymbolsTable.inferSymbolFromValue(node.raw); - return this.getOperatorSuggestionsForSymbol(literalSymbol); - } - - // When the node is an identifier look the parent to get more context for the suggestions - let inferNode: AnyNode = node; - if (node.type === 'Identifier') { - const parent = findParentNode(node, ast); - inferNode = parent && parent.type !== 'ExpressionStatement' ? parent : node; - } - - switch (inferNode.type) { - case 'MemberExpression': { - const pathParts = this.getSymbolsPathPartsForMemberExpressionNode( - inferNode, - cursorOffset, - { - withWildcardMatches: false, - } - ); - const symbolInfo = context.getSymbolInfo(pathParts); - return symbolInfo - ? this.getOperatorSuggestionsForSymbol(symbolInfo.definition) - : []; - } - case 'AssignmentExpression': - case 'BinaryExpression': - case 'UnaryExpression': { - // Starting to write a binary/logical operator so suggest operator matching the already - // typed character as operator. - const operator = inferNode.operator; - return ( - [...SUPPORTED_BINARY_OPERATORS, ...SUPPORTED_LOGICAL_OPERATORS] - .filter((op) => op.operator.startsWith(operator)) - // No need to include the operator that match exactly - .filter((op) => op.operator !== operator) - .map((op) => ({ - type: 'operator', - ...op, - })) - ); - } - default: - return []; - } - } - - /** - * Provides autocomplete operator suggestions based on the type of a symbol. - */ - private getOperatorSuggestionsForSymbol( - symbol: ExtractSymbolDef - ): Array { - switch (symbol.type) { - case SymbolType.Number: - case SymbolType.Boolean: - case SymbolType.Null: - case SymbolType.Undefined: - case SymbolType.Object: - case SymbolType.Array: { - const equalityOps = SUPPORTED_BINARY_OPERATORS.slice(0, 4); - const finalSuggestions = - symbol.type === SymbolType.Boolean - ? [ - ...equalityOps, - ...SUPPORTED_LOGICAL_OPERATORS, - ...SUPPORTED_CONDITIONAL_OPERATORS, - ] - : equalityOps; - return finalSuggestions.map((op) => ({ - type: 'operator', - ...op, - })); - } - case SymbolType.String: - return SUPPORTED_BINARY_OPERATORS.map((op) => ({ - type: 'operator', - ...op, - })); - case SymbolType.Function: - return this.getOperatorSuggestionsForSymbol(symbol.returns); - case SymbolType.Union: { - return symbol.members.reduce >((prev, cur) => { - prev.push(...this.getOperatorSuggestionsForSymbol(cur)); - return prev; - }, []); - } - default: - assertNever(symbol); - } - } -} - -/** - * Finds the parent of child node in the provided AST. - */ -function findParentNode(child: AnyNode, ast: Expression): AnyNode | undefined { - let foundParent: AnyNode | undefined; - - walk.ancestor(ast, { - [child.type]: (node: AcornNode, _state: undefined, ancestors: AnyNode[]) => { - if (node.start === child.start && node.end === child.end) { - // The parent is the second last ancestor in the stack (last one is the actual node) - foundParent = ancestors[ancestors.length - 2]; - } - }, - }); - - return foundParent; -} - -function isSupportedMemberProperty(node: Expression | PrivateIdentifier | Super) { - return node.type === 'Identifier' || node.type === 'Literal'; -} - -function isNodeAtCursor(node: AcornNode, cursorOffset: number) { - return cursorOffset >= node.start && cursorOffset <= node.end; -} - -function isAnyNode(node: AcornNode): node is AnyNode { - return 'type' in node; -} diff --git a/packages/expr/src/errors.ts b/packages/expr/src/errors.ts deleted file mode 100644 index 4e41423622..0000000000 --- a/packages/expr/src/errors.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Position, Token } from 'acorn'; - -export class ExpressionError extends Error { - /** - * The location of the error in the parsed expression. - */ - public location?: Position | null; - - /** - * The expression token with the error - */ - public token?: Token; - - constructor(message: string, loc?: Position | null, token?: Token) { - super(message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, ExpressionError); - } - this.name = 'ExpressionError'; - this.location = loc; - this.token = token; - } -} diff --git a/packages/expr/src/index.ts b/packages/expr/src/index.ts deleted file mode 100644 index 32132abcb3..0000000000 --- a/packages/expr/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './errors'; -export * from './input-values'; -export * from './runtime'; -export * from './symbols'; -export * from './template'; -export * from './types'; -export * from './utils'; diff --git a/packages/expr/src/input-values.ts b/packages/expr/src/input-values.ts deleted file mode 100644 index 6aa75cf461..0000000000 --- a/packages/expr/src/input-values.ts +++ /dev/null @@ -1,77 +0,0 @@ -import type { JSONSchema7 } from 'json-schema'; -import { filterOutNullable } from './utils'; - -type InputValuesType = - | null - | string - | number - | boolean - | { [key: string]: InputValuesType } - | InputValuesType[]; - -/** - * Infers a default inputValues object based on the JSON schema of an object. - */ -export function inferDefaultInputValuesFromObjectJSONSchema( - schema: JSONSchema7 -): Record { - if (schema.type !== 'object' || !schema.properties) { - throw new Error(`Expected schema of object to be provided: ${schema.type}`); - } - - const result: Record = {}; - - for (const [key, propertySchema] of Object.entries(schema.properties)) { - if (typeof propertySchema === 'boolean') { - continue; - } - - result[key] = inferDefaultInputValueFromJSONSchema(propertySchema); - } - - return result; -} - -function inferDefaultInputValueFromJSONSchema(schema: JSONSchema7): InputValuesType { - switch (schema.type) { - case 'object': - return inferDefaultInputValuesFromObjectJSONSchema(schema); - case 'array': { - if (schema.items && Array.isArray(schema.items)) { - return schema.items.map((itemSchema) => { - if (typeof itemSchema === 'boolean') { - return false; - } - return inferDefaultInputValueFromJSONSchema(itemSchema); - }); - } - return []; - } - case 'string': - case 'number': - case 'integer': - case 'boolean': - case 'null': - return inferDefaultInputValueFromPrimitive(schema); - default: - throw new Error(`Unsupported schema type: ${schema.type}`); - } -} - -function inferDefaultInputValueFromPrimitive(schema: JSONSchema7): InputValuesType { - switch (schema.type) { - case 'boolean': - return true; - case 'number': - case 'integer': - return 1234; - case 'string': { - const enumValues = schema.enum?.filter(filterOutNullable); - return enumValues?.[0] ?? 'default'; - } - case 'null': - return null; - default: - throw new Error(`Unsupported schema type: ${schema.type}`); - } -} diff --git a/packages/expr/src/runtime.ts b/packages/expr/src/runtime.ts deleted file mode 100644 index 8d3bc33a5a..0000000000 --- a/packages/expr/src/runtime.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { - type Options as AcornOptions, - type Expression, - type ExpressionStatement, - type Position, - type Program, - type Token, - parse, - tokenizer, -} from 'acorn'; -import { parse as parseLoose } from 'acorn-loose'; -import escodegen from 'escodegen'; -import evalESTreeExpr from 'eval-estree-expression'; -const { evaluate } = evalESTreeExpr; - -import { AutoComplete } from './autocomplete'; -import { ExpressionError } from './errors'; -import type { SymbolsTable } from './symbols'; -import type { TemplatePart } from './template'; -import { parseTemplate as parseTemplateParts } from './template'; -import type { ExpressionAutocompleteResults, ExpressionParserResult, Logger } from './types'; -import { formatExpressionResult } from './utils'; - -export class ExpressionRuntime { - #parserOptions: AcornOptions; - #autocompleter: AutoComplete; - #logger: Logger; - - constructor(logger: Logger = console) { - this.#parserOptions = { - ecmaVersion: 'latest', - sourceType: 'script', - allowHashBang: false, - locations: true, - }; - this.#autocompleter = new AutoComplete(this, logger); - this.#logger = logger; - } - - /** - * Evaluates an expression based on the given inputs/context. - */ - public evaluate(expr: string, inputs: object): unknown { - try { - const parsed = this.parse(expr); - - if (parsed.invalidNodes.length > 0) { - throw new ExpressionError('Invalid nodes found when parsing'); - } - - return evaluate.sync (parsed.result, inputs, { - functions: true, - withMembers: true, - generate: escodegen.generate, - }); - } catch (error) { - throw error instanceof Error - ? new ExpressionError(error.message) - : new ExpressionError('Unexpected error'); - } - } - - /** - * Evaluates an expression safely by returning the error instead of throwing when invalid. - */ - public safeEvaluate( - expr: string, - inputs: object - ): { value: unknown; error?: undefined } | { value?: undefined; error: ExpressionError } { - try { - const value = this.evaluate(expr, inputs); - return { - value, - }; - } catch (error) { - this.#logger.error(`Error while evaluating expression ${expr}`, error); - - if (error instanceof ExpressionError) { - return { - value: undefined, - error, - }; - } - - return { - value: undefined, - error: - error instanceof Error - ? new ExpressionError(error.message) - : new ExpressionError('Unexpected error'), - }; - } - } - - /** - * Evaluates a condition safely to a boolean. - */ - public evaluateBoolean(expr: string, inputs: object): boolean { - if (expr.trim().length === 0) { - return true; - } - - const evalResult = this.safeEvaluate(expr, inputs); - - if (typeof evalResult.error !== 'undefined') { - return false; - } - - return Boolean(evalResult.value); - } - - /** - * Evaluates an array of conditions as a single logical expression. - * The function treats the conditions as if they were joined by an AND operator, - * meaning the evaluation returns `true` only if all conditions are truthy. - */ - public evaluateBooleanAll(expressions: string[], inputs: object): boolean { - if (expressions.length === 0) { - return true; - } - - return expressions.every((expression) => this.evaluateBoolean(expression, inputs)); - } - - /** - * Parse a template and validate all embedded expressions. - */ - public parseTemplate(template: string): { parts: TemplatePart[]; errors: ExpressionError[] } { - const parts = parseTemplateParts(template); - const errors: ExpressionError[] = []; - - for (const part of parts) { - if (part.type === 'expression') { - try { - const { invalidNodes } = this.parse(part.value); - if (invalidNodes.length > 0) { - errors.push(new ExpressionError('Invalid expression')); - } - } catch (error) { - errors.push(error as ExpressionError); - } - } - } - - return { parts, errors }; - } - - /** - * Evaluate a template string containing `{{ expression }}` placeholders. - */ - public evaluateTemplate(template: string, inputs: object): string { - const { parts } = this.parseTemplate(template); - - return parts - .map((part) => { - if (part.type === 'text') { - return part.value; - } - const result = this.evaluate(part.value, inputs); - return formatExpressionResult(result, ''); - }) - .join(''); - } - - /** - * Parses a binary expression and returns an @ExpressionParserResult. - */ - public parse( - expr: string, - options: { loose?: boolean } = { - loose: false, - } - ): ExpressionParserResult { - try { - const ast = options.loose - ? parseLoose(expr, { ...this.#parserOptions }) - : parse(expr, { ...this.#parserOptions }); - - if (!ast.body || ast.body.length === 0) { - throw new ExpressionError('Empty or invalid expression'); - } - - // Extract the first expression statement that we find - const firstExprIndex = ast.body.findIndex((node) => isParsedExpressionStatement(node)); - const [statement] = ast.body.splice(firstExprIndex, 1); - - if (!statement || !isParsedExpressionStatement(statement)) { - throw new ExpressionError('Empty or invalid expression'); - } - - // Return information on the other nodes as invalid nodes - const invalidNodes = ast.body.filter(filterOutModuleDeclarationStatement); - - return { - result: statement.expression, - invalidNodes, - }; - } catch (error) { - if (error instanceof SyntaxError) { - throw createExpressionErrorFromSyntaxError(expr, error); - } - if (error instanceof ExpressionError) { - throw error; - } - throw new ExpressionError('Unexpected error'); - } - } - - /** - * Provides autocomplete suggestions for the given expression at the provided cursor offset. - */ - public autocomplete( - expr: string, - cursorOffset: number, - context: SymbolsTable - ): ExpressionAutocompleteResults { - const suggestions = this.#autocompleter.getSuggestions(expr, cursorOffset, context); - - return { suggestions }; - } - - public generate(_node: Expression): string { - throw new Error('Not yet implemented'); - } -} - -function createExpressionErrorFromSyntaxError( - code: string, - error: SyntaxError & { loc?: Position } -): ExpressionError { - const loc = error.loc; - - if (!loc) { - return new ExpressionError(error.message); - } - - const errorMessage = `${error.message.replace(/\s*\(\d+:\d+\)$/, '')} at ${code.split('\n').length > 1 ? `line ${loc.line}, ` : ''}char ${loc.column}`; - const token = getTokenAtLoc(code, loc); - - if (!token) { - return new ExpressionError(errorMessage, loc); - } - - return new ExpressionError(errorMessage, loc, token); -} -function getTokenAtLoc(code: string, errorLoc: Position): Token | undefined { - const tokens = tokenizer(code, { - ecmaVersion: 'latest', - locations: true, - }); - - try { - for (const token of tokens) { - if (!token.loc) { - continue; - } - - const { start, end } = token.loc; - - const onSameLine = errorLoc.line === start.line; - const inColumnRange = errorLoc.column >= start.column && errorLoc.column < end.column; - - if (onSameLine && inColumnRange) { - return token; - } - } - } catch (_error) { - return undefined; - } - - return undefined; -} - -function isParsedExpressionStatement( - statement: Program['body'][number] -): statement is ExpressionStatement { - return statement.type === 'ExpressionStatement'; -} - -export function filterOutModuleDeclarationStatement( - statement: Program['body'][number] -): statement is ExpressionStatement { - return ![ - 'ImportDeclaration', - 'ExportNamedDeclaration', - 'ExportDefaultDeclaration', - 'ExportAllDeclaration', - ].includes(statement.type); -} diff --git a/packages/expr/src/symbols/__tests__/symbols.test.ts b/packages/expr/src/symbols/__tests__/symbols.test.ts deleted file mode 100644 index 16a4abeef5..0000000000 --- a/packages/expr/src/symbols/__tests__/symbols.test.ts +++ /dev/null @@ -1,497 +0,0 @@ -import { describe, expect, it } from 'bun:test'; - -import { SymbolArray, SymbolObject, SymbolString } from '../symbols'; -import { SymbolsTable } from '../symbols-table'; -import type { SymbolType } from '../types'; - -describe('ExpressionRuntime', () => { - const initialSymbols = { - visitor: SymbolObject({ - name: 'visitor', - properties: { - claims: SymbolObject({ - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: SymbolString({ name: 'key' }), - flags: SymbolObject({ - name: 'flags', - properties: { - FLAG1: SymbolString({ name: 'FLAG1' }), - FLAG2: SymbolString({ name: 'FLAG2' }), - FLAG3: SymbolString({ name: 'FLAG3' }), - }, - methods: [], - }), - hello: SymbolArray({ - name: 'hello', - description: 'An array of string', - items: SymbolString(), - }), - }, - methods: [], - }), - }, - methods: [], - }), - }; - describe('addSymbols', () => { - it('should the symbols matching the provided object to the table', () => { - const symbolsTable = new SymbolsTable(initialSymbols); - - expect(symbolsTable.getSymbolInfo(['visitor'])).toMatchObject({ - definition: { - type: 'object', - name: 'visitor', - properties: { - claims: { - type: 'object', - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: { - type: 'string', - name: 'key', - }, - flags: { - type: 'object', - name: 'flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - hello: { - type: 'array', - name: 'hello', - description: 'An array of string', - items: { - type: 'string', - }, - }, - }, - methods: [], - }, - }, - methods: [], - }, - ref: 'visitor', - childrenRefs: ['visitor.claims'], - }); - - symbolsTable.addSymbols({ - space: SymbolObject({ - name: 'space', - properties: { - id: SymbolString({ name: 'id' }), - title: SymbolString({ name: 'title' }), - }, - methods: [], - }), - }); - - expect(symbolsTable.getSymbolInfo(['space'])).toMatchObject({ - definition: { - type: 'object', - name: 'space', - properties: { - id: { - type: 'string', - name: 'id', - }, - title: { - type: 'string', - name: 'title', - }, - }, - methods: [], - }, - ref: 'space', - childrenRefs: ['space.id', 'space.title'], - }); - }); - }); - - describe('Symbols standard library', () => { - it('should allow to access methods & properties defined as part of the standard library', () => { - const symbolsTable = new SymbolsTable({ - id: SymbolString({ name: 'id' }), - title: SymbolString({ name: 'title' }), - }); - - expect( - symbolsTable.getSymbolInfo ('id')?.definition.properties.length - ).toMatchObject({ - type: 'number', - name: 'length', - description: - 'The length data property of a String value contains the length of the string in UTF-16 code units.', - }); - }); - }); - - describe('getSymbolInfo', () => { - it('should add the symbols matching the initial symbol definition passed to the constructor', () => { - const symbolsTable = new SymbolsTable(initialSymbols); - - expect(symbolsTable.getSymbolInfo(['visitor'])).toMatchObject({ - definition: { - type: 'object', - name: 'visitor', - properties: { - claims: { - type: 'object', - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: { - type: 'string', - name: 'key', - }, - flags: { - type: 'object', - name: 'flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - hello: { - type: 'array', - name: 'hello', - description: 'An array of string', - items: { - type: 'string', - }, - }, - }, - methods: [], - }, - }, - methods: [], - }, - ref: 'visitor', - childrenRefs: ['visitor.claims'], - }); - - expect(symbolsTable.getSymbolInfo(['visitor', 'claims'])).toMatchObject({ - definition: { - type: 'object', - name: 'claims', - description: 'The claims contained in the visitor JWT token', - properties: { - key: { - type: 'string', - name: 'key', - }, - flags: { - type: 'object', - name: 'flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - hello: { - type: 'array', - name: 'hello', - description: 'An array of string', - items: { - type: 'string', - }, - }, - }, - methods: [], - }, - ref: 'visitor.claims', - parentRef: 'visitor', - childrenRefs: [ - 'visitor.claims.key', - 'visitor.claims.flags', - 'visitor.claims.hello', - ], - }); - - expect(symbolsTable.getSymbolInfo(['visitor', 'claims', 'key'])).toMatchObject({ - definition: { - type: 'string', - name: 'key', - }, - ref: 'visitor.claims.key', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.key.length', - 'visitor.claims.key.at', - 'visitor.claims.key.endsWith', - 'visitor.claims.key.includes', - ], - }); - - expect(symbolsTable.getSymbolInfo(['visitor', 'claims', 'flags'])).toMatchObject({ - definition: { - type: 'object', - name: 'flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - ref: 'visitor.claims.flags', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.flags.FLAG1', - 'visitor.claims.flags.FLAG2', - 'visitor.claims.flags.FLAG3', - ], - }); - - expect( - symbolsTable.getSymbolInfo(['visitor', 'claims', 'flags', 'FLAG1']) - ).toMatchObject({ - definition: { - type: 'string', - name: 'FLAG1', - }, - ref: 'visitor.claims.flags.FLAG1', - parentRef: 'visitor.claims.flags', - childrenRefs: [ - 'visitor.claims.flags.FLAG1.length', - 'visitor.claims.flags.FLAG1.at', - 'visitor.claims.flags.FLAG1.endsWith', - 'visitor.claims.flags.FLAG1.includes', - ], - }); - - expect( - symbolsTable.getSymbolInfo(['visitor', 'claims', 'flags', 'FLAG2']) - ).toMatchObject({ - definition: { - type: 'string', - name: 'FLAG2', - }, - ref: 'visitor.claims.flags.FLAG2', - parentRef: 'visitor.claims.flags', - childrenRefs: [ - 'visitor.claims.flags.FLAG2.length', - 'visitor.claims.flags.FLAG2.at', - 'visitor.claims.flags.FLAG2.endsWith', - 'visitor.claims.flags.FLAG2.includes', - ], - }); - - expect(symbolsTable.getSymbolInfo(['visitor', 'claims', 'hello'])).toMatchObject({ - definition: { - type: 'array', - name: 'hello', - description: 'An array of string', - items: { - type: 'string', - }, - }, - ref: 'visitor.claims.hello', - parentRef: 'visitor.claims', - childrenRefs: [ - 'visitor.claims.hello.length', - 'visitor.claims.hello.at', - 'visitor.claims.hello.includes', - 'visitor.claims.hello.some', - 'visitor.claims.hello.every', - ], - }); - }); - }); - - describe('inferSymbolFromValue', () => { - it('should infer properly a symbol based on a value', () => { - const symbolDef = SymbolsTable.inferSymbolFromValue( - { - visitor: { - claims: { - key: 'test', - flags: { - FLAG1: 'testflag1', - FLAG2: 'testflag2', - FLAG3: 'testflag3', - }, - hello: ['test', 'test1', 'test2'], - }, - }, - }, - 'context' - ); - expect(symbolDef).toMatchObject({ - type: 'object', - name: 'context', - properties: { - visitor: { - type: 'object', - name: 'visitor', - properties: { - claims: { - type: 'object', - name: 'claims', - properties: { - key: { - type: 'string', - name: 'key', - }, - flags: { - type: 'object', - name: 'flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - hello: { - type: 'array', - name: 'hello', - items: { - type: 'string', - }, - }, - }, - methods: [], - }, - }, - methods: [], - }, - }, - methods: [], - }); - }); - }); - - describe('inferSymbolFromJSONSchema', () => { - it('should infer properly a symbol table based on a JSON schema', () => { - const symbolDef = SymbolsTable.inferSymbolFromJSONSchema( - { - type: 'object', - description: `The attributes tied to a site's visitor.`, - properties: { - claims: { - type: 'object', - properties: { - key: { - type: 'string', - }, - flags: { - type: 'object', - description: 'The user feature flags', - properties: { - FLAG1: { type: 'string' }, - FLAG2: { type: 'string' }, - FLAG3: { type: 'string' }, - }, - }, - hello: { - type: 'string', - enum: ['test', 'test1', 'test2'], - }, - }, - }, - }, - }, - 'visitor' - ); - expect(symbolDef).toMatchObject({ - type: 'object', - name: 'visitor', - description: `The attributes tied to a site's visitor.`, - properties: { - claims: { - type: 'object', - name: 'claims', - properties: { - key: { - type: 'string', - name: 'key', - }, - flags: { - type: 'object', - name: 'flags', - description: 'The user feature flags', - properties: { - FLAG1: { - type: 'string', - name: 'FLAG1', - }, - FLAG2: { - type: 'string', - name: 'FLAG2', - }, - FLAG3: { - type: 'string', - name: 'FLAG3', - }, - }, - methods: [], - }, - hello: { - type: 'string', - enum: ['test', 'test1', 'test2'], - }, - }, - methods: [], - }, - }, - methods: [], - }); - }); - }); -}); diff --git a/packages/expr/src/symbols/index.ts b/packages/expr/src/symbols/index.ts deleted file mode 100644 index 0ad1b5b54b..0000000000 --- a/packages/expr/src/symbols/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './symbols'; -export * from './symbols-table'; -export * from './types'; diff --git a/packages/expr/src/symbols/symbols-table.ts b/packages/expr/src/symbols/symbols-table.ts deleted file mode 100644 index baa8bf3191..0000000000 --- a/packages/expr/src/symbols/symbols-table.ts +++ /dev/null @@ -1,350 +0,0 @@ -import type { JSONSchema7 } from 'json-schema'; - -import { filterOutNullable } from '../utils'; -import { - SymbolArray, - SymbolBoolean, - SymbolNull, - SymbolNumber, - SymbolObject, - SymbolString, - SymbolUndefined, -} from './symbols'; -import { - type ExtractSymbolDef, - type GenericSymbolDef, - type ObjectSymbolDef, - SymbolType, - type SymbolWithMethods, - type SymbolWithProperties, - resolveSymbolDef, -} from './types'; - -export interface SymbolInfo { - /** - * Definition of the symbol. - */ - definition: ExtractSymbolDef ; - - /** - * Reference of the symbol in the table of symbols. - */ - ref: string; - - /** - * Stores the reference to the parent symbol. - */ - parentRef?: string; - - /** - * Stores the reference to the children symbols. - */ - childrenRefs?: string[]; -} - -export class SymbolError extends Error { - constructor(message: string) { - super(message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, SymbolError); - } - this.name = 'SymbolError'; - } -} - -export class SymbolsTable { - /** - * Internal table that keeps track of all symbols reference. - */ - #table: Record ; - - /** - * Internal table that keep track of the raw symbols definitions. - */ - #rawSymbols: Record ; - - constructor(initialContext: Record = {}) { - this.#table = {}; - this.#rawSymbols = {}; - this.addSymbols(initialContext); - } - - /** - * Create a new symbols table by merging the current one with the provided one. - */ - merge(other: SymbolsTable): SymbolsTable { - return new SymbolsTable({ - ...this.#rawSymbols, - ...other.#rawSymbols, - }); - } - - toString() { - return JSON.stringify(this.#table, null, 2); - } - - /** - * Infer the symbol of a value and generate the appropriate symbol definition. - */ - static inferSymbolFromValue(value: unknown, name?: string): ExtractSymbolDef { - if (Array.isArray(value)) { - if (value.length === 0) { - return SymbolArray({ items: SymbolUndefined() }); - } - - const firstItemSymbol = SymbolsTable.inferSymbolFromValue(value.at(0)); - // Check that the array is not a mixin of different items types. - if (value.length > 1) { - const secondItemSymbol = SymbolsTable.inferSymbolFromValue(value.at(1)); - if (firstItemSymbol.type !== secondItemSymbol.type) { - throw new SymbolError('Array with mixin items types are not supported'); - } - } - return SymbolArray({ name, items: firstItemSymbol }); - } - - if (typeof value === 'undefined') { - return SymbolUndefined({ name }); - } - - if (value === null) { - return SymbolNull({ name }); - } - - const valueType = typeof value; - switch (valueType) { - case 'string': - return SymbolString({ name }); - case 'number': - return SymbolNumber({ name }); - case 'boolean': - return SymbolBoolean({ name }); - case 'object': { - const properties = Object.entries(value).reduce >( - (prev, [name, val]) => { - prev[name] = SymbolsTable.inferSymbolFromValue(val, name); - return prev; - }, - {} - ); - return SymbolObject({ name, properties, methods: [] }); - } - default: - throw new SymbolError(`Unsupported symbol type ${valueType}`); - } - } - - /** - * Infer a table of symbol based on a JSON schema object describing it. - */ - static inferSymbolFromJSONSchema( - schema: JSONSchema7, - name?: string - ): ExtractSymbolDef { - switch (schema.type) { - case 'string': - return SymbolString({ - name, - ...(schema.description ? { description: schema.description } : {}), - ...(schema.enum - ? { - enum: schema.enum - .filter(filterOutNullable) - .map((enumValue) => enumValue.toString()), - } - : {}), - }); - case 'number': - case 'integer': - return SymbolNumber({ - name, - ...(schema.description ? { description: schema.description } : {}), - }); - case 'boolean': - return SymbolBoolean({ - name, - ...(schema.description ? { description: schema.description } : {}), - }); - case 'null': - return SymbolNull({ - name, - ...(schema.description ? { description: schema.description } : {}), - }); - case 'object': - return SymbolsTable.#buildObjectSymbolFromJSONSchemaObject(schema, name); - case 'array': - return SymbolsTable.#buildArraySymbolFromJSONSchemaArray(schema, name); - default: - throw new Error(`Unsupported schema type: ${schema.type}`); - } - } - - static #buildObjectSymbolFromJSONSchemaObject( - schema: JSONSchema7, - name?: string - ): ObjectSymbolDef { - const properties: Record = {}; - - if (schema.properties) { - Object.entries(schema.properties).forEach(([propertyName, propertySchema]) => { - properties[propertyName] = SymbolsTable.inferSymbolFromJSONSchema( - propertySchema as JSONSchema7, - propertyName - ); - }); - } - - return SymbolObject({ - name, - properties, - ...(schema.description ? { description: schema.description } : {}), - methods: [], - }); - } - - static #buildArraySymbolFromJSONSchemaArray( - schema: JSONSchema7, - name?: string - ): ExtractSymbolDef { - if (schema.items) { - const itemSymbol = SymbolsTable.inferSymbolFromJSONSchema( - schema.items as JSONSchema7, - `${name || ''}_item` - ); - return SymbolArray({ - name, - ...(schema.description ? { description: schema.description } : {}), - items: itemSymbol, - }); - } - - return SymbolArray({ - name, - ...(schema.description ? { description: schema.description } : {}), - items: SymbolUndefined(), - }); - } - - private generateSymbolRefPath(path: string[]): string { - return path.join('.'); - } - - /** - * Add a single symbol to the table at the provided path. - */ - private addSymbol(path: string[], definition: GenericSymbolDef, raw = false): void { - const fullPath = this.generateSymbolRefPath(path); - const parentPath = path.slice(0, -1).join('.'); - - if (this.#table[fullPath]) { - throw new SymbolError(`Symbol "${fullPath}" already exists.`); - } - - if (raw) { - this.#rawSymbols[fullPath] = definition; - } - - // Add the new symbol linking it to its parent - this.#table[fullPath] = { - definition: resolveSymbolDef(definition), - ref: fullPath, - parentRef: parentPath || undefined, - childrenRefs: [], - }; - - if (parentPath && this.#table[parentPath]) { - if (this.#table[parentPath].childrenRefs) { - this.#table[parentPath].childrenRefs.push(fullPath); - } - } - - // Add any nested symbols if the value is a symbol with properties... - if (isSymbolWithProperties(definition)) { - Object.entries(definition.properties).forEach(([propKey, propSymbol]) => { - if (isObjectSymbol(propSymbol)) { - this.addSymbols({ [propKey]: propSymbol }, path, false); - } else { - this.addSymbol([...path, propKey], propSymbol, false); - } - }); - } - - // ...or a symbol with methods - if (isSymbolWithMethods(definition)) { - definition.methods.forEach((methodSymbol) => { - this.addSymbol([...path, methodSymbol.name], methodSymbol, false); - }); - } - } - - /** - * Add the provided object of symbols definitions to the symbol table. - */ - public addSymbols( - symbols: Record , - prefix: string[] = [], - raw = true - ): void { - for (const [key, symbolDef] of Object.entries(symbols)) { - const path = [...prefix, key]; - - // Add the current symbol to the table. - this.addSymbol(path, symbolDef, raw); - } - } - - /** - * Get a symbol's information using its path in the table. - */ - public getSymbolInfo (path: string | string[]): SymbolInfo | undefined { - const key = Array.isArray(path) ? path.join('.') : path; - const info = this.#table[key]; - return info ? typedSymbolInfo(info) : undefined; - } - - /** - * Get all symbol keys matching the pattern defined by the provided path. - */ - public getMatchingSymbolsKeys(path: string[]): string[] { - const wildcardRegex = new RegExp( - `^${path - .map((segment) => { - if (segment.includes('*')) { - return `${segment.split('*')[0]}([^.]+)?`; - } - return segment; - }) - .join('\\.')}$` - ); - - return Object.keys(this.#table) - .filter((key) => wildcardRegex.test(key)) - .filter(filterOutNullable); - } -} - -function isObjectSymbol(symbol: GenericSymbolDef): symbol is ObjectSymbolDef { - return symbol.type === SymbolType.Object; -} - -function isSymbolWithProperties(symbol: GenericSymbolDef): symbol is SymbolWithProperties { - return ( - symbol.type === SymbolType.Object || - symbol.type === SymbolType.Array || - symbol.type === SymbolType.String - ); -} - -function isSymbolWithMethods(symbol: GenericSymbolDef): symbol is SymbolWithMethods { - return ( - symbol.type === SymbolType.Object || - symbol.type === SymbolType.Array || - symbol.type === SymbolType.String - ); -} - -function typedSymbolInfo (info: SymbolInfo): SymbolInfo { - const definition = resolveSymbolDef(info.definition); - return { ...info, definition } as SymbolInfo ; -} diff --git a/packages/expr/src/symbols/symbols.ts b/packages/expr/src/symbols/symbols.ts deleted file mode 100644 index 78ab9d2f0e..0000000000 --- a/packages/expr/src/symbols/symbols.ts +++ /dev/null @@ -1,322 +0,0 @@ -import { - type ArraySymbolDef, - type BooleanSymbolDef, - type ExtractSymbolDef, - type FunctionSymbolDef, - type GenericSymbolDef, - type NullSymbolDef, - type NumberSymbolDef, - type ObjectSymbolDef, - type StringSymbolDef, - SymbolType, - type SymbolsWithPropertiesAndMethods, - type UndefinedSymbolDef, - type UnionSymbolDef, -} from './types'; - -export function SymbolBoolean(args: Omit = {}): BooleanSymbolDef { - return { - type: SymbolType.Boolean, - ...args, - }; -} - -export function SymbolNumber(args: Omit = {}): NumberSymbolDef { - return { - type: SymbolType.Number, - ...args, - }; -} - -export function SymbolString( - args: Omit = {} -): StringSymbolDef { - return createSymbolWithPropertiesAndMethods (SymbolType.String, args); -} - -export function SymbolObject(args: Omit ): ObjectSymbolDef { - return { - type: SymbolType.Object, - ...args, - }; -} - -export function SymbolArray( - args: Omit -): ArraySymbolDef { - return createSymbolWithPropertiesAndMethods(SymbolType.Array, args); -} - -export function SymbolFunction(args: Omit ): FunctionSymbolDef { - return { - type: SymbolType.Function, - ...args, - }; -} - -export function OptionalFunctionArg( - optionalArg: ExtractSymbolDef -): ExtractSymbolDef & { optional: true } { - return { - ...optionalArg, - optional: true, - }; -} - -export function SymbolUnion(args: Omit ): UnionSymbolDef { - return { - type: SymbolType.Union, - ...args, - }; -} - -export function SymbolUndefined(args: Omit = {}): UndefinedSymbolDef { - return { - type: SymbolType.Undefined, - ...args, - }; -} - -export function SymbolNull(args: Omit = {}): NullSymbolDef { - return { - type: SymbolType.Null, - ...args, - }; -} - -function createSymbolWithPropertiesAndMethods< - T extends SymbolsWithPropertiesAndMethods & { type: SymbolType }, ->(type: T['type'], args: Omit ): T { - const symbol = { type, ...args } as T; - - Object.defineProperty(symbol, 'properties', { - get() { - if (symbol.type === SymbolType.Array) { - return isArraySymbol(symbol) - ? StandardLibrary[SymbolType.Array]?.(symbol).properties - : {}; - } - return StandardLibrary[symbol.type]?.properties || {}; - }, - }); - - Object.defineProperty(symbol, 'methods', { - get() { - if (symbol.type === SymbolType.Array) { - return isArraySymbol(symbol) - ? StandardLibrary[SymbolType.Array]?.(symbol).methods - : []; - } - return StandardLibrary[symbol.type]?.methods || []; - }, - }); - - return symbol; -} - -// TODO-ADAPTIVE-CONTENT: extend the definition of the supported standard library methods and properties. - -const StandardLibrary: Partial< - { - [key in Exclude ]: { - properties: Record ; - methods: FunctionSymbolDef[]; - }; - } & { - [SymbolType.Array]: (symbol: ArraySymbolDef) => { - properties: Record ; - methods: FunctionSymbolDef[]; - }; - } -> = { - [SymbolType.String]: { - properties: { - length: SymbolNumber({ - name: 'length', - description: - 'The length data property of a String value contains the length of the string in UTF-16 code units.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length', - }), - }, - methods: [ - SymbolFunction({ - name: 'at', - description: `Takes an integer value and returns the item at that index, allowing for positive and negative integers. - Negative integers count back from the last item in the string.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at', - args: [ - SymbolNumber({ - name: 'index', - description: 'The index (position) of the string character to be returned', - }), - ], - returns: SymbolUnion({ - description: `A String consisting of the single UTF-16 code unit located at the specified position. - Returns undefined if the given index can not be found.`, - members: [SymbolString(), SymbolUndefined()], - }), - }), - SymbolFunction({ - name: 'endsWith', - description: `Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding - elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith', - args: [ - SymbolString({ - name: 'searchString', - description: `The characters to be searched for at the end of str. Cannot be a regex. - All values that are not regexes are coerced to strings, so omitting it or passing undefined causes endsWith() to search for - the string "undefined", which is rarely what you want.`, - }), - OptionalFunctionArg( - SymbolNumber({ - name: 'endPosition', - description: `The end position at which searchString is expected to be found - (the index of searchString's last character plus 1). Defaults to str.length.`, - }) - ), - ], - returns: SymbolBoolean({ - description: `true if the given characters are found at the end of the string, including when searchString is an empty string; - otherwise, false.`, - }), - }), - SymbolFunction({ - name: 'includes', - description: `Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions - that are greater than or equal to position; otherwise, returns false.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes', - args: [ - SymbolString({ - name: 'searchString', - description: `A string to be searched for within str. Cannot be a regex. All values that are not regexes are coerced to strings, so omitting it - or passing undefined causes includes() to search for the string "undefined", which is rarely what you want.`, - }), - OptionalFunctionArg( - SymbolNumber({ - name: 'position', - description: - 'The position within the string at which to begin searching for searchString. (Defaults to 0.)', - }) - ), - ], - returns: SymbolBoolean({ - description: `true if the search string is found anywhere within the given string, including when searchString is an empty string; - otherwise, false.`, - }), - }), - ], - }, - [SymbolType.Array]: (arraySymbolDef: ArraySymbolDef) => ({ - properties: { - length: SymbolNumber({ - name: 'length', - description: `The length data property of an Array instance represents the number of elements in that array. - The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length', - }), - }, - methods: [ - SymbolFunction({ - name: 'at', - description: `Takes an integer value and returns the item at that index, allowing for positive and negative integers. - Negative integers count back from the last item in the array.`, - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at', - args: [ - SymbolNumber({ - name: 'index', - description: `Zero-based index of the array element to be returned, converted to an integer. - Negative index counts back from the end of the array — if index < 0, index + array.length is accessed.`, - }), - ], - returns: SymbolUnion({ - description: `The element in the array matching the given index. Always returns undefined if index < -array.length or index >= array.length - without attempting to access the corresponding property.`, - members: [arraySymbolDef.items, SymbolUndefined()], - }), - }), - SymbolFunction({ - name: 'includes', - description: - 'Determines whether an array includes a certain value among its entries, returning true or false as appropriate.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes', - args: [ - { - ...arraySymbolDef.items, - name: 'searchElement', - description: 'The value to be searched for within the array.', - }, - OptionalFunctionArg( - SymbolNumber({ - name: 'fromIndex', - description: - 'The position within the string at which to begin searching for searchString. (Defaults to 0.)', - }) - ), - ], - returns: SymbolBoolean({ - description: - 'true if the value searchElement is found within the array (or the part of the array indicated by the index fromIndex, if specified).', - }), - }), - SymbolFunction({ - name: 'some', - description: - 'Tests whether at least one element in the array passes the test implemented by the provided function.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some', - args: [ - SymbolFunction({ - name: 'callback', - description: 'A function that tests each element of the array.', - args: [ - { - ...arraySymbolDef.items, - name: 'element', - description: 'The current element being processed in the array.', - }, - ], - returns: SymbolBoolean({ - description: - 'true if the callback function returns a truthy value for at least one element in the array.', - }), - }), - ], - returns: SymbolBoolean({ - description: - 'true if the callback function returns a truthy value for at least one element in the array.', - }), - }), - SymbolFunction({ - name: 'every', - description: - 'Tests whether all elements in the array pass the test implemented by the provided function.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every', - args: [ - SymbolFunction({ - name: 'callback', - description: 'A function that tests each element of the array.', - args: [ - { - ...arraySymbolDef.items, - name: 'element', - description: 'The current element being processed in the array.', - }, - ], - returns: SymbolBoolean({ - description: - 'true if the callback function returns a truthy value for all elements in the array.', - }), - }), - ], - returns: SymbolBoolean({ - description: - 'true if the callback function returns a truthy value for all elements in the array.', - }), - }), - ], - }), -}; - -function isArraySymbol(symbol: GenericSymbolDef): symbol is ArraySymbolDef { - return symbol.type === SymbolType.Array; -} diff --git a/packages/expr/src/symbols/types.ts b/packages/expr/src/symbols/types.ts deleted file mode 100644 index 401f094689..0000000000 --- a/packages/expr/src/symbols/types.ts +++ /dev/null @@ -1,193 +0,0 @@ -import type { MandateProps } from '../utils'; - -export enum SymbolType { - Boolean = 'boolean', - Number = 'number', - String = 'string', - Object = 'object', - Array = 'array', - Function = 'function', - Union = 'union', - Undefined = 'undefined', - Null = 'null', -} - -export interface SymbolMetadata { - /** - * Long description of the symbol. - */ - description?: string; - - /** - * Link to a documentation/manual page. - */ - link?: string; -} - -export interface GenericSymbolDef extends SymbolMetadata { - /** - * Type of the symbol. - */ - type: SymbolType; - - /** - * Name of the symbol. - */ - name?: string; -} - -export interface SymbolWithProperties extends GenericSymbolDef { - /** - * Properties on the symbol type. - */ - properties: Record ; -} - -export interface SymbolWithMethods extends GenericSymbolDef { - /** - * Methods that can be called on the symbol type. - */ - methods: FunctionSymbolDef[]; -} - -export interface BooleanSymbolDef extends GenericSymbolDef { - type: SymbolType.Boolean; -} - -export interface NumberSymbolDef extends GenericSymbolDef { - type: SymbolType.Number; -} - -export interface StringSymbolDef extends SymbolWithProperties, SymbolWithMethods { - type: SymbolType.String; - - /** - * Set of enumerated values that the string symbol is retristred to. - */ - enum?: string[]; - - /** - * Properties on strings. - */ - properties: { - length: NumberSymbolDef; - }; -} - -export interface ObjectSymbolDef extends SymbolWithProperties, SymbolWithMethods { - type: SymbolType.Object; -} - -export interface ArraySymbolDef extends SymbolWithProperties, SymbolWithMethods { - type: SymbolType.Array; - - /** - * Symbol representing the type of the items of the array - */ - items: ExtractSymbolDef ; - - /** - * Properties on arrays. - */ - properties: { - length: NumberSymbolDef; - }; -} - -export interface FunctionSymbolDef extends MandateProps { - type: SymbolType.Function; - - /** - * Symbols describing the arguments of the function. - */ - args: (ExtractSymbolDef & { optional?: boolean })[]; - - /** - * Symbol describing the returned value of the function. - */ - returns: ExtractSymbolDef ; -} - -export interface UnionSymbolDef extends GenericSymbolDef { - type: SymbolType.Union; - - /** - * Symbols composing the union. - */ - members: ExtractSymbolDef []; -} - -export interface UndefinedSymbolDef extends GenericSymbolDef { - type: SymbolType.Undefined; -} - -export interface NullSymbolDef extends GenericSymbolDef { - type: SymbolType.Null; -} - -export type SymbolsWithPropertiesAndMethods = ArraySymbolDef | ObjectSymbolDef | StringSymbolDef; - -export type ExtractSymbolDef = T extends SymbolType.String - ? StringSymbolDef - : T extends SymbolType.Number - ? NumberSymbolDef - : T extends SymbolType.Boolean - ? BooleanSymbolDef - : T extends SymbolType.Array - ? ArraySymbolDef - : T extends SymbolType.Object - ? ObjectSymbolDef - : T extends SymbolType.Function - ? FunctionSymbolDef - : T extends SymbolType.Union - ? UnionSymbolDef - : T extends SymbolType.Undefined - ? UndefinedSymbolDef - : T extends SymbolType.Null - ? NullSymbolDef - : never; - -export function resolveSymbolDef( - symbol: GenericSymbolDef -): - | StringSymbolDef - | NumberSymbolDef - | BooleanSymbolDef - | ArraySymbolDef - | ObjectSymbolDef - | FunctionSymbolDef - | UnionSymbolDef - | UndefinedSymbolDef - | NullSymbolDef { - switch (symbol.type) { - case SymbolType.String: - return symbol as StringSymbolDef; - - case SymbolType.Number: - return symbol as NumberSymbolDef; - - case SymbolType.Boolean: - return symbol as BooleanSymbolDef; - - case SymbolType.Array: - return symbol as ArraySymbolDef; - - case SymbolType.Object: - return symbol as ObjectSymbolDef; - - case SymbolType.Function: - return symbol as FunctionSymbolDef; - - case SymbolType.Union: - return symbol as UnionSymbolDef; - - case SymbolType.Undefined: - return symbol as UndefinedSymbolDef; - - case SymbolType.Null: - return symbol as NullSymbolDef; - - default: - throw new Error(`Unknown symbol type: ${symbol.type}`); - } -} diff --git a/packages/expr/src/template.ts b/packages/expr/src/template.ts deleted file mode 100644 index e71012c2cc..0000000000 --- a/packages/expr/src/template.ts +++ /dev/null @@ -1,57 +0,0 @@ -export type TemplateText = { - type: 'text'; - value: string; - start: number; - end: number; -}; - -export type TemplateExpression = { - type: 'expression'; - value: string; - start: number; // Start index of the expression content (after `{{`) - end: number; // End index of the expression content (before `}}`) -}; - -export type TemplatePart = TemplateText | TemplateExpression; - -/** - * Parse a template string containing `{{ expression }}` placeholders. - */ -export function parseTemplate(template: string): TemplatePart[] { - const parts: TemplatePart[] = []; - const regex = /\{\{(.*?)\}\}/gs; - let lastIndex = 0; - - for (const match of template.matchAll(regex)) { - const matchStart = match.index ?? 0; - const matchEnd = matchStart + match[0].length; - - if (matchStart > lastIndex) { - parts.push({ - type: 'text', - value: template.slice(lastIndex, matchStart), - start: lastIndex, - end: matchStart, - }); - } - - parts.push({ - type: 'expression', - value: (match[1] ?? '').trim(), - start: matchStart + 2, - end: matchEnd - 2, - }); - lastIndex = matchEnd; - } - - if (lastIndex < template.length) { - parts.push({ - type: 'text', - value: template.slice(lastIndex), - start: lastIndex, - end: template.length, - }); - } - - return parts; -} diff --git a/packages/expr/src/types.ts b/packages/expr/src/types.ts deleted file mode 100644 index 7d721480a1..0000000000 --- a/packages/expr/src/types.ts +++ /dev/null @@ -1,176 +0,0 @@ -import type { BinaryOperator, Expression, ExpressionStatement, LogicalOperator } from 'acorn'; - -import type { ArraySymbolDef, SymbolInfo, SymbolType } from './symbols'; - -export interface ExpressionGenerator { - /** - * Converts an ESTree compatible AST node into a string representing the corresponding expression. - */ - generate(node: Expression): string; -} - -export interface ExpressionParserResult { - /** - * The expression statement from the valid portion of the parsed expression. - * - * It is undefined when no valid expression statements could be found. - */ - result: Expression; - - /** - * The information of the invalid (non-expression) nodes found from the other portions of the parsed expression. - */ - invalidNodes: Array ; -} - -export interface ExpressionAutocompleteResults { - suggestions: AutocompleteSuggestions; -} - -type ConditionalOperator = '?'; - -export const SUPPORTED_BINARY_OPERATORS = [ - { - operator: '==', - description: 'Checks whether two values are equal.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality', - }, - { - operator: '!=', - description: 'Checks whether two values are unequal.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality', - }, - { - operator: '===', - description: 'Checks whether two values are equal (strict comparison).', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality', - }, - { - operator: '!==', - description: 'Checks whether two values are unequal (strict comparison).', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_inequality', - }, - { - operator: '<', - description: 'Checks if the left value is less than the right value.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than', - }, - { - operator: '<=', - description: 'Checks if the left value is less than or equal to the right value.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than_or_equal', - }, - { - operator: '>', - description: 'Checks if the left value is greater than the right value.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than', - }, - { - operator: '>=', - description: 'Checks if the left value is greater than or equal to the right value.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than_or_equal', - }, - { - operator: 'in', - description: 'Checks if a property exists in an object or if a value is in an array.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in', - }, -] as const; - -export const SUPPORTED_LOGICAL_OPERATORS = [ - { - operator: '&&', - description: 'Logical AND operator; returns true if both operands are true.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND', - }, - { - operator: '||', - description: 'Logical OR operator; returns true if at least one operand is true.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR', - }, -] as const; - -export const SUPPORTED_CONDITIONAL_OPERATORS = [ - { - operator: '?', - description: - 'Conditional (ternary) operator; returns one of two values based on a condition.', - link: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator', - }, -] as const; - -type DirectLiteralValue = { - kind: 'direct'; -} & ( - | { - type: SymbolType.Boolean; - data: boolean; - } - | { - type: SymbolType.Number; - data: number; - } - | { - type: SymbolType.String; - data: string; - } - | { - type: SymbolType.Null; - data: null; - } -); - -type InArrayLiteralValue = { - kind: 'in-array'; - srcSymbol: ArraySymbolDef; - matchedLiteralString: string; -}; - -export type DirectLiteralValueSuggestion = { - type: 'literal-value'; - value: DirectLiteralValue; -}; - -export type InArrayLiteralValueSuggestion = { - type: 'literal-value'; - value: InArrayLiteralValue; -}; - -export type AutocompleteLiteralValueSuggestion = - | DirectLiteralValueSuggestion - | InArrayLiteralValueSuggestion; - -export interface AutocompleteOperatorSuggestion { - type: 'operator'; - operator: - | Extract - | Extract - | Extract< - ConditionalOperator, - (typeof SUPPORTED_CONDITIONAL_OPERATORS)[number]['operator'] - >; - description: string; - link: string; -} - -export interface AutocompleteSymbolSuggestion { - type: 'symbol'; - symbol: SymbolInfo; -} - -export type AutocompleteSuggestions = Array< - | AutocompleteSymbolSuggestion - | AutocompleteLiteralValueSuggestion - | AutocompleteOperatorSuggestion ->; - -type LoggerFn = (message: string, ...args: any[]) => void; - -/** - * A logger that can be passed to the runtime. - */ -export interface Logger { - debug: LoggerFn; - info: LoggerFn; - error: LoggerFn; -} diff --git a/packages/expr/src/utils.ts b/packages/expr/src/utils.ts deleted file mode 100644 index 04a6c2c108..0000000000 --- a/packages/expr/src/utils.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Format the result value of an expression for display as a string. - */ -export function formatExpressionResult(value: any, defaultValue = ''): string { - if (value === undefined || value === null) { - return defaultValue; - } - - if (typeof value === 'string') { - return value; - } - - if (typeof value === 'number' || typeof value === 'boolean') { - return value.toString(); - } - - return defaultValue; -} - -/** - * Filter function to exclude `null` values - */ -export function filterOutNullable (value: T): value is NonNullable { - return !!value; -} - -/** - * Type to make optional properties on a object mandatory. - * - * interface SomeObject { - * uid: string; - * price: number | null; - * location?: string; - * } - * - * type ValuableObject = MandateProps ; - */ -export type MandateProps = T & { - [MK in K]-?: NonNullable ; -}; diff --git a/packages/expr/tsconfig.json b/packages/expr/tsconfig.json deleted file mode 100644 index 53a184c820..0000000000 --- a/packages/expr/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": ["@tsconfig/strictest/tsconfig.json", "@tsconfig/node20/tsconfig.json"], - "compilerOptions": { - "lib": ["ESNext", "DOM"], - "module": "ESNext", - "moduleResolution": "bundler", - "isolatedModules": true, - "incremental": true, - "noEmit": true, - "noPropertyAccessFromIndexSignature": false, - "exactOptionalPropertyTypes": false, - "types": [ - "bun-types" // add Bun global - ] - }, - "include": ["types/**/*.d.ts", "src/**/*.ts"] -} diff --git a/packages/expr/types/eval-estree-expression.d.ts b/packages/expr/types/eval-estree-expression.d.ts deleted file mode 100644 index 4bb4ff3876..0000000000 --- a/packages/expr/types/eval-estree-expression.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -declare module 'eval-estree-expression' { - /** - * Options for evaluation and compilation. - */ - export interface EvalESTreeExpressionOptions { - /** - * Force logical operators to return a boolean result. Default: undefined - */ - booleanLogicalOperators?: boolean; - /** - * Allow function calls to be evaluated. This is unsafe, please enable this option at your own risk. Default: false - */ - functions?: boolean; - /** - * Enable support for function statements and expressions by enabling the functions option AND by passing the .generate() function from the escodegen library. Default: undefined - */ - generate?: boolean | ((node: any) => string); - /** - * Enable the =~ regex operator to support testing values without using functions (example name =~ /^a.*c$/). Default: true - */ - regexOperator?: boolean; - /** - * Throw an error when variables are undefined. Default: false - */ - strict?: boolean; - /** - * Used with the variables method to return nested variables (e.g., variables with dot notation, like foo.bar.baz). Default: undefined - */ - withMembers?: boolean; - } - - /** - * Evaluates an ESTree expression asynchronously against a given context. - * @param expression - An object representing an ESTree-compliant AST node. - * @param context - An object containing variables and values to be used during evaluation. - * @returns A promise resolving to the result of the evaluation. - */ - export function evaluate ( - ast: ASTNode, - context: object, - options?: EvalESTreeExpressionOptions - ): Promise ; - - /** - * Evaluates an ESTree expression synchronously against a given context. - * @param expression - An object representing an ESTree-compliant AST node. - * @param context - An object containing variables and values to be used during evaluation. - * @returns The result of the evaluation. - */ - export namespace evaluate { - function sync ( - expression: ASTNode, - context: object, - options?: EvalESTreeExpressionOptions - ): any; - } -} diff --git a/packages/fonts/.gitignore b/packages/fonts/.gitignore deleted file mode 100644 index 253839862f..0000000000 --- a/packages/fonts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist/ -src/data/*.json diff --git a/packages/fonts/CHANGELOG.md b/packages/fonts/CHANGELOG.md deleted file mode 100644 index 44341b9f54..0000000000 --- a/packages/fonts/CHANGELOG.md +++ /dev/null @@ -1,19 +0,0 @@ -# @gitbook/fonts - -## 0.1.2 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles - -## 0.1.1 - -### Patch Changes - -- 295f03d: Republish packages - -## 0.1.0 - -### Minor Changes - -- fbfcca5: Initial version of the package diff --git a/packages/fonts/README.md b/packages/fonts/README.md deleted file mode 100644 index fef253f27f..0000000000 --- a/packages/fonts/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@gitbook/fonts` - -Utilities to lookup default fonts supported by GitBook. diff --git a/packages/fonts/bin/generate.ts b/packages/fonts/bin/generate.ts deleted file mode 100644 index d4326d615c..0000000000 --- a/packages/fonts/bin/generate.ts +++ /dev/null @@ -1,91 +0,0 @@ -import fs from 'node:fs/promises'; -import path from 'node:path'; - -import { APIv2 } from 'google-font-metadata'; - -import { CustomizationDefaultFont } from '@gitbook/api'; - -import type { FontDefinitions } from '../src/types'; - -const googleFontsMap: { [fontName in CustomizationDefaultFont]: string } = { - [CustomizationDefaultFont.Inter]: 'inter', - [CustomizationDefaultFont.FiraSans]: 'fira-sans-extra-condensed', - [CustomizationDefaultFont.IBMPlexSerif]: 'ibm-plex-serif', - [CustomizationDefaultFont.Lato]: 'lato', - [CustomizationDefaultFont.Merriweather]: 'merriweather', - [CustomizationDefaultFont.NotoSans]: 'noto-sans', - [CustomizationDefaultFont.OpenSans]: 'open-sans', - [CustomizationDefaultFont.Overpass]: 'overpass', - [CustomizationDefaultFont.Poppins]: 'poppins', - [CustomizationDefaultFont.Raleway]: 'raleway', - [CustomizationDefaultFont.Roboto]: 'roboto', - [CustomizationDefaultFont.RobotoSlab]: 'roboto-slab', - [CustomizationDefaultFont.SourceSansPro]: 'source-sans-3', - [CustomizationDefaultFont.Ubuntu]: 'ubuntu', - [CustomizationDefaultFont.ABCFavorit]: 'inter', -}; - -/** - * Scripts to generate the list of all icons. - */ -async function main() { - // @ts-expect-error - we build the object - const output: FontDefinitions = {}; - - for (const font of Object.values(CustomizationDefaultFont)) { - const googleFontName = googleFontsMap[font]; - const fontMetadata = APIv2[googleFontName.toLowerCase()]; - if (!fontMetadata) { - throw new Error(`Font ${googleFontName} not found`); - } - - output[font] = { - font: googleFontName, - unicodeRange: fontMetadata.unicodeRange, - variants: { - '400': {}, - '700': {}, - }, - }; - - Object.keys(output[font].variants).forEach((weight) => { - const variants = fontMetadata.variants[weight]; - const normalVariant = variants.normal; - if (!normalVariant) { - throw new Error(`Font ${googleFontName} has no normal variant`); - } - - output[font].variants[weight] = {}; - Object.entries(normalVariant).forEach(([script, url]) => { - output[font].variants[weight][script] = url.url.woff; - }); - }); - } - - await writeDataFile('fonts', JSON.stringify(output, null, 2)); -} - -/** - * We write both in dist and src as the build process might have happen already - * and tsc doesn't copy the files. - */ -async function writeDataFile(name, content) { - const srcData = path.resolve(__dirname, '../src/data'); - const distData = path.resolve(__dirname, '../dist/data'); - - // Ensure the directories exists - await Promise.all([ - fs.mkdir(srcData, { recursive: true }), - fs.mkdir(distData, { recursive: true }), - ]); - - await Promise.all([ - fs.writeFile(path.resolve(srcData, `${name}.json`), content), - fs.writeFile(path.resolve(distData, `${name}.json`), content), - ]); -} - -main().catch((error) => { - console.error(`Error generating icons list: ${error}`); - process.exit(1); -}); diff --git a/packages/fonts/package.json b/packages/fonts/package.json deleted file mode 100644 index 4471679b58..0000000000 --- a/packages/fonts/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@gitbook/fonts", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "version": "0.1.2", - "dependencies": { - "@gitbook/api": "catalog:" - }, - "devDependencies": { - "bun-types": "catalog:", - "google-font-metadata": "^6.0.7", - "tsdown": "catalog:", - "typescript": "catalog:" - }, - "scripts": { - "generate": "bun ./bin/generate.js", - "build": "tsdown", - "typecheck": "tsc --noEmit", - "dev": "bun run build -- --watch ./src", - "clean": "rm -rf ./dist && rm -rf ./src/data", - "unit": "bun test" - }, - "files": ["dist", "bin", "README.md", "CHANGELOG.md"], - "engines": { - "node": ">=20.0.0" - }, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/fonts/src/__snapshots__/getDefaultFont.test.ts.snap b/packages/fonts/src/__snapshots__/getDefaultFont.test.ts.snap deleted file mode 100644 index feec4abc58..0000000000 --- a/packages/fonts/src/__snapshots__/getDefaultFont.test.ts.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Bun Snapshot v1, https://bun.sh/docs/test/snapshots - -exports[`getDefaultFont should return correct object for Latin text 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hjp-Ek-_0ew.woff", -} -`; - -exports[`getDefaultFont should return correct object for Cyrillic text 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZthjp-Ek-_0ewmM.woff", -} -`; - -exports[`getDefaultFont should return correct object for Greek text 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZxhjp-Ek-_0ewmM.woff", -} -`; - -exports[`getDefaultFont should handle mixed script text 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZthjp-Ek-_0ewmM.woff", -} -`; - -exports[`getDefaultFont should handle different font weights: regular 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hjp-Ek-_0ew.woff", -} -`; - -exports[`getDefaultFont should handle different font weights: bold 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuFuYAZ9hjp-Ek-_0ew.woff", -} -`; - -exports[`getDefaultFont should handle different fonts: inter 1`] = ` -{ - "font": "Inter", - "url": "https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hjp-Ek-_0ew.woff", -} -`; - -exports[`getDefaultFont should handle different fonts: roboto 1`] = ` -{ - "font": "Roboto", - "url": "https://fonts.gstatic.com/s/roboto/v49/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmUiAz0klQm_20.woff", -} -`; diff --git a/packages/fonts/src/fonts.ts b/packages/fonts/src/fonts.ts deleted file mode 100644 index c9544efb19..0000000000 --- a/packages/fonts/src/fonts.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { FontDefinitions } from './types'; - -import rawFonts from './data/fonts.json' with { type: 'json' }; - -export const fonts: FontDefinitions = rawFonts; diff --git a/packages/fonts/src/getDefaultFont.test.ts b/packages/fonts/src/getDefaultFont.test.ts deleted file mode 100644 index 58afbeac93..0000000000 --- a/packages/fonts/src/getDefaultFont.test.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { describe, expect, it } from 'bun:test'; -import { CustomizationDefaultFont } from '@gitbook/api'; -import { getDefaultFont } from './getDefaultFont'; - -describe('getDefaultFont', () => { - it('should return null for invalid font', () => { - const result = getDefaultFont({ - font: 'invalid-font' as CustomizationDefaultFont, - text: 'Hello', - weight: 400, - }); - expect(result).toBeNull(); - }); - - it('should return null for invalid weight', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello', - weight: 999 as any, - }); - expect(result).toBeNull(); - }); - - it('should return null for text not supported by any script', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: '😀', // Emoji not supported by Inter - weight: 400, - }); - expect(result).toBeNull(); - }); - - it('should return correct object for Latin text', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello World', - weight: 400, - }); - expect(result).not.toBeNull(); - expect(result?.font).toBe(CustomizationDefaultFont.Inter); - expect(result).toMatchSnapshot(); - }); - - it('should return correct object for Cyrillic text', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Привет мир', - weight: 400, - }); - expect(result).not.toBeNull(); - expect(result?.font).toBe(CustomizationDefaultFont.Inter); - expect(result).toMatchSnapshot(); - }); - - it('should return correct object for Greek text', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Γεια σας', - weight: 400, - }); - expect(result).not.toBeNull(); - expect(result?.font).toBe(CustomizationDefaultFont.Inter); - expect(result).toMatchSnapshot(); - }); - - it('should handle mixed script text', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello Привет', - weight: 400, - }); - expect(result).not.toBeNull(); - expect(result?.font).toBe(CustomizationDefaultFont.Inter); - expect(result).toMatchSnapshot(); - }); - - it('should handle different font weights', () => { - const regular = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello', - weight: 400, - }); - const bold = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello', - weight: 700, - }); - expect(regular).not.toBeNull(); - expect(bold).not.toBeNull(); - expect(regular).toMatchSnapshot('regular'); - expect(bold).toMatchSnapshot('bold'); - }); - - it('should handle empty string', () => { - const result = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: '', - weight: 400, - }); - expect(result).toBeNull(); - }); - - it('should handle different fonts', () => { - const inter = getDefaultFont({ - font: CustomizationDefaultFont.Inter, - text: 'Hello', - weight: 400, - }); - const roboto = getDefaultFont({ - font: CustomizationDefaultFont.Roboto, - text: 'Hello', - weight: 400, - }); - expect(inter).not.toBeNull(); - expect(roboto).not.toBeNull(); - expect(inter).toMatchSnapshot('inter'); - expect(roboto).toMatchSnapshot('roboto'); - }); -}); diff --git a/packages/fonts/src/getDefaultFont.ts b/packages/fonts/src/getDefaultFont.ts deleted file mode 100644 index d5ffa48df1..0000000000 --- a/packages/fonts/src/getDefaultFont.ts +++ /dev/null @@ -1,112 +0,0 @@ -import type { CustomizationDefaultFont } from '@gitbook/api'; -import { fonts } from './fonts'; -import type { FontWeight } from './types'; - -/** - * Get the URL to load a font for a text. - */ -export function getDefaultFont(input: { - /** - * GitBook font to use. - */ - font: CustomizationDefaultFont; - - /** - * Text to display with the font. - */ - text: string; - - /** - * Font weight to use. - */ - weight: FontWeight; -}): { font: string; url: string } | null { - if (!input.text.trim()) { - return null; - } - - const fontDefinition = fonts[input.font]; - if (!fontDefinition) { - return null; - } - - const variant = fontDefinition.variants[`${input.weight}`]; - if (!variant) { - return null; - } - - const script = getBestUnicodeRange(input.text, fontDefinition.unicodeRange); - if (!script) { - return null; - } - - return variant[script] - ? { - font: input.font, - url: variant[script], - } - : null; -} - -/** - * Determine which named @font-face unicode-range covers - * the greatest share of the characters in `text`. - * - * @param text The text you want to inspect. - * @param ranges An object whose keys are range names and whose - * values are CSS-style comma-separated unicode-range - * declarations (e.g. "U+0370-03FF,U+1F00-1FFF"). - * @returns The key of the best-matching range, or `null` - * when nothing matches at all. - */ -function getBestUnicodeRange(text: string, ranges: Record ): string | null { - // ---------- helper: parse "U+XXXX" or "U+XXXX-YYYY" ---------- - const parseOne = (token: string): [number, number] | null => { - token = token.trim().toUpperCase(); - if (!token.startsWith('U+')) return null; - - const body = token.slice(2); // drop "U+" - const [startHex, endHex] = body.split('-'); - const start = Number.parseInt(startHex!, 16); - const end = endHex ? Number.parseInt(endHex, 16) : start; - - if (Number.isNaN(start) || Number.isNaN(end) || end < start) return null; - return [start, end]; - }; - - // ---------- helper: build lookup table ---------- - const parsed: Record = {}; - for (const [label, list] of Object.entries(ranges)) { - parsed[label] = list - .split(',') - .map(parseOne) - .filter((x): x is [number, number] => x !== null); - } - - // ---------- tally code-point hits ---------- - const hits: Record = Object.fromEntries(Object.keys(parsed).map((k) => [k, 0])); - - for (let i = 0; i < text.length; ) { - const cp = text.codePointAt(i)!; - i += cp > 0xffff ? 2 : 1; // advance by 1 UTF-16 code-unit (or 2 for surrogates) - - for (const [label, rangesArr] of Object.entries(parsed)) { - if (rangesArr.some(([lo, hi]) => cp >= lo && cp <= hi)) { - hits[label]!++; - } - } - } - - // ---------- choose the "best" ---------- - let winner: string | null = null; - let maxCount = 0; - - for (const [label, count] of Object.entries(hits)) { - if (count > maxCount) { - maxCount = count; - winner = label; - } - } - - return maxCount > 0 ? winner : null; -} diff --git a/packages/fonts/src/index.ts b/packages/fonts/src/index.ts deleted file mode 100644 index fbb3584899..0000000000 --- a/packages/fonts/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './getDefaultFont'; -export * from './types'; diff --git a/packages/fonts/src/types.ts b/packages/fonts/src/types.ts deleted file mode 100644 index 899b32c49f..0000000000 --- a/packages/fonts/src/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { CustomizationDefaultFont } from '@gitbook/api'; - -export type FontWeight = 400 | 700; - -export type FontDefinition = { - font: string; - unicodeRange: { - [script: string]: string; - }; - variants: { - [weight in string]: { - [script: string]: string; - }; - }; -}; - -export type FontDefinitions = { [fontName in CustomizationDefaultFont]: FontDefinition }; diff --git a/packages/fonts/tsconfig.json b/packages/fonts/tsconfig.json deleted file mode 100644 index 201ca09897..0000000000 --- a/packages/fonts/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "lib": ["es2023"], - "module": "ESNext", - "target": "es2022", - "strict": true, - "noUncheckedIndexedAccess": true, - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "bundler", - "allowJs": true, - "noEmit": false, - "declaration": true, - "outDir": "dist", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react-jsx", - "incremental": true, - "types": [ - "bun-types" // add Bun global - ] - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules"] -} diff --git a/packages/fonts/turbo.json b/packages/fonts/turbo.json deleted file mode 100644 index 9097cda33c..0000000000 --- a/packages/fonts/turbo.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": ["//"], - "tasks": { - "generate": { - "inputs": ["bin/**/*", "package.json"], - "outputs": ["src/data/*.json", "dist/data/*.json"] - } - } -} diff --git a/packages/gitbook/.gitignore b/packages/gitbook/.gitignore deleted file mode 100644 index f7a6b34753..0000000000 --- a/packages/gitbook/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ - -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# visual tests -screenshots/ - -/test-results/ -/playwright-report/ -/blob-report/ -/playwright/.cache/ - -# Generated public files -/public/~gitbook/static/* -!/public/~gitbook/static/images - -# cloudflare -.open-next -.wrangler -worker-configuration.d.ts \ No newline at end of file diff --git a/packages/gitbook/CHANGELOG.md b/packages/gitbook/CHANGELOG.md deleted file mode 100644 index 4b50c30d99..0000000000 --- a/packages/gitbook/CHANGELOG.md +++ /dev/null @@ -1,1073 +0,0 @@ -# gitbook - -## 0.19.2 - -### Patch Changes - -- 6142d6b: Mark as sideEffects, fix all package bundles -- 75543b1: Update minimum Node version in .npmrc -- 511f1cf: Add scroll margin to Expandable -- Updated dependencies [6142d6b] - - @gitbook/emoji-codepoints@0.2.2 - - @gitbook/react-contentkit@0.7.7 - - @gitbook/openapi-parser@3.0.4 - - @gitbook/browser-types@0.1.2 - - @gitbook/react-openapi@1.5.2 - - @gitbook/cache-tags@0.3.3 - - @gitbook/react-math@0.6.3 - - @gitbook/colors@0.4.2 - - @gitbook/fonts@0.1.2 - - @gitbook/icons@0.3.3 - - @gitbook/expr@1.2.3 - -## 0.19.1 - -### Patch Changes - -- 295f03d: Republish packages -- Updated dependencies [bdde392] -- Updated dependencies [295f03d] - - @gitbook/react-contentkit@0.7.6 - - @gitbook/browser-types@0.1.1 - - @gitbook/cache-tags@0.3.2 - - @gitbook/colors@0.4.1 - - @gitbook/emoji-codepoints@0.2.1 - - @gitbook/expr@1.2.2 - - @gitbook/fonts@0.1.1 - - @gitbook/icons@0.3.2 - - @gitbook/openapi-parser@3.0.3 - - @gitbook/react-math@0.6.2 - - @gitbook/react-openapi@1.5.1 - -## 0.19.0 - -### Minor Changes - -- ed7d47d: Show a toolbar for authenticated users with access to the current site. -- 50c1be3: Move inline expression evaluation from API to GBO -- 56e46ce: Add Italian translation -- b932e4e: Scope search across sections and variants - -### Patch Changes - -- 162cfe4: Hide sections if only one is present -- 1456251: Unify section display condition -- 9344431: Fix missing geo data in site insights because of incorrect proxying of events. -- eea8f1e: Enhance OpenAPI security scopes handling -- 2b8a2d2: Add stable scroll gutter to search container -- b498521: Fix robots.txt preventing favicon from being indexed. -- ceb32b1: Redo search scope UI -- 8e99871: Highlight discriminator properties in oneOf, allOf, anyOf objects -- 2fc2127: Make search accessible -- f3e4041: Adapt OpenAPI code samples to prefill API key using visitor data -- 6815dd1: Fix markdownPageURL for PageActions -- c06b3dd: Improve default site icon -- cba583a: Use sitespace title instead of space title in search -- e434442: Support nested site section groups -- 469b332: Add support for inline expressions rendering with visitor data on GBO side -- 0ef5dc8: Update to column width sizing -- 1e4e54e: Fix rounded outline items -- 379d486: Expose "Best match" when site has translations -- c21693f: Improve screen reader accessibility for hints -- badf3a9: Add alt text to inline image -- c23d4ef: Fix crash for card cover defined without objectFit -- d74f8a7: Improve wide page width layout -- b8388e5: Add scrollcontainer component -- b85eccd: Refactor section tabs -- 1e53f46: Fix button content truncate -- 7a504b7: Fix OpenAPI response dropdown & vertical overflow -- a4c3399: Fix OpenAPI alternatives not showing -- Updated dependencies [a629900] -- Updated dependencies [eea8f1e] -- Updated dependencies [8e99871] -- Updated dependencies [f3e4041] -- Updated dependencies [319a1e5] -- Updated dependencies [529f940] -- Updated dependencies [754cc11] -- Updated dependencies [d7948e3] -- Updated dependencies [a4c3399] - - @gitbook/expr@1.2.1 - - @gitbook/react-openapi@1.5.0 - -## 0.18.0 - -### Minor Changes - -- 262afa3: Expose a MCP server for the docs site under /~gitbook/mcp - -### Patch Changes - -- Updated dependencies [262afa3] - - @gitbook/icons@0.3.1 - - @gitbook/react-openapi@1.4.3 - - @gitbook/react-contentkit@0.7.5 - -## 0.17.2 - -### Patch Changes - -- @gitbook/react-openapi@1.4.2 - -## 0.17.1 - -### Patch Changes - -- 24f601d: Small optim in resolveTryItPrefillForOperation -- aea5eb1: Persist language choice across sections if possible -- 1165a81: Language selector edge cases -- f9a2977: Better handling for external link "mailto:" in Hovered Card in GBO -- Updated dependencies [24f601d] - - @gitbook/react-openapi@1.4.1 - -## 0.17.0 - -### Minor Changes - -- 12c9d76: Adapt OpenAPI blocks to eval adaptive exprs & prefill TryIt config -- 7911350: Add language selector to site header -- 659be55: Track insight event when embedded assistant is displayed. - -### Patch Changes - -- 2e0d706: Fix corner radius of active section on "Line" sidebar style -- 78a632b: Fix edit on GitHub button doesn't take you to GitHub -- 1edc5d6: Add "hold message" to Assistant -- 4520728: Support bold in headings -- 61b8507: OpenAPI: Make responses without objects clickable -- d1fdc13: Remove ligatures from Lato font -- a8fca0e: Fix custom assistant keyboard shortcut -- 262a9b1: Fix embed script and assets being cached for too long -- c890e01: Fix order in robots.txt preventing indexation of images by Google. -- 1839ea2: Fix content min-height with sections -- 9201e2c: Adds vertical align to column block -- 193d591: Use space language as source of truth for UI locale -- f08dd29: Fix Search results are not clickable on sites without header -- 17dd382: Add `original` background color step -- 4f35882: Fix event ask_question not being tracked -- d51b79e: Fix Search bar is broken on site with sections when header is disabled -- 6f368b5: Fix embed assistant window width on small screens -- Updated dependencies [193d591] -- Updated dependencies [12c9d76] -- Updated dependencies [4927e96] -- Updated dependencies [61b8507] -- Updated dependencies [7fefe49] -- Updated dependencies [360aa1c] -- Updated dependencies [98e42cf] -- Updated dependencies [17dd382] - - @gitbook/colors@0.4.0 - - @gitbook/react-openapi@1.4.0 - - @gitbook/openapi-parser@3.0.2 - -## 0.16.0 - -### Minor Changes - -- 6830815: Support custom AI providers -- cbc71a5: Allow integrations to provide tools to the Docs Assistant -- cc2e615: Emit a for the markdown version of a page -- 81a6bd7: Support customization of buttons and tools through iframe API -- 8927e8f: Start routes for embeddable version of the assistant and docs pages. - -### Patch Changes - -- d30bcba: Improve `Button` and `ButtonGroup` styling -- e1b2cf6: Fix scroll of page outline -- d655d3e: Support "objectivec" as alias for Objective C syntax -- 13ff22b: Fix AI Search follow-up question closing search -- ffa866c: Small fixes to search modal -- 36af03f: Fixes to `PageAside` -- fb858a1: Tweaks to AIChatButton and AIChatInput -- bcfa8d8: Improve vertical alignment of site items and fix floating page aside -- ea7e94f: Fix search bar layout shift caused by ToC -- 2e6e28e: Fix: Long strings overflow out of message bubble in docs assistant -- ff96bb5: Support new coverDefinitionDark for cards & image type -- 388b20d: Clear AI chat properly -- ba7ec14: Fix bug in search highlight in GBO -- 6217a2e: Page outline: scroll to active item -- 42c17f5: Improve OpenAPI parsing errors -- 854c448: Custom assistants followup -- 43766d6: Fix Custom logo not rendering on the published site -- Updated dependencies [cbc71a5] -- Updated dependencies [25e2b40] -- Updated dependencies [42c17f5] -- Updated dependencies [854c448] - - @gitbook/browser-types@0.1.0 - - @gitbook/icons@0.3.0 - - @gitbook/openapi-parser@3.0.1 - - @gitbook/react-contentkit@0.7.4 - - @gitbook/react-openapi@1.3.6 - -## 0.15.0 - -### Minor Changes - -- d130532: Suggest questions in the current space context - -### Patch Changes - -- 44f4151: Fix close buttons tooltips -- d903273: Strip visitor params from URL -- df7de8f: Fix an issue where links were not rendering properly in Ask AI answers -- d270b4a: All tracking is now disabled for dynamic routes such as the site preview. -- b1f608b: Implement basic URL scheme for assistant with ask -- d024658: Prevent page breaks inside blocks when printing -- 185cdb4: Fix scrolling to anchor positionning -- 5c49235: Remove highlighting in Safari for PowerShell and C++ to avoid page crash until next version with bug fix is released -- f1a6dec: Update OpenAPI parser -- 2cdba53: Upgrade to Tailwind v4 -- Updated dependencies [2cdba53] -- Updated dependencies [f1a6dec] - - @gitbook/react-math@0.6.1 - - @gitbook/icons@0.2.2 - - @gitbook/openapi-parser@3.0.0 - - @gitbook/react-contentkit@0.7.3 - - @gitbook/react-openapi@1.3.5 - -## 0.14.1 - -### Patch Changes - -- 7c951ef: 'Support new colors in text formatting -- 39c4f76: Add fullwidth page option -- eb1bd3a: AI response feedback buttons -- 2ba7e54: Fix headings styles in hint block -- 250c194: Add nosnippet to announcement banner. -- 4aeb81b: Fix search input styling & text cutoff -- 68f0dbc: Add confirmation modal to contentkit button -- 611e286: Remove padding on first Heading in Columns -- b0c534f: Tweaks to AI Chat and AI Actions Dropdown -- Updated dependencies [b5ad0ce] - - @gitbook/openapi-parser@2.2.2 - - @gitbook/react-openapi@1.3.4 - -## 0.14.0 - -### Minor Changes - -- 0003030: Implement AI actions dropdown -- acb9f53: New search layout - -### Patch Changes - -- 334cfdd: Fix responsive class for SearchInput button -- 6816f0f: add browserlists and fix old browser css-masks -- 9ee9082: Refactor icon loading state in AIAction components -- 52ab368: Reposition AI Actions dropdown -- 7212345: Fix AI Actions dropdown and LLM integration -- 8daede5: Ensure all content links are resolved relatively to preview. -- ed684c1: Move AI Actions markdown fetching to client-side -- 9cc5a78: Generalise keyboard shortcuts, add Cmd+J to AI Chat -- Updated dependencies [6816f0f] -- Updated dependencies [1738677] - - @gitbook/icons@0.2.1 - - @gitbook/openapi-parser@2.2.1 - - @gitbook/react-contentkit@0.7.2 - - @gitbook/react-openapi@1.3.3 - -## 0.13.1 - -### Patch Changes - -- f5894bc: Fix incorrect revision ID in Markdown fetch logic -- 1b59e7c: Styling improvements to AI Chat Followup questions -- Updated dependencies [bd553bc] - - @gitbook/openapi-parser@2.2.0 - - @gitbook/react-openapi@1.3.2 - -## 0.13.0 - -### Minor Changes - -- af98402: Add support for inline icons. -- 7d3fe23: Add circular corners and depth styling -- f3affc3: Display MCP tool calls in AI chat. -- fa12f9e: Support dark-mode specific page cover image -- df848ef: Add support for icons in buttons. -- b7a0db3: Fix rendering of ogimage with SVG logos. -- c3b620e: Best effort at preserving current variant when navigating between sections by matching the pathname against site spaces in the new section. -- 4fb2a4a: Rework full-width layout, add support for full-width page option -- df848ef: Add support for text alignment for headings and paragraphs. -- f033734: Add support for site customization option to change how external links open. -- 7b38f89: Enable AI chat when AI mode is configured to assistant -- 8d65983: Add AI chat - -### Patch Changes - -- 42d88da: Fix UX issue about highlighting the search term in search result sections -- 6aa3ff9: Fix three small visual issues - - - Fix sidebar showing on `no-toc` pages in the gradient theme - - Fix variant selector truncating incorrectly in header when sections are present - - Fix page cover alignment on `lg` screens without TOC - -- 015615d: Respect fullWidth and defaultWidth for images -- e8fb84d: Fix hash with align in columns -- 4721403: Hide scrollbar on sections -- d410381: Add docs.testgitbook.com to ADAPTIVE_CONTENT_HOSTS list -- 7d5a6d2: fix nested a tag causing hydration error -- bc1eca8: Error handling for AI Chat -- b3a7ad6: fix href being empty in TOC -- dc4268d: Fix navigation between sections/variants when previewing a site in v2 -- 58d7f3c: Fix revision id for computed content -- 11a6511: Fix crash when integration script fails to render block. -- 7a00880: Improve support for OAuth2 security type -- c0ee60e: Adds Columns layout block to GBO -- 9316ccd: Update Models page styling -- 42d43e0: Show scrollbars -- 72cd0e5: Optimize performances by using a smarter per-request cache arround data cached functions -- af66ff7: add a force-revalidate api route to force bust the cache in case of errors -- e2afc07: Fix resolution of page by resolving site redirects before space redirects -- 88a35ed: Fix crash when integration is triggering invalid requests. -- 711cf38: Optimize the fetch of revision files by using only the getRevision cache. -- f58b904: encode customization header -- 4f5fec7: Fix CodeBlock layout -- 3bfe347: Show tabs when there is a single section group present -- a7a713b: Scroll to active TOC when clicking a link -- ba0094a: fix ISR on preview env -- 521052d: Fix concurrent execution in Vercel causing pages to not be attached to the proper tags. -- 33726c8: Generate a llms-full.txt version of the docs site -- 500c8cb: Don't crash ogimage generation on RTL text, as a workaround until we can support it. -- 6859f7d: Fix rendering of ogimage when logo or icon are AVIF images. -- a28a997: Add margin to adjacent buttons -- 67998b6: Fix ogimage generation failing with some JPEG images. -- 8c0a53a: Fix page group not expanded by default -- dfa8a37: Don't cache unexpected API errors for more than a few minutes. -- 73e0cbb: Fix an issue where PDF export URLs were not keeping their query params. -- e5bac69: Fix markdown page generation for groups -- 6294bbb: add a global error boundary -- b60039b: Fix links to other spaces within a section. -- 59da30f: Add support for cover repositioning -- b403962: Handle nullish OpenAPI mediaTypeObject -- c730845: Fix missing title on button to close the announcement banner. -- 231167d: Make icons for page groups more contrasting -- d99da6a: Ignore case while highlighting search results. -- dae019c: Consistently show variant selector in section bar if site has sections -- dd65987: Include page group children under the .md route -- 57bb146: Make TOC height dynamic based on visible header and footer elements -- 4f7c0ee: Clicking an active TOC item toggles its descendants -- ca3b9ac: Improve AI Chat context popup -- 5726999: Fix viewing a page from a revision -- 392f594: Fix InlineLinkTooltip having a negative impact on performance, especially on larger pages. -- c9373ef: Fix bold header links hover color -- fa3eb07: cache fonts and static image used in OGImage in memory -- e7a591d: Fix border being added to cards -- 427f748: Add metadata for adding site to Apple devices home -- a3a944d: Fix crash during rendering of ogimage for VA sites with default icon. -- 4b67fe5: Add `urlObject.hash` to `linker.toLinkForContent` to pass through URL fragment identifiers, used in search -- caaa692: Allow to zoom images on mobile if relevant -- 902c3c6: apply customization for dynamic context -- b6b5975: Reverse order of feedback smileys -- fbfcca5: Fix ogimage using incorrect Google Font depending on language. -- 2932077: remove trailing slash from linker -- 2350baa: Support for OpenAPI Array request body -- Updated dependencies [957afd9] -- Updated dependencies [7a00880] -- Updated dependencies [11a6511] -- Updated dependencies [fbfcca5] -- Updated dependencies [a0c06a7] -- Updated dependencies [b403962] -- Updated dependencies [1e013cd] -- Updated dependencies [4f5cbfe] -- Updated dependencies [4c9a9d0] -- Updated dependencies [40df91a] -- Updated dependencies [2350baa] - - @gitbook/react-openapi@1.3.1 - - @gitbook/react-contentkit@0.7.1 - - @gitbook/fonts@0.1.0 - - @gitbook/openapi-parser@2.1.5 - -## 0.12.0 - -### Minor Changes - -- 8339e91: Fix images in reusable content across spaces. -- 326e28e: Design tweaks to code blocks and OpenAPI pages -- 3119066: Add support for reusable content across spaces. -- 7d7806d: Pass SVG images through image resizing without resizing them to serve them from optimal host. - -### Patch Changes - -- c4ebb3f: Fix openapi-select hover in responses -- aed79fd: Decrease rounding of header logo -- 42ca7e1: Fix openapi CR preview -- e6ddc0f: Fix URL in sitemap -- 5e975ab: Fix code highlighting for HTTP -- 5d504ff: Fix resolution of links in reusable contents -- 95a1f65: Better print layouts: wrap code blocks & force table column auto-sizing -- 0499966: Fix invalid sitemap.xml generated with relative URLs instead of absolute ones -- 2a805cc: Change OpenAPI schema-optional from `info` to `tint` color -- 580101d: Fix schemas disclosure label causing client error -- 12a455d: Fix OpenAPI layout issues -- 97b7c79: Increase logging around caching behaviour causing page crashes. -- 373f18f: Prevent section group popovers from opening on click -- 3f29206: Update the regex for validating site redirect -- 0c973a3: Always link main logo to the root of the site -- ae5f1ab: Change `Dropdown`s to use Radix's `DropdownMenu` -- 0e201d5: Add border to filled sidebar on gradient theme -- dd043df: Revert investigation work around URL caches. -- 89a5816: Fix OpenAPI disclosure label ("Show properties") misalignment on mobile -- Updated dependencies [c3f6b8c] -- Updated dependencies [d00dc8c] -- Updated dependencies [42ca7e1] -- Updated dependencies [326e28e] -- Updated dependencies [5e975ab] -- Updated dependencies [f7a3470] -- Updated dependencies [580101d] -- Updated dependencies [20ebecb] -- Updated dependencies [80cb52a] -- Updated dependencies [cb5598d] -- Updated dependencies [c6637b0] -- Updated dependencies [a3ec264] - - @gitbook/colors@0.3.3 - - @gitbook/openapi-parser@2.1.4 - - @gitbook/react-openapi@1.3.0 - -## 0.11.1 - -### Patch Changes - -- Updated dependencies [ebc39e9] -- Updated dependencies [b6b09d4] - - @gitbook/react-openapi@1.2.1 - -## 0.11.0 - -### Minor Changes - -- d67699a: Add OpenAPI Webhook block - -### Patch Changes - -- 4b8a621: Show sections tabs only if there is at least two sections -- 8ed1bda: Translate OpenAPI blocks -- 7588cfe: Improve OpenAPIResponses examples and schemas -- Updated dependencies [eeb977f] -- Updated dependencies [3363a18] -- Updated dependencies [d67699a] -- Updated dependencies [8ed1bda] -- Updated dependencies [7588cfe] -- Updated dependencies [ad1dc0b] - - @gitbook/react-openapi@1.2.0 - -## 0.10.1 - -### Patch Changes - -- Updated dependencies [77397ca] - - @gitbook/cache-tags@0.3.1 - -## 0.10.0 - -### Minor Changes - -- b62b101: Do not set cookie to identify visitor for insights when disabled. - -### Patch Changes - -- 95ea22d: Cache AI Page Link summary -- daf41fc: Tweak footer design (and refactor) -- de53946: Fix security issue with injection of "javacript:` url in the back button of PDFs -- b92ecfa: Implement retry logic for the DO cache to prevent when revalidating content. -- 528eee3: Add superscript and subscript text rendering -- aa3357a: Fix OpenAPISchemas description padding -- 168a4fa: Add support for buttons to GitBook. -- 70c4182: Improve OpenAPI schema style -- 2b6c593: Remove stable from x-stability -- 580f7ad: Improve the error message returned by the revalidate endpoint. -- cbd768a: Improve OpenAPI codesample (add OpenAPISelect component) -- c765463: Fix ogimage generation crashing when site is using a custom WOFF2 font -- e59076a: Improve OpenAPI schemas block ungrouped style. Classnames have changed, please refer to this PR to update GBX. -- 29aaba5: Override Scalar's overscroll-behavior -- 90ead98: Better error handling in cache revalidation. -- Updated dependencies [116575c] -- Updated dependencies [cdffd7c] -- Updated dependencies [70c4182] -- Updated dependencies [2b6c593] -- Updated dependencies [cbd768a] -- Updated dependencies [e59076a] -- Updated dependencies [eedefdd] -- Updated dependencies [23cedd2] - - @gitbook/cache-tags@0.3.0 - - @gitbook/colors@0.3.2 - - @gitbook/react-openapi@1.1.10 - - @gitbook/openapi-parser@2.1.3 - -## 0.9.2 - -### Patch Changes - -- da7b369: Fix missing headers in OpenAPIResponses -- 139a805: Fix OpenAPI enum display -- Updated dependencies [da7b369] -- Updated dependencies [da485f5] -- Updated dependencies [139a805] - - @gitbook/react-openapi@1.1.9 - -## 0.9.1 - -### Patch Changes - -- fb90eb0: Limit tinted background on bold theme to sites with filled sidebar -- 7d0b422: Handle grouped OpenAPISchemas -- Updated dependencies [7d0b422] -- Updated dependencies [fb90eb0] - - @gitbook/react-openapi@1.1.8 - - @gitbook/colors@0.3.1 - -## 0.9.0 - -### Minor Changes - -- 77fd393: Track event when visitor is opening a search result. -- d70d566: Support site announcement banner -- 77fd393: Track event when clicking announcement banner link. - -### Patch Changes - -- e84a46a: Fix OpenAPI tabs indicator overflow -- bc90adb: Fix favicon not being displayed in Google because `robots.txt` was preventing the indexation of the image route -- 434af90: Fix image resizing when using the proxy feature in a site. -- c756761: Add breadcrumbs to search results -- 40e8e69: Disallow crawling by web-robots of search/ask URLs -- 77fd393: Fix clicking search results when the site is embedded in an iframe. -- 1505ddb: Fix multiple request examples selector not showing -- 61db166: Add OpenAPI write-only indicator -- 6f71da8: Fix padding in schemas -- fa91eb7: Fix PDF generation when user has dark mode configured. -- 5b1e01c: Support for x-stability property -- 57ca4e0: Fix a crash when a page contains a block of an integration that is no longer installed -- d236bf0: Fix flash when loading sites with dark mode as default theme -- cd99ed5: Fix spec properties rendering and missing keys -- 813b2af: Support for x-enumDescriptions and x-gitbook-enum -- e9fa50d: Trim the search query to avoid showing a loading state when typing -- Updated dependencies [bd35348] -- Updated dependencies [ae78fc5] -- Updated dependencies [7bb37c7] -- Updated dependencies [373183a] -- Updated dependencies [1505ddb] -- Updated dependencies [61db166] -- Updated dependencies [5b1e01c] -- Updated dependencies [cd99ed5] -- Updated dependencies [813b2af] -- Updated dependencies [a25fded] - - @gitbook/react-openapi@1.1.7 - - @gitbook/openapi-parser@2.1.2 - -## 0.8.2 - -### Patch Changes - -- ed07206: Fix OpenAPI path overflow on mobile -- 4dab1c5: Fix alignment of `prominent` search bar on full-width pages -- 6eae764: Support body examples -- 54ee014: Add initial support for loading custom fonts -- d2facb2: Mark properties as optional if not required -- bba2e52: Fix site redirects when it includes a section/variant path -- 4723f03: Restyle section group dropdown -- 24b7808: Fix `prominent` search bar width on `md` screens -- 1fe3286: Fix OpenAPI block overflow issue -- Updated dependencies [48c18c0] -- Updated dependencies [6eae764] -- Updated dependencies [7212973] -- Updated dependencies [d2facb2] -- Updated dependencies [73e2b47] -- Updated dependencies [70be2c6] -- Updated dependencies [fc00b51] -- Updated dependencies [a84b06b] - - @gitbook/openapi-parser@2.1.1 - - @gitbook/react-openapi@1.1.6 - -## 0.8.1 - -### Patch Changes - -- 886e204: Update OpenAPI operation path design -- Updated dependencies [886e204] -- Updated dependencies [4f0a772] - - @gitbook/react-openapi@1.1.5 - - @gitbook/colors@0.3.0 - -## 0.8.0 - -### Minor Changes - -- eec3eed: Add styling for prominent search bar option - -### Patch Changes - -- 16292de: Display sidebar on no-TOC pages -- 9b5f971: Transparent background for OpenAPI path block -- 99da8df: Optimize favicons and og:image using the image resizer -- b011ea0: Fix rendering of code blocks in Ask AI when being streamed -- 9bc3d50: Info hint background and link color fixes -- 31d800e: Render OpenAPISchemas block -- Updated dependencies [6aaeae2] -- Updated dependencies [c60e9ba] -- Updated dependencies [9108c56] -- Updated dependencies [31d800e] -- Updated dependencies [ff3b708] -- Updated dependencies [f32bf1f] -- Updated dependencies [c9ea239] - - @gitbook/react-contentkit@0.7.0 - - @gitbook/react-openapi@1.1.4 - - @gitbook/cache-tags@0.2.0 - -## 0.7.3 - -### Patch Changes - -- eaf2d68: OpenAPI operation title fallback in sections -- Updated dependencies [844059f] -- Updated dependencies [88f64b0] - - @gitbook/react-openapi@1.1.3 - - @gitbook/icons@0.2.0 - - @gitbook/react-contentkit@0.6.2 - -## 0.7.2 - -### Patch Changes - -- f127d28: Rename OpenAPIModels to OpenAPISchemas -- Updated dependencies [f127d28] - - @gitbook/react-openapi@1.1.2 - -## 0.7.1 - -### Patch Changes - -- Updated dependencies [f574858] - - @gitbook/react-openapi@1.1.1 - -## 0.7.0 - -### Minor Changes - -- bb3ca9c: Implement OpenAPI models blocks - -### Patch Changes - -- 5907bd9: Adjust hint block spacing -- 9ffc3b6: Fix content overflowing out of its container in tabs -- Updated dependencies [0278a14] -- Updated dependencies [bb3ca9c] -- Updated dependencies [3173d8e] -- Updated dependencies [052e07a] - - @gitbook/openapi-parser@2.1.0 - - @gitbook/react-openapi@1.1.0 - -## 0.6.5 - -### Patch Changes - -- 05ffd0e: Improving data cache management for computed content -- 8beb5d6: Add input elements to ContentKit -- Updated dependencies [53f5dbe] -- Updated dependencies [05ffd0e] -- Updated dependencies [8beb5d6] - - @gitbook/openapi-parser@2.0.2 - - @gitbook/cache-tags@0.1.0 - - @gitbook/react-contentkit@0.6.1 - - @gitbook/react-openapi@1.0.5 - -## 0.6.4 - -### Patch Changes - -- 9b914d1: Fix getProxyModeBasePath that was computing incorrect base path in some scenarios -- 2ae76f9: Change how a site in proxy mode is resolved -- 027a859: Add support for links style customization option -- 3e11678: fix: lost section groups -- 3319375: Support OpenAPI operation block -- Updated dependencies [722f02e] -- Updated dependencies [0924259] - - @gitbook/react-openapi@1.0.4 - - @gitbook/openapi-parser@2.0.1 - -## 0.6.3 - -### Patch Changes - -- a820739: Remove unused search api method from gitbook/api/lib -- a054554: Implement a trusted mode to speed up OpenAPI spec validation -- 66d0fc0: Update design for hint block: use semantic colors (info, warning, danger, success) and add alternative styling for hints with headings -- 9f0de74: Add support for new OpenAPI ref -- da55fac: Render GitBook blocks in OpenAPI operation description -- Updated dependencies [c808bb1] -- Updated dependencies [dc2dbc5] -- Updated dependencies [f1d1d2f] -- Updated dependencies [e24206e] -- Updated dependencies [a054554] -- Updated dependencies [05e1d8c] -- Updated dependencies [b4a12d6] -- Updated dependencies [9f0de74] -- Updated dependencies [da55fac] - - @gitbook/openapi-parser@2.0.0 - - @gitbook/react-openapi@1.0.3 - -## 0.6.2 - -### Patch Changes - -- 359bb97: Fix opening external links when the GitBook page is embedded in an iframe -- 6157583: Improve Markdown parsing -- 82cd9f2: Add support for anchor links in OpenAPI blocks -- Updated dependencies [445baaa] -- Updated dependencies [bb5c6a4] -- Updated dependencies [a3f1fea] -- Updated dependencies [6157583] -- Updated dependencies [7419ee7] -- Updated dependencies [82cd9f2] - - @gitbook/colors@0.2.0 - - @gitbook/react-openapi@1.0.2 - - @gitbook/openapi-parser@1.0.1 - -## 0.6.1 - -### Patch Changes - -- dddb4ec: Fix long tab group description -- Updated dependencies [f8d4c76] -- Updated dependencies [dddb4ec] -- Updated dependencies [f8d4c76] - - @gitbook/react-openapi@1.0.1 - -## 0.6.0 - -### Minor Changes - -- 98245e5: Adapt code to pull token from customer backend generated custom cookies -- af3c6a9: Reintroduce a safety check around search whilst we continue investigating caching. -- 95f2aa4: Track new events for site insights when ads are being clicked -- 08acea6: Investigate an issue causing caches to return empty objects instead of null/undefined. -- 1138d59: Add support for sidebar background styles -- 9e18ae6: Overhaul colour scale & Tailwind colour classes -- e86e51f: Fix an issue where the redirects of potentially malicious images were not going through. -- 7059c2b: Add support for computed content by fetching computed documents for pages. -- c71d159: Track events for site insights using the new dedicated API. -- eb7c22f: Revert scalar to 1.0.87 to mitigate an issue with ApiClientModalProvider -- ea1468c: Send redirectOnError param to getPublishedContent when token is pulled from cookie -- 7ee9158: Restyle PageAside to use sidebar list styles -- dbba50c: Fix an issue where search and Ask AI triggers unnecessary renders when in a Visitor Authenticated site. -- 1417279: Track clicks on links (header, footer, content) for site insights. -- 9eca010: Improve the display of recommended questions by streaming them. -- 160fca1: new OpenAPI blocks design -- 71688a8: Introduction of new themes: Clean, Muted, Bold, and Gradient -- 1823101: Fix internal properties appearing in OpenAPI docs. -- 6a073e1: Add antialiasing for text rendering -- 8126a83: Improve readability of tables with hover style and vertical dividers -- db74ea3: Image optimization endpoint redirects to underlying image URL if the signature is not the latest. -- 99579ac: Fix a vulnerability issue for images using an older version of the image signing parameter. -- e4e2f52: Track an event into site insights when visitor is opening the Scalar API client. - -### Patch Changes - -- d876399: Fix UI search without ask AI enabled and fix error with questions not returned from API -- c30bc24: Fix empty sitemap -- e90c96f: page outline on the right remains visible when scrolling, move mode toggler to PageAside -- 5b4e710: Support llms.txt -- b6c3870: Add support for keyboard marks -- 6059efe: Fix search no results error showing while there are results -- c77142a: Log component stack in Sentry -- 1de9d1a: Apply antialiasing on any text that are not code inline/blocks to avoid contrast issues -- 32aa1f9: Handle security issue with cookies on Safari -- d935fb1: Don't add extra page scroll when footer is not present -- 53de5b1: Fix site section URL resolution in Ask AI sources -- 24f5249: Fix vertical section overflow color -- 1762f85: Reduce gap between subsequent header buttons -- c1e27cc: Fix pass Sentry release properly -- 5ae1b88: Fix shrinking page icons -- 8f046a9: Start using tint in more places, TOC and PageAside -- 665b6be: Ignore invalid API calls to `getSiteRedirectFromSource` API - - To reduce the load on the API and also avoid errors. - -- 26e6401: Remove KV cache backend and only rely on DO as an external cache backend -- 8cfa67c: Fix default outline list styling -- d66c184: Ignore errors from event flushing -- 6088fa5: Simplify search results logic to investigate a bug -- 68287d3: Cache API spec for 24 hours, revalidated every 2 hours -- 09c7c30: Try to fix error on og image generation -- ae99f87: Improve emoji setup, align with GitBook app -- 2906e60: Downgrade to Next.js v14 to fix incompatibilities with next-on-pages causing multiple bugs. -- 3a7210d: Fix zoom image view transition on Safari -- 718a8a5: Position the variant picker in the ToC -- e5dc05e: Update footer styling and allow for more than 4 footer groups -- 8276ba0: Make cookies access safer -- 1b8a456: Fix Image blocks zoomable behaviour -- 56c52e0: Handle Firefox security error on localStorage -- 0510b6f: Add section description to SectionGroupTile -- 1fcc807: Fix errors from customization not found -- 46edde9: Improve the OpenAPI package API -- 8af1abc: Improve contrast of search box placeholder -- 92b7668: Improve header offset -- d9c8d57: Do not dereference before caching OpenAPI spec. -- 94876e3: Fix regression issue with page icons for multi-line titles -- 47971dc: Fix OG image generation for non-latin characters -- 82dc9c4: Simplify the `useHash` algo used. -- 128ad20: Ignore cache invalidation error from local backend -- ff05e20: Improvements to inline images in headings -- cb100d5: Allow only good values for theme query parameter. Avoid having a 500 error when we pass an invalid value. -- d5aaccd: Remove use of deprecatd API createSitesPageFeedback -- 48ab59f: Improve colour contrast of list item decoration -- d2bc567: Set Sentry release -- 37d13d8: Avoid error on fetch by passing a string URL -- d3e573c: Generate sitemap for all sections and spaces -- f7b801b: Add feedback form to page rating control -- d370a3f: Update the routes for changes/revisions in multi-id mode to match the normal mode -- 46f63cb: Fix code format overriding inline link styles -- 5950657: Fix emojis display -- 528a053: Fix server actions stability leading to no results found sometimes on search -- eac1314: Lazy load iframely script to make page more responsive -- ad19060: Cards stand out slighly more on tinted and dark mode sites, and have better support for headings inside them -- 6f54826: New highlight colors -- 5c87ec7: Implement a safer way to interact with localStorage. - - If it's disabled on the browser it should not throw error. - -- 02d876e: Fix search UI behaviour -- f4a90de: Fix two issues where pages would crash due Recoil not behaving correctly in RSC. -- 5576906: Fix table of content displaying arrow next to page with only hidden pages -- aaab157: Visual fix for section group in Safari -- cbe6139: Fix dynamic tabs infinite loop -- 65cc4af: Fix error when accessing a change request not found -- 727bde2: Improve and split OpenAPI parser into its own package -- 0b6ddca: Fix variant selector contrast for non-default themes -- 87b8ea8: Fix issue leading to increase the storage write and the stability of the platform -- fde32e2: Force route handler to be dynamic to avoid errors -- a025118: Change card layout depending on cover aspect ratio -- 300f7bf: Fix search loading state -- 29d5979: Disable C/C++ highlight temporarily -- 18953b2: Subtler tint color when based on the primary color, by mixing in some gray -- 1c97536: Fix Sentry instrumentation -- b0bd871: Even safer localStorage -- b950a64: Avoid errors on legacy browsers -- 38061bd: Add section groups to section tabs -- 160fca1: Support deprecated and x-deprecated-sunset in OpenAPI spec -- 0e601e2: Improve styling of header buttons with shadows and high-contrast styles -- 6691492: Fix viewing PDF from space -- e8e64bf: Fix bullet list display on full size blocks -- 16194c5: Vertical orientation for sections list on sites without header -- b41d425: Improve OpenAPI rendering performances by caching markdown parsing -- 1f8e416: Improve performances by highlighting code client-side if the code block is offscreen -- 1429384: Fix error when accessing some not found pages. -- 21cbd9e: Change link color to primary-subtle -- 5dab70f: Fix "Parser" language syntax highlighting -- deb8c54: Upgrade Next.js to v15, upgrade Shiki and use JS RegExp engine -- 56331d2: Fix breadcrumbs emoji display + add contrast styles -- a6f6591: Fix server actions cache compromised. Leading to some bugs on frontend. -- 44a20fe: Improve smoothness of scroll listener -- 5664e5a: Fix variant dropdown styling in header -- 6b50360: Fix view transition error on Safari -- 741dd49: Bump `heading-3` font size to offset it from paragraphs -- 5112e3e: Fix Sentry instrumentation server-side -- 1de338c: Remove animation on section tabs. Page is reloaded (for technical reasons), so the animation is not accurate here. -- Updated dependencies [d9029c7] -- Updated dependencies [6e54a06] -- Updated dependencies [162b4b7] -- Updated dependencies [e4e2f52] -- Updated dependencies [0c03676] -- Updated dependencies [3e5e458] -- Updated dependencies [46edde9] -- Updated dependencies [d9c8d57] -- Updated dependencies [ccf2cff] -- Updated dependencies [dda0cc6] -- Updated dependencies [eb7c22f] -- Updated dependencies [ea1468c] -- Updated dependencies [648f0e9] -- Updated dependencies [160fca1] -- Updated dependencies [f92e906] -- Updated dependencies [e721f17] -- Updated dependencies [727bde2] -- Updated dependencies [dff08ae] -- Updated dependencies [fc7b16f] -- Updated dependencies [fe8acc9] -- Updated dependencies [1823101] -- Updated dependencies [a652958] -- Updated dependencies [2f73db7] -- Updated dependencies [160fca1] -- Updated dependencies [12c7862] -- Updated dependencies [b41d425] - - @gitbook/react-openapi@1.0.0 - - @gitbook/openapi-parser@1.0.0 - - @gitbook/react-contentkit@0.6.0 - -## 0.5.0 - -### Minor Changes - -- 57cdd25: GitBook Open now supports Ask AI in sites. When asking a question to Ask AI, GitBook will use context from across your site sections and variants to provide the best answer. -- ca134c8: Fix an issue where the active site section indicator appeared above any dropdowns. -- d48926e: Fix an issue where the space dropdown was shown under the site sections in Safari. -- 9fe8142: Fix an issue where Ask AI was erroring due to an object being passed as a param. -- d843e5e: Fix an issue where the space dropdown could appear behind the header. -- a2e5647: Fix the styling of site section tabs on smaller screens. - -### Patch Changes - -- 076dc48: Fix expandable block anchore resolution -- d9bb9f9: Fix an issue with the cookie banner buttons being non responsive -- 23584c9: Update the site header with new styling, a new search button, and refactored layout -- 664debc: Add support for tint color -- 4d56f11: Update styling of search+ask modal -- 061c0c1: Fix a regression in variant drop-down caused by missing z-index. -- 2f76712: Add breadcrumbs above page title -- 07cf835: Add scroll margin to the top when there are sections -- 5d72b35: Smoother tab transition for sections -- 7c71363: Don't adjust fallback font for mono font. -- 7675c2c: Optimize performances by using new API endpoint for fetching site data. -- 87eea73: Fix margin and image resolution of header logo -- aa2ed0f: Restyle hint blocks -- ffd3937: Fix security issue with image resizing that could be used for phishing -- 2ce59d7: Fix - whitespace added to site section tabs with icons. -- c73e07d: Increase token max length to fix code not highlighted -- 3b3d6e2: Add icons to sections -- 1ed18c0: style: adds missing scalar css variables -- Updated dependencies [b7a5106] -- Updated dependencies [4771c78] -- Updated dependencies [ff50ac2] -- Updated dependencies [867481c] -- Updated dependencies [7ba67fd] -- Updated dependencies [a78c1ec] - - @gitbook/cache-do@0.1.1 - - @gitbook/react-openapi@0.7.1 - -## 0.4.0 - -### Minor Changes - -- e09f747: Revalidate change request cached content when pressing refresh button -- 2fa0851: Add navigation tabs for sections -- a4b63b8: Support resolution of new site URLs with sections -- 5c35f36: Replace all icons, previously imported from Geist, by new package `@gitbook/icons` -- e9b31a5: Unify section tab styles with page item styles -- f12a215: Add support for Norwegian language -- f4c9536: Optimize layout shift while transitioning between pages with full width blocks (ex: OpenAPI blocks) -- 1f24fe4: Add support for page icons -- cda08a9: Add support for searching results in a sections site -- b32e40c: Persist state of tabs and dynamically sync them based on title -- 15d2ee3: Show the caption for file blocks -- f885e88: Improve the toolbar for change-requests and revisions to show more actions -- 07ea45b: Remove deprecated synced block from GitBook Open -- c3675fd: Added support for new Reusable Content block. -- 1f24fe4: Add support for icons style customization for sites -- 4c19014: Prevent search indexation for pages where it's configured as disabled -- 3422ad4: Update rendering of community ads to match new API response, and make it possible to preview ads. -- 1152445: Changed the alternative URL resolution criteria in order to support site URLs without /v/ prefix -- 2c437f7: Fix linking to a tab itself - -### Patch Changes - -- aa32198: Avoid multiple in the page by using a
for the title in the header -- 51fa3ab: Adds content-visibility css property to OpenAPI Operation for better render performance -- a7066cc: Fix scroll position when navigating pages on mobile -- c754fc9: Add automatic color contrast in site header, restyle search button -- 5fe7adb: RND-3532: drop down menu for hidden links at small screen size -- 6295881: Change dark mode shadow for multi-space search toolbar -- f89b31c: Upgrade the scalar api client package -- 13c7534: Use ellipsis and fix icon color for more links in the header on small screen -- f885e88: Improve consistency of change request preview by removing cache-control on response -- 16e6171: Improve performances of loading pages with embeds by caching them -- 34d36c6: Fix GitBook specific static assets not being served correctly when deployed on Cloudflare -- af9e66e: Only display spaces dropdown in compact header when site is multi-variants -- e3a3d6a: Improve perception of fast loading by not rendering skeletons for individual blocks in the top part of the viewport -- 042b850: Automatically scroll to active item in TOC -- d43202f: Optimize bundle size of the server output by reducing bundle size of shiki (skipping themes) -- bfbed1a: Ensure "Sponsored via GitBook" can be translated in all languages -- fe9e6c1: Update ogimage with new design -- 17f71ba: Use url hash to open Expandable and scroll to anchor -- 3c07e65: Fix margin for paragraphs in quote blocks -- 636b868: Use new cache backend, powered by Durable Objects, alongside the existing ones (KV, etc). -- f16560c: Include offset in calculations of whether scrollable element is in view -- 689f553: Fix inconsistent click area in table because of scroll indicator -- 6ce3cea: Stop using KV cache backend for now, but also improves it for higher performances -- e914903: Synchronize response and response example tabs -- 0f990c7: Show definition title when visible in cards -- e3a3d6a: Fix flickering when displaying an "Ask" answer with code blocks -- 4cbcc5b: Rollback of scalar modal while fixing perf issue -- 3996110: Optimize images rendered in community ads -- 133c3e7: Update design of Checkbox to be more consistent and readable -- 5096f7f: Disable KV cache for gitbook.com/docs as a test, also disable it for change-request to improve consistency -- 0f1565c: Add optional env `GITBOOK_INTEGRATIONS_HOST` to configure the host serving the integrations -- 2ff7ed1: Fix table of contents being visible on mobile when disabled at the page level -- b075f0f: Fix accessibility of the table of contents by using `aria-current` instead of `aria-selected` -- cb782a7: Fix "ip" being passed to BSA for community ads -- a7af3ca: Improving the look and feel of new section tabs -- 0bf985a: Don't show hidden pages in the empty state of a page -- d6c28a0: Update header styling of sections, variant selector, and button links - - - Change position of variant selector depending on context (next to logo or in table of contents) - - Update section tab styling and animation - - Make header buttons smaller with a new `medium` button size - -- Updated dependencies [51fa3ab] -- Updated dependencies [9b8d519] -- Updated dependencies [cf3045a] -- Updated dependencies [f89b31c] -- Updated dependencies [d0f4860] -- Updated dependencies [ef9d012] -- Updated dependencies [094e9cd] -- Updated dependencies [636b868] -- Updated dependencies [56f5fa1] -- Updated dependencies [5c35f36] -- Updated dependencies [4247361] -- Updated dependencies [aa8c49e] -- Updated dependencies [e914903] -- Updated dependencies [4cbcc5b] -- Updated dependencies [0f1565c] -- Updated dependencies [237b703] -- Updated dependencies [51955da] -- Updated dependencies [a679e72] -- Updated dependencies [c079c3c] -- Updated dependencies [5c35f36] -- Updated dependencies [776bc31] - - @gitbook/react-openapi@0.7.0 - - @gitbook/cache-do@0.1.0 - - @gitbook/icons@0.1.0 - - @gitbook/react-contentkit@0.5.1 - - @gitbook/react-math@0.6.0 - -## 0.3.0 - -### Minor Changes - -- 24b785c: Update shiki for code block syntax highlighting, with support for more languages and fixes for diffs. It also patches the deployment on Cloudflare to support edge functions larger than 4MB. - -### Patch Changes - -- acc3f2f: Fix error with the "Try it" of OpenAPI block because of the Scalar proxy failing on Cloudflare with the `cache` option -- Updated dependencies [709f1a1] -- Updated dependencies [ede2335] -- Updated dependencies [0426312] - - @gitbook/react-openapi@0.6.0 - -## 0.2.2 - -### Patch Changes - -- Updated dependencies [3445db4] - - @gitbook/react-contentkit@0.5.0 - - @gitbook/react-openapi@0.5.0 - - @gitbook/react-math@0.5.0 - -## 0.2.1 - -### Patch Changes - -- Updated dependencies [24cd72e] - - @gitbook/react-contentkit@0.4.0 - - @gitbook/react-math@0.4.0 - - @gitbook/react-openapi@0.4.0 - -## 0.2.0 - -### Minor Changes - -- de747b7: Refactor the repository to be a proper monorepo and publish JS files on NPM instead of TypeScript files. - -### Patch Changes - -- Updated dependencies [de747b7] -- Updated dependencies [de747b7] - - @gitbook/react-contentkit@0.3.0 - - @gitbook/react-openapi@0.3.0 - - @gitbook/react-math@0.3.0 diff --git a/packages/gitbook/README.md b/packages/gitbook/README.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/gitbook/e2e/customers.spec.ts b/packages/gitbook/e2e/customers.spec.ts deleted file mode 100644 index 1988ae73f1..0000000000 --- a/packages/gitbook/e2e/customers.spec.ts +++ /dev/null @@ -1,248 +0,0 @@ -import { type TestsCase, runTestCases, waitForCookiesDialog } from './util'; - -/** A list of test cases to run on the customers' docs sites. */ -const testCases: TestsCase[] = [ - { - name: 'Snyk', - contentBaseURL: 'https://docs.snyk.io', - tests: [ - { name: 'Home', url: '/', run: waitForCookiesDialog }, - { name: 'OpenAPI', url: '/snyk-api/reference/apps', run: waitForCookiesDialog }, - ], - }, - // { - // name: 'Nexthink', - // contentBaseURL: 'https://docs.nexthink.com', - // tests: [ - // { - // name: 'Home', - // url: '/', - // screenshot: { waitForTOCScrolling: false }, - // run: waitForCookiesDialog, - // }, - // ], - // }, - { - name: 'asiksupport-stg.dto.kemkes.go.id', - contentBaseURL: 'https://asiksupport-stg.dto.kemkes.go.id', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'jasons-tutorials.gitbook.io', - contentBaseURL: 'https://jasons-tutorials.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'faq.deltaemulator.com', - contentBaseURL: 'https://faq.deltaemulator.com', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.dify.ai', - contentBaseURL: 'https://docs.dify.ai', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'seeddao.gitbook.io', - contentBaseURL: 'https://seeddao.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'faq.altstore.io', - contentBaseURL: 'https://faq.altstore.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'support.audacityteam.org', - contentBaseURL: 'https://support.audacityteam.org', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.gmgn.ai', - contentBaseURL: 'https://docs.gmgn.ai', - tests: [{ name: 'Home', url: '/' }], - }, - // { - // name: 'docs.spicychat.ai', - // contentBaseURL: 'https://docs.spicychat.ai', - // tests: [{ name: 'Home', url: '/' }], - // }, - { - name: 'docs.portainer.io', - contentBaseURL: 'https://docs.portainer.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.chirptoken.io', - contentBaseURL: 'https://docs.chirptoken.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.dexscreener.com', - contentBaseURL: 'https://docs.dexscreener.com', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.pancakeswap.finance', - contentBaseURL: 'https://docs.pancakeswap.finance', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'book.character.ai', - contentBaseURL: 'https://book.character.ai', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'azcoiner.gitbook.io', - contentBaseURL: 'https://azcoiner.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.midas.app', - contentBaseURL: 'https://docs.midas.app', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.keeper.io', - contentBaseURL: 'https://docs.keeper.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'adiblar.gitbook.io', - contentBaseURL: 'https://adiblar.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - // { - // name: 'docs.gradient.network', - // contentBaseURL: 'https://docs.gradient.network', - // tests: [{ name: 'Home', url: '/' }], - // }, - // { - // name: 'mygate-network.gitbook.io', - // contentBaseURL: 'https://mygate-network.gitbook.io', - // tests: [{ name: 'Home', url: '/' }], - // }, - { - name: 'treasurenft.gitbook.io', - contentBaseURL: 'https://treasurenft.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'browndust2.gitbook.io', - contentBaseURL: 'https://browndust2.gitbook.io', - tests: [{ name: 'Home', url: '/', screenshot: { waitForTOCScrolling: false } }], - }, - { - name: 'junookyo.gitbook.io', - contentBaseURL: 'https://junookyo.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'meshnet.nordvpn.com', - contentBaseURL: 'https://meshnet.nordvpn.com', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'manual.bubble.io', - contentBaseURL: 'https://manual.bubble.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.tickettool.xyz', - contentBaseURL: 'https://docs.tickettool.xyz', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'wiki.redmodding.org', - contentBaseURL: 'https://wiki.redmodding.org', - tests: [{ name: 'Home', url: '/' }], - }, - // { - // name: 'docs.cherry-ai.com', - // contentBaseURL: 'https://docs.cherry-ai.com', - // tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - // }, - { - name: 'docs.snyk.io', - contentBaseURL: 'https://docs.snyk.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.realapp.link', - contentBaseURL: 'https://docs.realapp.link', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.publicai.io', - contentBaseURL: 'https://docs.publicai.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'hyperliquid.gitbook.io', - contentBaseURL: 'https://hyperliquid.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.umbraco.com', - contentBaseURL: 'https://docs.umbraco.com', - tests: [ - { - name: 'Home', - url: '/welcome', - run: waitForCookiesDialog, - screenshot: { waitForTOCScrolling: false }, - }, - ], - }, - { - name: 'sosovalue-white-paper.gitbook.io', - contentBaseURL: 'https://sosovalue-white-paper.gitbook.io', - tests: [{ name: 'Home', url: '/' }], - }, - // { - // name: 'docs.revrobotics.com', - // contentBaseURL: 'https://docs.revrobotics.com', - // tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - // }, - { - name: 'chartschool.stockcharts.com', - contentBaseURL: 'https://chartschool.stockcharts.com', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.soniclabs.com', - contentBaseURL: 'https://docs.soniclabs.com', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.meshchain.ai', - contentBaseURL: 'https://docs.meshchain.ai', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.thousandeyes.com', - contentBaseURL: 'https://docs.thousandeyes.com', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'docs.raydium.io', - contentBaseURL: 'https://docs.raydium.io', - tests: [{ name: 'Home', url: '/' }], - }, - { - name: 'docs.fluentbit.io', - contentBaseURL: 'https://docs.fluentbit.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, - { - name: 'run-ai-docs.nvidia.com', - contentBaseURL: 'https://run-ai-docs.nvidia.com', - skip: process.env.ARGOS_BUILD_NAME !== 'customers-v2', - tests: [ - { name: 'Home', url: '/' }, - { name: 'OG Image', url: '/~gitbook/ogimage/h17zQIFwy3MaafVNmItO', mode: 'image' }, - ], - }, -]; - -runTestCases(testCases); diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts deleted file mode 100644 index d4b33458c2..0000000000 --- a/packages/gitbook/e2e/internal.spec.ts +++ /dev/null @@ -1,1914 +0,0 @@ -import { - CustomizationAIMode, - CustomizationBackground, - CustomizationCorners, - CustomizationDefaultMonospaceFont, - CustomizationDepth, - CustomizationHeaderPreset, - CustomizationIconsStyle, - CustomizationSidebarListStyle, - CustomizationThemeMode, -} from '@gitbook/api'; -import { expect } from '@playwright/test'; -import jwt from 'jsonwebtoken'; - -import { - VISITOR_TOKEN_COOKIE, - getVisitorAuthCookieName, - getVisitorAuthCookieValue, -} from '@/lib/visitors'; - -import { getSiteAPIToken } from '../tests/utils'; -import { - type Test, - type TestsCase, - allDeprecatedThemePresets, - allLocales, - allSearchStyles, - allSidebarBackgroundStyles, - allThemeModes, - allThemes, - allTintColors, - getCustomizationURL, - headerLinks, - runTestCases, - waitForCookiesDialog, - waitForCoverImages, - waitForNotFound, -} from './util'; - -const searchTestCases: Test[] = [ - { - name: 'Search - AI Mode: None - Complete flow', - url: getCustomizationURL({ - ai: { - mode: CustomizationAIMode.None, - }, - }), - screenshot: false, - run: async (page) => { - const searchInput = page.getByTestId('search-input'); - await searchInput.focus(); - await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions. - - // Fill search input, expecting search results - await searchInput.fill('gitbook'); - await expect(page.getByTestId('search-results')).toBeVisible(); - const pageResults = await page.getByTestId('search-page-result').all(); - await expect(pageResults.length).toBeGreaterThanOrEqual(1); - const pageSectionResults = await page.getByTestId('search-page-section-result').all(); - await expect(pageSectionResults.length).toBeGreaterThanOrEqual(2); - await expect(page.getByTestId('search-ask-question')).toHaveCount(0); // No AI search results with aiMode=None. - }, - }, - { - name: 'Search - AI Mode: None - Keyboard shortcut', - url: getCustomizationURL({ - ai: { - mode: CustomizationAIMode.None, - }, - }), - screenshot: false, - run: async (page) => { - await page.keyboard.press('ControlOrMeta+K'); - await expect(page.getByTestId('search-input')).toBeFocused(); - }, - }, - { - name: 'Search - AI Mode: None - URL query (Initial)', - url: `${getCustomizationURL({ - ai: { - mode: CustomizationAIMode.None, - }, - })}&q=`, - run: async (page) => { - await expect(page.getByTestId('search-results')).toHaveCount(0); // No pop-up yet because there's no recommended questions. - }, - }, - { - name: 'Search - AI Mode: None - URL query (Results)', - url: `${getCustomizationURL({ - ai: { - mode: CustomizationAIMode.None, - }, - })}&q=gitbook`, - run: async (page) => { - await expect(page.getByTestId('search-input')).toBeFocused(); - await expect(page.getByTestId('search-input')).toHaveValue('gitbook'); - await expect(page.getByTestId('search-results')).toBeVisible(); - }, - }, - // TODO: Re-enable the following tests when we have fixed the AI Search timing out: - // - Search - AI Mode: Search - Complete flow - // - Search - AI Mode: Search - URL query (Initial) - { - name: 'Search - AI Mode: Search - URL query (Results)', - url: `${getCustomizationURL({ - ai: { - mode: CustomizationAIMode.Search, - }, - })}&q=gitbook`, - screenshot: false, - run: async (page) => { - await expect(page.getByTestId('search-input')).toBeFocused(); - await expect(page.getByTestId('search-input')).toHaveValue('gitbook'); - await expect(page.getByTestId('search-results')).toBeVisible(); - }, - }, - // TODO: Re-enable the following tests when we have fixed the AI Search timing out: - // - Ask - AI Mode: Search - URL query (Ask initial) - // - Ask - AI Mode: Search - URL query (Ask results) - { - name: 'Ask - AI Mode: Assistant - Complete flow', - url: getCustomizationURL({ - ai: { - mode: CustomizationAIMode.Assistant, - }, - }), - screenshot: false, - run: async (page) => { - const searchInput = page.locator('css=[data-testid="search-input"]'); - - // Focus search input, expecting recommended questions - await searchInput.focus(); - // TODO: Re-enable this part of the test when we have fixed the AI Search timing out - // await expect(page.getByTestId('search-results')).toBeVisible(); - // const recommendedQuestions = await page - // .getByTestId('search-recommended-question') - // .all(); - // await expect(recommendedQuestions.length).toBeGreaterThan(2); // Expect at least 3 questions - - // Fill search input, expecting AI search option - await searchInput.fill('What is gitbook?'); - const aiSearchResult = page.getByTestId('search-ask-question'); - await expect(aiSearchResult).toBeVisible(); - await aiSearchResult.click(); - await expect(page.getByTestId('ai-chat')).toBeVisible(); - }, - }, - { - name: 'Ask - AI Mode: Assistant - Keyboard shortcut', - url: getCustomizationURL({ - ai: { - mode: CustomizationAIMode.Assistant, - }, - }), - screenshot: false, - run: async (page) => { - await page.keyboard.press('ControlOrMeta+I'); - await expect(page.getByTestId('ai-chat')).toBeVisible(); - await expect(page.getByTestId('ai-chat-input')).toBeFocused(); - }, - }, - // { - // name: 'Ask - AI Mode: Assistant - Button', - // url: getCustomizationURL({ - // ai: { - // mode: CustomizationAIMode.Assistant, - // }, - // }), - // screenshot: false, - // run: async (page) => { - // await page.getByTestId('ai-chat-button').click(); - // await expect(page.getByTestId('ai-chat')).toBeVisible(); - // await expect(page.getByTestId('ai-chat-input')).toBeFocused(); - // }, - // }, - { - name: 'Ask - AI Mode: Assistant - URL query (Initial)', - url: `${getCustomizationURL({ - ai: { - mode: CustomizationAIMode.Assistant, - }, - })}&ask=`, - screenshot: false, - run: async (page) => { - await expect(page.getByTestId('search-input')).not.toBeFocused(); - await expect(page.getByTestId('search-input')).not.toHaveValue('What is GitBook?'); - await expect(page.getByTestId('ai-chat')).toBeVisible(); - await expect(page.getByTestId('ai-chat-input')).toBeFocused(); - }, - }, - { - name: 'Ask - AI Mode: Assistant - URL query (Results)', - url: `${getCustomizationURL({ - ai: { - mode: CustomizationAIMode.Assistant, - }, - })}&ask=What+is+GitBook%3F`, - screenshot: false, - run: async (page) => { - await expect(page.getByTestId('search-input')).not.toBeFocused(); - await expect(page.getByTestId('search-input')).not.toHaveValue('What is GitBook?'); - await expect(page.getByTestId('ai-chat')).toBeVisible({ - timeout: 15_000, - }); - await expect(page.getByTestId('ai-chat-message').first()).toHaveText( - 'What is GitBook?' - ); - }, - }, -]; - -const testCases: TestsCase[] = [ - { - name: 'GitBook Site (Single Variant)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/', - tests: [ - { - name: 'Home', - url: '', - run: waitForCookiesDialog, - }, - { - name: 'No variants dropdown', - url: '', - run: async (page) => { - await expect(page.locator('[data-testid="space-dropdown-button"]')).toHaveCount( - 0 - ); - }, - }, - { - name: 'Expandable TOC navigation', - url: '', - run: async (page) => { - await waitForCookiesDialog(page); - - // Verify "Navigation" link is not visible initially - const navigationLink = page.getByRole('link', { name: 'Navigation' }); - await expect(navigationLink).not.toBeVisible(); - - // Find and click the chevron element that is next to "Editor" in the TOC - // It is a span inside the link - const editorChevron = page - .getByRole('link', { name: 'Editor' }) - .locator('span'); - await editorChevron.click(); - - // Verify "Navigation" link becomes visible after expansion - await expect(navigationLink).toBeVisible(); - }, - }, - { - name: 'Expandable nested TOC navigation', - url: '', - screenshot: false, - run: async (page) => { - await waitForCookiesDialog(page); - - // Verify "Spaces" link is not visible initially - const navigationLink = page.getByRole('link', { name: 'Spaces' }); - await expect(navigationLink).not.toBeVisible(); - - // Find and click the chevron element that is next to "Editor" in the TOC - // It is a span inside the link - const editorChevron = page - .getByRole('link', { name: 'Editor' }) - .locator('span'); - await editorChevron.click(); - - // At this stage the link should still not be visible - await expect(navigationLink).not.toBeVisible(); - - // Then we click 'Content Structure' chevron to expand further - const contentStructureChevron = page - .getByRole('link', { name: 'Content Structure' }) - .locator('span'); - await contentStructureChevron.click(); - - // Verify "Spaces" link becomes visible after expansion - await expect(navigationLink).toBeVisible(); - }, - }, - ...searchTestCases, - { - name: 'Not found', - url: 'content-not-found', - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'GitBook Site (Multi Variants)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/multi-variants/', - tests: [ - { - name: 'Variants dropdown', - url: '', - run: async (page) => { - const spaceDrowpdown = page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDrowpdown.waitFor(); - }, - }, - { - name: 'Default variant', - url: '', - }, - { - name: 'RFC variant', - url: 'rfcs', - }, - { - name: 'Customized variant titles are displayed', - url: '', - run: async (page) => { - const spaceDropdown = page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDropdown.click(); - - const variantSelectionDropdown = page.locator( - 'css=[data-testid="dropdown-menu"]' - ); - // the customized space title - await expect( - variantSelectionDropdown.getByRole('menuitem', { - name: 'Multi-Variants', - }) - ).toBeVisible(); - - // the NON-customized space title - await expect( - variantSelectionDropdown.getByRole('menuitem', { - name: 'RFCs', - }) - ).toBeVisible(); - }, - }, - { - name: 'Switch variant with alternate link in metadata', - url: 'rfcs', - run: async (page) => { - const spaceDropdown = page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDropdown.click(); - - const variantSelectionDropdown = page.locator( - 'css=[data-testid="dropdown-menu"]' - ); - - // Click the variant space called 'Multi-Variants' for which - // there is an alternate link in the current (RFC variant) page metadata - await variantSelectionDropdown - .getByRole('menuitem', { - name: 'Multi-Variants', - }) - .click(); - - // It should navigate to the alternate link defined in the metadata (a completely different page) - await page.waitForURL((url) => - url.pathname.includes('multi-variants/reference/api-reference/pets') - ); - // Verify we are on the correct page by checking the h1 - await expect( - page.getByRole('heading', { level: 1, name: 'Pets' }) - ).toBeVisible(); - }, - }, - ], - }, - { - name: 'GitBook Site (Navigation when switching variant)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/', - tests: [ - { - name: 'Keep navigation path/route when switching variant (Public)', - url: 'api-multi-versions/reference/api-reference/pets', - screenshot: false, - run: async (page) => { - const spaceDropdown = await page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDropdown.click(); - - const variantSelectionDropdown = page.locator( - 'css=[data-testid="dropdown-menu"]' - ); - // Click the second variant in the dropdown - await variantSelectionDropdown - .getByRole('menuitem', { - name: '2.0', - }) - .click(); - - // It should keep the current page path, i.e "reference/api-reference/pets" when navigating to the new variant - await page.waitForURL((url) => - url.pathname.includes('api-multi-versions/2.0/reference/api-reference/pets') - ); - }, - }, - { - name: 'Keep navigation path/route when switching variant (Share link)', - url: 'api-multi-versions-share-links/8tNo6MeXg7CkFMzSSz81/reference/api-reference/pets', - screenshot: false, - run: async (page) => { - const spaceDropdown = await page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDropdown.click(); - - const variantSelectionDropdown = page.locator( - 'css=[data-testid="dropdown-menu"]' - ); - - // Click the second variant in the dropdown - await variantSelectionDropdown - .getByRole('menuitem', { - name: '2.0', - }) - .click(); - - // It should keep the current page path, i.e "reference/api-reference/pets" when navigating to the new variant - await page.waitForURL((url) => - url.pathname.includes( - 'api-multi-versions-share-links/8tNo6MeXg7CkFMzSSz81/2.0/reference/api-reference/pets' - ) - ); - }, - }, - { - name: 'Keep navigation path/route when switching variant (VA)', - screenshot: false, - url: () => { - const privateKey = 'c26190fc-74b2-4b54-9fc7-df9941104953'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `api-multi-versions-va/reference/api-reference/pets?jwt_token=${token}`; - }, - run: async (page) => { - const spaceDropdown = await page - .locator('[data-testid="space-dropdown-button"]') - .locator('visible=true'); - await spaceDropdown.click(); - - const variantSelectionDropdown = page.locator( - 'css=[data-testid="dropdown-menu"]' - ); - - // Click the second variant in the dropdown - await variantSelectionDropdown - .getByRole('menuitem', { - name: '2.0', - }) - .click(); - - // It should keep the current page path, i.e "reference/api-reference/pets" when navigating to the new variant - await page.waitForURL((url) => - url.pathname.includes( - 'api-multi-versions-va/2.0/reference/api-reference/pets' - ) - ); - }, - }, - ], - }, - { - name: 'GitBook Site (Sections and Section Groups)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/sections/', - tests: [ - { - name: 'Site with sections and section groups', - url: '', - }, - { - name: 'Section group dropdown', - url: '', - run: async (page) => { - await page.getByRole('button', { name: 'Test Section Group 1' }).hover(); - await expect(page.getByRole('link', { name: /Section B/ })).toBeVisible(); - }, - }, - { - name: 'Section group link', - url: '', - screenshot: false, - run: async (page) => { - const sectionGroupDropdown = await page.getByText('Test Section Group 1'); - await sectionGroupDropdown.hover(); - await page.getByText('Section B').click(); - await page.waitForURL((url) => url.pathname.includes('/sections/sections-4')); - }, - }, - ], - }, - { - name: 'GitBook', - contentBaseURL: 'https://gitbook.com/docs/', - tests: [ - { - name: 'Home', - url: '', - run: waitForCookiesDialog, - }, - ...searchTestCases, - { - name: 'Not found', - url: 'content-not-found', - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Versioning', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Revision', - url: '~/revisions/S55pwsEr5UVoroaOiWnP/blocks/headings', - run: waitForCookiesDialog, - }, - { - name: 'Invalid revision', - url: '~/revisions/idnotfound/blocks/headings', - run: waitForNotFound, - screenshot: false, - }, - { - name: 'Invalid change request', - url: '~/changes/idnotfound/blocks/headings', - run: waitForNotFound, - screenshot: false, - }, - ], - }, - { - name: 'PDF', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'PDF', - url: '~gitbook/pdf?limit=10', - screenshot: { - waitForTOCScrolling: false, - }, - run: async (page) => { - await expect(page.locator('[data-testid="print-button"]')).toBeVisible(); - }, - }, - ], - }, - { - name: 'Space PDF', - tests: [ - { - name: 'Main content', - url: async () => { - const data = await getSiteAPIToken( - 'https://gitbook.gitbook.io/test-gitbook-open/' - ); - - const searchParams = new URLSearchParams(); - searchParams.set('limit', '10'); - searchParams.set('token', data.apiToken); - - return `~space/${data.space}/~gitbook/pdf?${searchParams.toString()}`; - }, - screenshot: false, - run: async (page) => { - await expect(page.locator('[data-testid="print-button"]')).toBeVisible(); - }, - }, - { - name: 'Change request', - url: async () => { - const data = await getSiteAPIToken( - 'https://gitbook.gitbook.io/test-gitbook-open/' - ); - - const searchParams = new URLSearchParams(); - searchParams.set('limit', '10'); - searchParams.set('token', data.apiToken); - - return `~space/${data.space}/~/changes/HrtgUd5MlFusCMv1elA7/~gitbook/pdf?${searchParams.toString()}`; - }, - screenshot: false, - run: async (page) => { - await expect(page.locator('[data-testid="print-button"]')).toBeVisible(); - }, - }, - ], - }, - { - name: 'Site Preview', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - tests: [ - { - name: 'Main content', - url: async () => { - const data = await getSiteAPIToken( - 'https://gitbook.gitbook.io/test-gitbook-open/' - ); - - const searchParams = new URLSearchParams(); - searchParams.set('token', data.apiToken); - - return `url/preview/${data.site}/?${searchParams.toString()}`; - }, - screenshot: false, - run: async (page) => { - await expect(page.locator('[data-testid="table-of-contents"]')).toBeVisible(); - }, - }, - { - name: 'With sections', - url: async () => { - const data = await getSiteAPIToken('https://gitbook.com/docs'); - - const searchParams = new URLSearchParams(); - searchParams.set('token', data.apiToken); - - return `url/preview/${data.site}/?${searchParams.toString()}`; - }, - screenshot: false, - run: async (page) => { - const sectionTabs = page.getByLabel('Sections'); - await expect(sectionTabs).toBeVisible(); - - const sectionTabLinks = sectionTabs.getByRole('link'); - for (const link of await sectionTabLinks.all()) { - const href = await link.getAttribute('href'); - expect(href).toMatch(/^\/url\/preview\/site_p4Xo4\/?/); - } - }, - }, - ], - }, - { - name: 'Markdown page', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Text page', - url: 'text-page.md', - screenshot: false, - run: async (_page, response) => { - expect(response?.status()).toBe(200); - expect(response?.headers()['content-type']).toContain('text/markdown'); - }, - }, - ], - }, - { - name: 'llms.txt', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'llms.txt', - url: 'llms.txt', - screenshot: false, - run: async (_page, response) => { - expect(response?.status()).toBe(200); - expect(response?.headers()['content-type']).toContain('text/markdown'); - }, - }, - ], - }, - { - name: 'llms-full.txt', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'llms-full.txt', - url: 'llms-full.txt', - screenshot: false, - run: async (_page, response) => { - expect(response?.status()).toBe(200); - expect(response?.headers()['content-type']).toContain('text/markdown'); - }, - }, - ], - }, - { - name: '[page].md', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'blocks.md', - url: 'blocks.md', - screenshot: false, - run: async (_page, response) => { - expect(response?.status()).toBe(200); - expect(response?.headers()['content-type']).toContain('text/markdown'); - }, - }, - ], - }, - { - name: 'Site subdirectory (proxy)', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://nextjs-gbo-proxy.vercel.app/documentation/', - tests: [ - { - name: 'Main', - url: '', - fullPage: true, - }, - ], - }, - { - name: 'Site subdirectory (proxy) with VA', - skip: process.env.ARGOS_BUILD_NAME !== 'v2-vercel', - contentBaseURL: 'https://nextjs-gbo-proxy-va.vercel.app/va/docs/', - tests: [ - { - name: 'Main', - url: () => { - const privateKey = - 'rqSfA6x7eAKx1qDRCDq9aCXwivpUvQ8YkXeDdFvCCUa9QchIcM7pF1iJ4o7AGOU49spmOWjKoIPtX0pVUVQ81w=='; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - fullPage: true, - }, - ], - }, - { - name: 'Content tests', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Text', - url: 'text-page', - run: waitForCookiesDialog, - }, - { - name: 'Long text', - url: 'text-page/long-text', - run: waitForCookiesDialog, - }, - { - name: 'Images', - url: 'blocks/block-images', - run: waitForCookiesDialog, - fullPage: true, - screenshot: { threshold: 0.9 }, - }, - { - name: 'Images (with zoom)', - url: 'blocks/block-images', - run: async (page) => { - await waitForCookiesDialog(page); - const zoomImage = page.getByTestId('zoom-image'); - await zoomImage.first().click(); - await expect(page.getByTestId('zoom-image-modal')).toBeVisible(); - }, - screenshot: { threshold: 0.8 }, - }, - { - name: 'Inline Images', - url: 'blocks/inline-images', - run: async (page) => { - await waitForCookiesDialog(page); - // Make the text invisible to fix flakiness due to the text position. - await page.evaluate(() => { - for (const p of document.querySelectorAll('p')) { - if ( - p.textContent?.includes( - 'This image has intrinsic 400px width, but renders as 300px:' - ) - ) { - p.style.color = 'transparent'; - } - } - }); - }, - }, - { - name: 'Tabs', - url: 'blocks/tabs', - run: waitForCookiesDialog, - }, - { - name: 'Hints', - url: 'blocks/hints', - run: waitForCookiesDialog, - }, - { - name: 'Integration Blocks', - url: 'blocks/integrations', - run: async (page) => { - await waitForCookiesDialog(page); - const mermaidIframe = page - .locator('iframe[title*="mermaid"]') - .first() - .contentFrame(); - await expect(mermaidIframe.getByText('Mermaid', { exact: true })).toBeVisible(); - await expect(mermaidIframe.getByText('Diagram', { exact: true })).toBeVisible(); - }, - }, - { - name: 'Tables', - url: 'blocks/tables', - run: waitForCookiesDialog, - fullPage: true, - }, - { - name: 'Expandables', - url: 'blocks/expandables', - run: waitForCookiesDialog, - }, - { - name: 'API Blocks', - url: 'blocks/api-blocks', - run: waitForCookiesDialog, - }, - { - name: 'Headings', - url: 'blocks/headings', - run: waitForCookiesDialog, - }, - { - name: 'Marks', - url: 'blocks/marks', - run: waitForCookiesDialog, - }, - { - name: 'Emojis', - url: 'blocks/emojis', - run: waitForCookiesDialog, - }, - { - name: 'Icons', - url: 'blocks/icons', - run: waitForCookiesDialog, - }, - { - name: 'Links', - url: 'blocks/links', - run: waitForCookiesDialog, - }, - { - name: 'Buttons', - url: 'blocks/buttons', - run: waitForCookiesDialog, - }, - { - name: 'Lists', - url: 'blocks/lists', - fullPage: true, - }, - { - name: 'Code', - url: 'blocks/code', - fullPage: true, - }, - { - name: 'Cards', - url: 'blocks/cards', - fullPage: true, - }, - { - name: 'Math', - url: 'blocks/math', - run: async (page) => { - await page.waitForFunction(() => { - const fonts = Array.from(document.fonts.values()); - const mjxFonts = fonts.filter( - (font) => font.family === 'MJXZERO' || font.family === 'MJXTEX' - ); - return ( - mjxFonts.length === 2 && - mjxFonts.every((font) => font.status === 'loaded') - ); - }); - }, - }, - { - name: 'Files', - url: 'blocks/files', - fullPage: true, - }, - { - name: 'Embeds', - url: 'blocks/embeds', - fullPage: true, - }, - { - name: 'Page links', - url: 'blocks/page-links', - fullPage: true, - }, - { - name: 'Annotations', - url: 'blocks/annotations', - run: async (page) => { - await page.waitForSelector('[data-testid="annotation-button"]'); - await page.click('[data-testid="annotation-button"]'); - }, - }, - { - name: 'Stepper', - url: 'blocks/stepper', - }, - { name: 'Columns', url: 'blocks/columns' }, - ], - }, - { - name: 'Page options', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Hidden', - url: 'page-options/page-hidden', - run: waitForCookiesDialog, - }, - { - name: 'With cover', - url: 'page-options/page-with-cover', - run: async (page) => { - await waitForCookiesDialog(page); - await waitForCoverImages(page); - }, - }, - { - name: 'With cover for dark mode', - url: `page-options/page-with-dark-cover${getCustomizationURL({ - themes: { - default: CustomizationThemeMode.Dark, - toggeable: false, - }, - })}`, - run: waitForCookiesDialog, - }, - { - name: 'With hero cover', - url: 'page-options/page-with-hero-cover', - run: async (page) => { - await waitForCookiesDialog(page); - await waitForCoverImages(page); - }, - }, - { - name: 'With cover and no TOC', - url: 'page-options/page-with-cover-and-no-toc', - run: async (page) => { - await waitForCookiesDialog(page); - await waitForCoverImages(page); - }, - screenshot: { - waitForTOCScrolling: false, - }, - }, - { - name: 'With icon', - url: 'page-options/page-with-icon', - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Customization', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: allThemeModes.flatMap((themeMode) => [ - { - name: `Without header - Theme mode ${themeMode}`, - url: getCustomizationURL({ - header: { - preset: CustomizationHeaderPreset.None, - links: [], - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - }, - { - name: `With duotone icons - Theme mode ${themeMode}`, - url: `page-options/page-with-icon${getCustomizationURL({ - styling: { - icons: CustomizationIconsStyle.Duotone, - }, - themes: { - default: themeMode, - toggeable: false, - }, - })}`, - run: waitForCookiesDialog, - }, - { - name: `With header buttons - Theme mode ${themeMode}`, - url: getCustomizationURL({ - header: { - preset: CustomizationHeaderPreset.Default, - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - }, - { - name: `Without tint - Default preset - Theme mode ${themeMode}`, - url: getCustomizationURL({ - header: { - preset: CustomizationHeaderPreset.Default, - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - }, - { - name: `With custom monospace font - Theme mode ${themeMode}`, - url: `blocks/code${getCustomizationURL({ - styling: { - monospaceFont: CustomizationDefaultMonospaceFont.SpaceMono, - }, - })}`, - run: waitForCookiesDialog, - }, - // New site themes - ...allThemes.flatMap((theme) => [ - ...allTintColors.flatMap((tint) => [ - ...allSidebarBackgroundStyles.flatMap((sidebarStyle) => ({ - name: `Theme ${theme} - Tint ${tint.label} - Sidebar ${sidebarStyle} - Mode ${themeMode}`, - url: getCustomizationURL({ - styling: { - theme, - ...(tint.value ? { tint: { color: tint.value } } : {}), - sidebar: { - background: sidebarStyle, - list: CustomizationSidebarListStyle.Default, - }, - }, - header: { - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - })), - ]), - ...allSearchStyles.flatMap((searchStyle) => ({ - name: `Theme ${theme} – Search ${searchStyle} – Mode ${themeMode}`, - url: getCustomizationURL({ - styling: { - theme, - search: searchStyle, - }, - header: { - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - })), - ]), - // Deprecated header themes - ...allDeprecatedThemePresets.flatMap((preset) => [ - ...allSidebarBackgroundStyles.flatMap((sidebarStyle) => ({ - name: `With tint - Legacy header preset ${preset} - Sidebar ${sidebarStyle} - Theme mode ${themeMode}`, - url: getCustomizationURL({ - styling: { - tint: { color: { light: '#346DDB', dark: '#346DDB' } }, - sidebar: { - background: sidebarStyle, - list: CustomizationSidebarListStyle.Default, - }, - }, - header: { - preset, - ...(preset === CustomizationHeaderPreset.Custom - ? { - backgroundColor: { light: '#C62C68', dark: '#EF96B8' }, - linkColor: { light: '#4DDE98', dark: '#0C693D' }, - } - : {}), - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - })), - ]), - { - name: `With tint - Legacy background match - Theme mode ${themeMode}`, - url: getCustomizationURL({ - styling: { - background: CustomizationBackground.Match, - }, - header: { - preset: CustomizationHeaderPreset.Default, - links: headerLinks, - }, - themes: { - default: themeMode, - toggeable: false, - }, - }), - run: waitForCookiesDialog, - }, - { - name: `With flat and circular corners - Theme mode ${themeMode}`, - url: getCustomizationURL({ - styling: { - depth: CustomizationDepth.Flat, - corners: CustomizationCorners.Circular, - }, - }), - run: waitForCookiesDialog, - }, - ]), - }, - { - name: 'Page actions', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Without page actions', - url: getCustomizationURL({ - pageActions: { - markdown: false, - externalAI: false, - }, - }), - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Ads', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Without previewed ads', - url: 'text-page?ads_preview=1', - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Shared space navigation (first site)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/shared-space-uno/', - tests: [ - { - name: 'Navigation to shared space', - url: '', - run: async (page) => { - const sharedSpaceLink = page.locator('a.underline'); - await sharedSpaceLink.click(); - await expect( - page.getByRole('heading', { level: 1, name: 'shared' }) - ).toBeVisible(); - const url = page.url(); - expect(url.includes('shared-space-uno')).toBeTruthy(); // same uno site - expect(url.endsWith('/shared/')).toBeTruthy(); // correct page - }, - screenshot: false, - }, - ], - }, - { - name: 'Shared space navigation (second site)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/shared-space-dos/', - tests: [ - { - name: 'Navigation to shared space', - url: '', - run: async (page) => { - await page.locator('a.underline').click(); - await expect( - page.getByRole('heading', { level: 1, name: 'shared' }) - ).toBeVisible(); - const url = page.url(); - expect(url.includes('shared-space-dos')).toBeTruthy(); // same dos site - expect(url.endsWith('/shared/')).toBeTruthy(); // correct page - }, - screenshot: false, - }, - ], - }, - { - name: 'Site Redirects', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/', - tests: [ - { - name: 'Redirect to SSO page', - url: 'a/redirect/to/sso', - run: async (page) => { - await expect(page.locator('h1')).toHaveText('SSO'); - }, - screenshot: false, - }, - ], - }, - { - name: 'Content Redirects', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/', - tests: [ - { - name: 'Redirect to new location', - url: '/content-editor/editing-content/inline/redirect-test', - run: async (page) => { - await expect(page.locator('h1')).toHaveText('Redirect test'); - }, - screenshot: false, - }, - ], - }, - { - name: 'Site Redirects with sections', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/sections/', - tests: [ - { - // This test that a redirect that incudes a section path works - name: 'Redirect to Quickstart page', - url: 'sections-2/redirect-test', - run: async (page) => { - await expect(page.locator('h1')).toHaveText('Quickstart'); - }, - screenshot: false, - }, - ], - }, - { - name: 'Share links', - contentBaseURL: 'https://gitbook.gitbook.io/gbo-tests-share-links/', - tests: [ - { - name: 'Valid link', - url: 'thDznyWXCeEoT55WB7HC/', - }, - { - name: 'Invalid link', - url: 'invalid/', - run: async (page) => { - await expect( - page.getByText('Authentication missing to access this content') - ).toBeVisible(); - }, - screenshot: false, - }, - ], - }, - { - name: 'Visitor Auth - Space', - contentBaseURL: 'https://gitbook.gitbook.io/gbo-va-space/', - tests: [ - { - name: 'First', - url: () => { - const privateKey = '70b844d0-c519-4532-8586-5970ce48c537'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `first?jwt_token=${token}`; - }, - run: async (page) => { - await expect( - page.getByRole('heading', { level: 1, name: 'first' }) - ).toBeVisible(); - }, - screenshot: false, - }, - { - name: 'Second', - url: () => { - const privateKey = '70b844d0-c519-4532-8586-5970ce48c537'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `second?jwt_token=${token}`; - }, - run: async (page) => { - await expect( - page.getByRole('heading', { level: 1, name: 'second' }) - ).toBeVisible(); - }, - screenshot: false, - }, - ], - }, - { - name: 'Visitor Auth - Collection', - contentBaseURL: 'https://gitbook.gitbook.io/gbo-va-collection/', - tests: [ - { - name: 'Root', - url: () => { - const privateKey = 'af5688dc-f0b6-4146-9b1d-6d834c62c980'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - { - name: 'Primary (Space A)', - url: () => { - const privateKey = 'af5688dc-f0b6-4146-9b1d-6d834c62c980'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - - // Test that when accessing the non-canonical URL, we are redirected to the canonical URL - // with the jwt token in the query string - return `spacea?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - { - name: 'Space B', - url: () => { - const privateKey = 'af5688dc-f0b6-4146-9b1d-6d834c62c980'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `spaceb?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - { - name: 'Space C', - url: () => { - const privateKey = 'af5688dc-f0b6-4146-9b1d-6d834c62c980'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `spacec?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Visitor Auth - Space (custom domain)', - contentBaseURL: 'https://test.gitbook.community/', - tests: [ - { - name: 'Root', - url: () => { - const privateKey = '19c8166f-c436-4ed1-a24e-60954b804021'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - { - name: 'First', - url: () => { - const privateKey = '19c8166f-c436-4ed1-a24e-60954b804021'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `first?jwt_token=${token}`; - }, - run: async (page) => { - await expect( - page.getByRole('heading', { level: 1, name: 'first' }) - ).toBeVisible(); - }, - screenshot: false, - }, - { - name: 'Custom page', - url: () => { - const privateKey = '19c8166f-c436-4ed1-a24e-60954b804021'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `custom-page?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - { - name: 'Inner page', - url: () => { - const privateKey = '19c8166f-c436-4ed1-a24e-60954b804021'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `custom-page/inner-page?jwt_token=${token}`; - }, - run: waitForCookiesDialog, - }, - ], - }, - { - name: 'Visitor Auth - Site (redirects to fallback/auth URL)', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/va-site-redirects-fallback/', - tests: [ - { - name: 'Redirect to fallback on invalid token pulled from cookie', - url: '', - screenshot: false, - cookies: (() => { - const basePath = '/va-site-redirects-fallback/'; - const invalidToken = jwt.sign( - { - name: 'gitbook-open-tests', - }, - 'invalidKey', - { - expiresIn: '24h', - } - ); - return [ - { - name: getVisitorAuthCookieName(basePath), - value: getVisitorAuthCookieValue(basePath, invalidToken), - httpOnly: true, - }, - ]; - })(), - run: async (page) => { - await expect(page).toHaveURL(/https:\/\/www.google.com/); - }, - }, - { - name: 'Show error message when invalid token is passed to url', - screenshot: false, - url: () => { - const token = jwt.sign( - { - name: 'gitbook-open-tests', - }, - 'invalidKey', - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: async (page) => { - await expect(page.locator('pre')).toContainText( - 'Error while validating the JWT token. Reason: The token signature is invalid.' - ); - }, - }, - ], - }, - { - name: 'Languages', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: allLocales.map((locale) => ({ - name: locale, - url: getCustomizationURL({ - internationalization: { - locale, - }, - }), - run: waitForCookiesDialog, - })), - }, - { - name: 'SEO', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Index by default', - url: '?x-gitbook-search-indexation=true', - screenshot: false, - run: async (page) => { - const metaRobots = page.locator('meta[name="robots"]'); - await expect(metaRobots).toHaveAttribute('content', 'index, follow'); - }, - }, - { - name: `Don't index noIndex`, - url: 'page-options/page-no-index?x-gitbook-search-indexation=true', - screenshot: false, - run: async (page) => { - const metaRobots = page.locator('meta[name="robots"]'); - await expect(metaRobots).toHaveAttribute('content', 'noindex, nofollow'); - }, - }, - { - name: `Don't index descendant of noIndex`, - url: 'page-options/page-no-index/descendant-of-page-no-index?x-gitbook-search-indexation=true', - screenshot: false, - run: async (page) => { - const metaRobots = page.locator('meta[name="robots"]'); - await expect(metaRobots).toHaveAttribute('content', 'noindex, nofollow'); - }, - }, - { - name: `Don't index noRobotsIndex`, - url: 'page-options/page-no-robots-index?x-gitbook-search-indexation=true', - screenshot: false, - run: async (page) => { - const metaRobots = page.locator('meta[name="robots"]'); - await expect(metaRobots).toHaveAttribute('content', 'noindex, nofollow'); - }, - }, - { - name: `Don't index descendant of noRobotsIndex`, - url: 'page-options/page-no-robots-index/descendant-of-page-no-robots-index?x-gitbook-search-indexation=true', - screenshot: false, - run: async (page) => { - const metaRobots = page.locator('meta[name="robots"]'); - await expect(metaRobots).toHaveAttribute('content', 'noindex, nofollow'); - }, - }, - ], - }, - { - name: 'Adaptive Content - VA', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/adaptive-content-va/', - tests: [ - { - name: 'isAlphaUser', - url: () => { - const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isAlphaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: async (page) => { - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha users' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta users' }); - await expect(alphaUserPage).toBeVisible(); - await expect(betaUserPage).toHaveCount(0); - }, - }, - { - name: 'isBetaUser', - url: () => { - const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isBetaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: async (page) => { - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha users' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta users' }); - await expect(betaUserPage).toBeVisible(); - await expect(alphaUserPage).toHaveCount(0); - }, - }, - { - name: 'isAlphaUser & isBetaUser', - url: () => { - const privateKey = 'afe09cdf-0f43-480a-b54c-8b1f62f174f9'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isAlphaUser: true, - isBetaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return `?jwt_token=${token}`; - }, - run: async (page) => { - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha users' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta users' }); - await expect(alphaUserPage).toBeVisible(); - await expect(betaUserPage).toBeVisible(); - }, - }, - ], - }, - { - name: 'Adaptive Content - Public', - contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/adaptive-content-public/', - tests: [ - { - name: 'No custom cookie', - url: '', - run: async (page) => { - const welcomePage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Welcome Page' }); - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha User' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta User' }); - - await expect(welcomePage).toBeVisible(); - await expect(alphaUserPage).toHaveCount(0); - await expect(betaUserPage).toHaveCount(0); - }, - }, - { - name: 'Custom cookie with isAlphaUser claim', - cookies: (() => { - const privateKey = '4ddd3c2f-e4b7-4e73-840b-526c3be19746'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isAlphaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return [ - { - name: VISITOR_TOKEN_COOKIE, - value: token, - httpOnly: true, - }, - ]; - })(), - url: '', - run: async (page) => { - const welcomePage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Welcome Page' }); - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha User' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta User' }); - - await expect(welcomePage).toBeVisible(); - await expect(alphaUserPage).toBeVisible(); - await expect(betaUserPage).toHaveCount(0); - }, - }, - { - name: 'Custom cookie with isBetaUser claim', - cookies: (() => { - const privateKey = '4ddd3c2f-e4b7-4e73-840b-526c3be19746'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isBetaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return [ - { - name: VISITOR_TOKEN_COOKIE, - value: token, - httpOnly: true, - }, - ]; - })(), - url: '', - run: async (page) => { - const welcomePage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Welcome Page' }); - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha User' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta User' }); - - await expect(welcomePage).toBeVisible(); - await expect(betaUserPage).toBeVisible(); - await expect(alphaUserPage).toHaveCount(0); - }, - }, - { - name: 'Custom cookie with isAlphaUser & isBetaUser claims', - cookies: (() => { - const privateKey = '4ddd3c2f-e4b7-4e73-840b-526c3be19746'; - const token = jwt.sign( - { - name: 'gitbook-open-tests', - isAlphaUser: true, - isBetaUser: true, - }, - privateKey, - { - expiresIn: '24h', - } - ); - return [ - { - name: VISITOR_TOKEN_COOKIE, - value: token, - httpOnly: true, - }, - ]; - })(), - url: '', - run: async (page) => { - const welcomePage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Welcome Page' }); - const alphaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Alpha User' }); - const betaUserPage = page - .locator('a[class*="group\\/toclink"]') - .filter({ hasText: 'Beta User' }); - - await expect(welcomePage).toBeVisible(); - await expect(betaUserPage).toBeVisible(); - await expect(alphaUserPage).toBeVisible(); - }, - }, - ], - }, - { - name: 'Tables', - contentBaseURL: 'https://gitbook.gitbook.io/test-gitbook-open/', - tests: [ - { - name: 'Default table', - url: 'blocks/tables', - run: waitForCookiesDialog, - fullPage: true, - }, - { - name: 'Table with straight corners', - url: `blocks/tables${getCustomizationURL({ - styling: { - corners: CustomizationCorners.Straight, - }, - })}`, - run: waitForCookiesDialog, - fullPage: true, - }, - { - name: 'Table with primary color', - url: `blocks/tables${getCustomizationURL({ - styling: { - tint: { color: { light: '#346DDB', dark: '#346DDB' } }, - }, - })}`, - run: waitForCookiesDialog, - fullPage: true, - }, - // Test dark mode for each variant - ...allThemeModes.flatMap((theme) => [ - { - name: `Table in ${theme} mode`, - url: `blocks/tables${getCustomizationURL({ - themes: { - default: theme, - toggeable: false, - }, - })}`, - run: waitForCookiesDialog, - fullPage: true, - }, - { - name: `Table with straight corners in ${theme} mode`, - url: `blocks/tables${getCustomizationURL({ - styling: { - corners: CustomizationCorners.Straight, - }, - themes: { - default: theme, - toggeable: false, - }, - })}`, - run: waitForCookiesDialog, - fullPage: true, - }, - { - name: `Table with primary color in ${theme} mode`, - url: `blocks/tables${getCustomizationURL({ - styling: { - tint: { color: { light: '#346DDB', dark: '#346DDB' } }, - }, - themes: { - default: theme, - toggeable: false, - }, - })}`, - run: waitForCookiesDialog, - fullPage: true, - }, - ]), - ], - }, -]; - -runTestCases(testCases); diff --git a/packages/gitbook/e2e/pdf.spec.ts b/packages/gitbook/e2e/pdf.spec.ts deleted file mode 100644 index 4798a2a047..0000000000 --- a/packages/gitbook/e2e/pdf.spec.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { argosScreenshot } from '@argos-ci/playwright'; -import { expect, test } from '@playwright/test'; -import { getContentTestURL } from '../tests/utils'; -import { waitForIcons } from './util'; - -test.describe('PDF export', () => { - test('export all pages as PDF (e2e)', async ({ page }) => { - // Set the header to disable the Vercel toolbar - // But only on the main document as it'd cause CORS issues on other resources - await page.route('**/*', async (route, request) => { - if (request.resourceType() === 'document') { - await route.continue({ - headers: { - ...request.headers(), - 'x-vercel-skip-toolbar': '1', - }, - }); - } else { - await route.continue(); - } - }); - - await page.goto( - getContentTestURL( - 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/~gitbook/pdf?limit=10' - ) - ); - - const printBtn = page.getByTestId('print-button'); - await expect(printBtn).toBeVisible(); - - await argosScreenshot(page, 'pdf - all pages', { - viewports: ['macbook-13'], - argosCSS: ` - /* Hide Intercom */ - .intercom-lightweight-app { - display: none !important; - } - `, - threshold: undefined, - fullPage: true, - beforeScreenshot: async ({ runStabilization }) => { - await runStabilization(); - await waitForIcons(page); - }, - }); - }); - - test('export all pages as PDF (GitBook docs)', async ({ page }) => { - // Set the header to disable the Vercel toolbar - // But only on the main document as it'd cause CORS issues on other resources - await page.route('**/*', async (route, request) => { - if (request.resourceType() === 'document') { - await route.continue({ - headers: { - ...request.headers(), - 'x-vercel-skip-toolbar': '1', - }, - }); - } else { - await route.continue(); - } - }); - - await page.goto(getContentTestURL('https://gitbook.com/docs/~gitbook/pdf?limit=10')); - - const printBtn = page.getByTestId('print-button'); - await expect(printBtn).toBeVisible(); - - await argosScreenshot(page, 'pdf - all pages', { - viewports: ['macbook-13'], - argosCSS: ` - /* Hide Intercom */ - .intercom-lightweight-app { - display: none !important; - } - `, - threshold: undefined, - fullPage: true, - beforeScreenshot: async ({ runStabilization }) => { - await runStabilization(); - await waitForIcons(page); - }, - }); - }); - - test('export a single page as PDF (e2e)', async ({ page }) => { - // Set the header to disable the Vercel toolbar - // But only on the main document as it'd cause CORS issues on other resources - await page.route('**/*', async (route, request) => { - if (request.resourceType() === 'document') { - await route.continue({ - headers: { - ...request.headers(), - 'x-vercel-skip-toolbar': '1', - }, - }); - } else { - await route.continue(); - } - }); - - await page.goto( - getContentTestURL( - 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/~gitbook/pdf?page=Bw7LjWwgTjV8nIV4s7rs&only=yes&limit=2' - ) - ); - - const printBtn = page.getByTestId('print-button'); - await expect(printBtn).toBeVisible(); - - await argosScreenshot(page, 'pdf - all pages', { - viewports: ['macbook-13'], - argosCSS: ` - /* Hide Intercom */ - .intercom-lightweight-app { - display: none !important; - } - `, - threshold: undefined, - fullPage: true, - beforeScreenshot: async ({ runStabilization }) => { - await runStabilization(); - await waitForIcons(page); - }, - }); - }); - - test('export a single page as PDF (GitBook docs)', async ({ page }) => { - // Set the header to disable the Vercel toolbar - // But only on the main document as it'd cause CORS issues on other resources - await page.route('**/*', async (route, request) => { - if (request.resourceType() === 'document') { - await route.continue({ - headers: { - ...request.headers(), - 'x-vercel-skip-toolbar': '1', - }, - }); - } else { - await route.continue(); - } - }); - - await page.goto( - getContentTestURL( - 'https://gitbook.com/docs/~gitbook/pdf?page=DfnNkU49mvLe2ythHAyx&only=yes&limit=2' - ) - ); - - const printBtn = page.getByTestId('print-button'); - await expect(printBtn).toBeVisible(); - - await argosScreenshot(page, 'pdf - all pages', { - viewports: ['macbook-13'], - argosCSS: ` - /* Hide Intercom */ - .intercom-lightweight-app { - display: none !important; - } - `, - threshold: undefined, - fullPage: true, - beforeScreenshot: async ({ runStabilization }) => { - await runStabilization(); - await waitForIcons(page); - }, - }); - }); -}); diff --git a/packages/gitbook/e2e/util.ts b/packages/gitbook/e2e/util.ts deleted file mode 100644 index 6b62dea8c0..0000000000 --- a/packages/gitbook/e2e/util.ts +++ /dev/null @@ -1,470 +0,0 @@ -import { argosScreenshot } from '@argos-ci/playwright'; -import { - CustomizationAIMode, - CustomizationBackground, - CustomizationCorners, - CustomizationDefaultFont, - CustomizationDefaultMonospaceFont, - CustomizationDepth, - type CustomizationHeaderItem, - CustomizationHeaderPreset, - CustomizationIconsStyle, - CustomizationLinksStyle, - CustomizationLocale, - CustomizationSearchStyle, - CustomizationSidebarBackgroundStyle, - CustomizationSidebarListStyle, - CustomizationTheme, - CustomizationThemeMode, - type CustomizationThemedColor, - type SiteCustomizationSettings, - SiteExternalLinksTarget, -} from '@gitbook/api'; -import { type BrowserContext, type Page, type Response, expect, test } from '@playwright/test'; -import deepMerge from 'deepmerge'; -import rison from 'rison'; -import type { DeepPartial } from 'ts-essentials'; - -import { getContentTestURL, getTestURL } from '../tests/utils'; - -export interface Test { - name: string; - /** - * URL to visit for testing. - */ - url: string | (() => string | Promise- } - onClick={() => assistant.open()} - > - {showLabel ? t(language, 'ask') : null} - - ); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatControlButton.tsx b/packages/gitbook/src/components/AIChat/AIChatControlButton.tsx deleted file mode 100644 index f909b62ab9..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatControlButton.tsx +++ /dev/null @@ -1,40 +0,0 @@ -'use client'; - -import { useLanguage } from '@/intl/client'; -import { t, tString } from '@/intl/translate'; -import { Icon } from '@gitbook/icons'; -import { useAIChatController, useAIChatState } from '../AI'; -import { Button, DropdownMenu, DropdownMenuItem } from '../primitives'; - -/** - * Button to control the chat (clear, etc.) - */ -export function AIChatControlButton() { - const language = useLanguage(); - const chat = useAIChatState(); - const chatController = useAIChatController(); - - return chat.messages.length > 0 ? ( -); - cookies?: Parameters [0]; - /** - * Test to run - */ - run?: (page: Page, response: Response | null) => Promise ; - /** - * Mode for the test. - */ - mode?: 'page' | 'image'; - /** - * Whether the test should be fullscreened during testing. - */ - fullPage?: boolean; - /** - * Whether to take a screenshot of the test or set a threshold for the screenshot. - */ - screenshot?: - | false - | { - /** - * Screenshot threshold. - * From 0 to 1, where 0 is the most strict and 1 is the most permissive. - * @default 0.5 - */ - threshold?: number; - /** - * Whether to wait for the table of contents to finish scrolling before taking the screenshot. - */ - waitForTOCScrolling?: boolean; - }; - /** - * Whether to only run this test. - */ - only?: boolean; -} - -export type TestsCase = { - name: string; - skip?: boolean; - tests: Array ; - contentBaseURL?: string; -}; - -export const allLocales: CustomizationLocale[] = [ - CustomizationLocale.Fr, - CustomizationLocale.Es, - CustomizationLocale.Ja, - CustomizationLocale.Zh, -]; - -export const allThemeModes: CustomizationThemeMode[] = [ - CustomizationThemeMode.Light, - CustomizationThemeMode.Dark, -]; - -export const allTintColors: Array<{ - label: string; - value: CustomizationThemedColor | undefined; -}> = [ - { - label: 'Off', - value: undefined, - }, - { label: 'Primary', value: { light: '#346DDB', dark: '#346DDB' } }, - { label: 'Custom', value: { light: '#C62C68', dark: '#EF96B8' } }, -]; - -export const allThemes: CustomizationTheme[] = [ - CustomizationTheme.Clean, - CustomizationTheme.Muted, - CustomizationTheme.Bold, - CustomizationTheme.Gradient, -]; - -export const allDeprecatedThemePresets: CustomizationHeaderPreset[] = [ - CustomizationHeaderPreset.Default, - CustomizationHeaderPreset.Bold, - CustomizationHeaderPreset.Contrast, - CustomizationHeaderPreset.Custom, -]; - -export const allSidebarBackgroundStyles: CustomizationSidebarBackgroundStyle[] = [ - CustomizationSidebarBackgroundStyle.Default, - CustomizationSidebarBackgroundStyle.Filled, -]; - -export const allSearchStyles: CustomizationSearchStyle[] = [ - CustomizationSearchStyle.Prominent, - CustomizationSearchStyle.Subtle, -]; - -// Common customization settings - -export const headerLinks: CustomizationHeaderItem[] = [ - { - title: 'Secondary button', - to: { kind: 'url', url: 'https://www.gitbook.com' }, - style: 'button-secondary', - links: [], - }, - { - title: 'Primary button', - to: { kind: 'url', url: 'https://www.gitbook.com' }, - style: 'button-primary', - links: [], - }, -]; - -export async function waitForCookiesDialog(page: Page) { - const dialog = page.getByTestId('cookies-dialog'); - await expect(dialog).toBeVisible({ - // Cookies dialog may take some times to appear - timeout: 10_000, - }); -} - -export async function waitForNotFound(_page: Page, response: Response | null) { - expect(response).not.toBeNull(); - expect(response?.status()).toBe(404); -} - -export async function waitForCoverImages(page: Page) { - // Wait for cover images to exist (not the shimmer placeholder) - await expect(page.locator('img[alt="Page cover"]').first()).toBeVisible({ - timeout: 10_000, - }); -} - -/** - * Transform test cases into Playwright tests and run it. - */ -export function runTestCases(testCases: TestsCase[]) { - for (const testCase of testCases) { - if (testCase.skip) { - continue; - } - - test.describe(testCase.name, () => { - for (const testEntry of testCase.tests) { - const { mode = 'page' } = testEntry; - const testFn = testEntry.only ? test.only : test; - testFn(testEntry.name, async ({ page, context }) => { - const testEntryPathname = - typeof testEntry.url === 'function' ? await testEntry.url() : testEntry.url; - const url = testCase.contentBaseURL - ? getContentTestURL( - new URL(testEntryPathname, testCase.contentBaseURL).toString() - ) - : getTestURL(testEntryPathname); - - if (testEntry.cookies) { - await context.addCookies( - testEntry.cookies.map((cookie) => ({ - ...cookie, - domain: new URL(url).host, - path: '/', - })) - ); - } - - // Set the header to disable the Vercel toolbar - // But only on the main document as it'd cause CORS issues on other resources - await page.route('**/*', async (route, request) => { - if (request.resourceType() === 'document') { - await route.continue({ - headers: { - ...request.headers(), - 'x-vercel-skip-toolbar': '1', - }, - }); - } else { - await route.continue(); - } - }); - - const response = await page.goto(url); - if (testEntry.run) { - await testEntry.run(page, response); - } - const screenshotOptions = testEntry.screenshot; - if (screenshotOptions !== false) { - const screenshotName = `${testCase.name} - ${testEntry.name}`; - if (mode === 'image') { - await argosScreenshot(page, screenshotName, { - viewports: ['macbook-13'], - threshold: screenshotOptions?.threshold ?? undefined, - fullPage: true, - }); - } else { - await argosScreenshot(page, screenshotName, { - viewports: ['macbook-16', 'macbook-13', 'ipad-2', 'iphone-x'], - argosCSS: ` - /* Hide Intercom */ - .intercom-lightweight-app { - display: none !important; - } - `, - threshold: screenshotOptions?.threshold ?? undefined, - fullPage: testEntry.fullPage ?? false, - beforeScreenshot: async ({ runStabilization }) => { - await runStabilization(); - if (screenshotOptions?.waitForTOCScrolling !== false) { - await waitForTOCScrolling(page); - } - await waitForIcons(page); - }, - }); - } - } - }); - } - }); - } -} - -/** - * Create a URL with customization settings. - */ -export function getCustomizationURL(partial: DeepPartial ): string { - // We replicate the theme migration logic from the API to the tests, because the don't get these settings from the API. - // We can remove this once the migration to the new themes have been completed and the new theme styles are verified - // Map the theme preset (+ tint) to one of the new themes - const newTheme = (() => { - if (partial.styling?.theme) { - return partial.styling.theme; - } - - switch (partial.header?.preset) { - case CustomizationHeaderPreset.Bold: - case CustomizationHeaderPreset.Contrast: - case CustomizationHeaderPreset.Custom: - return CustomizationTheme.Bold; - - case CustomizationHeaderPreset.None: - case CustomizationHeaderPreset.Default: - if (partial.styling?.tint) { - return CustomizationTheme.Muted; - } - - return CustomizationTheme.Clean; - default: - return CustomizationTheme.Clean; - } - })(); - - /** - * Default customization settings. - * - * The customization object passed to the URL should be a valid API settings object. Hence we extend the test with necessary defaults. - */ - const DEFAULT_CUSTOMIZATION: SiteCustomizationSettings = { - styling: { - theme: newTheme, - primaryColor: { light: '#346DDB', dark: '#346DDB' }, - infoColor: { light: '#787878', dark: '#787878' }, - warningColor: { light: '#FE9A00', dark: '#FE9A00' }, - dangerColor: { light: '#FB2C36', dark: '#FB2C36' }, - successColor: { light: '#00C950', dark: '#00C950' }, - corners: CustomizationCorners.Rounded, - depth: CustomizationDepth.Subtle, - font: CustomizationDefaultFont.Inter, - monospaceFont: CustomizationDefaultMonospaceFont.IBMPlexMono, - background: CustomizationBackground.Plain, - icons: CustomizationIconsStyle.Regular, - links: CustomizationLinksStyle.Default, - sidebar: { - background: CustomizationSidebarBackgroundStyle.Default, - list: CustomizationSidebarListStyle.Default, - }, - search: CustomizationSearchStyle.Subtle, - }, - internationalization: { - locale: CustomizationLocale.En, - }, - insights: { - trackingCookie: true, - }, - favicon: {}, - header: { - preset: CustomizationHeaderPreset.Default, - links: [], - }, - footer: { - groups: [], - }, - themes: { - default: CustomizationThemeMode.Light, - toggeable: true, - }, - pdf: { - enabled: true, - }, - feedback: { - enabled: false, - }, - ai: { - mode: CustomizationAIMode.None, - }, - externalLinks: { - target: SiteExternalLinksTarget.Self, - }, - advancedCustomization: { - enabled: true, - }, - git: { - showEditLink: false, - }, - pagination: { - enabled: true, - }, - pageActions: { - externalAI: true, - markdown: true, - mcp: true, - }, - trademark: { - enabled: true, - }, - privacyPolicy: { - url: 'https://www.gitbook.com/privacy', - }, - socialPreview: {}, - }; - - const encoded = rison.encode_object(deepMerge(DEFAULT_CUSTOMIZATION, partial)); - - const searchParams = new URLSearchParams(); - searchParams.set('customization', encoded); - - return `?${searchParams.toString()}`; -} - -/** - * Wait for all icons present on the page to be loaded. - */ -export async function waitForIcons(page: Page) { - await page.waitForFunction(() => { - const urlStates: Record< - string, - { state: 'pending'; uri: null } | { state: 'loaded'; uri: string } - > = (window as any).__ICONS_STATES__ || {}; - (window as any).__ICONS_STATES__ = urlStates; - - const fetchSvgAsDataUri = async (url: string): Promise => { - const response = await fetch(url); - if (!response.ok) { - throw new Error(`Failed to fetch SVG: ${response.status}`); - } - - const svgText = await response.text(); - const encoded = encodeURIComponent(svgText).replace(/'/g, '%27').replace(/"/g, '%22'); - - return `data:image/svg+xml;charset=utf-8,${encoded}`; - }; - - const loadUrl = (url: string) => { - // Mark the URL as pending. - urlStates[url] = { state: 'pending', uri: null }; - fetchSvgAsDataUri(url).then((uri) => { - urlStates[url] = { state: 'loaded', uri }; - }); - }; - - const icons = Array.from(document.querySelectorAll('svg.gb-icon')); - const results = icons.map((icon) => { - if (!(icon instanceof SVGElement)) { - throw new Error('Icon is not an SVGElement'); - } - - // Ignore icons that are not visible. - if (!icon.checkVisibility()) { - return true; - } - - const state = icon.getAttribute('data-argos-state'); - - if (state === 'pending') { - return false; - } - - if (state === 'loaded') { - return true; - } - - // url("https://ka-p.fontawesome.com/releases/v6.6.0/svgs/light/moon.svg?v=2&token=a463935e93") - const maskImage = window.getComputedStyle(icon).getPropertyValue('mask-image'); - const urlMatch = maskImage.match(/url\("([^"]+)"\)/); - const url = urlMatch?.[1]; - - // If URL is invalid we throw an error. - if (!url) { - throw new Error('No mask-image'); - } - - // If the URL is already queued for loading, we return the state. - if (urlStates[url]) { - if (urlStates[url].state === 'loaded') { - icon.setAttribute('data-argos-state', 'pending'); - icon.style.maskImage = `url("${urlStates[url].uri}")`; - requestAnimationFrame(() => { - icon.setAttribute('data-argos-state', 'loaded'); - }); - return false; - } - - return false; - } - - loadUrl(url); - return false; - }); - - return results.every((x) => x); - }); -} - -/** - * Wait for TOC to be correctly scrolled into view. - */ -async function waitForTOCScrolling(page: Page) { - const viewport = await page.viewportSize(); - if (viewport && viewport.width >= 1024) { - const toc = page.getByTestId('table-of-contents'); - await expect(toc).toBeVisible(); - await page.evaluate(() => { - const tocScrollContainer = document.querySelector( - '[data-testid="table-of-contents"] [data-testid="toc-scroll-container"]' - ); - if (!tocScrollContainer) { - throw new Error('TOC scroll container not found'); - } - tocScrollContainer.scrollTo(0, 0); - }); - } -} diff --git a/packages/gitbook/next.config.mjs b/packages/gitbook/next.config.mjs deleted file mode 100644 index 4dbe0d3ffa..0000000000 --- a/packages/gitbook/next.config.mjs +++ /dev/null @@ -1,79 +0,0 @@ -// @ts-check - -/** - * @type {import('next').NextConfig} - */ -const nextConfig = { - experimental: { - // This is needed to throw "forbidden" when the api token expired during revalidation - authInterrupts: true, - useCache: true, - - // Content is fully static, we can cache it in the session memory cache for a long time - staleTimes: { - dynamic: 3600, // 1 hour - static: 3600, // 1 hour - }, - - // Since content is fully static, we don't want to fetch on hover again - optimisticClientCache: false, - }, - - env: { - BUILD_VERSION: (process.env.GITHUB_SHA ?? '').slice(0, 7), - - // GitBook envs - GITBOOK_API_URL: process.env.GITBOOK_API_URL, - GITBOOK_APP_URL: process.env.GITBOOK_APP_URL, - GITBOOK_INTEGRATIONS_HOST: process.env.GITBOOK_INTEGRATIONS_HOST, - GITBOOK_IMAGE_RESIZE_URL: process.env.GITBOOK_IMAGE_RESIZE_URL, - GITBOOK_ICONS_URL: process.env.GITBOOK_ICONS_URL, - GITBOOK_ICONS_TOKEN: process.env.GITBOOK_ICONS_TOKEN, - GITBOOK_URL: process.env.GITBOOK_URL, - GITBOOK_API_TOKEN: process.env.GITBOOK_API_TOKEN, - GITBOOK_ASSETS_PREFIX: process.env.GITBOOK_ASSETS_PREFIX, - GITBOOK_SECRET: process.env.GITBOOK_SECRET, - GITBOOK_IMAGE_RESIZE_SIGNING_KEY: process.env.GITBOOK_IMAGE_RESIZE_SIGNING_KEY, - GITBOOK_IMAGE_RESIZE_MODE: process.env.GITBOOK_IMAGE_RESIZE_MODE, - GITBOOK_FONTS_URL: process.env.GITBOOK_FONTS_URL, - GITBOOK_RUNTIME: process.env.GITBOOK_RUNTIME, - - // Next.js envs - NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: process.env.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, - - // Used to detect if the app is running in V2 mode - GITBOOK_V2: 'true', - }, - - assetPrefix: process.env.GITBOOK_ASSETS_PREFIX, - poweredByHeader: false, - - images: { - remotePatterns: [ - { - protocol: 'https', - hostname: '*.gitbook.io', - }, - ], - }, - - async headers() { - return [ - { - source: '/~gitbook/static/:path*', - headers: [ - { - key: 'Cache-Control', - value: 'public, max-age=31536000, immutable', - }, - { - key: 'Access-Control-Allow-Origin', - value: '*', - }, - ], - }, - ]; - }, -}; - -export default nextConfig; diff --git a/packages/gitbook/open-next.config.ts b/packages/gitbook/open-next.config.ts deleted file mode 100644 index f4f5c25dff..0000000000 --- a/packages/gitbook/open-next.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { OpenNextConfig } from '@opennextjs/cloudflare'; - -export default { - default: { - override: { - wrapper: 'cloudflare-node', - converter: 'edge', - proxyExternalRequest: 'fetch', - queue: () => import('./openNext/queue/middleware').then((m) => m.default), - incrementalCache: () => - import('./openNext/incrementalCache/server').then((m) => m.default), - tagCache: () => import('./openNext/tagCache/middleware').then((m) => m.default), - }, - }, - middleware: { - external: true, - override: { - wrapper: 'cloudflare-edge', - converter: 'edge', - proxyExternalRequest: 'fetch', - queue: () => import('./openNext/queue/middleware').then((m) => m.default), - incrementalCache: () => - import('./openNext/incrementalCache/middleware').then((m) => m.default), - tagCache: () => import('./openNext/tagCache/middleware').then((m) => m.default), - }, - }, - dangerous: { - enableCacheInterception: true, - }, - edgeExternals: ['node:crypto'], -} satisfies OpenNextConfig; diff --git a/packages/gitbook/openNext/customWorkers/default.js b/packages/gitbook/openNext/customWorkers/default.js deleted file mode 100644 index c7da9ee964..0000000000 --- a/packages/gitbook/openNext/customWorkers/default.js +++ /dev/null @@ -1,39 +0,0 @@ -import { runWithCloudflareRequestContext } from '../../.open-next/cloudflare/init.js'; - -import { DurableObject } from 'cloudflare:workers'; - -//Only needed to run locally, in prod we'll use the one from do.js -export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js'; - -// Only needed to run locally, in prod we'll use the one from do.js -export class R2WriteBuffer extends DurableObject { - writePromise; - - async write(cacheKey, value) { - // We are already writing to this key - if (this.writePromise) { - return; - } - - this.writePromise = this.env.NEXT_INC_CACHE_R2_BUCKET.put(cacheKey, value); - this.ctx.waitUntil( - this.writePromise.finally(() => { - this.writePromise = undefined; - }) - ); - } -} - -export default { - async fetch(request, env, ctx) { - return runWithCloudflareRequestContext(request, env, ctx, async () => { - // We can't move the handler import to the top level, otherwise the runtime will not be properly initialized - const { handler } = await import( - '../../.open-next/server-functions/default/handler.mjs' - ); - - // - `Request`s are handled by the Next server - return handler(request, env, ctx); - }); - }, -}; diff --git a/packages/gitbook/openNext/customWorkers/defaultWrangler.jsonc b/packages/gitbook/openNext/customWorkers/defaultWrangler.jsonc deleted file mode 100644 index 22f8f02053..0000000000 --- a/packages/gitbook/openNext/customWorkers/defaultWrangler.jsonc +++ /dev/null @@ -1,176 +0,0 @@ -{ - "main": "default.js", - "name": "gitbook-open-v2-server", - "keep_names": false, - "compatibility_date": "2025-04-14", - "compatibility_flags": [ - "nodejs_compat", - "allow_importable_env", - "global_fetch_strictly_public" - ], - "vars": { - "NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true" - }, - "env": { - "dev": { - "vars": { - "STAGE": "dev", - "OPEN_NEXT_REQUEST_ID_HEADER": "true", - "GITBOOK_URL": "http://localhost:8771" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-preview" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-server-dev" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["R2WriteBuffer", "DOShardedTagCache"] - } - ] - }, - "preview": { - "vars": { - "STAGE": "preview", - // Just as a test for the preview environment to check that everything works - "NEXT_PRIVATE_DEBUG_CACHE": "true" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-preview" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-server-preview" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-preview" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-preview" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-preview" - } - ] - } - }, - "staging": { - "vars": { - "OPEN_NEXT_REQUEST_ID_HEADER": "true" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-staging" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-server-staging" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-staging" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-staging" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-staging" - } - ] - }, - "tail_consumers": [ - { - "service": "gitbook-x-staging-tail" - } - ] - }, - "production": { - "vars": { - // This is a bit misleading, but it means that we can have 500 concurrent revalidations - // This means that we'll have up to 100 durable objects instance running at the same time - "MAX_REVALIDATE_CONCURRENCY": "100", - "OPEN_NEXT_REQUEST_ID_HEADER": "true" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-production" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-server-production" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-production" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-production" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-production" - } - ] - }, - "tail_consumers": [ - { - "service": "gitbook-x-prod-tail" - } - ] - } - } -} diff --git a/packages/gitbook/openNext/customWorkers/do.js b/packages/gitbook/openNext/customWorkers/do.js deleted file mode 100644 index 04f3cf3bec..0000000000 --- a/packages/gitbook/openNext/customWorkers/do.js +++ /dev/null @@ -1,38 +0,0 @@ -// This worker only purposes it to host the different DO that we will need in the other workers. -import { DurableObject } from 'cloudflare:workers'; - -// `use cache` could cause multiple writes to the same key to happen concurrently, there is a limit of 1 write per key/second -// so we need to buffer writes to the R2 bucket to avoid hitting this limit. -export class R2WriteBuffer extends DurableObject { - writePromise; - - async write(cacheKey, value) { - // We are already writing to this key - if (this.writePromise) { - return; - } - - this.writePromise = this.env.NEXT_INC_CACHE_R2_BUCKET.put(cacheKey, value); - this.ctx.waitUntil( - this.writePromise.finally(() => { - this.writePromise = undefined; - }) - ); - } -} - -export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js'; - -export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js'; - -export default { - async fetch() { - // This worker does not handle any requests, it only provides Durable Objects - return new Response('This worker is not meant to handle requests directly', { - status: 400, - headers: { - 'Content-Type': 'text/plain', - }, - }); - }, -}; diff --git a/packages/gitbook/openNext/customWorkers/doWrangler.jsonc b/packages/gitbook/openNext/customWorkers/doWrangler.jsonc deleted file mode 100644 index 421c2e5c86..0000000000 --- a/packages/gitbook/openNext/customWorkers/doWrangler.jsonc +++ /dev/null @@ -1,147 +0,0 @@ -{ - "main": "do.js", - "name": "gitbook-open-v2-do", - "compatibility_date": "2025-04-14", - "keep_names": false, - "compatibility_flags": [ - "nodejs_compat", - "allow_importable_env", - "global_fetch_strictly_public" - ], - "env": { - "preview": { - "vars": { - "STAGE": "preview", - "NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-preview" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-preview" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache" - }, - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["DOQueueHandler", "DOShardedTagCache", "R2WriteBuffer"] - } - ] - }, - "staging": { - "vars": { - "STAGE": "staging", - "NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-staging" - } - ], - "tail_consumers": [ - { - "service": "gitbook-x-staging-tail" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-staging" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache" - }, - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["DOQueueHandler", "DOShardedTagCache", "R2WriteBuffer"] - } - ] - }, - "production": { - "vars": { - // R2 is strongly consistent, so we can disable SQLite - "NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true", - // We don't want to pollute the memory with broken cache entries - // Most of the time, those are fake requests. - "NEXT_CACHE_DO_QUEUE_MAX_RETRIES": "1", - "STAGE": "production" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-production" - } - ], - "tail_consumers": [ - { - "service": "gitbook-x-prod-tail" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-production" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache" - }, - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["DOQueueHandler", "DOShardedTagCache", "R2WriteBuffer"] - } - ] - } - } -} diff --git a/packages/gitbook/openNext/customWorkers/middleware.js b/packages/gitbook/openNext/customWorkers/middleware.js deleted file mode 100644 index e6fc2f7517..0000000000 --- a/packages/gitbook/openNext/customWorkers/middleware.js +++ /dev/null @@ -1,83 +0,0 @@ -import { WorkerEntrypoint } from 'cloudflare:workers'; -import { runWithCloudflareRequestContext } from '../../.open-next/cloudflare/init.js'; - -import { handler as middlewareHandler } from '../../.open-next/middleware/handler.mjs'; - -export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js'; - -export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js'; - -//Format used by the tail logger -const formatLog = (requestDuration, responseCode, responseCache, responseRoute) => - `%${JSON.stringify({ requestDuration, responseCode, responseCache, responseRoute })}%[main] Response Done`; - -const getResolvedRoute = (reqOrResp, defaultValue) => { - try { - const resolvedRoutes = JSON.parse( - reqOrResp.headers.get('x-opennext-resolved-routes') ?? '' - )[0].route; - return resolvedRoutes ?? defaultValue; - } catch { - return defaultValue; - } -}; - -export default class extends WorkerEntrypoint { - async fetch(request) { - return runWithCloudflareRequestContext(request, this.env, this.ctx, async () => { - const startTime = Date.now(); - const middlewareRequest = new Request(request.url, request); - middlewareRequest.headers.set('x-open-next-continent', request.cf?.continent || ''); - // - `Request`s are handled by the Next server - const reqOrResp = await middlewareHandler(middlewareRequest, this.env, this.ctx); - if (reqOrResp instanceof Response) { - const duration = Date.now() - startTime; - const logMessage = formatLog( - duration, - reqOrResp.status, - reqOrResp.headers.get('x-opennext-cache') ?? 'MISS', - getResolvedRoute(reqOrResp, 'middleware') - ); - // biome-ignore lint/suspicious/noConsole: - console.log(logMessage); - return reqOrResp; - } - - if (this.env.STAGE !== 'preview') { - // https://developers.cloudflare.com/workers/configuration/versions-and-deployments/gradual-deployments/#version-affinity - reqOrResp.headers.set( - 'Cloudflare-Workers-Version-Overrides', - `gitbook-open-v2-${this.env.STAGE}="${this.env.WORKER_VERSION_ID}"` - ); - const response = await this.env.DEFAULT_WORKER?.fetch(reqOrResp, { - redirect: 'manual', - cf: { - cacheEverything: false, - }, - }); - const formatedLog = formatLog( - Date.now() - startTime, - response.status, - `SERVER-${response.headers.get('x-nextjs-cache') ?? 'MISS'}`, - getResolvedRoute(reqOrResp, 'unresolved') - ); - // biome-ignore lint/suspicious/noConsole: - console.log(formatedLog); - - return response; - } - // If we are in preview mode, we need to send the request to the preview URL - const modifiedUrl = new URL(reqOrResp.url); - modifiedUrl.hostname = this.env.PREVIEW_HOSTNAME; - const nextRequest = new Request(modifiedUrl, reqOrResp); - return fetch(nextRequest, { - // We never want to follow the redirects here. - // Redirects are supposed to happen from the client. - redirect: 'manual', - cf: { - cacheEverything: false, - }, - }); - }); - } -} diff --git a/packages/gitbook/openNext/customWorkers/middlewareWrangler.jsonc b/packages/gitbook/openNext/customWorkers/middlewareWrangler.jsonc deleted file mode 100644 index 990db7e225..0000000000 --- a/packages/gitbook/openNext/customWorkers/middlewareWrangler.jsonc +++ /dev/null @@ -1,221 +0,0 @@ -{ - "main": "middleware.js", - "name": "gitbook-open-v2", - "compatibility_date": "2025-04-14", - "keep_names": false, - "compatibility_flags": [ - "nodejs_compat", - "allow_importable_env", - "global_fetch_strictly_public" - ], - "assets": { - "directory": "../../.open-next/assets", - "binding": "ASSETS" - }, - "vars": { - "NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true" - }, - "env": { - "dev": { - "vars": { - "STAGE": "dev", - "NEXT_PRIVATE_DEBUG_CACHE": "true", - // When deployed locally, we don't have access to the tag cache here, - // we should just bypass the cache to go to the server directly - "SHOULD_BYPASS_CACHE": "true", - "OPEN_NEXT_REQUEST_ID_HEADER": "true", - "GITBOOK_URL": "http://localhost:8771" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-preview" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-dev" - }, - { - "binding": "DEFAULT_WORKER", - "service": "gitbook-open-v2-server-dev" - } - ] - }, - "preview": { - "vars": { - "STAGE": "preview", - "PREVIEW_HOSTNAME": "TO_REPLACE", - "WORKER_VERSION_ID": "TO_REPLACE" - }, - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-preview" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-preview" - }, - { - "binding": "DEFAULT_WORKER", - "service": "gitbook-open-v2-server-preview" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-preview" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-preview" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-preview" - } - ] - } - }, - "staging": { - "vars": { - "STAGE": "staging", - "WORKER_VERSION_ID": "TO_REPLACE", - "OPEN_NEXT_REQUEST_ID_HEADER": "true" - }, - "routes": [ - { - "pattern": "open-2c.gitbook-staging.com/*", - "zone_name": "gitbook-staging.com" - }, - { - "pattern": "static-2c.gitbook-staging.com/*", - "zone_name": "gitbook-staging.com" - } - ], - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-staging" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-staging" - }, - { - "binding": "DEFAULT_WORKER", - "service": "gitbook-open-v2-server-staging" - } - ], - "tail_consumers": [ - { - "service": "gitbook-x-staging-tail" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-staging" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-staging" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-staging" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["DOQueueHandler", "DOShardedTagCache"] - } - ] - }, - "production": { - "vars": { - // This is a bit misleading, but it means that we can have 500 concurrent revalidations - // This means that we'll have up to 100 durable objects instance running at the same time - "MAX_REVALIDATE_CONCURRENCY": "100", - // Temporary variable to find the issue once deployed - // TODO: remove this once the issue is fixed - "DEBUG_CLOUDFLARE": "true", - "WORKER_VERSION_ID": "TO_REPLACE", - "STAGE": "production", - "OPEN_NEXT_REQUEST_ID_HEADER": "true" - }, - "routes": [ - { - "pattern": "open-2c.gitbook.com/*", - "zone_name": "gitbook.com" - }, - { - "pattern": "static-2c.gitbook.com/*", - "zone_name": "gitbook.com" - } - ], - "r2_buckets": [ - { - "binding": "NEXT_INC_CACHE_R2_BUCKET", - "bucket_name": "gitbook-open-v2-cache-production" - } - ], - "services": [ - { - "binding": "WORKER_SELF_REFERENCE", - "service": "gitbook-open-v2-production" - }, - { - "binding": "DEFAULT_WORKER", - "service": "gitbook-open-v2-server-production" - } - ], - "tail_consumers": [ - { - "service": "gitbook-x-prod-tail" - } - ], - "durable_objects": { - "bindings": [ - { - "name": "WRITE_BUFFER", - "class_name": "R2WriteBuffer", - "script_name": "gitbook-open-v2-do-production" - }, - { - "name": "NEXT_TAG_CACHE_DO_SHARDED", - "class_name": "DOShardedTagCache", - "script_name": "gitbook-open-v2-do-production" - }, - { - "name": "NEXT_CACHE_DO_QUEUE", - "class_name": "DOQueueHandler", - "script_name": "gitbook-open-v2-do-production" - } - ] - }, - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["DOQueueHandler", "DOShardedTagCache"] - } - ] - } - } -} diff --git a/packages/gitbook/openNext/customWorkers/script/updateWrangler.ts b/packages/gitbook/openNext/customWorkers/script/updateWrangler.ts deleted file mode 100644 index 738ff7df18..0000000000 --- a/packages/gitbook/openNext/customWorkers/script/updateWrangler.ts +++ /dev/null @@ -1,26 +0,0 @@ -// In this script, we use the args from the cli to update the PREVIEW_URL vars in the wrangler config file for the middleware -import fs from 'node:fs'; -import path from 'node:path'; - -const wranglerConfigPath = path.join(__dirname, '../middlewareWrangler.jsonc'); - -const file = fs.readFileSync(wranglerConfigPath, 'utf-8'); - -const args = process.argv.slice(2); -// The versionId is in the format xxx-xxx-xxx-xxx, we need the first part to reconstruct the preview URL -const versionId = args[0]; - -// The preview URL is in the format https:// -gitbook-open-v2-server-preview.gitbook.workers.dev -const previewHostname = `${versionId?.split('-')[0]}-gitbook-open-v2-server-preview.gitbook.workers.dev`; - -let updatedFile = file.replace( - /"PREVIEW_HOSTNAME": "TO_REPLACE"/, - `"PREVIEW_HOSTNAME": "${previewHostname}"` -); - -updatedFile = updatedFile.replaceAll( - /"WORKER_VERSION_ID": "TO_REPLACE"/g, - `"WORKER_VERSION_ID": "${versionId}"` -); - -fs.writeFileSync(wranglerConfigPath, updatedFile); diff --git a/packages/gitbook/openNext/incrementalCache/incrementalCache.ts b/packages/gitbook/openNext/incrementalCache/incrementalCache.ts deleted file mode 100644 index 11c0f89774..0000000000 --- a/packages/gitbook/openNext/incrementalCache/incrementalCache.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { createHash } from 'node:crypto'; -import type { - CacheEntryType, - CacheValue, - IncrementalCache, - WithLastModified, -} from '@opennextjs/aws/types/overrides.js'; -import { getCloudflareContext } from '@opennextjs/cloudflare'; - -import type { DurableObjectNamespace, Rpc } from '@cloudflare/workers-types'; - -export const BINDING_NAME = 'NEXT_INC_CACHE_R2_BUCKET'; -export const DEFAULT_PREFIX = 'incremental-cache'; - -export type KeyOptions = { - cacheType?: CacheEntryType; -}; - -/** - * - * It is very similar to the `R2IncrementalCache` in the `@opennextjs/cloudflare` package, but it has an additional - * R2WriteBuffer Durable Object to handle writes to R2. Given how we set up cache, we often end up writing to the same key too fast. - */ -export class GitbookIncrementalCache implements IncrementalCache { - name = 'GitbookIncrementalCache'; - - async get ( - key: string, - cacheType?: CacheType - ): Promise > | null> { - const cacheKey = this.getR2Key(key, cacheType); - - const r2 = getCloudflareContext().env[BINDING_NAME]; - if (!r2) throw new Error('No R2 bucket'); - if (process.env.SHOULD_BYPASS_CACHE === 'true') { - // We are in a local middleware environment, we should bypass the cache - // and go directly to the server. - return null; - } - try { - const r2Object = await r2.get(cacheKey); - if (!r2Object) return null; - - const json = (await r2Object.json()) as CacheValue ; - const lastModified = r2Object.uploaded.getTime(); - - if (!json) return null; - - return this.returnNullOn404({ - value: json, - lastModified, - }); - } catch (e) { - console.error('Failed to get from cache', e); - return null; - } - } - - //TODO: This is a workaround to handle 404 responses in the cache. - // It should be handled by OpenNext cache interception directly. This should be removed once OpenNext cache interception is fixed. - returnNullOn404 ( - cacheEntry: WithLastModified > | null - ): WithLastModified > | null { - if (!cacheEntry?.value) return null; - if ('meta' in cacheEntry.value && cacheEntry.value.meta?.status === 404) { - return null; - } - return cacheEntry; - } - - async set ( - key: string, - value: CacheValue , - cacheType?: CacheType - ): Promise { - const cacheKey = this.getR2Key(key, cacheType); - - try { - await this.writeToR2(cacheKey, JSON.stringify(value)); - } catch (e) { - console.error('Failed to set to cache', e); - } - } - - async delete(key: string): Promise { - const cacheKey = this.getR2Key(key); - - const r2 = getCloudflareContext().env[BINDING_NAME]; - if (!r2) throw new Error('No R2 bucket'); - - try { - await r2.delete(cacheKey); - } catch (e) { - console.error('Failed to delete from cache', e); - } - } - - async writeToR2(key: string, value: string): Promise { - try { - const env = getCloudflareContext().env as { - WRITE_BUFFER: DurableObjectNamespace< - Rpc.DurableObjectBranded & { - write: (key: string, value: string) => Promise ; - } - >; - }; - const id = env.WRITE_BUFFER.idFromName(key); - - // A stub is a client used to invoke methods on the Durable Object - const stub = env.WRITE_BUFFER.get(id); - - await stub.write(key, value); - } catch { - // We fallback to writing directly to R2 - // it can fail locally because the limit is 1Mb per args - // It is 32Mb in production, so we should be fine - const r2 = getCloudflareContext().env[BINDING_NAME]; - r2?.put(key, value); - } - } - - // Utility function to generate keys for R2/Cache API - getR2Key(initialKey: string, cacheType: CacheEntryType = 'cache'): string { - let key = initialKey; - if (cacheType === 'composable') { - // For composable cache, we need to discard the build ID from the key - const [_buildId, ...restOfTheKey] = JSON.parse(initialKey); - key = JSON.stringify([...restOfTheKey]); - } - - const hash = createHash('sha256').update(key).digest('hex'); - return `${DEFAULT_PREFIX}/${cacheType === 'cache' ? process.env?.NEXT_BUILD_ID : 'dataCache'}/${hash}.${cacheType}`.replace( - /\/+/g, - '/' - ); - } -} diff --git a/packages/gitbook/openNext/incrementalCache/middleware.ts b/packages/gitbook/openNext/incrementalCache/middleware.ts deleted file mode 100644 index 2204ae4c68..0000000000 --- a/packages/gitbook/openNext/incrementalCache/middleware.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { withRegionalCache } from '@opennextjs/cloudflare/overrides/incremental-cache/regional-cache'; -import { GitbookIncrementalCache } from './incrementalCache'; - -export default withRegionalCache(new GitbookIncrementalCache(), { - mode: 'long-lived', - // We can do it because we use our own logic to invalidate the cache - bypassTagCacheOnCacheHit: true, - defaultLongLivedTtlSec: 60 * 60 * 24 /* 24 hours */, - // We don't want to update the cache entry on every cache hit - shouldLazilyUpdateOnCacheHit: false, -}); diff --git a/packages/gitbook/openNext/incrementalCache/server.ts b/packages/gitbook/openNext/incrementalCache/server.ts deleted file mode 100644 index 87c4963254..0000000000 --- a/packages/gitbook/openNext/incrementalCache/server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { withRegionalCache } from '@opennextjs/cloudflare/overrides/incremental-cache/regional-cache'; -import { GitbookIncrementalCache } from './incrementalCache'; - -export default withRegionalCache(new GitbookIncrementalCache(), { - mode: 'long-lived', - // Because of a race condition, the middleware may have populated the cache entry before `cache.match` had time to run on the server. - // TODO: We should bypass the incremental cache entirely when the interceptor has caught the request. Should be done in OpenNext. - bypassTagCacheOnCacheHit: false, - defaultLongLivedTtlSec: 60 * 60 * 24 /* 24 hours */, - // We don't want to update the cache entry on every cache hit - shouldLazilyUpdateOnCacheHit: false, -}); diff --git a/packages/gitbook/openNext/queue/middleware.ts b/packages/gitbook/openNext/queue/middleware.ts deleted file mode 100644 index 11428f4640..0000000000 --- a/packages/gitbook/openNext/queue/middleware.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Queue } from '@opennextjs/aws/types/overrides.js'; -import { getCloudflareContext } from '@opennextjs/cloudflare'; -import doQueue from '@opennextjs/cloudflare/overrides/queue/do-queue'; - -export default { - name: 'GitbookISRQueue', - send: async (msg) => { - const { ctx } = getCloudflareContext(); - ctx.waitUntil(doQueue.send(msg)); - }, -} satisfies Queue; diff --git a/packages/gitbook/openNext/queue/server.ts b/packages/gitbook/openNext/queue/server.ts deleted file mode 100644 index 9e3756748c..0000000000 --- a/packages/gitbook/openNext/queue/server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { getLogger } from '@/lib/logger'; -import type { Queue } from '@opennextjs/aws/types/overrides.js'; - -export default { - name: 'GitbookISRQueue', - send: async (msg) => { - const logger = getLogger().subLogger('GitbookISRQueue'); - // We should never reach this point in the server. If that's the case, we should log it. - logger.warn('send called on server side, this should not happen.', msg); - }, -} satisfies Queue; diff --git a/packages/gitbook/openNext/tagCache/middleware.ts b/packages/gitbook/openNext/tagCache/middleware.ts deleted file mode 100644 index e5a6fb4ad0..0000000000 --- a/packages/gitbook/openNext/tagCache/middleware.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { createLogger, getLogger } from '@/lib/logger'; -import type { NextModeTagCache } from '@opennextjs/aws/types/overrides.js'; -import doShardedTagCache from '@opennextjs/cloudflare/overrides/tag-cache/do-sharded-tag-cache'; -import { softTagFilter } from '@opennextjs/cloudflare/overrides/tag-cache/tag-cache-filter'; - -const originalTagCache = doShardedTagCache({ - baseShardSize: 12, - regionalCache: true, - regionalCacheTtlSec: 60 * 5 /* 5 minutes */, - // Because we invalidate the Cache API on update, we can safely set this to true - regionalCacheDangerouslyPersistMissingTags: true, - shardReplication: { - numberOfSoftReplicas: 2, - numberOfHardReplicas: 1, - regionalReplication: { - defaultRegion: 'enam', - }, - }, -}); - -export default { - name: 'GitbookTagCache', - mode: 'nextMode', - // We don't really use this one, as of now it is only used for soft tags - getLastRevalidated: async (tags: string[]) => { - const tagsToCheck = tags.filter(softTagFilter); - if (tagsToCheck.length === 0) { - return 0; // If no tags to check, return 0 - } - - return await originalTagCache.getLastRevalidated(tagsToCheck); - }, - hasBeenRevalidated: async (tags: string[], lastModified?: number) => { - try { - const tagsToCheck = tags.filter(softTagFilter); - if (tagsToCheck.length === 0) { - return false; // If no tags to check, return false - } - - return await originalTagCache.hasBeenRevalidated(tagsToCheck, lastModified); - } catch (e) { - createLogger('gitbookTagCache', {}).error( - `hasBeenRevalidated - Error checking tags ${tags.join(', ')}`, - e - ); - return false; // In case of error, return false - } - }, - writeTags: async (tags: string[]) => { - const tagsToWrite = tags.filter(softTagFilter); - if (tagsToWrite.length === 0) { - const logger = getLogger().subLogger('gitbookTagCache'); - logger.warn('writeTags - No valid tags to write'); - return; // If no tags to write, exit early - } - - await originalTagCache.writeTags(tagsToWrite); - }, -} satisfies NextModeTagCache; diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json deleted file mode 100644 index ad463e26d8..0000000000 --- a/packages/gitbook/package.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "name": "gitbook", - "version": "0.19.2", - "private": true, - "dependencies": { - "@cloudflare/workers-types": "^4.20251011.0", - "@gitbook/api": "catalog:", - "@gitbook/browser-types": "workspace:*", - "@gitbook/cache-tags": "workspace:*", - "@gitbook/colors": "workspace:*", - "@gitbook/emoji-codepoints": "workspace:*", - "@gitbook/expr": "workspace:*", - "@gitbook/embed": "workspace:*", - "@gitbook/fonts": "workspace:*", - "@gitbook/icons": "workspace:*", - "@gitbook/openapi-parser": "workspace:*", - "@gitbook/react-contentkit": "workspace:*", - "@gitbook/react-math": "workspace:*", - "@gitbook/react-openapi": "workspace:*", - "@modelcontextprotocol/sdk": "1.17.5", - "@opennextjs/aws": "^3.8.5", - "@opennextjs/cloudflare": "^1.11.0", - "@radix-ui/react-checkbox": "^1.0.4", - "@radix-ui/react-dropdown-menu": "^2.1.12", - "@radix-ui/react-hover-card": "^1.1.15", - "@radix-ui/react-navigation-menu": "^1.2.3", - "@radix-ui/react-popover": "^1.0.7", - "@radix-ui/react-tooltip": "^1.1.8", - "@sindresorhus/fnv1a": "^3.1.0", - "@tailwindcss/container-queries": "^0.1.1", - "@tailwindcss/typography": "^0.5.16", - "@tusbar/cache-control": "^1.0.2", - "ai": "^4.2.2", - "assert-never": "catalog:", - "bidc": "catalog:", - "classnames": "catalog:", - "direction": "^2.0.1", - "event-iterator": "^2.0.0", - "image-size": "^2.0.2", - "js-cookie": "^3.0.5", - "jsontoxml": "^1.0.1", - "jwt-decode": "^4.0.0", - "mcp-handler": "^1.0.2", - "mdast-util-from-markdown": "^2.0.2", - "mdast-util-frontmatter": "^2.0.1", - "mdast-util-gfm": "^3.1.0", - "mdast-util-to-markdown": "^2.1.2", - "memoizee": "^0.4.17", - "micromark-extension-frontmatter": "^2.0.0", - "micromark-extension-gfm": "^3.0.0", - "motion": "^12.23.24", - "next": "15.4.0", - "next-themes": "^0.4.6", - "nuqs": "^2.2.3", - "object-hash": "^3.0.0", - "object-identity": "^0.1.2", - "openapi-types": "^12.1.3", - "p-map": "^7.0.3", - "quick-lru": "^7.0.1", - "react": "catalog:", - "react-dom": "catalog:", - "react-hotkeys-hook": "^4.4.1", - "rehype-sanitize": "^6.0.0", - "rehype-stringify": "^10.0.1", - "remark-gfm": "^4.0.1", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.1", - "rison": "^0.1.1", - "server-only": "^0.0.1", - "shiki": "^3.2.0", - "tailwind-merge": "^2.2.0", - "tailwind-shades": "^1.1.2", - "unified": "^11.0.5", - "unist-util-remove": "^4.0.0", - "unist-util-visit": "^5.0.0", - "url-join": "^5.0.0", - "usehooks-ts": "catalog:", - "warn-once": "^0.1.1", - "zod": "^3", - "zustand": "^5.0.3" - }, - "devDependencies": { - "@argos-ci/playwright": "^5.0.9", - "@playwright/test": "^1.54.2", - "@scalar/api-client-react": "catalog:", - "@tailwindcss/postcss": "^4.1.11", - "@types/js-cookie": "^3.0.6", - "@types/jsontoxml": "^1.0.5", - "@types/jsonwebtoken": "^9.0.6", - "@types/mdast": "^4.0.4", - "@types/node": "^20", - "@types/object-hash": "^3.0.6", - "@types/parse-cache-control": "^1.0.4", - "@types/react": "catalog:", - "@types/react-dom": "catalog:", - "@types/rison": "^0.0.9", - "bun-types": "catalog:", - "deepmerge": "^4.3.1", - "env-cmd": "^10.1.0", - "jsonwebtoken": "^9.0.2", - "postcss": "^8", - "stylelint": "^16.16.0", - "tailwindcss": "^4.1.11", - "ts-essentials": "^10.0.1", - "typescript": "catalog:", - "vercel": "^39.3.0", - "wrangler": "^4.43.0" - }, - "scripts": { - "generate": "./scripts/generate.sh", - "clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math", - "dev": "env-cmd --silent -f ../../.env.local next", - "build": "next build", - "build:local": "GITBOOK_URL=http://localhost:3000 next build", - "start": "GITBOOK_URL=http://localhost:3000 next start", - "build:cloudflare": "opennextjs-cloudflare build", - "dev:cloudflare": "wrangler dev --port 8771 --env preview", - "dev:cf:middleware": "wrangler dev --port 8771 --inspector-port 9230 --env dev --config ./openNext/customWorkers/middlewareWrangler.jsonc", - "dev:cf:server": "wrangler dev --port 8772 --env dev --config ./openNext/customWorkers/defaultWrangler.jsonc", - "e2e": "playwright test e2e/internal.spec.ts e2e/pdf.spec.ts --project=chromium", - "e2e-customers": "playwright test e2e/customers.spec.ts --project=chromium", - "unit": "bun test {src,packages} --preload ./tests/preload-bun.ts", - "e2e-browserless": "bun test ./tests/", - "typecheck": "tsc --noEmit" - }, - "browserslist": [ - ">0.3%, chrome >= 64, edge >= 79, firefox >= 67, opera >= 51, safari >= 12 and not dead" - ], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } -} diff --git a/packages/gitbook/playwright.config.ts b/packages/gitbook/playwright.config.ts deleted file mode 100644 index abfdaca9cd..0000000000 --- a/packages/gitbook/playwright.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { defineConfig, devices } from '@playwright/test'; - -export default defineConfig({ - testDir: './e2e', - fullyParallel: true, - forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 0, - reporter: [ - process.env.CI ? ['dot'] : ['list'], - ['@argos-ci/playwright/reporter', { uploadToArgos: !!process.env.CI }], - ], - projects: [ - // To speed up CI, we only test on Chrome. - // https://github.com/microsoft/playwright/issues/14434 - // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge - { - name: 'chromium', - use: { - ...devices['Desktop Chrome'], - channel: 'chrome', - }, - }, - ], - use: { - trace: 'on-first-retry', - screenshot: 'only-on-failure', - contextOptions: { - reducedMotion: 'reduce', - }, - }, -}); diff --git a/packages/gitbook/postcss.config.js b/packages/gitbook/postcss.config.js deleted file mode 100644 index 432659d9a2..0000000000 --- a/packages/gitbook/postcss.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - plugins: { - '@tailwindcss/postcss': {}, - }, -}; diff --git a/packages/gitbook/public/_headers b/packages/gitbook/public/_headers deleted file mode 100644 index 0d7eadbf4b..0000000000 --- a/packages/gitbook/public/_headers +++ /dev/null @@ -1,7 +0,0 @@ -# GitBook immutable static assets -# Duplicated from next.config.mjs until OpenNext supports generating static headers -/~gitbook/static/* - cache-control: public,max-age=31536000,immutable - Access-Control-Allow-Origin: * -/_next/static/* - Access-Control-Allow-Origin: * diff --git a/packages/gitbook/public/~gitbook/static/images/ogimage-grid-black.png b/packages/gitbook/public/~gitbook/static/images/ogimage-grid-black.png deleted file mode 100644 index cb8004b752..0000000000 Binary files a/packages/gitbook/public/~gitbook/static/images/ogimage-grid-black.png and /dev/null differ diff --git a/packages/gitbook/public/~gitbook/static/images/ogimage-grid-white.png b/packages/gitbook/public/~gitbook/static/images/ogimage-grid-white.png deleted file mode 100644 index 10296d8b2c..0000000000 Binary files a/packages/gitbook/public/~gitbook/static/images/ogimage-grid-white.png and /dev/null differ diff --git a/packages/gitbook/scripts/clean.sh b/packages/gitbook/scripts/clean.sh deleted file mode 100755 index 3fb7db2de6..0000000000 --- a/packages/gitbook/scripts/clean.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail - -rm -rf ./.next -rm -rf ./public/~gitbook/static/icons -rm -rf ./public/~gitbook/static/math -rm -rf ./public/~gitbook/static/embed diff --git a/packages/gitbook/scripts/generate.sh b/packages/gitbook/scripts/generate.sh deleted file mode 100755 index a1cfab43bd..0000000000 --- a/packages/gitbook/scripts/generate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail - -# Copy the assets -gitbook-icons ./public/~gitbook/static/icons custom-icons -gitbook-math ./public/~gitbook/static/math -cp -r ../embed/standalone/ ./public/~gitbook/static/embed - -# Generate the types -wrangler types diff --git a/packages/gitbook/src/app/global-error.tsx b/packages/gitbook/src/app/global-error.tsx deleted file mode 100644 index abf0186a40..0000000000 --- a/packages/gitbook/src/app/global-error.tsx +++ /dev/null @@ -1,18 +0,0 @@ -'use client'; - -import NextError from 'next/error'; - -export default function GlobalError({ - error, -}: { - error: Error & { digest?: string }; -}) { - console.error('Global error:', error); - return ( - - - - - - ); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/loading.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/loading.tsx deleted file mode 100644 index 8892cd8bc0..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/loading.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { SitePageSkeleton } from '@/components/SitePage'; - -export default function Loading() { - return ; -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx deleted file mode 100644 index c715d5dd4e..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { SitePageNotFound } from '@/components/SitePage'; - -export default async function NotFound() { - return ; -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx deleted file mode 100644 index 5d4395d12f..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { type RouteParams, getDynamicSiteContext, getPagePathFromParams } from '@/app/utils'; -import { - SitePage, - generateSitePageMetadata, - generateSitePageViewport, -} from '@/components/SitePage'; -import type { Metadata, Viewport } from 'next'; - -type PageProps = { - params: Promise ; - searchParams: Promise<{ fallback?: string }>; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getDynamicSiteContext(params); - const pathname = getPagePathFromParams(params); - - return ; -} - -export async function generateViewport(props: PageProps): Promise { - const { context } = await getDynamicSiteContext(await props.params); - return generateSitePageViewport(context); -} - -export async function generateMetadata(props: PageProps): Promise { - const params = await props.params; - const { context } = await getDynamicSiteContext(params); - const pathname = getPagePathFromParams(params); - - return generateSitePageMetadata({ - context, - pageParams: { pathname }, - }); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/layout.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/layout.tsx deleted file mode 100644 index eea0f85164..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/layout.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { type RouteLayoutParams, getDynamicSiteContext } from '@/app/utils'; -import { CustomizationRootLayout } from '@/components/RootLayout'; -import { - SiteLayout, - generateSiteLayoutMetadata, - generateSiteLayoutViewport, -} from '@/components/SiteLayout'; -import { getThemeFromMiddleware } from '@/lib/middleware'; -import { shouldTrackEvents } from '@/lib/tracking'; -import { headers } from 'next/headers'; - -interface SiteDynamicLayoutProps { - params: Promise ; -} - -export default async function SiteDynamicLayout({ - params, - children, -}: React.PropsWithChildren ) { - const { context, visitorAuthClaims } = await getDynamicSiteContext(await params); - const forcedTheme = await getThemeFromMiddleware(); - const withTracking = shouldTrackEvents(await headers()); - - return ( - - - ); -} - -export async function generateViewport({ params }: SiteDynamicLayoutProps) { - const { context } = await getDynamicSiteContext(await params); - return generateSiteLayoutViewport(context); -} - -export async function generateMetadata({ params }: SiteDynamicLayoutProps) { - const { context } = await getDynamicSiteContext(await params); - return generateSiteLayoutMetadata(context); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx deleted file mode 100644 index 65325a491f..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import type { RouteLayoutParams } from '@/app/utils'; -import { EmbeddableAssistantPage } from '@/components/Embeddable'; -import { getEmbeddableDynamicContext } from '@/lib/embeddable'; - -export const dynamic = 'force-static'; - -type PageProps = { - params: Promise- {children} - -; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getEmbeddableDynamicContext(params); - - return ; -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx deleted file mode 100644 index 36a75310ae..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import type { RouteLayoutParams } from '@/app/utils'; -import { - EmbeddableRootLayout, - generateEmbeddableMetadata, - generateEmbeddableViewport, -} from '@/components/Embeddable'; -import { getEmbeddableStaticContext } from '@/lib/embeddable'; -import { shouldTrackEvents } from '@/lib/tracking'; -import { headers } from 'next/headers'; - -interface SiteStaticLayoutProps { - params: Promise ; -} - -export default async function RootLayout({ - params, - children, -}: React.PropsWithChildren ) { - const { context, visitorAuthClaims } = await getEmbeddableStaticContext(await params); - const withTracking = shouldTrackEvents(await headers()); - - return ( - - {children} - - ); -} - -export async function generateViewport({ params }: SiteStaticLayoutProps) { - const { context } = await getEmbeddableStaticContext(await params); - return generateEmbeddableViewport({ context }); -} - -export async function generateMetadata({ params }: SiteStaticLayoutProps) { - const { context } = await getEmbeddableStaticContext(await params); - return generateEmbeddableMetadata({ context }); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx deleted file mode 100644 index 16c1ca51c8..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { type RouteParams, getPagePathFromParams } from '@/app/utils'; -import { EmbeddableDocsPage, generateEmbeddableDocsPageMetadata } from '@/components/Embeddable'; -import { getEmbeddableDynamicContext } from '@/lib/embeddable'; -import type { Metadata } from 'next'; - -type PageProps = { - params: Promise; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getEmbeddableDynamicContext(params); - const pathname = getPagePathFromParams(params); - - return ; -} - -export async function generateMetadata(props: PageProps): Promise { - const params = await props.params; - const { context } = await getEmbeddableDynamicContext(params); - const pathname = getPagePathFromParams(params); - return generateEmbeddableDocsPageMetadata({ context, pageParams: { pathname } }); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts deleted file mode 100644 index 1ea6f0650d..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getDynamicSiteContext } from '@/app/utils'; -import { serveIcon } from '@/routes/icon'; - -export async function GET( - request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getDynamicSiteContext(await params); - return serveIcon(context, request); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts deleted file mode 100644 index 5c52031e48..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getDynamicSiteContext } from '@/app/utils'; -import type { PageIdParams } from '@/components/SitePage'; -import { serveOGImage } from '@/routes/ogimage'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getDynamicSiteContext(await params); - return serveOGImage(context, await params); -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/layout.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/layout.tsx deleted file mode 100644 index 30aa899476..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/layout.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { type RouteLayoutParams, getDynamicSiteContext } from '@/app/utils'; -import { PDFRootLayout } from '@/components/PDF'; - -export default async function RootLayout(props: { - params: Promise ; - children: React.ReactNode; -}) { - const { params, children } = props; - const { context } = await getDynamicSiteContext(await params); - - return {children} ; -} diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/page.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/page.tsx deleted file mode 100644 index 6f1c13e034..0000000000 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/~gitbook/pdf/page.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { type RouteLayoutParams, getDynamicSiteContext } from '@/app/utils'; -import { PDFPage, generatePDFMetadata } from '@/components/PDF'; - -export async function generateMetadata({ - params, -}: { - params: Promise; -}) { - const { context } = await getDynamicSiteContext(await params); - return generatePDFMetadata(context); -} - -export default async function Page(props: { - params: Promise ; - searchParams: Promise<{ [key: string]: string }>; -}) { - const { params, searchParams } = props; - const { context } = await getDynamicSiteContext(await params); - return ; -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx deleted file mode 100644 index c715d5dd4e..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { SitePageNotFound } from '@/components/SitePage'; - -export default async function NotFound() { - return ; -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx deleted file mode 100644 index 238630ae73..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { type RouteParams, getPagePathFromParams, getStaticSiteContext } from '@/app/utils'; -import { - SitePage, - generateSitePageMetadata, - generateSitePageViewport, -} from '@/components/SitePage'; - -import type { Metadata, Viewport } from 'next'; - -export const dynamic = 'force-static'; - -type PageProps = { - params: Promise ; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getStaticSiteContext(params); - const pathname = getPagePathFromParams(params); - - return ; -} - -export async function generateViewport(props: PageProps): Promise { - const { context } = await getStaticSiteContext(await props.params); - return generateSitePageViewport(context); -} - -export async function generateMetadata(props: PageProps): Promise { - const params = await props.params; - const { context } = await getStaticSiteContext(params); - const pathname = getPagePathFromParams(params); - - return generateSitePageMetadata({ - context, - pageParams: { pathname }, - }); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/layout.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/layout.tsx deleted file mode 100644 index 97bec81b3d..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/(content)/layout.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { CustomizationRootLayout } from '@/components/RootLayout'; -import { - SiteLayout, - generateSiteLayoutMetadata, - generateSiteLayoutViewport, -} from '@/components/SiteLayout'; -import { shouldTrackEvents } from '@/lib/tracking'; - -interface SiteStaticLayoutProps { - params: Promise ; -} - -export default async function SiteStaticLayout({ - params, - children, -}: React.PropsWithChildren ) { - const { context, visitorAuthClaims } = await getStaticSiteContext(await params); - const withTracking = shouldTrackEvents(); - - return ( - - - ); -} - -export async function generateViewport({ params }: SiteStaticLayoutProps) { - const { context } = await getStaticSiteContext(await params); - return generateSiteLayoutViewport(context); -} - -export async function generateMetadata({ params }: SiteStaticLayoutProps) { - const { context } = await getStaticSiteContext(await params); - return generateSiteLayoutMetadata(context); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/[page]/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/[page]/route.ts deleted file mode 100644 index f9ef65cde5..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/[page]/route.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveLLMsFullTxt } from '@/routes/llms-full'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise- {children} - -} -) { - const awaitedParams = await params; - const page = Number(awaitedParams.page); - // If page is not a number, not an integer, or less than 0, return an error - if (Number.isNaN(page) || !Number.isInteger(page) || page < 0) { - return new Response('Invalid page', { status: 400 }); - } - const { context } = await getStaticSiteContext(awaitedParams); - return serveLLMsFullTxt(context, page); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/route.ts deleted file mode 100644 index 09c6645340..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms-full.txt/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveLLMsFullTxt } from '@/routes/llms-full'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveLLMsFullTxt(context); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms.txt/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms.txt/route.ts deleted file mode 100644 index da1176d9b7..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/llms.txt/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveLLMsTxt } from '@/routes/llms'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveLLMsTxt(context, { withMarkdownPages: true }); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/robots.txt/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/robots.txt/route.ts deleted file mode 100644 index 3ea9e6b008..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/robots.txt/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveRobotsTxt } from '@/routes/robots'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveRobotsTxt(context); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap-pages.xml/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap-pages.xml/route.ts deleted file mode 100644 index b9329ac82a..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap-pages.xml/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { servePagesSitemap } from '@/routes/sitemap'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return servePagesSitemap(context); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap.xml/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap.xml/route.ts deleted file mode 100644 index c306ca1e68..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/sitemap.xml/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveRootSitemap } from '@/routes/sitemap'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveRootSitemap(context); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx deleted file mode 100644 index 34c6bdd72c..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/assistant/page.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import type { RouteLayoutParams } from '@/app/utils'; -import { EmbeddableAssistantPage } from '@/components/Embeddable'; -import { getEmbeddableStaticContext } from '@/lib/embeddable'; - -export const dynamic = 'force-static'; - -type PageProps = { - params: Promise ; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getEmbeddableStaticContext(params); - - return ; -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/demo/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/demo/route.ts deleted file mode 100644 index 28a4f61622..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/demo/route.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import type { NextRequest } from 'next/server'; - -export const dynamic = 'force-static'; - -/** - * This route serves a quick demo to test the script.js script. - * It is not used in production. - */ -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - - return new Response( - ` - - - - - - - - - - -`, - { - headers: { - 'Content-Type': 'text/html', - 'Cache-Control': 'no-cache, no-store, must-revalidate', - }, - } - ); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx deleted file mode 100644 index 01a28af484..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/layout.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import type { RouteLayoutParams } from '@/app/utils'; -import { - EmbeddableRootLayout, - generateEmbeddableMetadata, - generateEmbeddableViewport, -} from '@/components/Embeddable'; -import { getEmbeddableStaticContext } from '@/lib/embeddable'; -import { shouldTrackEvents } from '@/lib/tracking'; - -interface SiteStaticLayoutProps { - params: Promise ; -} - -export default async function RootLayout({ - params, - children, -}: React.PropsWithChildren ) { - const { context, visitorAuthClaims } = await getEmbeddableStaticContext(await params); - const withTracking = shouldTrackEvents(); - - return ( - - {children} - - ); -} - -export async function generateViewport({ params }: SiteStaticLayoutProps) { - const { context } = await getEmbeddableStaticContext(await params); - return generateEmbeddableViewport({ context }); -} - -export async function generateMetadata({ params }: SiteStaticLayoutProps) { - const { context } = await getEmbeddableStaticContext(await params); - return generateEmbeddableMetadata({ context }); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx deleted file mode 100644 index 6e65f8b68d..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/page/[pagePath]/page.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { type RouteParams, getPagePathFromParams } from '@/app/utils'; -import { EmbeddableDocsPage, generateEmbeddableDocsPageMetadata } from '@/components/Embeddable'; -import { getEmbeddableStaticContext } from '@/lib/embeddable'; -import type { Metadata } from 'next'; - -export const dynamic = 'force-static'; - -type PageProps = { - params: Promise; -}; - -export default async function Page(props: PageProps) { - const params = await props.params; - const { context } = await getEmbeddableStaticContext(params); - const pathname = getPagePathFromParams(params); - - return ; -} - -export async function generateMetadata(props: PageProps): Promise { - const params = await props.params; - const { context } = await getEmbeddableStaticContext(params); - const pathname = getPagePathFromParams(params); - return generateEmbeddableDocsPageMetadata({ context, pageParams: { pathname } }); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/script.js/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/script.js/route.ts deleted file mode 100644 index be51d24e10..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/embed/script.js/route.ts +++ /dev/null @@ -1,77 +0,0 @@ -import type { RouteLayoutParams } from '@/app/utils'; -import { getAssetURL } from '@/lib/assets'; -import { buildVersion } from '@/lib/build'; -import { getEmbeddableStaticContext } from '@/lib/embeddable'; -import type { CreateGitBookOptions } from '@gitbook/embed'; -import type { NextRequest } from 'next/server'; - -export const dynamic = 'force-static'; - -/** - * This route is used to serve the assistant.js script. - */ -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getEmbeddableStaticContext(await params); - const initOptions: CreateGitBookOptions = { - siteURL: context.linker.toAbsoluteURL(context.linker.toPathInSite('')), - }; - - return new Response( - ` -(function () { - const w = window; - const gb = w.GitBook; - const initOptions = window.gitbookSettings || ${JSON.stringify(initOptions)}; - - if (typeof gb === "function") { - gb('init', initOptions); - } else { - var d = document; - - var g = function () { - g.c(arguments); - }; - g.q = []; - g.c = function (args) { - g.q.push(args); - }; - w.GitBook = g; - - g('init', initOptions); - - const load = function () { - const style = document.createElement('link'); - style.rel = 'stylesheet'; - style.href = ${JSON.stringify(getAssetURL(`embed/index.css?v=${buildVersion()}`))}; - document.head.appendChild(style); - - const script = d.createElement('script'); - script.type = 'text/javascript'; - script.async = true; - script.src = ${JSON.stringify(getAssetURL(`embed/index.js?v=${buildVersion()}`))}; - - var latestScript = d.getElementsByTagName('script')[0]; - latestScript.parentNode.insertBefore(script, latestScript); - }; - - if (document.readyState === 'complete') { - load(); - } else if (w.attachEvent) { - w.attachEvent('onload', load); - } else { - w.addEventListener('load', load, false); - } - } -})(); - `, - { - headers: { - 'Content-Type': 'application/javascript', - 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800', - }, - } - ); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts deleted file mode 100644 index ed56130203..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/icon/route.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { serveIcon } from '@/routes/icon'; - -export const dynamic = 'force-static'; - -export async function GET( - request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveIcon(context, request); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/markdown/[pagePath]/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/markdown/[pagePath]/route.ts deleted file mode 100644 index 1631baf317..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/markdown/[pagePath]/route.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { type RouteParams, getPagePathFromParams, getStaticSiteContext } from '@/app/utils'; -import { servePageMarkdown } from '@/routes/markdownPage'; -import type { NextRequest } from 'next/server'; - -export const dynamic = 'force-static'; - -export async function GET(_request: NextRequest, { params }: { params: Promise }) { - const { context } = await getStaticSiteContext(await params); - const pathname = getPagePathFromParams(await params); - return servePageMarkdown(context, pathname); -} diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/mcp/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/mcp/route.ts deleted file mode 100644 index b327be7762..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/mcp/route.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import { throwIfDataError } from '@/lib/data'; -import { joinPathWithBaseURL } from '@/lib/paths'; -import { findSiteSpaceBy } from '@/lib/sites'; -import { createMcpHandler } from 'mcp-handler'; -import type { NextRequest } from 'next/server'; -import { z } from 'zod'; - -async function handler( - nextRequest: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - const { dataFetcher, linker, site } = context; - - const mcpHandler = createMcpHandler( - (server) => { - server.tool( - 'searchDocumentation', - `Search across the documentation to find relevant information, code examples, API references, and guides. Use this tool when you need to answer questions about ${site.title}, find specific documentation, understand how features work, or locate implementation details. The search returns contextual content with titles and direct links to the documentation pages.`, - { - query: z.string(), - }, - async ({ query }) => { - const results = await throwIfDataError( - dataFetcher.searchSiteContent({ - organizationId: context.organizationId, - siteId: site.id, - query, - scope: { mode: 'all' }, - }) - ); - - return { - content: results.flatMap((spaceResult) => { - const found = findSiteSpaceBy( - context.structure, - (siteSpace) => siteSpace.space.id === spaceResult.id - ); - const spaceURL = found?.siteSpace.urls.published; - if (!spaceURL) { - return []; - } - - return spaceResult.pages.map((pageResult) => { - const pageURL = linker.toAbsoluteURL( - linker.toLinkForContent( - joinPathWithBaseURL(spaceURL, pageResult.path) - ) - ); - - const body = pageResult.sections - ?.map((section) => section.body) - .join('\n'); - - return { - type: 'text', - text: [ - `Title: ${pageResult.title}`, - `Link: ${pageURL}`, - body ? `Content: ${body}` : '', - ] - .filter(Boolean) - .join('\n'), - }; - }); - }), - }; - } - ); - }, - {}, - { - basePath: context.linker.toPathInSite('~gitbook/'), - streamableHttpEndpoint: '/mcp', - maxDuration: 60, - verboseLogs: true, - disableSse: true, - } - ); - - // Next.js request.url is the original URL and not the rewritten one from the middleware - const requestURL = new URL( - context.linker.toAbsoluteURL(context.linker.toPathInSite('~gitbook/mcp')) - ); - requestURL.search = nextRequest.nextUrl.search; - - const request = new Request(requestURL, nextRequest); - return mcpHandler(request); -} - -export { handler as GET, handler as POST }; diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts deleted file mode 100644 index 08d3b3c283..0000000000 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/~gitbook/ogimage/[pageId]/route.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { type RouteLayoutParams, getStaticSiteContext } from '@/app/utils'; -import type { PageIdParams } from '@/components/SitePage'; -import { serveOGImage } from '@/routes/ogimage'; - -export const dynamic = 'force-static'; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise } -) { - const { context } = await getStaticSiteContext(await params); - return serveOGImage(context, await params); -} diff --git a/packages/gitbook/src/app/utils.ts b/packages/gitbook/src/app/utils.ts deleted file mode 100644 index 0e5d1688b0..0000000000 --- a/packages/gitbook/src/app/utils.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { getVisitorAuthClaims, getVisitorAuthClaimsFromToken } from '@/lib/adaptive'; -import { type SiteURLData, fetchSiteContextByURLLookup, getBaseContext } from '@/lib/context'; -import { getDynamicCustomizationSettings } from '@/lib/customization'; -import type { SiteAPIToken } from '@gitbook/api'; -import { jwtDecode } from 'jwt-decode'; -import { forbidden } from 'next/navigation'; -import rison from 'rison'; - -export type RouteParamMode = 'url-host' | 'url'; - -export type RouteLayoutParams = { - mode: string; - - /** URL encoded site URL */ - siteURL: string; - - /** URL and Rison encoded site data from resolvePublishedContentByUrl */ - siteData: string; -}; - -export type RouteParams = RouteLayoutParams & { - pagePath: string; -}; - -/** - * Get the static context when rendering statically a site. - */ -export async function getStaticSiteContext(params: RouteLayoutParams) { - const siteURL = getSiteURLFromParams(params); - const siteURLData = getSiteURLDataFromParams(params); - - // For static routes, we check the expiration of the JWT token - // as the route might be revalidated after expiration - const decoded = jwtDecode (siteURLData.apiToken); - if (decoded.exp && decoded.exp < Date.now() / 1000 + 120) { - forbidden(); - } - - const context = await fetchSiteContextByURLLookup( - getBaseContext({ - siteURL, - siteURLData, - urlMode: getModeFromParams(params.mode), - }), - siteURLData - ); - - return { - context, - visitorAuthClaims: getVisitorAuthClaimsFromToken(decoded), - }; -} - -/** - * Get the site context when rendering dynamically. - * The context will depend on the request. - */ -export async function getDynamicSiteContext(params: RouteLayoutParams) { - const siteURL = getSiteURLFromParams(params); - const siteURLData = getSiteURLDataFromParams(params); - - const context = await fetchSiteContextByURLLookup( - getBaseContext({ - siteURL, - siteURLData, - urlMode: getModeFromParams(params.mode), - }), - siteURLData - ); - - context.customization = await getDynamicCustomizationSettings(context.customization); - - return { - context, - visitorAuthClaims: getVisitorAuthClaims(siteURLData), - }; -} - -/** - * Get the decoded page path from the params. - */ -export function getPagePathFromParams(params: RouteParams) { - const decoded = decodeURIComponent(params.pagePath); - return decoded; -} - -function getSiteURLFromParams(params: RouteLayoutParams) { - const decoded = decodeURIComponent(params.siteURL); - const url = new URL(`https://${decoded}`); - return url; -} - -function getModeFromParams(mode: string): RouteParamMode { - if (mode === 'url-host') { - return 'url-host'; - } - - return 'url'; -} - -/** - * Get the decoded site data from the params. - */ -function getSiteURLDataFromParams(params: RouteLayoutParams): SiteURLData { - const decoded = decodeURIComponent(params.siteData); - return rison.decode(decoded); -} diff --git a/packages/gitbook/src/app/~gitbook/env/route.ts b/packages/gitbook/src/app/~gitbook/env/route.ts deleted file mode 100644 index 5d89fe423e..0000000000 --- a/packages/gitbook/src/app/~gitbook/env/route.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { type NextRequest, NextResponse } from 'next/server'; - -import { - GITBOOK_API_PUBLIC_URL, - GITBOOK_API_TOKEN, - GITBOOK_API_URL, - GITBOOK_APP_URL, - GITBOOK_ASSETS_URL, - GITBOOK_DISABLE_TRACKING, - GITBOOK_FONTS_URL, - GITBOOK_ICONS_URL, - GITBOOK_IMAGE_RESIZE_SIGNING_KEY, - GITBOOK_INTEGRATIONS_HOST, - GITBOOK_SECRET, - GITBOOK_URL, - GITBOOK_USER_AGENT, -} from '@/lib/env'; - -/** - * Output the public environment variables for this deployment - */ -export async function GET(_req: NextRequest) { - return NextResponse.json({ - GITBOOK_URL, - GITBOOK_APP_URL, - GITBOOK_API_URL, - GITBOOK_API_PUBLIC_URL, - GITBOOK_ASSETS_URL, - GITBOOK_FONTS_URL, - GITBOOK_ICONS_URL, - GITBOOK_USER_AGENT, - GITBOOK_INTEGRATIONS_HOST, - GITBOOK_DISABLE_TRACKING, - - // Secret envs - GITBOOK_SECRET: !!GITBOOK_SECRET, - GITBOOK_API_TOKEN: !!GITBOOK_API_TOKEN, - GITBOOK_IMAGE_RESIZE_SIGNING_KEY: !!GITBOOK_IMAGE_RESIZE_SIGNING_KEY, - }); -} diff --git a/packages/gitbook/src/app/~gitbook/revalidate/route.ts b/packages/gitbook/src/app/~gitbook/revalidate/route.ts deleted file mode 100644 index fd90ade235..0000000000 --- a/packages/gitbook/src/app/~gitbook/revalidate/route.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { type NextRequest, NextResponse } from 'next/server'; - -import { getLogger } from '@/lib/logger'; -import { withVerifySignature } from '@/lib/routes'; -import { revalidateTag } from 'next/cache'; - -interface JsonBody { - tags: string[]; -} - -/** - * Revalidate cached data based on tags. - * The body should be a JSON with { tags: string[] } - */ -export async function POST(req: NextRequest) { - const logger = getLogger().subLogger('revalidate'); - return withVerifySignature (req, async (body) => { - if (!body.tags || !Array.isArray(body.tags)) { - return NextResponse.json( - { - error: 'tags must be an array', - }, - { status: 400 } - ); - } - - body.tags.forEach((tag) => { - logger.log(`Revalidating tag: ${tag}`); - revalidateTag(tag); - }); - - return NextResponse.json({ - success: true, - }); - }); -} diff --git a/packages/gitbook/src/app/~space/[spaceId]/pdf.ts b/packages/gitbook/src/app/~space/[spaceId]/pdf.ts deleted file mode 100644 index 44ab82b992..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/pdf.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - type GitBookBaseContext, - type GitBookSpaceContext, - fetchSpaceContextByIds, -} from '@/lib/context'; -import { createDataFetcher } from '@/lib/data'; -import { createLinker } from '@/lib/links'; -import { getAPITokenFromMiddleware } from '@/lib/middleware'; - -export type SpacePDFRouteParams = { - spaceId: string; - changeRequestId?: string; - revisionId?: string; -}; - -export async function getSpacePDFContext( - params: SpacePDFRouteParams -): Promise { - const { spaceId } = params; - - const apiToken = await getAPITokenFromMiddleware(); - - const basePath = getPDFRoutePath(params); - const linker = createLinker({ - spaceBasePath: basePath, - siteBasePath: basePath, - }); - const dataFetcher = createDataFetcher({ - apiToken: apiToken, - }); - - const baseContext: GitBookBaseContext = { - linker, - dataFetcher, - }; - - return await fetchSpaceContextByIds(baseContext, { - space: spaceId, - shareKey: undefined, - changeRequest: params.changeRequestId, - revision: params.revisionId, - }); -} - -function getPDFRoutePath(params: SpacePDFRouteParams) { - let path = `/~space/${params.spaceId}`; - - if (params.changeRequestId) { - path += `/~/changes/${params.changeRequestId}`; - } - - if (params.revisionId) { - path += `/~/revisions/${params.revisionId}`; - } - - path += '~gitbook/pdf'; - - return path; -} diff --git a/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/layout.tsx b/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/layout.tsx deleted file mode 100644 index 521ade4200..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/layout.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import RootLayout from '@/app/~space/[spaceId]/~gitbook/pdf/layout'; -export default RootLayout; diff --git a/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/page.tsx b/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/page.tsx deleted file mode 100644 index f66ca58645..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~/changes/[changeRequestId]/~gitbook/pdf/page.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import PDFPage, { generateMetadata } from '@/app/~space/[spaceId]/~gitbook/pdf/page'; - -export default PDFPage; -export { generateMetadata }; diff --git a/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/layout.tsx b/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/layout.tsx deleted file mode 100644 index 521ade4200..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/layout.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import RootLayout from '@/app/~space/[spaceId]/~gitbook/pdf/layout'; -export default RootLayout; diff --git a/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/page.tsx b/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/page.tsx deleted file mode 100644 index f66ca58645..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~/revisions/[changeRequestId]/~gitbook/pdf/page.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import PDFPage, { generateMetadata } from '@/app/~space/[spaceId]/~gitbook/pdf/page'; - -export default PDFPage; -export { generateMetadata }; diff --git a/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/layout.tsx b/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/layout.tsx deleted file mode 100644 index c3205d2bf0..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/layout.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { type SpacePDFRouteParams, getSpacePDFContext } from '@/app/~space/[spaceId]/pdf'; -import { PDFRootLayout } from '@/components/PDF'; - -export default async function RootLayout(props: { - params: Promise ; - children: React.ReactNode; -}) { - const { params, children } = props; - const context = await getSpacePDFContext(await params); - - return {children} ; -} diff --git a/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/page.tsx b/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/page.tsx deleted file mode 100644 index fdf11e13d7..0000000000 --- a/packages/gitbook/src/app/~space/[spaceId]/~gitbook/pdf/page.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { type SpacePDFRouteParams, getSpacePDFContext } from '@/app/~space/[spaceId]/pdf'; -import { PDFPage, generatePDFMetadata } from '@/components/PDF'; - -export async function generateMetadata({ - params, -}: { - params: Promise; -}) { - const context = await getSpacePDFContext(await params); - return generatePDFMetadata(context); -} - -export default async function Page(props: { - params: Promise ; - searchParams: Promise<{ [key: string]: string }>; -}) { - const { params, searchParams } = props; - const context = await getSpacePDFContext(await params); - return ; -} diff --git a/packages/gitbook/src/components/AI/index.ts b/packages/gitbook/src/components/AI/index.ts deleted file mode 100644 index c7e0827a22..0000000000 --- a/packages/gitbook/src/components/AI/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './useAI'; -export * from './useAIChat'; -export type { RenderAIMessageOptions } from './server-actions'; diff --git a/packages/gitbook/src/components/AI/server-actions/AIMessageView.tsx b/packages/gitbook/src/components/AI/server-actions/AIMessageView.tsx deleted file mode 100644 index 0850ac5498..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/AIMessageView.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import type { GitBookSiteContext } from '@/lib/context'; -import { tcls } from '@/lib/tailwind'; -import type { AIMessage } from '@gitbook/api'; -import { DocumentView } from '../../DocumentView'; -import { AIToolCallsSummary } from './AIToolCallsSummary'; -import type { RenderAIMessageOptions } from './types'; - -/** - * Render a message from the API backend. - */ -export function AIMessageView( - props: RenderAIMessageOptions & { - message: AIMessage; - context: GitBookSiteContext; - } -) { - const { message, context, withToolCalls = true, withLinkPreviews = true } = props; - - return ( - - {message.steps.map((step, index) => { - return ( -- ); -} diff --git a/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx b/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx deleted file mode 100644 index 00abbf8ae1..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx +++ /dev/null @@ -1,311 +0,0 @@ -import { HighlightQuery } from '@/components/Search/HighlightQuery'; -import { Link, StyledLink } from '@/components/primitives'; -import { getSpaceLanguage } from '@/intl/server'; -import { t } from '@/intl/translate'; -import type { GitBookSiteContext } from '@/lib/context'; -import { resolveContentRef } from '@/lib/references'; -import { tcls } from '@/lib/tailwind'; -import type { - AIToolCall, - AIToolCallGetPageContent, - AIToolCallGetPages, - AIToolCallMCP, - AIToolCallOther, - AIToolCallSearch, - ContentRef, -} from '@gitbook/api'; -import { Icon, type IconName } from '@gitbook/icons'; -import type * as React from 'react'; - -/** - * Display the tool calls in a message or step. - */ -export function AIToolCallsSummary(props: { - toolCalls: AIToolCall[]; - context: GitBookSiteContext; -}) { - const { toolCalls, context } = props; - - return ( -0 ? 'has-content' : '' - )} - > - - - {withToolCalls && step.toolCalls && step.toolCalls.length > 0 ? ( -- ); - })} -- ) : null} - - {toolCalls.map((toolCall, index) => ( -- ); -} - -function ToolCallSummary(props: { toolCall: AIToolCall; context: GitBookSiteContext }) { - const { toolCall, context } = props; - - return ( -- ))} - -- ); -} - -function getDescriptionForToolCall(toolCall: AIToolCall, context: GitBookSiteContext) { - switch (toolCall.tool) { - case 'getPageContent': - return- {getDescriptionForToolCall(toolCall, context)} - ; - case 'search': - return ; - case 'getPages': - return ; - case 'mcp': - return ; - case 'other': - return ; - default: - return <>{toolCall.tool}>; - } -} - -function DescriptionForPageContentToolCall(props: { - toolCall: AIToolCallGetPageContent; - context: GitBookSiteContext; -}) { - const { toolCall, context } = props; - - const language = getSpaceLanguage(context); - - return ( - - {t( - language, - 'ai_chat_tools_read_page', - <> -
- ); -} - -function DescriptionForMCPToolCall(props: { - toolCall: AIToolCallMCP; - context: GitBookSiteContext; -}) { - const { toolCall, context } = props; - - const language = getSpaceLanguage(context); - - return ( -- - > - )} - - {t( - language, - 'ai_chat_tools_mcp_tool', - {toolCall.mcpToolTitle ?? toolCall.mcpToolName} - )} -
- ); -} - -function DescriptionForOtherToolCall(props: { - toolCall: AIToolCallOther; - context: GitBookSiteContext; -}) { - const { toolCall } = props; - - return{toolCall.summary.text}
; -} - -async function DescriptionForSearchToolCall(props: { - toolCall: AIToolCallSearch; - context: GitBookSiteContext; -}) { - const { toolCall, context } = props; - - const language = getSpaceLanguage(context); - - // Resolve all hrefs for search results in parallel - const searchResultsWithHrefs = await Promise.all( - toolCall.results.map(async (result) => { - const resolved = await resolveContentRef( - result.anchor - ? { - kind: 'anchor', - page: result.pageId, - space: result.spaceId, - anchor: result.anchor, - } - : { - kind: 'page', - page: result.pageId, - space: result.spaceId, - }, - context - ); - return { - ...result, - href: resolved?.href || '#', - }; - }) - ); - - const hasResults = toolCall.results.length > 0; - - return ( --- ); -} - -function DescriptionForGetPagesToolCall(props: { - toolCall: AIToolCallGetPages; - context: GitBookSiteContext; -}) { - const { toolCall, context } = props; - - const language = getSpaceLanguage(context); - - return ( --
- {hasResults ? ( --- {hasResults ? ( -{t(language, 'searched_for', {toolCall.query})}
-- {hasResults - ? t(language, 'search_results_count', toolCall.results.length) - : t(language, 'search_no_results')} -
-- {t(language, 'view')} - {t(language, 'close')} -- ) : null} -- -- ) : null} -- {searchResultsWithHrefs.map((result, index) => ( -
-- - -
- ))} -- ---
- {result.description && ( -- -
- )} -- - - - {t(language, 'ai_chat_tools_listed_pages')} -
- ); -} - -function getIconForToolCall(toolCall: AIToolCall): IconName { - switch (toolCall.tool) { - case 'getPageContent': - return 'memo'; - case 'search': - return 'magnifying-glass'; - case 'getPages': - return 'files'; - case 'other': - return (toolCall.summary.icon as IconName) ?? 'hammer'; - default: - return 'hammer'; - } -} - -/** - * Link to a space that is not the current space. - */ -function OtherSpaceLink(props: { - spaceId: string; - context: GitBookSiteContext; - prefix?: React.ReactNode; -}) { - const { spaceId, prefix = ' in ', context } = props; - - if (context.space.id === spaceId) { - return null; - } - - return ( - <> - {prefix} -- - > - ); -} - -async function ContentRefLink(props: { - contentRef: ContentRef; - context: GitBookSiteContext; - fallback?: React.ReactNode; -}) { - const { contentRef, context, fallback } = props; - - const resolved = await resolveContentRef(contentRef, context); - - if (!resolved) { - return {fallback}; - } - - return {resolved.text} ; -} diff --git a/packages/gitbook/src/components/AI/server-actions/api.tsx b/packages/gitbook/src/components/AI/server-actions/api.tsx deleted file mode 100644 index 23440a6ae7..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/api.tsx +++ /dev/null @@ -1,168 +0,0 @@ -'use server'; -import type { GitBookBaseContext } from '@/lib/context'; -import { fetchServerActionSiteContext } from '@/lib/server-actions'; -import { traceErrorOnly } from '@/lib/tracing'; -import { - type AIMessage, - AIMessageRole, - type AIMessageStep, - type AIStreamResponse, -} from '@gitbook/api'; -import { EventIterator } from 'event-iterator'; -import { AIMessageView } from './AIMessageView'; -import type { RenderAIMessageOptions } from './types'; - -/** - * Stream the generation of a document. - */ -export async function streamRenderAIMessage( - baseContext: GitBookBaseContext, - rawStream: AsyncIterable, - options?: RenderAIMessageOptions -) { - return traceErrorOnly('AI.streamRenderAIMessage', async () => { - const message: AIMessage = { - id: '', - role: AIMessageRole.Assistant, - steps: [], - }; - - const updateProcessingMessageStep = ( - stepIndex: number, - callback: (step: AIMessageStep) => void - ) => { - if (stepIndex > message.steps.length) { - throw new Error( - `Step index out of bounds ${stepIndex} (${message.steps.length} steps)` - ); - } - - if (message.steps[stepIndex]) { - message.steps = [...message.steps]; - // @ts-expect-error - message.steps[stepIndex] = { ...message.steps[stepIndex] }; - // @ts-expect-error - callback(message.steps[stepIndex]); - } else { - message.steps = [ - ...message.steps, - { - content: { - object: 'document', - data: {}, - nodes: [], - }, - }, - ]; - // @ts-expect-error - callback(message.steps[stepIndex]); - } - }; - - // Fetch the full-context in the background to avoid blocking the stream. - const promiseContext = fetchServerActionSiteContext(baseContext); - - return parseResponse<{ - content: React.ReactNode; - event: AIStreamResponse; - }>(rawStream, async (event) => { - switch (event.type) { - /** - * The agent is processing a tool call in a new message. - */ - case 'response_tool_call': { - updateProcessingMessageStep(event.stepIndex, (step) => { - step.toolCalls ??= []; - step.toolCalls.push(event.toolCall); - }); - break; - } - - /** - * The agent is writing the content of a new message. - */ - case 'response_reasoning': - case 'response_document': { - updateProcessingMessageStep(event.stepIndex, (step) => { - const container = - event.type === 'response_reasoning' ? 'reasoning' : 'content'; - - step[container] ??= { - object: 'document', - data: {}, - nodes: [], - }; - step[container] = { - ...step[container], - nodes: [...step[container].nodes], - }; - if (event.operation === 'insert') { - step[container].nodes.push(...event.blocks); - } else { - step[container].nodes.splice( - -event.blocks.length, - event.blocks.length, - ...event.blocks - ); - } - }); - break; - } - } - - return { - event, - content: ( - - ), - }; - }); - }); -} - -/** - * Parse a stream from the API to extract the responseId. - */ -function parseResponse ( - responseStream: EventIterator , - parse: (response: AIStreamResponse) => T | undefined | Promise -): { - stream: EventIterator ; - response: Promise<{ responseId: string }>; -} { - let resolveResponse: (value: { responseId: string }) => void; - const response = new Promise<{ responseId: string }>((resolve) => { - resolveResponse = resolve; - }); - - const stream = new EventIterator ((queue) => { - (async () => { - let foundResponse = false; - - for await (const event of responseStream) { - const parsed = await parse(event); - if (parsed !== undefined) { - queue.push(parsed); - } - - if (event.type === 'response_finish') { - foundResponse = true; - resolveResponse({ responseId: event.responseId }); - } - } - - if (!foundResponse) { - throw new Error('No response found'); - } - })().then( - () => { - queue.stop(); - }, - (error) => { - queue.fail(error); - } - ); - }); - - return { stream, response }; -} diff --git a/packages/gitbook/src/components/AI/server-actions/chat.ts b/packages/gitbook/src/components/AI/server-actions/chat.ts deleted file mode 100644 index 8a81ffc805..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/chat.ts +++ /dev/null @@ -1,69 +0,0 @@ -'use server'; -import { getEmbeddableLinker } from '@/lib/embeddable'; -import { getSiteURLDataFromMiddleware } from '@/lib/middleware'; -import { getServerActionBaseContext } from '@/lib/server-actions'; -import { traceErrorOnly } from '@/lib/tracing'; -import { - type AIMessageContext, - AIMessageRole, - AIModel, - type AIToolCallResult, - type AIToolDefinition, -} from '@gitbook/api'; -import { streamRenderAIMessage } from './api'; -import type { RenderAIMessageOptions } from './types'; - -/** - * Generate a response to a chat message. - */ -export async function* streamAIChatResponse({ - message, - messageContext, - previousResponseId, - toolCall, - tools, - options, -}: { - message?: string; - messageContext: AIMessageContext; - previousResponseId?: string; - toolCall?: AIToolCallResult; - tools?: AIToolDefinition[]; - options?: RenderAIMessageOptions; -}) { - const { stream } = await traceErrorOnly('AI.streamAIChatResponse', async () => { - let context = await getServerActionBaseContext(); - if (options?.asEmbeddable) { - context = { ...context, linker: getEmbeddableLinker(context.linker) }; - } - - const siteURLData = await getSiteURLDataFromMiddleware(); - - const api = await context.dataFetcher.api(); - const rawStream = api.orgs.streamAiResponseInSite( - siteURLData.organization, - siteURLData.site, - { - input: message - ? [ - { - role: AIMessageRole.User, - content: message, - context: messageContext, - }, - ] - : [], - model: AIModel.ReasoningLow, - previousResponseId, - toolCall, - tools, - } - ); - - return await streamRenderAIMessage(context, rawStream, options); - }); - - for await (const output of stream) { - yield output; - } -} diff --git a/packages/gitbook/src/components/AI/server-actions/index.ts b/packages/gitbook/src/components/AI/server-actions/index.ts deleted file mode 100644 index be055934e9..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './types'; -export * from './chat'; diff --git a/packages/gitbook/src/components/AI/server-actions/types.ts b/packages/gitbook/src/components/AI/server-actions/types.ts deleted file mode 100644 index f16764ce76..0000000000 --- a/packages/gitbook/src/components/AI/server-actions/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { AIStreamResponse } from '@gitbook/api'; - -/** - * Stream when rendering an AI message. - */ -export type AIMessageRenderStream = AsyncIterable<{ - content: React.ReactNode; - event: AIStreamResponse; -}>; - -/** - * Options that can be passed when generating a AI message stream. - */ -export type RenderAIMessageOptions = { - /** - * Render the tool calls. - * @default true - */ - withToolCalls?: boolean; - - /** - * Render the link previews. - * @default true - */ - withLinkPreviews?: boolean; - - /** - * Generate links in the context of an embeddable view. - * @default false - */ - asEmbeddable?: boolean; -}; diff --git a/packages/gitbook/src/components/AI/useAI.tsx b/packages/gitbook/src/components/AI/useAI.tsx deleted file mode 100644 index 29df1f2356..0000000000 --- a/packages/gitbook/src/components/AI/useAI.tsx +++ /dev/null @@ -1,144 +0,0 @@ -'use client'; - -import { CustomizationAIMode } from '@gitbook/api'; -import { Icon, type IconName } from '@gitbook/icons'; -import * as React from 'react'; -import type { ReactNode } from 'react'; - -import { tString, useLanguage } from '@/intl/client'; -import type { GitBookAssistant } from '@gitbook/browser-types'; -import { useAIChatController, useAIChatState } from '.'; -import { AIChatIcon, AISearchIcon, getAIChatName } from '../AIChat'; -import { useIntegrationAssistants } from '../Integrations'; -import { useSearch } from '../Search/useSearch'; - -// Unify assistants configuration context with the assistants hook in one place -export type AIConfig = { - aiMode: CustomizationAIMode; - trademark: boolean; -}; - -export type Assistant = Omit & { - /** - * Unique identifier for the assistant. Generated automatically using Crypto.randomUUID(). - * @example '123e4567-e89b-12d3-a456-426614174000' - */ - id: string; - - /** - * Display mode for the assistant. Currently, only `overlay` is supported for custom assistants. - * - `overlay`: Display the assistant in an overlay on top of the page. - * - `sidebar`: Display the assistant in a sidebar next to the page. Only supported for the GitBook Assistant. - * - `search`: Display the assistant inside the search container. Only supported for GitBook AI Search. - * @default 'overlay' - */ - mode?: 'overlay' | 'sidebar' | 'search'; - - /** - * Whether the assistant is displayed in the page action menu. - * @default false - */ - pageAction: boolean; - - /** - * Icon of the assistant displayed in the UI. - */ - icon: ReactNode; -}; - -const AIContext = React.createContext (null); - -export function AIContextProvider(props: React.PropsWithChildren ): React.ReactElement { - const { aiMode, trademark, children } = props; - const value = React.useMemo(() => ({ aiMode, trademark }), [aiMode, trademark]); - return {children} ; -} - -function useAIConfig(): AIConfig { - const ctx = React.useContext(AIContext); - if (!ctx) { - throw new Error('useAI must be used within AIContextProvider'); - } - return ctx; -} - -type AIContext = { - config: AIConfig; - assistants: Assistant[]; -}; - -/** - * Unified assistants list combining the built-in GitBook Assistant (when enabled) - * with any custom assistants registered at runtime. - */ -export function useAI(): AIContext { - const config = useAIConfig(); - const chat = useAIChatState(); - const chatController = useAIChatController(); - const language = useLanguage(); - const [, setSearchState] = useSearch(); - - const assistants: Assistant[] = []; - - if (config.aiMode === CustomizationAIMode.Assistant) { - assistants.push({ - id: 'gitbook-assistant', - label: getAIChatName(language, config.trademark), - icon: ( -- ), - open: (query?: string) => { - chatController.open(); - if (query) { - chatController.postMessage({ message: query }); - } - }, - pageAction: true, - ui: true, - mode: 'sidebar', - }); - } else if (config.aiMode === CustomizationAIMode.Search) { - assistants.push({ - id: 'gitbook-ai-search', - label: tString(language, 'ai_chat_context_badge'), - icon: , - open: (query?: string) => { - if (query) { - setSearchState((prev) => - prev ? { ...prev, query: null, ask: query, open: true } : null - ); - } - }, - pageAction: false, - ui: false, - mode: 'search', - }); - } - - const integrationAssistants = useIntegrationAssistants(); - if (integrationAssistants.length > 0) { - assistants.push( - ...integrationAssistants.map((assistant) => ({ - ...assistant, - icon: , - open: (query?: string) => { - setSearchState((prev) => ({ - ask: null, // Reset ask as we assume the assistant will handle it - query: prev?.query ?? null, - scope: prev?.scope ?? 'default', - open: false, - })); - assistant.open(query); - }, - })) - ); - } - - return { - config, - assistants, - }; -} diff --git a/packages/gitbook/src/components/AI/useAIChat.tsx b/packages/gitbook/src/components/AI/useAIChat.tsx deleted file mode 100644 index 55317f8d76..0000000000 --- a/packages/gitbook/src/components/AI/useAIChat.tsx +++ /dev/null @@ -1,469 +0,0 @@ -'use client'; - -import * as zustand from 'zustand'; - -import { useLanguage } from '@/intl/client'; -import { tString } from '@/intl/translate'; -import { - AIMessageRole, - type AIStreamResponseToolCallPending, - type AIToolCallResult, -} from '@gitbook/api'; -import type { IconName } from '@gitbook/icons'; -import * as React from 'react'; -import { useTrackEvent } from '../Insights'; -import { integrationsAssistantTools } from '../Integrations'; -import { useSearch } from '../Search'; -import { type RenderAIMessageOptions, streamAIChatResponse } from './server-actions'; -import { useAIMessageContextRef } from './useAIMessageContext'; - -export type AIChatMessage = { - role: AIMessageRole; - content: React.ReactNode; - query?: string; -}; - -export type AIChatPendingTool = { - icon?: IconName; - label: string; - - /** - * Confirm the tool call by calling this function. - */ - confirm: () => Promise ; - - /** - * Tool call result to cancel it. - */ - cancelToolCall: AIToolCallResult; -}; - -export type AIChatState = { - /** - * If true, the chat is open. - */ - opened: boolean; - - /** - * ID of the latest AI response. - */ - responseId: string | null; - - /** - * The latest query sent to the AI. - */ - query: string | null; - - /** - * The first query sent to the AI. This is appended to the URL when the AI chat is opened. - */ - initialQuery: string | null; - - /** - * Messages in the session. - */ - messages: AIChatMessage[]; - - /** - * Suggestions for follow-up messages. - */ - followUpSuggestions: string[]; - - /** - * Tools that are pending confirmation to be executed. - */ - pendingTools: AIChatPendingTool[]; - - /** - * If true, the session is in progress. - */ - loading: boolean; - - /** - * Set to true when an error occurred while communicating with the server. When - * this flag is true, the chat input should be read-only and the UI should - * display an error alert. Clearing the conversation will reset this flag. - */ - error: boolean; -}; - -export type AIChatController = { - /** Open the dialog */ - open: () => void; - /** Close the dialog */ - close: () => void; - /** Post a message to the session */ - postMessage: (input: { message: string }) => void; - /** Clear the conversation */ - clear: () => void; -}; - -const AIChatControllerContext = React.createContext (null); - -// Global state store for AI chat -const globalState = zustand.create (() => { - return { - opened: false, - responseId: null, - messages: [], - query: null, - followUpSuggestions: [], - pendingTools: [], - loading: false, - error: false, - initialQuery: null, - }; -}); - -/** - * Get the current state of the AI chat. - */ -export function useAIChatState(): AIChatState { - const state = zustand.useStore(globalState); - return state; -} - -/** - * Provide the controller to interact with the AI chat. - */ -export function AIChatProvider(props: { - renderMessageOptions?: RenderAIMessageOptions; - children: React.ReactNode; -}) { - const { renderMessageOptions, children } = props; - - const messageContextRef = useAIMessageContextRef(); - const trackEvent = useTrackEvent(); - const [, setSearchState] = useSearch(); - const language = useLanguage(); - - // Open AI chat and sync with search state - const onOpen = React.useCallback(() => { - const { initialQuery } = globalState.getState(); - globalState.setState((state) => ({ ...state, opened: true })); - - // Update search state to show ask mode with first message or current ask value - setSearchState((prev) => ({ - ask: prev?.ask ?? initialQuery ?? '', - query: prev?.query ?? null, - scope: prev?.scope ?? 'default', - open: false, // Close search popover when opening chat - })); - }, [setSearchState]); - - // Close AI chat and clear ask parameter - const onClose = React.useCallback(() => { - globalState.setState((state) => ({ ...state, opened: false })); - - // Clear ask parameter but keep other search state - setSearchState((prev) => ({ - ask: null, - query: prev?.query ?? null, - scope: prev?.scope ?? 'default', - open: false, - })); - }, [setSearchState]); - - // Stream a message with the AI backend - const streamResponse = React.useCallback( - async (input: { - /** Text message to send to the AI backend */ - message?: string; - /** Tool call to send to the AI backend */ - toolCall?: AIToolCallResult; - }) => { - globalState.setState((state) => { - return { - ...state, - followUpSuggestions: [], - pendingTools: [], - loading: true, - error: false, - messages: [ - ...state.messages, - { - role: AIMessageRole.Assistant, - content: null, // Placeholder for streaming response - }, - ], - }; - }); - - // Execute a tool call - const executeToolCall = async (event: AIStreamResponseToolCallPending) => { - const integrationTools = integrationsAssistantTools.getState().tools; - const toolDef = integrationTools.find((tool) => tool.name === event.toolCall.tool); - - if (!toolDef) { - throw new Error(`Tool ${event.toolCall.tool} not found`); - } - - try { - const result = await toolDef.execute(event.toolCall.input); - streamResponse({ - toolCall: { - tool: event.toolCall.tool, - toolCallId: event.toolCallId, - output: result.output, - summary: result.summary, - }, - }); - } catch (error) { - streamResponse({ - toolCall: { - tool: event.toolCall.tool, - toolCallId: event.toolCallId, - output: { - error: error instanceof Error ? error.message : 'Unknown error', - }, - summary: { - icon: 'bomb', - text: 'An error occurred while executing the tool', - }, - }, - }); - } - }; - - let toolToExecute: AIStreamResponseToolCallPending | null = null; - try { - const integrationTools = integrationsAssistantTools.getState().tools; - const stream = await streamAIChatResponse({ - message: input.message, - toolCall: input.toolCall, - messageContext: messageContextRef.current, - previousResponseId: globalState.getState().responseId ?? undefined, - tools: integrationTools.map((tool) => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })), - options: { - withLinkPreviews: renderMessageOptions?.withLinkPreviews ?? true, - withToolCalls: renderMessageOptions?.withToolCalls ?? true, - asEmbeddable: renderMessageOptions?.asEmbeddable ?? false, - }, - }); - - // Process streaming response - for await (const data of stream) { - if (!data) continue; - - if (input.message && globalState.getState().query !== input.message) { - // Chat was cleared, stop processing the stream - break; - } - - const event = data.event; - - switch (event.type) { - case 'response_finish': { - globalState.setState((state) => ({ - ...state, - responseId: event.responseId, - // Mark as not loading when the response is finished - // Even if the stream might continue as we receive 'response_followup_suggestion' - loading: false, - error: false, - })); - break; - } - case 'response_followup_suggestion': { - globalState.setState((state) => ({ - ...state, - followUpSuggestions: [ - ...state.followUpSuggestions, - ...event.suggestions, - ], - })); - break; - } - case 'response_tool_call_pending': { - const toolDef = integrationTools.find( - (tool) => tool.name === event.toolCall.tool - ); - if (!toolDef) { - throw new Error(`Tool ${event.toolCall.tool} not found`); - } - - const confirmation = toolDef.confirmation; - if (confirmation) { - globalState.setState((state) => ({ - ...state, - pendingTools: [ - ...state.pendingTools, - { - icon: confirmation.icon, - label: confirmation.label, - cancelToolCall: { - tool: event.toolCall.tool, - toolCallId: event.toolCallId, - output: { - cancelled: 'User did not confirm the tool call', - }, - summary: { - icon: 'forward', - text: tString( - language, - 'tool_call_skipped', - confirmation.label - ), - }, - }, - confirm: async () => { - await executeToolCall(event); - }, - }, - ], - })); - } else { - toolToExecute = event; - } - break; - } - } - - // Update the assistant message with streamed content - globalState.setState((state) => ({ - ...state, - messages: [ - ...state.messages.slice(0, -1), - { - role: AIMessageRole.Assistant, - content: data.content, - }, - ], - })); - } - - // Execute the tool call if it doesn't require confirmation - if (toolToExecute) { - await executeToolCall(toolToExecute); - } - - globalState.setState((state) => ({ - ...state, - loading: false, - error: false, - })); - } catch (error) { - console.error('Error streaming AI response', error); - globalState.setState((state) => ({ - ...state, - loading: false, - error: true, - })); - } - }, - [ - messageContextRef.current, - renderMessageOptions?.withLinkPreviews, - renderMessageOptions?.withToolCalls, - renderMessageOptions?.asEmbeddable, - language, - ] - ); - - // Post a message to the AI chat - const onPostMessage = React.useCallback( - async (input: { message: string }) => { - const { query, messages, pendingTools } = globalState.getState(); - - // For first message, update the ask parameter in URL - if (messages.length === 0) { - setSearchState((prev) => ({ - ask: input.message, - query: prev?.query ?? null, - scope: prev?.scope ?? 'default', - open: false, - })); - } - - if (query === input.message) { - // Return early if the message is the same as the previous message - return; - } - - trackEvent({ type: 'ask_question', query: input.message }); - - // Add user message and placeholder for AI response - globalState.setState((state) => { - return { - ...state, - messages: [ - ...state.messages, - { - role: AIMessageRole.User, - content: input.message, - query: input.message, - }, - ], - query: input.message, - followUpSuggestions: [], - loading: true, - error: false, - initialQuery: state.initialQuery ?? input.message, - }; - }); - - const pendingTool = pendingTools[0]; - streamResponse({ - message: input.message, - // If we had a pending tool call, we need to send it as being cancelled - // otherwise the AI will fail to process the message - ...(pendingTool ? { toolCall: pendingTool.cancelToolCall } : {}), - }); - }, - [setSearchState, trackEvent, streamResponse] - ); - - // Clear the conversation and reset ask parameter - const onClear = React.useCallback(() => { - globalState.setState((state) => ({ - opened: state.opened, - loading: false, - messages: [], - query: null, - followUpSuggestions: [], - pendingTools: [], - responseId: null, - error: false, - initialQuery: null, - })); - - // Reset ask parameter to empty string (keeps chat open but clears content) - setSearchState((prev) => ({ - ask: '', - query: prev?.query ?? null, - scope: prev?.scope ?? 'default', - open: false, - })); - }, [setSearchState]); - - const controller = React.useMemo(() => { - return { - open: onOpen, - close: onClose, - clear: onClear, - postMessage: onPostMessage, - }; - }, [onOpen, onClose, onClear, onPostMessage]); - - return ( - - {children} - - ); -} - -/** - * Get the controller to interact with the AI chat. - * Integrates with search state to synchronize ?ask= parameter. - */ -export function useAIChatController(): AIChatController { - const controller = React.useContext(AIChatControllerContext); - if (!controller) { - throw new Error('useAIChatController must be used within an AIChatProvider'); - } - return controller; -} diff --git a/packages/gitbook/src/components/AI/useAIMessageContext.ts b/packages/gitbook/src/components/AI/useAIMessageContext.ts deleted file mode 100644 index dd8d1dbc32..0000000000 --- a/packages/gitbook/src/components/AI/useAIMessageContext.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { AIMessageContext } from '@gitbook/api'; -import React from 'react'; -import { useCurrentPage } from '../hooks'; - -/** - * Return the context for the AI message. - */ -export function useAIMessageContext(): AIMessageContext { - const currentPage = useCurrentPage(); - - return React.useMemo(() => { - return { - location: currentPage - ? { - spaceId: currentPage.spaceId, - pageId: currentPage.pageId, - } - : undefined, - }; - }, [currentPage]); -} - -/** - * Return the context for the AI message as a mutable React ref - */ -export function useAIMessageContextRef(): React.MutableRefObject{ - const context = useAIMessageContext(); - const ref = React.useRef(context); - - React.useEffect(() => { - ref.current = context; - }, [context]); - - return ref; -} diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx deleted file mode 100644 index 8cdbe49c0a..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ /dev/null @@ -1,318 +0,0 @@ -'use client'; - -import { t, tString, useLanguage } from '@/intl/client'; -import type { TranslationLanguage } from '@/intl/translations'; -import { tcls } from '@/lib/tailwind'; -import { Icon } from '@gitbook/icons'; -import React from 'react'; -import { useHotkeys } from 'react-hotkeys-hook'; -import { - type AIChatController, - type AIChatState, - useAIChatController, - useAIChatState, -} from '../AI'; -import { - EmbeddableFrame, - EmbeddableFrameBody, - EmbeddableFrameButtons, - EmbeddableFrameHeader, - EmbeddableFrameHeaderMain, - EmbeddableFrameSubtitle, - EmbeddableFrameTitle, -} from '../Embeddable/EmbeddableFrame'; -import { useTrackEvent } from '../Insights'; -import { useNow } from '../hooks'; -import { Button } from '../primitives'; -import { AIChatControlButton } from './AIChatControlButton'; -import { AIChatIcon } from './AIChatIcon'; -import { AIChatInput } from './AIChatInput'; -import { AIChatMessages } from './AIChatMessages'; -import AIChatSuggestedQuestions from './AIChatSuggestedQuestions'; - -export function AIChat(props: { trademark: boolean }) { - const { trademark } = props; - - const language = useLanguage(); - const chat = useAIChatState(); - const chatController = useAIChatController(); - const containerRef = React.useRef (null); - - // When the chat is opened, scroll to it (applicable on mobile, where it's displayed above the content) - React.useEffect(() => { - if (chat.opened) { - containerRef.current?.scrollIntoView({ - behavior: 'smooth', - block: 'start', - }); - } - }, [chat.opened]); - - useHotkeys( - 'esc', - () => { - chatController.close(); - }, - [] - ); - - // Track the view of the AI chat - const trackEvent = useTrackEvent(); - React.useEffect(() => { - if (chat.opened) { - trackEvent({ - type: 'ask_view', - }); - } - }, [chat.opened, trackEvent]); - - return ( - -- ); -} - -/** - * Dynamic icon to indicate the AI chat state. - */ -export function AIChatDynamicIcon(props: { - trademark: boolean; -}) { - const { trademark } = props; - const chat = useAIChatState(); - - return ( -- -- -- - -- {getAIChatName(language, trademark)} - -- - -- - -- 0 - ? chat.pendingTools.length > 0 - ? 'confirm' - : 'done' - : 'default' - } - /> - ); -} - -/** - * Subtitle of the AI chat window. - */ -export function AIChatSubtitle(props: { - chat: AIChatState; -}) { - const { chat } = props; - const language = useLanguage(); - - return ( - - {chat.messages[chat.messages.length - 1]?.content - ? tString(language, 'ai_chat_working') - : tString(language, 'ai_chat_thinking')} - - ); -} - -/** - * Body of the AI chat window. - */ -export function AIChatBody(props: { - chatController: AIChatController; - chat: AIChatState; - trademark: boolean; - welcomeMessage?: string; - suggestions?: string[]; -}) { - const { chatController, chat, trademark, suggestions } = props; - - const [input, setInput] = React.useState(''); - - const scrollContainerRef = React.useRef(null); - // Ref for the last user message element - const lastUserMessageRef = React.useRef (null); - const inputRef = React.useRef (null); - - const [inputHeight, setInputHeight] = React.useState(0); - const language = useLanguage(); - const now = useNow(60 * 60 * 1000); // Refresh every hour for greeting - - const isEmpty = !chat.messages.length; - - const timeGreeting = React.useMemo(() => { - const hour = new Date(now).getHours(); - if (hour < 6) return tString(language, 'ai_chat_assistant_greeting_night'); - if (hour < 12) return tString(language, 'ai_chat_assistant_greeting_morning'); - if (hour < 18) return tString(language, 'ai_chat_assistant_greeting_afternoon'); - return tString(language, 'ai_chat_assistant_greeting_evening'); - }, [now, language]); - - // Auto-scroll to the latest user message when messages change - React.useEffect(() => { - if (chat.messages.length > 0 && lastUserMessageRef.current) { - lastUserMessageRef.current.scrollIntoView({ - behavior: 'smooth', - block: 'start', - }); - } - }, [chat.messages.length]); - - React.useEffect(() => { - const timeout = setTimeout(() => { - if (lastUserMessageRef.current) { - lastUserMessageRef.current.scrollIntoView({ - behavior: 'smooth', - block: 'start', - }); - } - }, 100); - - // We want the chat messages to scroll underneath the input, but they should scroll past the input when scrolling all the way down. - // The best way to do this is to observe the input height and adjust the padding bottom of the scroll container accordingly. - const observer = new ResizeObserver((entries) => { - entries.forEach((entry) => { - setInputHeight(entry.contentRect.height + 32); - }); - }); - if (inputRef.current) { - observer.observe(inputRef.current); - } - return () => { - observer.disconnect(); - clearTimeout(timeout); - }; - }, []); - - return ( - <> - - {isEmpty ? ( ---- ) : ( ---- -- {!chat.error ? ( -- {timeGreeting} -
-- {t(language, 'ai_chat_assistant_description')} -
-- ) : null} - - )} - - {/* Display an error banner when something went wrong. */} - {chat.error ?- > - ); -} - -function AIChatError(props: { chatController: AIChatController }) { - const language = useLanguage(); - const { chatController } = props; - - return ( -: null} - - { - chatController.postMessage({ message: input }); - setInput(''); - }} - /> - -- ); -} - -export function getAIChatName(language: TranslationLanguage, trademark: boolean) { - return trademark - ? tString(language, 'ai_chat_assistant_name') - : tString(language, 'ai_chat_assistant_name_unbranded'); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatButton.tsx b/packages/gitbook/src/components/AIChat/AIChatButton.tsx deleted file mode 100644 index abe996cece..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatButton.tsx +++ /dev/null @@ -1,43 +0,0 @@ -'use client'; -import { useLanguage } from '@/intl/client'; -import { t } from '@/intl/translate'; -import type { Assistant } from '../AI'; -import { Button } from '../primitives'; -import { KeyboardShortcut } from '../primitives/KeyboardShortcut'; - -/** - * Button to open/close the AI chat. - */ -export function AIChatButton(props: { - assistant: Assistant; - showLabel?: boolean; - withShortcut?: boolean; -}) { - const { assistant, showLabel = true, withShortcut = true } = props; - const language = useLanguage(); - - return ( ---- {t(language, 'ai_chat_error')} - --{}} - iconOnly - icon="ellipsis" - label={tString(language, 'actions')} - variant="blank" - size="default" - /> - } - > - - ) : null; -} diff --git a/packages/gitbook/src/components/AIChat/AIChatIcon.tsx b/packages/gitbook/src/components/AIChat/AIChatIcon.tsx deleted file mode 100644 index a4cf051540..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatIcon.tsx +++ /dev/null @@ -1,199 +0,0 @@ -import { tcls } from '@/lib/tailwind'; -import { Icon, IconStyle } from '@gitbook/icons'; -import type React from 'react'; - -interface AIChatIconProps extends React.SVGProps{ - chatController.clear(); - }} - > - -- {t(language, 'ai_chat_clear_conversation')} - { - className?: string; - size?: number; - state?: 'default' | 'intro' | 'thinking' | 'working' | 'done' | 'error' | 'confirm'; - trademark?: boolean; -} - -export function AIChatIcon({ - className = 'size-4', - size, - trademark = true, - state = 'default', - ...props -}: AIChatIconProps) { - if (!trademark) { - return ( - - ); - } - - return ( - - ); -} - -export function AISearchIcon({ - className = 'size-4', - state = 'default', -}: Pick ) { - return ( - -- ); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatInput.tsx b/packages/gitbook/src/components/AIChat/AIChatInput.tsx deleted file mode 100644 index 437291d12a..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatInput.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import { t, tString, useLanguage } from '@/intl/client'; -import { tcls } from '@/lib/tailwind'; -import { Icon } from '@gitbook/icons'; -import { useEffect, useRef } from 'react'; -import { useHotkeys } from 'react-hotkeys-hook'; -import { Button, HoverCard, HoverCardRoot, HoverCardTrigger } from '../primitives'; -import { KeyboardShortcut } from '../primitives/KeyboardShortcut'; - -export function AIChatInput(props: { - value: string; - disabled?: boolean; - /** - * When true, the input is disabled - */ - loading: boolean; - onChange: (value: string) => void; - onSubmit: (value: string) => void; -}) { - const { value, onChange, onSubmit, disabled, loading } = props; - - const language = useLanguage(); - - const inputRef = useRef- - (null); - - const handleInput = (event: React.ChangeEvent ) => { - const textarea = event.currentTarget; - onChange(textarea.value); - - // Auto-resize - textarea.style.height = 'auto'; - textarea.style.height = `${textarea.scrollHeight}px`; - }; - - useEffect(() => { - if (!disabled && !loading) { - // Add a small delay to ensure the input is rendered before focusing - // This fixes inconsistent focus behaviour across browsers - const timeout = setTimeout(() => { - inputRef.current?.focus(); - }, 150); - - return () => clearTimeout(timeout); - } - }, [disabled, loading]); - - useHotkeys( - 'mod+i', - (e) => { - e.preventDefault(); - inputRef.current?.focus(); - }, - { - enableOnFormTags: true, - } - ); - - return ( - -- ); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatMessages.tsx b/packages/gitbook/src/components/AIChat/AIChatMessages.tsx deleted file mode 100644 index 700d31bcc1..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatMessages.tsx +++ /dev/null @@ -1,143 +0,0 @@ -import { useLanguage } from '@/intl/client'; -import { tString } from '@/intl/translate'; -import { tcls } from '@/lib/tailwind'; -import { AIMessageRole } from '@gitbook/api'; -import type React from 'react'; -import type { AIChatController, AIChatState } from '../AI'; -import { AIChatToolConfirmations } from './AIChatToolConfirmations'; -import { AIResponseFeedback } from './AIResponseFeedback'; -import { AIChatFollowupSuggestions } from './AiChatFollowupSuggestions'; - -export function AIChatMessages(props: { - chat: AIChatState; - chatController: AIChatController; - lastUserMessageRef?: React.RefObject; -}) { - const { chat, chatController, lastUserMessageRef } = props; - - return ( - <> - {chat.messages.map((message, index) => { - const isLastMessage = index === chat.messages.length - 1; - const isLastUserMessage = - message.role === AIMessageRole.User && - index === chat.messages.map((m) => m.role).lastIndexOf(AIMessageRole.User); - - return ( - - {message.content ? message.content : null} - - {isLastMessage && chat.loading ? ( -- ); - })} - > - ); -} - -export function HoldMessage({ - breakLines = false, - className = '', -}: { breakLines?: boolean; className?: string }) { - const language = useLanguage(); - - return ( -- {!message.content ?- ) : null} - - {isLastMessage ? ( - <> - {!chat.loading && - !chat.error && - chat.query && - chat.responseId && - chat.pendingTools.length === 0 ? ( -: null} - - - ) : null} - - - > - ) : null} - - {tString(language, 'ai_chat_hold_message_1') - .split(' ') - .map((word, index) => ( - - {word}{' '} - - ))} - {breakLines ?- ); -} - -function LoadingSkeleton() { - return ( -
: null} - {tString(language, 'ai_chat_hold_message_2') - .split(' ') - .map((word, index) => ( - - {word}{' '} - - ))} -- {Array.from({ length: 7 }).map((_, index) => ( - - ))} -- ); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx b/packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx deleted file mode 100644 index f3951698eb..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { tString, useLanguage } from '@/intl/client'; -import type { AIChatController } from '../AI'; -import { Button } from '../primitives'; - -export default function AIChatSuggestedQuestions(props: { - chatController: AIChatController; - suggestions?: string[]; -}) { - const language = useLanguage(); - const { - chatController, - suggestions = [ - tString(language, 'ai_chat_suggested_questions_about_this_page'), - tString(language, 'ai_chat_suggested_questions_read_next'), - tString(language, 'ai_chat_suggested_questions_example'), - ], - } = props; - - return ( -- {suggestions.map((question, index) => ( - - ))} -- ); -} diff --git a/packages/gitbook/src/components/AIChat/AIChatToolConfirmations.tsx b/packages/gitbook/src/components/AIChat/AIChatToolConfirmations.tsx deleted file mode 100644 index f7202c991c..0000000000 --- a/packages/gitbook/src/components/AIChat/AIChatToolConfirmations.tsx +++ /dev/null @@ -1,69 +0,0 @@ -'use client'; -import { useLanguage } from '@/intl/client'; -import { t } from '@/intl/translate'; -import { useHotkeys } from 'react-hotkeys-hook'; -import type { AIChatState } from '../AI'; -import { Button } from '../primitives'; -import { KeyboardShortcut } from '../primitives/KeyboardShortcut'; - -/** - * Display buttons to confirm tool calls. - */ -export function AIChatToolConfirmations(props: { - chat: AIChatState; -}) { - const { chat } = props; - - const language = useLanguage(); - - useHotkeys( - 'mod+enter', - (e) => { - e.preventDefault(); - chat.pendingTools[0]?.confirm(); - }, - { - enableOnFormTags: true, - }, - [chat.pendingTools] - ); - - return ( -- {chat.pendingTools.map((tool, index) => ( -- ); -} diff --git a/packages/gitbook/src/components/AIChat/AIResponseFeedback.tsx b/packages/gitbook/src/components/AIChat/AIResponseFeedback.tsx deleted file mode 100644 index 5c94a1e191..0000000000 --- a/packages/gitbook/src/components/AIChat/AIResponseFeedback.tsx +++ /dev/null @@ -1,70 +0,0 @@ -'use client'; - -import { useLanguage } from '@/intl/client'; -import { t, tString } from '@/intl/translate'; -import { type ClassValue, tcls } from '@/lib/tailwind'; -import { useState } from 'react'; -import { useTrackEvent } from '../Insights'; -import { Button } from '../primitives'; - -export function AIResponseFeedback(props: { - className?: ClassValue; - responseId: string; - query: string; -}) { - const { className, responseId, query } = props; - - const language = useLanguage(); - const [rating, setRating] = useState<1 | -1 | null>(null); - const trackEvent = useTrackEvent(); - - const handleRating = (rating: 1 | -1) => { - setRating(rating); - trackEvent({ type: 'ask_rate_response', query, responseId, rating }); - }; - - return ( --- ))} --- ); -} diff --git a/packages/gitbook/src/components/AIChat/AiChatFollowupSuggestions.tsx b/packages/gitbook/src/components/AIChat/AiChatFollowupSuggestions.tsx deleted file mode 100644 index afe208990e..0000000000 --- a/packages/gitbook/src/components/AIChat/AiChatFollowupSuggestions.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type { AIChatController, AIChatState } from '../AI'; -import { Button } from '../primitives'; - -/** - * Display follow-up suggestions for the user to pick from. - */ -export function AIChatFollowupSuggestions(props: { - chat: AIChatState; - chatController: AIChatController; -}) { - const { chat, chatController } = props; - - if (chat.followUpSuggestions.length === 0) { - return null; - } - - return ( -- {chat.followUpSuggestions.map((suggestion, index) => ( -- ); -} diff --git a/packages/gitbook/src/components/AIChat/assets/icon-default.svg b/packages/gitbook/src/components/AIChat/assets/icon-default.svg deleted file mode 100644 index 8813eae069..0000000000 --- a/packages/gitbook/src/components/AIChat/assets/icon-default.svg +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/packages/gitbook/src/components/AIChat/index.ts b/packages/gitbook/src/components/AIChat/index.ts deleted file mode 100644 index 12eaa899e5..0000000000 --- a/packages/gitbook/src/components/AIChat/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './AIChat'; -export * from './AIChatButton'; -export * from './AIChatIcon'; -export * from './AIResponseFeedback'; -export * from './AIChatControlButton'; diff --git a/packages/gitbook/src/components/Adaptive/AdaptiveVisitorContextProvider.tsx b/packages/gitbook/src/components/Adaptive/AdaptiveVisitorContextProvider.tsx deleted file mode 100644 index 1edf650683..0000000000 --- a/packages/gitbook/src/components/Adaptive/AdaptiveVisitorContextProvider.tsx +++ /dev/null @@ -1,98 +0,0 @@ -'use client'; - -import type { GitBookSiteContext } from '@/lib/context'; -import { OpenAPIPrefillContextProvider } from '@gitbook/react-openapi'; -import * as React from 'react'; -import { createContext, useContext } from 'react'; -import type { AdaptiveVisitorClaims } from './types'; - -/** - * In-memory cache of visitor claim readers keyed by contextId. - */ -const adaptiveVisitorReaderCache = new Map< - string, - ReturnType{ - chatController.postMessage({ message: suggestion }); - }} - label={suggestion} - className="whitespace-normal! max-w-full animate-[present_500ms_both] text-left ring-1 ring-tint-subtle" - size="medium" - variant="blank" - style={{ - animationDelay: `${250 + Math.min(index * 50, 150)}ms`, - }} - /> - ))} - > ->(); - -function createResourceReader (promise: Promise ) { - let result: T | null | undefined; - - const suspender = (async () => { - try { - result = await promise; - } catch { - result = null; - } - })(); - - return { - read() { - if (result === undefined) { - throw suspender; - } - return result; - }, - }; -} - -/** - * Return an adaptive visitor claims cached reader for a given endpoint URL and contextId. - */ -function getAdaptiveVisitorClaimsReader(url: string, contextId: string) { - let reader = adaptiveVisitorReaderCache.get(contextId); - if (!reader) { - const promise = (async () => { - try { - const res = await fetch(url); - if (!res.ok) { - return null; - } - return await res.json (); - } catch { - return null; - } - })(); - - reader = createResourceReader(promise); - adaptiveVisitorReaderCache.set(contextId, reader); - } - return reader; -} - -export type AdaptiveVisitorContextValue = () => AdaptiveVisitorClaims | null; - -const AdaptiveVisitorContext = createContext (() => null); - -/** - * Provide context to adapt site based on visitor claims. - */ -export function AdaptiveVisitorContextProvider( - props: React.PropsWithChildren<{ - visitorClaimsURL: string; - contextId: GitBookSiteContext['contextId'] | undefined; - }> -) { - const { visitorClaimsURL, contextId, children } = props; - - const getAdaptiveVisitorClaims = React.useCallback(() => { - if (!contextId) { - return null; - } - return getAdaptiveVisitorClaimsReader(visitorClaimsURL, contextId).read(); - }, [visitorClaimsURL, contextId]); - - return ( - - - ); -} - -/** - * Hook that returns a suspensable getter for adaptive visitor claims data. - */ -export function useAdaptiveVisitor(): AdaptiveVisitorContextValue { - return useContext(AdaptiveVisitorContext); -} diff --git a/packages/gitbook/src/components/Adaptive/index.ts b/packages/gitbook/src/components/Adaptive/index.ts deleted file mode 100644 index 4b3df49b74..0000000000 --- a/packages/gitbook/src/components/Adaptive/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './types'; -export * from './utils'; -export * from './AdaptiveVisitorContextProvider'; diff --git a/packages/gitbook/src/components/Adaptive/types.ts b/packages/gitbook/src/components/Adaptive/types.ts deleted file mode 100644 index f467643762..0000000000 --- a/packages/gitbook/src/components/Adaptive/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type AdaptiveVisitorClaimsData = Record- {children} - -& { - unsigned: Record ; -}; - -export type AdaptiveVisitorClaims = { - visitor: { - claims: AdaptiveVisitorClaimsData; - }; -}; diff --git a/packages/gitbook/src/components/Adaptive/utils.ts b/packages/gitbook/src/components/Adaptive/utils.ts deleted file mode 100644 index 304410a7a1..0000000000 --- a/packages/gitbook/src/components/Adaptive/utils.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { Variables } from '@gitbook/api'; -import type { AdaptiveVisitorClaims } from './types'; - -/** - * Return an evaluation context to evaluate expressions. - */ -export function createExpressionEvaluationContext(args: { - visitorClaims: AdaptiveVisitorClaims | null; - variables: { - space?: Variables; - page?: Variables; - }; -}) { - const { visitorClaims, variables } = args; - return { - ...(visitorClaims ? visitorClaims : {}), - space: { - vars: variables.space ?? {}, - }, - ...(variables.page - ? { - page: { - vars: variables.page ?? {}, - }, - } - : {}), - }; -} diff --git a/packages/gitbook/src/components/AdminToolbar/AdminToolbar.tsx b/packages/gitbook/src/components/AdminToolbar/AdminToolbar.tsx deleted file mode 100644 index fa406accd9..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/AdminToolbar.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import type { GitBookSiteContext } from '@/lib/context'; -import { AdminToolbarClient } from './AdminToolbarClient'; -import type { AdminToolbarContext } from './types'; - -export interface AdminToolbarProps { - context: GitBookSiteContext; -} - -/** - * Server component that determines what type of toolbar to show and passes data to client component - */ -export async function AdminToolbar(props: AdminToolbarProps) { - const { context } = props; - - // Create a minimal context to avoid serializing and passing too many data to the client - const minimalContext: AdminToolbarContext = { - organizationId: context.organizationId, - revisionId: context.revisionId, - space: { - id: context.space.id, - revision: context.space.revision, - urls: { - app: context.space.urls.app, - }, - }, - changeRequest: context.changeRequest - ? { - id: context.changeRequest.id, - number: context.changeRequest.number, - subject: context.changeRequest.subject, - revision: context.changeRequest.revision, - updatedAt: context.changeRequest.updatedAt, - createdBy: { - displayName: context.changeRequest.createdBy.displayName, - }, - urls: { - app: context.changeRequest.urls.app, - }, - } - : null, - revision: { - createdAt: context.revision.createdAt, - urls: { - app: context.revision.urls.app, - }, - git: context.revision.git - ? { - url: context.revision.git.url, - } - : null, - }, - site: { - id: context.site.id, - title: context.site.title, - urls: { - app: context.site.urls.app, - published: context.site.urls.published, - }, - }, - }; - - return ; -} diff --git a/packages/gitbook/src/components/AdminToolbar/AdminToolbarClient.tsx b/packages/gitbook/src/components/AdminToolbar/AdminToolbarClient.tsx deleted file mode 100644 index 8a39f863ef..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/AdminToolbarClient.tsx +++ /dev/null @@ -1,391 +0,0 @@ -'use client'; -import { Icon } from '@gitbook/icons'; -import { MotionConfig } from 'motion/react'; -import { useCheckForContentUpdate } from '../AutoRefreshContent'; -import { useVisitorSession } from '../Insights'; -import { useCurrentPagePath } from '../hooks'; -import { DateRelative } from '../primitives'; -import { HideToolbarButton } from './HideToolbarButton'; -import { IframeWrapper } from './IframeWrapper'; -import { RefreshContentButton } from './RefreshContentButton'; -import { - Toolbar, - ToolbarBody, - ToolbarButton, - ToolbarButtonGroup, - type ToolbarButtonProps, - ToolbarSeparator, - ToolbarSubtitle, - ToolbarTitle, -} from './Toolbar'; -import { - type ToolbarControlsContextValue, - ToolbarControlsProvider, -} from './ToolbarControlsContext'; -import type { AdminToolbarClientProps, AdminToolbarContext } from './types'; -import { useToolbarVisibility } from './utils'; - -export function AdminToolbarClient(props: AdminToolbarClientProps) { - const { context, onPersistentClose, onSessionClose, onToggleMinify } = props; - const { - minified, - setMinified, - shouldAutoExpand, - hidden, - minimize, - closeSession, - closePersistent, - } = useToolbarVisibility({ - onPersistentClose, - onSessionClose, - onToggleMinify, - }); - - const visitorSession = useVisitorSession(); - - const toolbarControls: ToolbarControlsContextValue = { - minimize, - closeSession, - closePersistent, - shouldAutoExpand, - }; - - if (hidden) { - return null; - } - - // If there is a change request, show the change request toolbar - if (context.changeRequest) { - return ( - - - ); - } - - // If the revision is not the current revision, the user is looking at a previous version of the site, so show the revision toolbar - if (context.revisionId !== context.space.revision) { - return ( -- - - ); - } - - // If the user is authenticated and part of the organization owning this site, show the authenticated user toolbar - if (visitorSession?.organizationId === context.organizationId) { - return ( -- - - ); - } - - return null; -} - -/** - * Reusable wrapper that provides tooling and containers that are used by all types of toolbar views. - */ -export function ToolbarControlsWrapper( - props: React.PropsWithChildren<{ value: ToolbarControlsContextValue | null }> -) { - const { children, value } = props; - return ( -- - - ); -} - -interface ToolbarViewProps { - context: AdminToolbarContext; - minified: boolean; - onMinifiedChange: (value: boolean) => void; -} - -function ChangeRequestToolbar(props: ToolbarViewProps) { - const { context, minified, onMinifiedChange } = props; - const { changeRequest, site } = context; - if (!changeRequest) { - throw new Error('Change request is not set'); - } - - const author = changeRequest.createdBy.displayName; - - const { refreshForUpdates, updated } = useCheckForContentUpdate({ - revisionId: changeRequest.revision, - }); - - return ( -- -{children} -- - ); -} - -function RevisionToolbar(props: ToolbarViewProps) { - const { context, minified, onMinifiedChange } = props; - const { revision, site } = context; - if (!revision) { - throw new Error('Revision is not set'); - } - - const gitURL = revision.git?.url; - const isGitHub = gitURL?.includes('github.com'); - const gitProvider = isGitHub ? 'GitHub' : 'GitLab'; - - return ( -- - -- - by {author} - > - } - /> - - - - {/* Refresh to retrieve latest changes */} - {updated ? -: null} - - {/* Edit in GitBook */} - - - {/* Comment in app */} - - - {/* Open published/live site */} - {site.urls.published ? ( - - ) : null} - - {/* Open CR in GitBook */} - - - - ); -} - -function AuthenticatedUserToolbar(props: ToolbarViewProps) { - const { context, minified, onMinifiedChange } = props; - const { revision, space, site } = context; - const { refreshForUpdates, updated } = useCheckForContentUpdate({ - revisionId: space.revision, - }); - - return ( -- -- - Created - > - } - /> - - - {/* Open commit in Git client */} - -- Setup GitSync to edit using Git{' '} - - - ) - } - href={gitURL} - disabled={!gitURL} - icon={gitURL ? (isGitHub ? 'github' : 'gitlab') : 'github'} - /> - {site.urls.published ? ( - - ) : null} - - - - ); -} - -function ToolbarActions(props: { children: React.ReactNode }) { - const { children } = props; - - return ( -- -- - Updated - > - } - /> - - - {/* Refresh to retrieve latest changes */} - {updated ? -: null} - - {/* Edit in GitBook */} - - - {/* Open site in GitBook */} - - - {/* Customize in GitBook */} - - - {/* Open insights in GitBook */} - - - {children} - - ); -} - -function EditPageButton(props: { - href: string; - siteId: string; - motionValues?: ToolbarButtonProps['motionValues']; -}) { - const { href, motionValues, siteId } = props; - const pagePath = useCurrentPagePath(); - - return ( -- - ); -} - -/** - * Append utm parameters to a URL to track usage of the toolbar. - */ -function getToolbarHref({ - href, - siteId, - buttonId, -}: { href: string; siteId: string; buttonId: string }) { - const url = new URL(href); - url.searchParams.set('utm_source', 'content'); - url.searchParams.set('utm_medium', 'toolbar'); - url.searchParams.set('utm_campaign', siteId); - url.searchParams.set('utm_content', buttonId); - - return url.toString(); -} diff --git a/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.module.css b/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.module.css deleted file mode 100644 index dc2938ef10..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.module.css +++ /dev/null @@ -1,185 +0,0 @@ -.svgLogo { - --logo-fill: var(--color-neutral-100); - --seg-A-color: #2782c4; - --seg-B-color: #43b7f2; - --seg-C-color: #8be2ff; - --trace-color: #46474c; - - - --T: 2s; - shape-rendering: geometricPrecision; - vector-effect: non-scaling-stroke; -} - -.static .trace { - animation: none; - fill: var(--logo-fill); - stroke: none; -} - -.static .seg { - animation: none; - opacity: 0; -} - -/* Base segment animation */ -.seg { - opacity: 0; - animation: segFade var(--T) ease both 0.06s, segAMove var(--T) linear, - segALen var(--T) linear; - animation-delay: 0.06s; - animation-fill-mode: forwards; -} - -.segA { - animation-name: segFade, segAMove, segALen; -} - -.segB { - animation-name: segFade, segBMove, segBLen; -} - -.segC { - animation-name: segFade, segCMove, segCLen; -} - -.trace { - animation: traceFill var(--T) ease both 0.06s; - animation-fill-mode: forwards; -} - -@keyframes traceFill { - 0% { - fill: transparent; - stroke:var(--trace-color); - } - 95% { - fill: transparent; - stroke:var(--trace-color); - } - 100% { - fill: var(--logo-fill); - stroke:none; - } -} - - -/* Segment A animation */ -@keyframes segAMove { - 0% { - stroke-dashoffset: 0; - stroke: var(--seg-A-color); - } - 50% { - stroke-dashoffset: -0.5; - stroke: var(--seg-A-color); - } - 95% { - stroke-dashoffset: -1; - } - 100% { - stroke-dashoffset: 0; - stroke: none; - } -} - -@keyframes segALen { - 0% { - stroke-dasharray: 0.18 0.82; - } - 95% { - stroke-dasharray: 0.22 0.78; - } - 100% { - stroke-dasharray: 1; - } -} - -/* Segment B animation */ -@keyframes segBMove { - 0% { - stroke-dashoffset: -0.18; - stroke: var(--seg-B-color); - } - 50% { - stroke-dashoffset: -0.72; - stroke: var(--seg-B-color); - } - 95% { - stroke-dashoffset: -1.18; - stroke: var(--seg-B-color); - } - 100% { - stroke-dashoffset: 0; - stroke: none; - } -} - -@keyframes segBLen { - 0%, - 50%, - 95% { - stroke-dasharray: 0.2 0.8; - } - 100% { - stroke-dasharray: 1; - } -} - -/* Segment C animation */ -@keyframes segCMove { - 0% { - stroke-dashoffset: -0.38; - stroke: var(--seg-C-color); - } - 50% { - stroke-dashoffset: -0.92; - stroke: var(--seg-C-color); - } - 95% { - stroke-dashoffset: -1.38; - stroke: var(--seg-C-color); - } - 100% { - stroke-dashoffset: 0; - stroke: none; - } -} - -@keyframes segCLen { - 0% { - stroke-dasharray: 0.22 0.78; - } - 95% { - stroke-dasharray: 0.18 0.82; - } - 100% { - stroke-dasharray: 1; - } -} - -/* Segment fade animation - stays visible at end */ -@keyframes segFade { - 0% { - opacity: 0; - } - 10% { - opacity: 1; - } - 100% { - opacity: 1; - } -} - -/* Reduced motion support */ -@media (prefers-reduced-motion: reduce) { - .seg { - animation: none; - opacity: 0; - } - .trace { - animation: none; - fill: var(--logo-fill); - stroke:none; - } -} diff --git a/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.tsx b/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.tsx deleted file mode 100644 index c5e2ac8e95..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/AnimatedLogo.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { tcls } from '@/lib/tailwind'; -import type React from 'react'; -import styles from './AnimatedLogo.module.css'; - -interface AnimatedLogoProps { - shouldAnimate?: boolean; -} - -export const AnimatedLogo: React.FC = (props) => { - const { shouldAnimate = true } = props; - - return ( - - ); -}; - -const dPath = - 'M-5.07306 1.64898C-1.92626 3.46518 -0.352865 4.37328 1.37504 4.37477C3.10303 4.37628 4.67794 3.47098 7.82794 1.66027C7.82794 1.66027 27.9071 -9.88183 27.9071 -9.88183C28.8136 -10.4029 29.3724 -11.3687 29.3724 -12.4143C29.3724 -13.4598 28.8136 -14.4257 27.9071 -14.9467C27.9071 -14.9467 7.82063 -26.4931 7.82063 -26.4931C4.67414 -28.3018 3.10083 -29.2062 1.37453 -29.2055C-0.351665 -29.2048 -1.92427 -28.2992 -5.06947 -26.488C-5.06947 -26.488 -22.3372 -16.5441 -22.3372 -16.5441C-22.4651 -16.4704 -22.5291 -16.4336 -22.5888 -16.3986C-28.4872 -12.9457 -32.1315 -6.64173 -32.1802 0.192975C-32.1807 0.262075 -32.1807 0.335975 -32.1807 0.483575C-32.1807 0.631075 -32.1807 0.704875 -32.1802 0.773875C-32.1316 7.60087 -28.4955 13.899 -22.6075 17.3547C-22.548 17.3897 -22.4841 17.4266 -22.3564 17.5003C-22.3564 17.5003 -11.5399 23.7454 -11.5399 23.7454C-5.23716 27.3844 -2.08587 29.2039 1.37484 29.2051C4.83554 29.2062 7.98813 27.3889 14.2932 23.7541C14.2932 23.7541 25.7115 17.1718 25.7115 17.1718C28.8686 15.3518 30.4471 14.4418 31.3139 12.9416C32.1807 11.4414 32.1807 9.61938 32.1807 5.97517C32.1807 5.97517 32.1807 -1.06463 32.1807 -1.06463C32.1807 -2.07553 31.6332 -3.00723 30.75 -3.49913C29.8953 -3.97513 28.8536 -3.96802 28.0054 -3.48053C28.0054 -3.48053 4.59224 9.97808 4.59224 9.97808C3.02144 10.8811 2.23593 11.3326 1.37404 11.3329C0.512135 11.3331 -0.273565 10.8821 -1.84506 9.98007C-1.84506 9.98007 -17.6916 0.883775 -17.6916 0.883775C-18.4854 0.428075 -18.8823 0.200275 -19.2011 0.159175C-19.9279 0.065375 -20.6267 0.472475 -20.9036 1.15108C-21.025 1.44858 -21.0225 1.90628 -21.0176 2.82148C-21.014 3.49528 -21.0122 3.83218 -20.9492 4.14208C-20.8082 4.83607 -20.4431 5.46448 -19.91 5.93068C-19.672 6.13888 -19.3802 6.30727 -18.7966 6.64407C-18.7966 6.64407 -1.85397 16.4227 -1.85397 16.4227C-0.278465 17.332 0.509335 17.7867 1.37434 17.7869C2.23934 17.7872 3.02734 17.3329 4.60333 16.4245C4.60333 16.4245 25.3699 4.45377 25.3699 4.45377C25.9083 4.14348 26.1774 3.98828 26.3792 4.10488C26.5811 4.22148 26.5811 4.53218 26.5811 5.15357C26.5811 5.15357 26.5811 8.34667 26.5811 8.34667C26.5811 9.25768 26.5811 9.71317 26.3643 10.0883C26.1476 10.4634 25.753 10.6908 24.9637 11.1458C24.9637 11.1458 7.83524 21.0193 7.83524 21.0193C4.68194 22.837 3.10533 23.7458 1.37463 23.7451C-0.356065 23.7443 -1.93186 22.834 -5.08347 21.0134C-5.08347 21.0134 -21.1086 11.7563 -21.1086 11.7563C-21.1595 11.7269 -21.1849 11.7122 -21.2087 11.6984C-24.5687 9.73487 -26.642 6.14287 -26.6614 2.25128C-26.6616 2.22378 -26.6616 2.19438 -26.6616 2.13567C-26.6616 2.13567 -26.6616 -0.795425 -26.6616 -0.795425C-26.6616 -2.94372 -25.5174 -4.92953 -23.6587 -6.00682C-22.0163 -6.95883 -19.9905 -6.96072 -18.3463 -6.01183C-18.3463 -6.01183 -5.07306 1.64898 -5.07306 1.64898Z'; diff --git a/packages/gitbook/src/components/AdminToolbar/HideToolbarButton.tsx b/packages/gitbook/src/components/AdminToolbar/HideToolbarButton.tsx deleted file mode 100644 index 1405f829b4..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/HideToolbarButton.tsx +++ /dev/null @@ -1,233 +0,0 @@ -'use client'; -import { tcls } from '@/lib/tailwind'; -import { Icon, type IconName, IconStyle } from '@gitbook/icons'; -import { motion } from 'motion/react'; -import React, { useRef } from 'react'; -import { useOnClickOutside } from 'usehooks-ts'; -import { ToolbarButton, type ToolbarButtonProps } from './Toolbar'; -import styles from './Toolbar.module.css'; -import { useToolbarControls } from './ToolbarControlsContext'; - -const ARC_DURATION_SECONDS = 0.4; -const ARC_STAGGER_MS = 80; -const BASE_ROTATION_DEG = 95; -const ROTATION_STEP_DEG = 18; - -interface HideToolbarButtonProps { - motionValues?: ToolbarButtonProps['motionValues']; -} - -/** - * Hide menu trigger. Expands a macOS Dock-like submenu with 3 labeled actions. - */ -export function HideToolbarButton(props: HideToolbarButtonProps) { - const { motionValues } = props; - const [open, setOpen] = React.useState(false); - const controls = useToolbarControls(); - - const ref = useRef (null); - const buttonRef = useRef (null); - - const handleClickOutsideArcMenu = (event: Event) => { - // Don't close the arc if we are clicking on the button itself - if (buttonRef.current?.contains(event.target as Node)) { - return; - } - setOpen(false); - }; - // @ts-expect-error wrong type for ref - useOnClickOutside(ref, handleClickOutsideArcMenu); - - // Close arc menu on scroll - React.useEffect(() => { - if (!open) return; - - const handleScroll = () => setOpen(false); - window.addEventListener('scroll', handleScroll, { passive: true }); - - return () => window.removeEventListener('scroll', handleScroll); - }, [open]); - - const items = [ - controls?.minimize - ? { - id: 'minimize', - icon: 'minus', - label: 'Minimize', - onClick: controls.minimize, - } - : null, - controls?.closeSession - ? { - id: 'session-close', - icon: 'xmark', - label: 'Close for one session', - onClick: controls.closeSession, - } - : null, - controls?.closePersistent - ? { - id: 'persistent-close', - icon: 'ban', - label: "Don't show again", - onClick: controls.closePersistent, - } - : null, - ].filter(Boolean) as Array ; - - const sharedMotionStyle = motionValues - ? { - x: motionValues.x, - } - : undefined; - - return ( - { - setOpen((v) => !v); - }} - motionValues={motionValues} - icon="eye-slash" - > - {/* Expanding arc menu */} - {open && ( - - ); -} - -type ArcMenuItem = { - id: string; - icon: IconName; - label: string; - description: string; - onClick?: () => void; -}; - -type ArcToolbarButtonProps = Pick- - )} -- {items.map((item, index) => ( --{ - setOpen(false); - item.onClick?.(); - }} - /> - ))} - & { - index: number; - staggerIndex?: number; - disabled?: boolean; - className?: string; - iconClassName?: string; -}; - -export function ArcToolbarButton(props: ArcToolbarButtonProps) { - const { - index, - staggerIndex = index, - label, - disabled, - className, - onClick = () => {}, - icon, - iconClassName, - } = props; - - const targetOffset = `calc(var(--start-distance) + ${index} * var(--spread-distance))`; - - // Calculate rotation based on position along the arc - const calculateRotation = () => { - return BASE_ROTATION_DEG - index * ROTATION_STEP_DEG; - }; - - const itemRotation = calculateRotation(); - - return ( - -- ); -} diff --git a/packages/gitbook/src/components/AdminToolbar/IframeWrapper.tsx b/packages/gitbook/src/components/AdminToolbar/IframeWrapper.tsx deleted file mode 100644 index 270d41c85f..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/IframeWrapper.tsx +++ /dev/null @@ -1,27 +0,0 @@ -'use client'; - -import React from 'react'; - -interface IframeWrapperProps { - children: React.ReactNode; -} - -/** - * Client component that detects if we're in an iframe and conditionally renders children - */ -export function IframeWrapper({ children }: IframeWrapperProps) { - const [isInIframe, setIsInIframe] = React.useState(false); - - React.useEffect(() => { - // Check if we're running inside an iframe - const inIframe = window !== window.parent; - setIsInIframe(inIframe); - }, []); - - // Don't render children if we're in an iframe (GitBook app preview) - if (isInIframe) { - return null; - } - - return children; -} diff --git a/packages/gitbook/src/components/AdminToolbar/RefreshContentButton.tsx b/packages/gitbook/src/components/AdminToolbar/RefreshContentButton.tsx deleted file mode 100644 index 310d2a0c88..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/RefreshContentButton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -'use client'; -import React from 'react'; - -import { ToolbarButton, type ToolbarButtonProps } from './Toolbar'; - -/** - * Button to refresh the page if the content has been updated. - */ -export function RefreshContentButton(props: { - refreshForUpdates: () => Promise{ - onClick(); - }} - style={ - { - '--target-offset-distance': targetOffset, - '--arc-duration': `${ARC_DURATION_SECONDS}s`, - '--arc-delay': `${(staggerIndex ?? 0) * ARC_STAGGER_MS}ms`, - '--rotation-offset': `${itemRotation}deg`, - offsetPath: 'border-box', - offsetDistance: targetOffset, - offsetAnchor: '0% 40%', - offsetRotate: `auto ${itemRotation}deg`, - } as React.CSSProperties - } - className={tcls( - 'group', - 'absolute', - 'top-0', - 'left-0', - 'w-40', - 'opacity-0', - 'pointer-events-auto', - 'flex', - 'items-center', - 'gap-2', - styles.arcMenuItem, - className - )} - > - --- - {label} - -- ; - motionValues?: ToolbarButtonProps['motionValues']; -}) { - const { refreshForUpdates, motionValues } = props; - - const [loading, setLoading] = React.useState(false); - - const refresh = React.useCallback(async () => { - setLoading(true); - try { - await refreshForUpdates(); - } finally { - setLoading(false); - } - }, [refreshForUpdates]); - - return ( - { - if (loading) { - return; - } - event.preventDefault(); - refresh(); - }} - disabled={loading} - motionValues={motionValues} - icon="rotate" - iconClassName={loading ? 'animate-spin' : undefined} - /> - ); -} diff --git a/packages/gitbook/src/components/AdminToolbar/Toolbar.module.css b/packages/gitbook/src/components/AdminToolbar/Toolbar.module.css deleted file mode 100644 index 72b1ddd325..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/Toolbar.module.css +++ /dev/null @@ -1,40 +0,0 @@ -.arcMenu { - --arc-width: 505px; - --arc-height: 400px; - --arc-radius: 34%; - --start-distance: -240px; - --spread-distance: 45px; -} - -.arcMenuPath { - bottom: calc(var(--arc-height) / -2); - width: var(--arc-width); - height: var(--arc-height); - border-radius: var(--arc-radius); - transform: translate(0%, 0%); -} - -.arcMenuItem { - animation-name: hide-toolbar-arc-enter; - animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); - animation-fill-mode: forwards; - animation-duration: var(--arc-duration, 0.4s); - animation-delay: var(--arc-delay, 0s); - transform-origin: center left; - offset-path: border-box; - offset-anchor: 0% 0%; - offset-rotate: auto var(--rotation-offset, 0deg); -} - -@keyframes hide-toolbar-arc-enter { - from { - offset-distance: var(--start-distance); - transform: scale(0.5); - opacity: 0; - } - to { - offset-distance: var(--target-offset-distance); - transform: scale(1); - opacity: 1; - } -} diff --git a/packages/gitbook/src/components/AdminToolbar/Toolbar.tsx b/packages/gitbook/src/components/AdminToolbar/Toolbar.tsx deleted file mode 100644 index 3d56292e6c..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/Toolbar.tsx +++ /dev/null @@ -1,347 +0,0 @@ -'use client'; -import { - AnimatePresence, - type MotionValue, - motion, - useReducedMotion, - useSpring, -} from 'motion/react'; -import React, { isValidElement } from 'react'; -import { AnimatedLogo } from './AnimatedLogo'; -import { useToolbarControls } from './ToolbarControlsContext'; - -import { tcls } from '@/lib/tailwind'; -import { Icon, type IconName, IconStyle } from '@gitbook/icons'; -import { Tooltip } from '../primitives'; -import { getCopyVariants, toolbarEasings } from './transitions'; -import { useMagnificationEffect } from './useMagnificationEffect'; - -const DURATION_LOGO_APPEARANCE = 2000; -const DELAY_BETWEEN_LOGO_AND_CONTENT = 100; - -interface ToolbarProps { - label: React.ReactNode; - children: React.ReactNode; - minified: boolean; - onMinifiedChange: (value: boolean) => void; -} - -export function Toolbar(props: ToolbarProps) { - const { children, label, minified, onMinifiedChange } = props; - const controls = useToolbarControls(); - const [isReady, setIsReady] = React.useState(false); - const autoExpandTriggeredRef = React.useRef(false); - - const shouldAutoExpand = Boolean(controls?.shouldAutoExpand); - const [shouldAnimateLogo, setShouldAnimateLogo] = React.useState(shouldAutoExpand); - - // Wait for page to be ready, then show the toolbar - React.useEffect(() => { - const handleLoad = () => { - setIsReady(true); - }; - - if (document.readyState === 'complete') { - handleLoad(); - } else { - window.addEventListener('load', handleLoad); - return () => window.removeEventListener('load', handleLoad); - } - }, []); - - // After toolbar appears, wait, then show the full content - React.useEffect(() => { - if (!isReady || autoExpandTriggeredRef.current) { - return; - } - - if (!shouldAutoExpand) { - // When we already know the toolbar should stay expanded (e.g. the user previously - // opened it this session) we short-circuit the auto-expand animation and immediately - // render the expanded state without replaying the logo animation. - autoExpandTriggeredRef.current = true; - setShouldAnimateLogo(false); - return; - } - - autoExpandTriggeredRef.current = true; - - // On a fresh session we let the toolbar appear in its compact form, play the logo - // animation, and only then expand the toolbar. The timeout mirrors the duration of the - // logo animation so both transitions feel connected. - const expandAfterTimeout = setTimeout(() => { - setShouldAnimateLogo(false); - onMinifiedChange(false); - }, DURATION_LOGO_APPEARANCE + DELAY_BETWEEN_LOGO_AND_CONTENT); - - return () => clearTimeout(expandAfterTimeout); - }, [isReady, onMinifiedChange, shouldAutoExpand]); - - React.useEffect(() => { - if (!minified) { - // Any manual expansion should stop the logo animation so the icon stays in its - // “settled” state once the toolbar is open. - setShouldAnimateLogo(false); - } - }, [minified]); - - // Don't render anything until page is ready - if (!isReady) { - return null; - } - - return ( - - - ); -} - -export function ToolbarBody(props: { children: React.ReactNode }) { - return- -- -{ - if (minified) { - setShouldAnimateLogo(false); - onMinifiedChange(false); - } - }} - layout - transition={toolbarEasings.spring} - className={tcls( - minified ? 'cursor-pointer px-2' : 'pr-2 pl-3.5', - 'flex', - 'items-center', - 'justify-center', - 'min-h-11', - 'min-w-12', - 'h-12', - 'py-2', - 'backdrop-blur-sm', - 'origin-center', - 'border-[0.5px] border-neutral-5 border-solid dark:border-neutral-8', - 'bg-[linear-gradient(45deg,rgba(39,39,39,0.8)_100%,rgba(39,39,39,0.4)_80%)]', - 'dark:bg-[linear-gradient(45deg,rgba(39,39,39,0.5)_100%,rgba(39,39,39,0.3)_80%)]' - )} - style={{ - borderRadius: '100px', // This is set on `style` so Framer Motion can correct for distortions - }} - > - {/* Logo with stroke segments animation in blue-tints */} - -- - - {!minified ? children : null} -- {props.children}; -} - -export function ToolbarButtonGroup(props: { children: React.ReactNode }) { - const { children } = props; - const containerRef = React.useRef(null); - - const buttonChildren = React.Children.toArray(children).filter((child) => !!child); - const { buttonMotionValues } = useMagnificationEffect({ - childrenCount: buttonChildren.length, - containerRef, - }); - - return ( - - {buttonChildren.map((child, index) => { - const childEl = child as React.ReactElement; - const childKey = childEl.key ?? `toolbar-button-${index}`; - return ( - - ); -} - -export interface ToolbarButtonProps extends Omit- ); - })} - , 'title'> { - motionValues?: { - scale: MotionValue ; - x: MotionValue ; - }; - icon: IconName; - iconClassName?: string; - title?: React.ReactNode; - children?: React.ReactNode; -} - -export const ToolbarButton = React.forwardRef ((props, ref) => { - const { - title, - disabled, - motionValues, - className, - style, - href, - onClick, - icon, - iconClassName, - children, - } = props; - const reduceMotion = useReducedMotion(); - - return ( - - {children ? children : null} - - ); -}); - -ToolbarButton.displayName = 'ToolbarButton'; - -function ToolbarButtonWrapper(props: { - child: React.ReactElement; - rawMotionValues?: { scale: MotionValue- -- -- ; x: MotionValue }; -}) { - const { child, rawMotionValues } = props; - - // Convert the raw motion values to smooth spring easings - const springScale = useSpring(rawMotionValues?.scale.get() ?? 1, { - stiffness: 400, - damping: 30, - }); - const springX = useSpring(rawMotionValues?.x.get() ?? 0, { stiffness: 400, damping: 30 }); - - // Sync springs with raw motion values - React.useEffect(() => { - if (!rawMotionValues) return; - - const unsubScale = rawMotionValues.scale.on('change', (v) => springScale.set(v)); - const unsubX = rawMotionValues.x.on('change', (v) => springX.set(v)); - - return () => { - unsubScale(); - unsubX(); - }; - }, [rawMotionValues, springScale, springX]); - - const motionValues = { - scale: springScale, - x: springX, - }; - - if (!isValidElement<{ motionValues: typeof motionValues }>(child)) { - return null; - } - - return React.cloneElement(child, { - motionValues, - }); -} - -export function ToolbarSeparator() { - return ; -} - -export function ToolbarTitle(props: { prefix?: string; suffix: string }) { - return ( - - {props.prefix ?- ); -} - -function ToolbarTitlePrefix(props: { title: string }) { - return ( -: null} - - - {props.title} - - ); -} - -function ToolbarTitleSuffix(props: { title: string }) { - return ( -- {props.title} - - ); -} - -export function ToolbarSubtitle(props: { subtitle: React.ReactNode }) { - return ( -- {props.subtitle} - - ); -} diff --git a/packages/gitbook/src/components/AdminToolbar/ToolbarControlsContext.tsx b/packages/gitbook/src/components/AdminToolbar/ToolbarControlsContext.tsx deleted file mode 100644 index 185c04d41b..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/ToolbarControlsContext.tsx +++ /dev/null @@ -1,27 +0,0 @@ -'use client'; -import React from 'react'; - -export interface ToolbarControlsContextValue { - minimize: () => void; - closeSession?: () => void; - closePersistent?: () => void; - shouldAutoExpand?: boolean; -} - -const ToolbarControlsContext = React.createContext(null); - -/* - * Provides reusable state setters (mainly for hiding/showing the toolbar) for the toolbar controls propagated through to the children - */ -export function ToolbarControlsProvider( - props: React.PropsWithChildren<{ value: ToolbarControlsContextValue | null }> -) { - const { children, value } = props; - return ( - {children} - ); -} - -export function useToolbarControls() { - return React.useContext(ToolbarControlsContext); -} diff --git a/packages/gitbook/src/components/AdminToolbar/index.ts b/packages/gitbook/src/components/AdminToolbar/index.ts deleted file mode 100644 index 490e4b6aea..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './AdminToolbar'; -export * from './AdminToolbarClient'; -export * from './IframeWrapper'; -export * from './Toolbar'; -export * from './transitions'; -export * from './utils'; diff --git a/packages/gitbook/src/components/AdminToolbar/transitions.ts b/packages/gitbook/src/components/AdminToolbar/transitions.ts deleted file mode 100644 index bfd0bcb34d..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/transitions.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { Transition } from 'motion/react'; - -// Slight bounce but minimal overshoot esp. at the minimized state. -const spring = { - type: 'spring' as const, - stiffness: 130, - damping: 19, - mass: 1, -}; - -const parent = { - hidden: { opacity: 0 }, - show: { - opacity: 1, - transition: { - delayChildren: 0.4, - staggerChildren: 0.1, - }, - }, -}; - -const staggeringChild = { - hidden: { - opacity: 0, - scale: 0.7, - }, - show: { - opacity: 1, - scale: 1, - transition: { - duration: 0.3, - type: 'spring', - } as Transition, - }, -}; - -export const minifyButtonAnimation = { - initial: { - scale: 0.5, - opacity: 0, - }, - animate: { - scale: 1, - opacity: 1, - }, - exit: { - scale: 0.5, - opacity: 0, - }, -}; - -export const getCopyVariants = (position: number) => { - return { - initial: { - opacity: 0, - x: -10, - }, - animate: { - opacity: 1, - x: 0, - }, - transition: { - duration: 0.1, - delay: position / 10 + 0.3, - } as Transition, - }; -}; - -export const toolbarEasings = { - spring, - parent, - staggeringChild, -}; diff --git a/packages/gitbook/src/components/AdminToolbar/types.ts b/packages/gitbook/src/components/AdminToolbar/types.ts deleted file mode 100644 index f3ec3fed61..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/types.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Minimal types containing only the fields needed for AdminToolbar to restrict what gets serialized - */ - -export type MinimalChangeRequest = { - id: string; - number: number; - subject: string | null; - revision: string; - updatedAt: string; - createdBy: { - displayName: string; - }; - urls: { - app: string; - }; -}; - -export type MinimalRevision = { - createdAt: string; - urls: { - app: string; - }; - git?: { - url: string | undefined; - } | null; -}; - -export type MinimalSpace = { - id: string; - revision: string; - urls: { - app: string; - }; -}; - -export type MinimalSite = { - id: string; - title: string; - urls: { - app: string; - published: string | undefined; - }; -}; - -export type AdminToolbarContext = { - organizationId: string; - revisionId: string; - space: MinimalSpace; - changeRequest: MinimalChangeRequest | null; - revision: MinimalRevision; - site: MinimalSite; -}; - -export interface AdminToolbarClientProps { - context: AdminToolbarContext; - onSessionClose?: () => void; - onPersistentClose?: () => void; - onToggleMinify?: () => void; -} diff --git a/packages/gitbook/src/components/AdminToolbar/useMagnificationEffect.ts b/packages/gitbook/src/components/AdminToolbar/useMagnificationEffect.ts deleted file mode 100644 index 5acb3c14eb..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/useMagnificationEffect.ts +++ /dev/null @@ -1,237 +0,0 @@ -import { type MotionValue, motionValue } from 'motion/react'; -import React from 'react'; - -interface MagnificationConfig { - /** Size of each button in pixels - used for spacing calculations */ - buttonSize?: number; - /** Maximum scale factor for buttons when mouse is directly over them */ - maxScale?: number; - /** Distance in pixels from mouse where buttons start scaling */ - influenceRadius?: number; - /** Multiplier for spacing between buttons - higher values create more space */ - spacingMultiplier?: number; - /** Controls scaling curve - higher values make scaling more dramatic near mouse */ - scaleExponent?: number; - /** Padding around container for mouse detection in pixels */ - padding?: number; -} - -const defaultConfig: Required= { - buttonSize: 32, // Standard button size for 32px (size-8) buttons - maxScale: 1.25, // 25% scale increase - noticeable but not overwhelming - influenceRadius: 80, // ~2.5 button widths of influence - spacingMultiplier: 1.3, // Creates proportional spacing to scale increase - scaleExponent: 2.5, // Exponential curve for dramatic close-range scaling - padding: 10, // Small buffer zone around container edges -}; - -const resetMotionValues = ( - motionValues: Array<{ scale: MotionValue ; x: MotionValue }> -) => { - motionValues.forEach(({ scale, x }) => { - scale.set(1); - x.set(0); - }); -}; - -const captureButtonPositions = (buttons: HTMLElement[]) => { - // Reset transforms to get original positions - buttons.forEach((button) => { - button.style.transform = ''; - }); - return buttons.map((button) => { - const rect = button.getBoundingClientRect(); - return { - left: rect.left, - width: rect.width, - top: rect.top, - height: rect.height, - }; - }); -}; - -const calculateScale = ( - mouseX: number, - buttonCenterX: number, - containerRect: DOMRect, - config: Required -) => { - // Calculate only X-axis distance from mouse to button center - const distance = Math.abs(mouseX - buttonCenterX); - - if (distance > config.influenceRadius) return 1; - - // Calculate distance from container edge (X-axis only) - const distanceFromEdgeX = Math.min(mouseX - containerRect.left, containerRect.right - mouseX); - const distanceFromEdge = distanceFromEdgeX; - - // Define the "heart" zone - 8px from center (16x16px total area) - const heartZoneRadius = 8; - - let baseScale: number; - - if (distance <= heartZoneRadius) { - // Within the heart zone - always at max scale - baseScale = config.maxScale; - } else { - // Outside heart zone - scale from max to 1 based on distance - const outerRadius = config.influenceRadius - heartZoneRadius; - const outerDistance = distance - heartZoneRadius; - const progress = Math.min(outerDistance / outerRadius, 1); - const exponentialProgress = (1 - progress) ** config.scaleExponent; - baseScale = 1 + (config.maxScale - 1) * exponentialProgress; - } - - // Only apply entry transition if we're very close to the edge (within 10px) - // This prevents the entry logic from interfering with normal scaling - if (distanceFromEdge < 10) { - const entryProgress = distanceFromEdge / 10; - return 1 + (baseScale - 1) * entryProgress; - } - - return baseScale; -}; - -const calculateSpacing = ( - buttonIndex: number, - buttonEffects: Array<{ scale: number; translateX: number }>, - positions: Array<{ left: number; width: number; top: number; height: number }>, - config: Required -) => { - const currentPos = positions[buttonIndex]; - if (!currentPos) return 0; - - const buttonCenterX = currentPos.left + currentPos.width / 2; - let leftPush = 0; - let rightPush = 0; - - buttonEffects.forEach((otherEffect, otherIndex) => { - if (otherIndex === buttonIndex) return; - - const otherPos = positions[otherIndex]; - if (!otherPos) return; - - const otherCenterX = otherPos.left + otherPos.width / 2; - const distanceBetween = Math.abs(buttonCenterX - otherCenterX); - - // Only apply influence if close enough - if (distanceBetween < config.influenceRadius * 1.5) { - const influenceStrength = Math.max( - 0, - 1 - distanceBetween / (config.influenceRadius * 1.5) - ); - const extraSpace = (otherEffect.scale - 1) * config.buttonSize; - const pushAmount = (extraSpace / 2) * config.spacingMultiplier * influenceStrength; - - if (otherCenterX < buttonCenterX) { - rightPush += pushAmount; - } else { - leftPush += pushAmount; - } - } - }); - - return rightPush - leftPush; -}; - -export function useMagnificationEffect(props: { - childrenCount: number; - containerRef: React.RefObject ; - config?: MagnificationConfig; -}) { - const { childrenCount, containerRef, config } = props; - const originalPositionsRef = React.useRef< - Array<{ left: number; width: number; top: number; height: number }> - >([]); - - const finalConfig = React.useMemo(() => ({ ...defaultConfig, ...config }), [config]); - - // Create basic motion values that will be consumed by springs in the components - const buttonMotionValues = React.useMemo(() => { - return Array.from({ length: childrenCount }, () => ({ - scale: motionValue(1), - x: motionValue(0), - })); - }, [childrenCount]); - - React.useEffect(() => { - const container = containerRef.current; - if (!container) return; - - const buttons = Array.from(container.querySelectorAll('.toolbar-button')) as HTMLElement[]; - - if (buttons.length !== childrenCount) { - console.error( - `Button count (${buttons.length}) does not match children count (${childrenCount})` - ); - return; - } - - const handleMouseMove = (event: MouseEvent) => { - const buttons = Array.from( - container.querySelectorAll('.toolbar-button') - ) as HTMLElement[]; - - // Capture positions if needed - if (originalPositionsRef.current.length !== buttons.length) { - originalPositionsRef.current = captureButtonPositions(buttons); - } - - const containerRect = container.getBoundingClientRect(); - const { clientX: mouseX, clientY: mouseY } = event; - - // Check if mouse is in range - const isInRange = - mouseX >= containerRect.left - finalConfig.padding && - mouseX <= containerRect.right + finalConfig.padding && - mouseY >= containerRect.top - finalConfig.padding && - mouseY <= containerRect.bottom + finalConfig.padding; - - if (!isInRange) { - resetMotionValues(buttonMotionValues); - return; - } - - // Calculate scales for all buttons - const buttonEffects = buttons.map((_, index) => { - const pos = originalPositionsRef.current[index]; - if (!pos) return { scale: 1, translateX: 0 }; - - const buttonCenterX = pos.left + pos.width / 2; - const scale = calculateScale(mouseX, buttonCenterX, containerRect, finalConfig); - return { scale, translateX: 0 }; - }); - - // Calculate spacing for all buttons - buttonEffects.forEach((effect, index) => { - effect.translateX = calculateSpacing( - index, - buttonEffects, - originalPositionsRef.current, - finalConfig - ); - }); - - // Update motion values - buttonEffects.forEach((effect, index) => { - const motionValue = buttonMotionValues[index]; - if (motionValue) { - motionValue.scale.set(effect.scale); - motionValue.x.set(effect.translateX); - } - }); - }; - - const handleMouseLeave = () => resetMotionValues(buttonMotionValues); - - container.addEventListener('mousemove', handleMouseMove); - container.addEventListener('mouseleave', handleMouseLeave); - - return () => { - container.removeEventListener('mousemove', handleMouseMove); - container.removeEventListener('mouseleave', handleMouseLeave); - }; - }, [finalConfig, containerRef, buttonMotionValues, childrenCount]); - - return { buttonMotionValues }; -} diff --git a/packages/gitbook/src/components/AdminToolbar/utils.ts b/packages/gitbook/src/components/AdminToolbar/utils.ts deleted file mode 100644 index 9778d5b452..0000000000 --- a/packages/gitbook/src/components/AdminToolbar/utils.ts +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react'; - -import { - getLocalStorageItem, - getSessionStorageItem, - removeSessionStorageItem, - setLocalStorageItem, - setSessionStorageItem, -} from '@/lib/browser/local-storage'; - -const STORAGE_KEY = 'gitbook_toolbar_closed'; -const SESSION_STORAGE_KEY = 'gitbook_toolbar_session_closed'; -const SESSION_MINIFIED_KEY = 'gitbook_toolbar_minified'; - -type SessionHideReason = 'session' | 'persistent'; - -/** - * Read the current session hide state. We store whether the toolbar was hidden “for session” or - * “persistently” so we can distinguish between a temporary dismissal and a user preference. - */ -export const getSessionHideState = (): { hidden: boolean; reason?: SessionHideReason } => { - const value = getSessionStorageItem (SESSION_STORAGE_KEY, null); - if (value === 'session' || value === 'persistent') { - return { hidden: true, reason: value }; - } - return { hidden: false, reason: undefined }; -}; - -/** - * Persist the session hide state. Passing `false` clears the stored preference entirely. - */ -export const setSessionHidden = (value: boolean, reason?: SessionHideReason) => { - if (value && reason) { - setSessionStorageItem(SESSION_STORAGE_KEY, reason); - } else { - removeSessionStorageItem(SESSION_STORAGE_KEY); - } -}; - -/** - * Retrieve the last minified state from session storage. If no value was ever stored we return - * `undefined`, which signals that the toolbar should auto-expand once the logo animation finishes. - */ -export const getStoredMinified = (): boolean | undefined => { - const stored = getSessionStorageItem (SESSION_MINIFIED_KEY, null); - if (stored === null || stored === undefined) { - removeSessionStorageItem(SESSION_MINIFIED_KEY); - return undefined; - } - return stored; -}; - -/** - * Persist the current minified state for the ongoing session. - */ -export const setStoredMinified = (value: boolean) => { - setSessionStorageItem(SESSION_MINIFIED_KEY, value); -}; - -interface UseToolbarVisibilityOptions { - onPersistentClose?: () => void; - onSessionClose?: () => void; - onToggleMinify?: () => void; -} - -export function useToolbarVisibility(options: UseToolbarVisibilityOptions = {}) { - const { onPersistentClose, onSessionClose, onToggleMinify } = options; - - const [initialStoredMinified] = React.useState (() => - typeof window !== 'undefined' ? getStoredMinified() : undefined - ); - const shouldAutoExpand = initialStoredMinified === undefined; - - const [minified, setMinifiedState] = React.useState (() => - initialStoredMinified !== undefined ? initialStoredMinified : true - ); - - const [persistentHidden, setPersistentHidden] = React.useState(() => - getLocalStorageItem(STORAGE_KEY, false) - ); - - const [sessionReason, setSessionReason] = React.useState (() => { - const state = getSessionHideState(); - return state.hidden ? state.reason : undefined; - }); - - React.useEffect(() => { - if (typeof window === 'undefined') { - return; - } - - const handleStorage = () => { - setPersistentHidden(getLocalStorageItem(STORAGE_KEY, false)); - const state = getSessionHideState(); - setSessionReason(state.hidden ? state.reason : undefined); - }; - - window.addEventListener('storage', handleStorage); - return () => window.removeEventListener('storage', handleStorage); - }, []); - - React.useEffect(() => { - if (persistentHidden) { - if (sessionReason !== 'persistent') { - // Sync the session flag so we honour the persistent preference and avoid flashes when - // opening new tabs in the same browsing session. - setSessionHidden(true, 'persistent'); - setSessionReason('persistent'); - } - return; - } - - if (sessionReason === 'persistent') { - // If the persistent preference was cleared we also clear the session flag so the toolbar - // can reappear immediately without requiring a full reload. - setSessionHidden(false); - setSessionReason(undefined); - } - }, [persistentHidden, sessionReason]); - - const setMinified = (value: boolean) => { - setMinifiedState(value); - setStoredMinified(value); - onToggleMinify?.(); - }; - - const minimize = () => setMinified(true); - - const closeSession = () => { - setSessionHidden(true, 'session'); - setSessionReason('session'); - onSessionClose?.(); - }; - - const closePersistent = () => { - setLocalStorageItem(STORAGE_KEY, true); - setPersistentHidden(true); - setSessionHidden(true, 'persistent'); - setSessionReason('persistent'); - onPersistentClose?.(); - }; - - const hidden = persistentHidden || sessionReason === 'session'; - - return { - minified, - setMinified, - shouldAutoExpand, - hidden, - minimize, - closeSession, - closePersistent, - }; -} diff --git a/packages/gitbook/src/components/Ads/Ad.tsx b/packages/gitbook/src/components/Ads/Ad.tsx deleted file mode 100644 index 81fb4f64e4..0000000000 --- a/packages/gitbook/src/components/Ads/Ad.tsx +++ /dev/null @@ -1,149 +0,0 @@ -'use client'; - -import { - type SiteAds, - SiteAdsStatus, - type SiteInsightsAd, - type SiteInsightsAdPlacement, - SiteInsightsTrademarkPlacement, -} from '@gitbook/api'; -import * as React from 'react'; - -import { t, useLanguage } from '@/intl/client'; -import { type ClassValue, tcls } from '@/lib/tailwind'; - -import { useTrackEvent } from '../Insights'; -import { useHasBeenInViewport } from '../hooks/useHasBeenInViewport'; -import { Link } from '../primitives'; -import { renderAd } from './renderAd'; - -/** - * Zone ID provided by BuySellAds for the preview. - */ -const PREVIEW_ZONE_ID = 'CVAIKKQM'; - -/** - * Fetch and render the Ad placement. - * https://docs.buysellads.com/ad-serving-api - */ -export function Ad({ - zoneId, - spaceId, - placement, - ignore, - siteAdsStatus, - style, - mode = 'auto', -}: { - zoneId: string | null; - spaceId: string; - placement: SiteInsightsAdPlacement; - ignore: boolean; - style?: ClassValue; - siteAdsStatus?: SiteAds['status']; - mode?: 'classic' | 'auto' | 'cover'; -}) { - const containerRef = React.useRef (null); - const [ad, setAd] = React.useState< - { children: React.ReactNode; insightsAd: SiteInsightsAd | null } | undefined - >(undefined); - const trackEvent = useTrackEvent(); - - // Track display of the ad - React.useEffect(() => { - if (ad?.insightsAd) { - trackEvent({ - type: 'ad_display', - ad: ad.insightsAd, - }); - } - }, [ad, trackEvent]); - - const hasBeenInViewport = useHasBeenInViewport(containerRef, { threshold: 0.1 }); - - // When the container is visible, - // track an impression on the ad and fetch it - React.useEffect(() => { - if (!hasBeenInViewport) { - return; - } - - let cancelled = false; - - const previewParam = new URL(window.location.href).searchParams.get('ads_preview'); - const preview = !!previewParam; - const realZoneId = preview ? PREVIEW_ZONE_ID : zoneId; - const showPlaceholderAd = - previewParam === 'placeholder' || - (siteAdsStatus && - (siteAdsStatus === SiteAdsStatus.Pending || - siteAdsStatus === SiteAdsStatus.InReview)); - - if (!realZoneId && !showPlaceholderAd) { - return; - } - - (async () => { - const result = showPlaceholderAd - ? await renderAd({ source: 'placeholder' }) - : realZoneId - ? await renderAd({ - placement, - ignore: ignore || preview, - zoneId: realZoneId, - mode, - source: 'live', - }) - : undefined; - - if (cancelled) { - return; - } - - if (result) { - setAd(result); - } - })(); - - return () => { - cancelled = true; - }; - }, [hasBeenInViewport, zoneId, ignore, placement, mode, siteAdsStatus]); - - return ( - - {ad ? ( - <> - {ad.children} -- ); -} - -function AdSponsoredLink(props: { spaceId: string }) { - const { spaceId } = props; - const language = useLanguage(); - - const viaUrl = new URL('https://www.gitbook.com'); - viaUrl.searchParams.set('utm_source', 'content'); - viaUrl.searchParams.set('utm_medium', 'sponsored-by-gitbook'); - viaUrl.searchParams.set('utm_campaign', spaceId); - - return ( -- > - ) : null} - - - {t(language, 'sponsored_via_gitbook')} - -
- ); -} diff --git a/packages/gitbook/src/components/Ads/AdClassicRendering.tsx b/packages/gitbook/src/components/Ads/AdClassicRendering.tsx deleted file mode 100644 index 5e594cae81..0000000000 --- a/packages/gitbook/src/components/Ads/AdClassicRendering.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import type { GitBookBaseContext } from '@/lib/context'; -import { getResizedImageURL } from '@/lib/images'; -import type { SiteInsightsAd } from '@gitbook/api'; - -import { tcls } from '@/lib/tailwind'; - -import { Link } from '../primitives'; -import type { AdItem } from './types'; - -/** - * Classic rendering for an ad. - */ -export async function AdClassicRendering({ - ad, - insightsAd, - context, -}: { - ad: AdItem; - insightsAd: SiteInsightsAd | null; - context: GitBookBaseContext; -}) { - const [smallImgSrc, logoSrc] = await Promise.all([ - 'smallImage' in ad - ? getResizedImageURL(context.imageResizer, ad.smallImage, { width: 192, dpr: 2 }) - : null, - 'logo' in ad - ? getResizedImageURL(context.imageResizer, ad.logo, { width: 192 - 48, dpr: 2 }) - : null, - ]); - return ( - - {smallImgSrc && 'smallImage' in ad ? ( --- ) : logoSrc && 'logo' in ad ? ( --
-- ) : null} --
-- - ); -} diff --git a/packages/gitbook/src/components/Ads/AdCoverRendering.tsx b/packages/gitbook/src/components/Ads/AdCoverRendering.tsx deleted file mode 100644 index 558c74d9c5..0000000000 --- a/packages/gitbook/src/components/Ads/AdCoverRendering.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import type { GitBookBaseContext } from '@/lib/context'; -import { getResizedImageURL } from '@/lib/images'; -import type { SiteInsightsAd } from '@gitbook/api'; -import { hexToRgba } from '@gitbook/colors'; - -import { tcls } from '@/lib/tailwind'; - -import { Link } from '../primitives'; -import type { AdCover } from './types'; - -/** - * Cover rendering for an ad. - */ -export async function AdCoverRendering({ - ad, - insightsAd, - context, -}: { - ad: AdCover; - insightsAd: SiteInsightsAd | null; - context: GitBookBaseContext; -}) { - const largeImage = await getResizedImageURL(context.imageResizer, ad.largeImage, { - width: 128, - dpr: 2, - }); - - return ( - - - -{ad.description}----
---
--{ad.companyTagline}-- {ad.description} --- - {ad.callToAction} - -- - - ); -} diff --git a/packages/gitbook/src/components/Ads/AdPixels.tsx b/packages/gitbook/src/components/Ads/AdPixels.tsx deleted file mode 100644 index b1297b1bff..0000000000 --- a/packages/gitbook/src/components/Ads/AdPixels.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { tcls } from '@/lib/tailwind'; - -/** - * Render attribution or verification pixels. - * https://docs.buysellads.com/ad-serving-api#pixels - */ -export function AdPixels({ rawPixel }: { rawPixel: string }) { - const pixels = rawPixel.split('||'); - const time = String(Math.round(Date.now() / 1e4) | 0); - - return ( -- {pixels.map((pixel, index) => { - return ( -- ); -} diff --git a/packages/gitbook/src/components/Ads/assets/ad-gitbook-sponsored.svg b/packages/gitbook/src/components/Ads/assets/ad-gitbook-sponsored.svg deleted file mode 100644 index ebe5c2d920..0000000000 --- a/packages/gitbook/src/components/Ads/assets/ad-gitbook-sponsored.svg +++ /dev/null @@ -1,86 +0,0 @@ - diff --git a/packages/gitbook/src/components/Ads/index.ts b/packages/gitbook/src/components/Ads/index.ts deleted file mode 100644 index b9dc3e63ac..0000000000 --- a/packages/gitbook/src/components/Ads/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Ad'; diff --git a/packages/gitbook/src/components/Ads/renderAd.tsx b/packages/gitbook/src/components/Ads/renderAd.tsx deleted file mode 100644 index 5a964fcc18..0000000000 --- a/packages/gitbook/src/components/Ads/renderAd.tsx +++ /dev/null @@ -1,153 +0,0 @@ -'use server'; - -import type { SiteInsightsAd, SiteInsightsAdPlacement } from '@gitbook/api'; -import { headers } from 'next/headers'; - -import { getServerActionBaseContext } from '@/lib/server-actions'; -import { traceErrorOnly } from '@/lib/tracing'; -import { AdClassicRendering } from './AdClassicRendering'; -import { AdCoverRendering } from './AdCoverRendering'; -import { AdPixels } from './AdPixels'; -import adGitbookSponsored from './assets/ad-gitbook-sponsored.svg'; -import type { AdItem, AdsResponse } from './types'; - -type FetchAdOptions = FetchLiveAdOptions | FetchPlaceholderAdOptions; - -interface FetchLiveAdOptions { - /** - * Source of the ad (live: from the platform) - */ - source: 'live'; - /** ID of the zone to fetch Ads for */ - zoneId: string; - /** Mode to render the Ad */ - mode: 'classic' | 'auto' | 'cover'; - /** Name of the placement for the ad */ - placement: SiteInsightsAdPlacement; - /** If true, we'll not track it as an impression */ - ignore: boolean; -} - -interface FetchPlaceholderAdOptions { - /** - * Source of the ad (placeholder: static placeholder ad) - */ - source: 'placeholder'; -} - -/** - * Server action to render the Ad placement. - * We use a server-action to avoid caching issues with server-side components, - * and properly access user-agent and IP. - */ -export async function renderAd(options: FetchAdOptions) { - return traceErrorOnly('Ads.renderAd', async () => { - const [context, result] = await Promise.all([ - getServerActionBaseContext(), - options.source === 'live' ? fetchAd(options) : getPlaceholderAd(), - ]); - - const mode = options.source === 'live' ? options.mode : 'classic'; - if (!result || !result.ad.description || !result.ad.statlink) { - return null; - } - - const { ad } = result; - - const insightsAd: SiteInsightsAd | null = - options.source === 'live' - ? { - placement: options.placement, - zoneId: options.zoneId, - domain: 'company' in ad ? ad.company : '', - } - : null; - - return { - children: ( - <> - {mode === 'classic' || !('callToAction' in ad) ? ( -- ); - })} -
- ) : ( - - )} - {ad.pixel ? : null} - > - ), - insightsAd, - }; - }); -} - -async function fetchAd({ - zoneId, - placement, - ignore, -}: FetchLiveAdOptions): Promise<{ ad: AdItem; ip: string } | null> { - const { ip, userAgent } = await getUserAgentAndIp(); - - const url = new URL(`https://srv.buysellads.com/ads/${zoneId}.json`); - url.searchParams.set('segment', `placement:${placement}`); - url.searchParams.set('v', 'true'); - url.searchParams.set('forwardedip', ip); - url.searchParams.set('useragent', userAgent); - if (ignore) { - url.searchParams.set('ignore', 'true'); - } - - const res = await fetch(url); - const json: AdsResponse = await res.json(); - - const first = json.ads[0]; - if (first && 'active' in first) { - return { ad: first, ip }; - } - - return null; -} - -async function getPlaceholderAd(): Promise<{ ad: AdItem; ip: string }> { - const { ip } = await getUserAgentAndIp(); - - return { - ad: { - active: '1', - ad_via_link: '', - bannerid: '', - creativeid: '', - description: 'Published for free with GitBook’s Community Plan', - evenodd: '0', - external_id: '', - height: '0', - i: '0', - identifier: '', - longimp: '', - longlink: '', - num_slots: '1', - rendering: 'carbon', - smallImage: adGitbookSponsored.src, - statimp: '', - statlink: - 'https://www.gitbook.com/solutions/open-source?utm_campaign=sponsored-content&utm_medium=ad&utm_source=content', - timestamp: Date.now().toString(), - width: '0', - zoneid: '', - zonekey: '', - }, - ip, - }; -} - -async function getUserAgentAndIp() { - const headersSet = await headers(); - const ip = - headersSet.get('x-gitbook-ipv4') ?? - headersSet.get('x-gitbook-ip') ?? - headersSet.get('cf-pseudo-ipv4') ?? - headersSet.get('cf-connecting-ip') ?? - headersSet.get('x-forwarded-for') ?? - ''; - const userAgent = headersSet.get('user-agent') ?? ''; - - return { ip, userAgent }; -} diff --git a/packages/gitbook/src/components/Ads/types.ts b/packages/gitbook/src/components/Ads/types.ts deleted file mode 100644 index e4cbb3be75..0000000000 --- a/packages/gitbook/src/components/Ads/types.ts +++ /dev/null @@ -1,51 +0,0 @@ -export interface AdGeneric { - active: string; - ad_via_link: string; - bannerid: string; - creativeid: string; - evenodd: string; - external_id: string; - height: string; - i: string; - identifier: string; - longimp: string; - longlink: string; - num_slots: string; - statimp: string; - statlink: string; - timestamp: string; - width: string; - zoneid: string; - zonekey: string; - rendering: 'carbon'; - pixel?: string; -} - -export interface AdClassic extends AdGeneric { - description: string; - smallImage: string; -} - -export interface AdCover extends AdGeneric { - backgroundColor: string; - backgroundHoverColor?: string; - textColor?: string; - textColorHover?: string; - callToAction: string; - company: string; - companyTagline: string; - description: string; - largeImage: string; - image?: string; - logo: string; - ctaBackgroundColor?: string; - ctaBackgroundHoverColor?: string; - ctaTextColor?: string; - ctaTextColorHover?: string; -} - -export type AdItem = AdClassic | AdCover; - -export interface AdsResponse { - ads: Array ; -} diff --git a/packages/gitbook/src/components/Announcement/Announcement.tsx b/packages/gitbook/src/components/Announcement/Announcement.tsx deleted file mode 100644 index 87ae41bec2..0000000000 --- a/packages/gitbook/src/components/Announcement/Announcement.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import type { GitBookSiteContext } from '@/lib/context'; -import { resolveContentRef } from '@/lib/references'; -import { AnnouncementBanner } from './AnnouncementBanner'; - -/** - * Server-side component to resolve content refs and pass down to client-side component - */ -export async function Announcement(props: { - context: GitBookSiteContext; -}) { - const { context } = props; - const { customization } = context; - - if ( - !customization.announcement || - !customization.announcement.enabled || - !customization.announcement.message - ) { - return null; - } - - const resolvedContentRef = customization.announcement?.link - ? await resolveContentRef(customization.announcement?.link?.to, context) - : null; - - return ( - - ); -} diff --git a/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx b/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx deleted file mode 100644 index 815df44b87..0000000000 --- a/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx +++ /dev/null @@ -1,150 +0,0 @@ -'use client'; - -import { tString, useLanguage } from '@/intl/client'; -import { setLocalStorageItem } from '@/lib/browser'; -import type { ResolvedContentRef } from '@/lib/references'; -import { tcls } from '@/lib/tailwind'; -import { type CustomizationAnnouncement, SiteInsightsLinkPosition } from '@gitbook/api'; -import { Icon, type IconName } from '@gitbook/icons'; -import { CONTAINER_STYLE } from '../layout'; -import { Button, Link } from '../primitives'; -import { LinkStyles } from '../primitives/styles'; -import { ANNOUNCEMENT_CSS_CLASS, ANNOUNCEMENT_STORAGE_KEY } from './constants'; - -/** - * Client-side component to enable closing the banner - */ -export function AnnouncementBanner(props: { - announcement: CustomizationAnnouncement; - contentRef: ResolvedContentRef | null; -}) { - const { announcement, contentRef } = props; - - const language = useLanguage(); - - const hasLink = announcement.link && contentRef?.href; - const closeable = announcement.style !== 'danger'; - - const Tag = hasLink ? Link : 'div'; - const style = BANNER_STYLES[announcement.style]; - - return ( - - ); -} - -/** - * Dismiss the announcement banner and store the dismissal state in local storage. - * @see AnnouncementScript - */ -function dismissAnnouncement() { - setLocalStorageItem(ANNOUNCEMENT_STORAGE_KEY, { - visible: false, - at: Date.now(), - }); - - document.documentElement.classList.add(ANNOUNCEMENT_CSS_CLASS); -} - -const BANNER_STYLES = { - info: { - container: 'bg-info ring-info-subtle', - hover: 'hover:bg-info-hover active:bg-info-active', - icon: 'circle-info', - iconColor: 'text-info-subtle', - close: 'hover:bg-tint-base hover:ring-info-subtle', - link: '', - }, - warning: { - container: 'bg-warning decoration-warning/6 ring-warning-subtle', - hover: 'hover:bg-warning-hover', - icon: 'circle-exclamation', - iconColor: 'text-warning-subtle', - close: 'hover:bg-tint-base hover:ring-warning-subtle', - link: 'links-default:text-warning hover:links-default:text-warning-strong links-default:decoration-warning/6 links-accent:decoration-warning', - }, - danger: { - container: 'bg-danger decoration-danger/6 ring-danger-subtle', - hover: 'hover:bg-danger-hover', - icon: 'triangle-exclamation', - iconColor: 'text-danger-subtle', - close: 'hover:bg-tint-base hover:ring-danger-subtle', - link: 'links-default:text-danger hover:links-default:text-danger-strong links-default:decoration-danger/6 links-accent:decoration-danger', - }, - success: { - container: 'bg-success decoration-success/6 ring-success-subtle', - hover: 'hover:bg-success-hover', - icon: 'circle-check', - iconColor: 'text-success-subtle', - close: 'hover:bg-tint-base hover:ring-success-subtle', - link: 'links-default:text-success hover:links-default:text-success-strong links-default:decoration-success/6 links-accent:decoration-success', - }, -}; diff --git a/packages/gitbook/src/components/Announcement/AnnouncementDismissedScript.tsx b/packages/gitbook/src/components/Announcement/AnnouncementDismissedScript.tsx deleted file mode 100644 index 7d202e3456..0000000000 --- a/packages/gitbook/src/components/Announcement/AnnouncementDismissedScript.tsx +++ /dev/null @@ -1,39 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { - ANNOUNCEMENT_CSS_CLASS, - ANNOUNCEMENT_DAYS_TILL_RESET, - ANNOUNCEMENT_STORAGE_KEY, -} from './constants'; -import { checkStorageForDismissedScript } from './script'; - -/** - * Inject a script to read the local storage state for the announcement banner and apply the appropriate CSS class to the element as early as possible. - * Bypasses react state to prevent flickering. - */ -export function AnnouncementDismissedScript() { - const scriptArgs = JSON.stringify([ - ANNOUNCEMENT_STORAGE_KEY, - ANNOUNCEMENT_DAYS_TILL_RESET, - ANNOUNCEMENT_CSS_CLASS, - ]).slice(1, -1); - - // makes sure the banner dismissed state is kept when navigating between sites - React.useEffect(() => { - checkStorageForDismissedScript( - ANNOUNCEMENT_STORAGE_KEY, - ANNOUNCEMENT_DAYS_TILL_RESET, - ANNOUNCEMENT_CSS_CLASS - ); - }, []); - - return ( - - ); -} diff --git a/packages/gitbook/src/components/Announcement/constants.ts b/packages/gitbook/src/components/Announcement/constants.ts deleted file mode 100644 index ceca2c207b..0000000000 --- a/packages/gitbook/src/components/Announcement/constants.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The local storage key for the announcement banner. - */ -export const ANNOUNCEMENT_STORAGE_KEY = '@gitbook/announcement'; -/** - * The CSS class to hide the announcement banner. Applies to the element. - */ -export const ANNOUNCEMENT_CSS_CLASS = 'announcement-hidden'; -/** - * The number of days until the announcement banner resets. - */ -export const ANNOUNCEMENT_DAYS_TILL_RESET = 7; diff --git a/packages/gitbook/src/components/Announcement/index.ts b/packages/gitbook/src/components/Announcement/index.ts deleted file mode 100644 index 46a6eead1e..0000000000 --- a/packages/gitbook/src/components/Announcement/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Announcement'; -export * from './AnnouncementDismissedScript'; diff --git a/packages/gitbook/src/components/Announcement/script.ts b/packages/gitbook/src/components/Announcement/script.ts deleted file mode 100644 index 287e9fc8b6..0000000000 --- a/packages/gitbook/src/components/Announcement/script.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Read the local storage state for the announcement banner and apply the appropriate CSS class to the element. - * - * NOTE: this script is stringified and run in the browser, so it must be self-contained and have syntax supported in all browsers. - */ -export function checkStorageForDismissedScript( - storageKey: string, - daysTillReset: number, - cssClass: string -) { - let showBanner = true; - - try { - const announcementStateStr = window.localStorage.getItem(storageKey); - const announcementState = announcementStateStr - ? JSON.parse(announcementStateStr) - : undefined; - - if (announcementState && !announcementState.visible) { - const dismissedAt = announcementState.at; - const nowTime = new Date().getTime(); - - // Check if enough days have passed since dismissal - const daysSinceDismissal = Math.floor((nowTime - dismissedAt) / (1000 * 60 * 60 * 24)); - if (daysSinceDismissal < daysTillReset) { - showBanner = false; - } - } - } catch {} - - if (!showBanner) { - document.documentElement.classList.add(cssClass); - } -} diff --git a/packages/gitbook/src/components/AutoRefreshContent/index.ts b/packages/gitbook/src/components/AutoRefreshContent/index.ts deleted file mode 100644 index a08fc85521..0000000000 --- a/packages/gitbook/src/components/AutoRefreshContent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useCheckForContentUpdate'; diff --git a/packages/gitbook/src/components/AutoRefreshContent/server-actions.ts b/packages/gitbook/src/components/AutoRefreshContent/server-actions.ts deleted file mode 100644 index 33d7ea5619..0000000000 --- a/packages/gitbook/src/components/AutoRefreshContent/server-actions.ts +++ /dev/null @@ -1,43 +0,0 @@ -'use server'; - -import { getDataOrNull } from '@/lib/data'; -import { getSiteURLDataFromMiddleware } from '@/lib/middleware'; -import { getServerActionBaseContext } from '@/lib/server-actions'; -import { traceErrorOnly } from '@/lib/tracing'; - -/** - * Return true if the content has been updated. - * It compares the revision ID displayed on the client side with the latest revision ID from the server/cache. - */ -export async function hasContentBeenUpdated(props: { - revisionId: string; -}) { - return traceErrorOnly('AutoRefreshContent.hasContentBeenUpdated', async () => { - const context = await getServerActionBaseContext(); - const siteURLData = await getSiteURLDataFromMiddleware(); - - if (siteURLData.changeRequest) { - const changeRequest = await getDataOrNull( - context.dataFetcher.getChangeRequest({ - spaceId: siteURLData.space, - changeRequestId: siteURLData.changeRequest, - }) - ); - if (!changeRequest) { - return false; - } - return changeRequest.revision !== props.revisionId; - } - - const space = await getDataOrNull( - context.dataFetcher.getSpace({ - spaceId: siteURLData.space, - shareKey: siteURLData.shareKey, - }) - ); - if (!space) { - return false; - } - return space.revision !== props.revisionId; - }); -} diff --git a/packages/gitbook/src/components/AutoRefreshContent/useCheckForContentUpdate.ts b/packages/gitbook/src/components/AutoRefreshContent/useCheckForContentUpdate.ts deleted file mode 100644 index beb531d5fd..0000000000 --- a/packages/gitbook/src/components/AutoRefreshContent/useCheckForContentUpdate.ts +++ /dev/null @@ -1,75 +0,0 @@ -'use client'; - -import React from 'react'; - -import { hasContentBeenUpdated } from './server-actions'; - -/** - * Return a callback to check if a content has been updated and to refresh the page if it has. - */ -export function useCheckForContentUpdate(props: { - /** - * ID of the revision of the content currently being displayed. - */ - revisionId: string; - /** - * How long after page load to check for updates. - * @default 5min - */ - checkAfterLoad?: number; -}) { - const { revisionId, checkAfterLoad = 5 * 60 * 1000 } = props; - const [updated, setUpdated] = React.useState(false); - - const checkForUpdates = React.useCallback(async () => { - if (updated) { - // No need to check for updates if we already know the content has been updated - return true; - } - - const result = await hasContentBeenUpdated({ revisionId }); - setUpdated(result); - return result; - }, [revisionId, updated]); - - const refreshForUpdates = React.useCallback(async () => { - if (await checkForUpdates()) { - window.location.reload(); - } - }, [checkForUpdates]); - - // Check for updates after the page has loaded - React.useEffect(() => { - const timeout = setTimeout(() => { - if (document.visibilityState === 'visible') { - // We check only if the tab is visible; otherwise we'll check when the tab is focus again - checkForUpdates(); - } - }, checkAfterLoad); - - return () => { - clearTimeout(timeout); - }; - }, [checkForUpdates, checkAfterLoad]); - - // Check for updates when the tab is becoming visible - React.useEffect(() => { - if (updated) { - // No need to check for updates if we already know the content has been updated - return; - } - - const callback = () => { - if (document.visibilityState === 'visible') { - checkForUpdates(); - } - }; - - document.addEventListener('visibilitychange', callback); - return () => { - document.removeEventListener('visibilitychange', callback); - }; - }, [checkForUpdates, updated]); - - return { refreshForUpdates, updated }; -} diff --git a/packages/gitbook/src/components/Cookies/CookiesToast.tsx b/packages/gitbook/src/components/Cookies/CookiesToast.tsx deleted file mode 100644 index caba3a2cfa..0000000000 --- a/packages/gitbook/src/components/Cookies/CookiesToast.tsx +++ /dev/null @@ -1,106 +0,0 @@ -'use client'; -import * as React from 'react'; - -import { Button, StyledLink } from '@/components/primitives'; -import { useLanguage } from '@/intl/client'; -import { t, tString } from '@/intl/translate'; -import { tcls } from '@/lib/tailwind'; - -import { isCookiesTrackingDisabled, setCookiesTracking } from '../Insights'; - -/** - * Toast to accept or reject the use of cookies. - */ -export function CookiesToast(props: { privacyPolicy?: string }) { - const { privacyPolicy = 'https://policies.gitbook.com/privacy/cookies' } = props; - const [show, setShow] = React.useState(false); - const language = useLanguage(); - - React.useEffect(() => { - setShow(isCookiesTrackingDisabled() === undefined); - }, []); - - if (!show) { - return null; - } - - const onUpdateState = (enabled: boolean) => { - setCookiesTracking(enabled); - // Reload the page to take the change in consideration - window.location.reload(); - }; - - const describedById = 'cookies-description'; - - return ( - -- ); -} diff --git a/packages/gitbook/src/components/Cookies/index.ts b/packages/gitbook/src/components/Cookies/index.ts deleted file mode 100644 index 49c11d15fe..0000000000 --- a/packages/gitbook/src/components/Cookies/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CookiesToast'; diff --git a/packages/gitbook/src/components/DocumentView/Annotation/Annotation.tsx b/packages/gitbook/src/components/DocumentView/Annotation/Annotation.tsx deleted file mode 100644 index c0300fc015..0000000000 --- a/packages/gitbook/src/components/DocumentView/Annotation/Annotation.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import type { DocumentInlineAnnotation } from '@gitbook/api'; - -import { getNodeFragmentByType } from '@/lib/document'; - -import { Blocks } from '../Blocks'; -import type { InlineProps } from '../Inline'; -import { Inlines } from '../Inlines'; -import { AnnotationPopover } from './AnnotationPopover'; - -export function Annotation(props: InlineProps- {t( - language, - 'cookies_prompt', -
-- {t(language, 'cookies_prompt_privacy')} - - )} -setShow(false)} - className={tcls('absolute', 'top-2', 'right-2', 'hover:bg-tint-hover')} - /> - --{ - onUpdateState(true); - }} - label={tString(language, 'cookies_accept')} - /> - { - onUpdateState(false); - }} - label={tString(language, 'cookies_reject')} - /> - ) { - const { inline, context, document, children } = props; - - const fragment = getNodeFragmentByType(inline, 'annotation-body'); - const content = children ?? ( - - ); - - if (!fragment) { - return <>{content}>; - } - - return ( - - } - > - {content} - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/Annotation/AnnotationPopover.tsx b/packages/gitbook/src/components/DocumentView/Annotation/AnnotationPopover.tsx deleted file mode 100644 index 07b0ebfe83..0000000000 --- a/packages/gitbook/src/components/DocumentView/Annotation/AnnotationPopover.tsx +++ /dev/null @@ -1,84 +0,0 @@ -'use client'; - -import * as Popover from '@radix-ui/react-popover'; -import type React from 'react'; - -import { tString, useLanguage } from '@/intl/client'; -import { tcls } from '@/lib/tailwind'; - -export function AnnotationPopover(props: { children: React.ReactNode; body: React.ReactNode }) { - const { children, body } = props; - const language = useLanguage(); - - return ( - - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/Annotation/index.ts b/packages/gitbook/src/components/DocumentView/Annotation/index.ts deleted file mode 100644 index ac90322ebe..0000000000 --- a/packages/gitbook/src/components/DocumentView/Annotation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Annotation'; diff --git a/packages/gitbook/src/components/DocumentView/Block.tsx b/packages/gitbook/src/components/DocumentView/Block.tsx deleted file mode 100644 index 46a0776350..0000000000 --- a/packages/gitbook/src/components/DocumentView/Block.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import type { DocumentBlock, JSONDocument } from '@gitbook/api'; - -import { - SkeletonCard, - SkeletonHeading, - SkeletonImage, - SkeletonParagraph, - SkeletonSmall, - SkeletonUpdate, -} from '@/components/primitives'; -import type { ClassValue } from '@/lib/tailwind'; - -import { nullIfNever } from '@/lib/typescript'; -import { BlockContentRef } from './BlockContentRef'; -import { CodeBlock } from './CodeBlock'; -import { Columns } from './Columns'; -import { Divider } from './Divider'; -import type { DocumentContextProps } from './DocumentView'; -import { Drawing } from './Drawing'; -import { Embed } from './Embed'; -import { Expandable } from './Expandable'; -import { File } from './File'; -import { Heading } from './Heading'; -import { Hint } from './Hint'; -import { Images } from './Images'; -import { IntegrationBlock } from './Integration'; -import { List } from './List'; -import { ListItem } from './ListItem'; -import { BlockMath } from './Math'; -import { OpenAPIOperation, OpenAPISchemas, OpenAPIWebhook } from './OpenAPI'; -import { Paragraph } from './Paragraph'; -import { Quote } from './Quote'; -import { ReusableContent } from './ReusableContent'; -import { Stepper } from './Stepper'; -import { StepperStep } from './StepperStep'; -import { Table } from './Table'; -import { Tabs } from './Tabs'; -import { Update } from './Update'; -import { Updates } from './Updates'; - -export interface BlockProps- -- {children} - -- -- {body} - -- - -extends DocumentContextProps { - block: Block; - document: JSONDocument; - ancestorBlocks: DocumentBlock[]; - /** If true, we estimate that the block will be outside the initial viewport */ - isEstimatedOffscreen: boolean; - /** Class names to be passed to the underlying DOM element */ - style?: ClassValue; -} - -export function Block (props: BlockProps ) { - const { block } = props; - - const content = (() => { - switch (block.type) { - case 'paragraph': - return ; - case 'heading-1': - case 'heading-2': - case 'heading-3': - return ; - case 'list-ordered': - case 'list-unordered': - case 'list-tasks': - return ; - case 'list-item': - return
; - case 'columns': - return ; - case 'code': - return ; - case 'hint': - return ; - case 'images': - return ; - case 'tabs': - return ; - case 'expandable': - return ; - case 'table': - return ; - case 'swagger': - case 'openapi-operation': - return
; - case 'openapi-schemas': - return ; - case 'openapi-webhook': - return ; - case 'embed': - return ; - case 'blockquote': - return ; - case 'math': - return; - case 'file': - return ; - case 'divider': - return ; - case 'drawing': - return ; - case 'content-ref': - return ; - case 'integration': - return ; - case 'reusable-content': - return ; - case 'stepper': - return ; - case 'stepper-step': - return ; - case 'updates': - return ; - case 'update': - return ; - case 'if': - // If block should be processed by the API. - return null; - case 'image': - case 'code-line': - case 'tabs-item': - case 'column': - throw new Error(`Blocks (${block.type}) should be directly rendered by parent`); - default: - return nullIfNever(block); - } - })(); - - return content; -} - -/** - * Skeleton for a block while it is being loaded. - */ -export function BlockSkeleton(props: { block: DocumentBlock; style: ClassValue }) { - const { block, style } = props; - const id = 'meta' in block && block.meta && 'id' in block.meta ? block.meta.id : undefined; - - switch (block.type) { - case 'heading-1': - case 'heading-2': - case 'heading-3': - case 'file': - return ; - case 'paragraph': - return ; - case 'list-ordered': - case 'list-unordered': - case 'list-tasks': - case 'list-item': - case 'blockquote': - case 'code': - case 'hint': - case 'tabs': - case 'stepper-step': - case 'if': - return ; - case 'expandable': - case 'table': - case 'swagger': - case 'openapi-operation': - case 'openapi-schemas': - case 'openapi-webhook': - case 'math': - case 'divider': - case 'content-ref': - case 'integration': - case 'stepper': - case 'reusable-content': - case 'columns': - return ; - case 'embed': - case 'images': - case 'drawing': - return ; - case 'updates': - return ; - case 'image': - case 'code-line': - case 'tabs-item': - case 'column': - case 'update': - throw new Error(`Blocks (${block.type}) should be directly rendered by parent`); - default: - return nullIfNever(block); - } -} diff --git a/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx b/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx deleted file mode 100644 index 7640a66e28..0000000000 --- a/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { type DocumentBlockContentRef, SiteInsightsLinkPosition } from '@gitbook/api'; - -import { Card } from '@/components/primitives'; -import { type ResolvedContentRef, resolveContentRef } from '@/lib/references'; - -import type { BlockProps } from './Block'; - -export async function BlockContentRef(props: BlockProps ) { - const { block, context, style } = props; - - const resolved = context.contentContext - ? await resolveContentRef(block.data.ref, context.contentContext, { - resolveAnchorText: true, - iconStyle: ['text-xl', 'text-tint'], - }) - : null; - - if (!resolved) { - return null; - } - - const isContentInOtherSpace = - context.contentContext?.space && - 'space' in block.data.ref && - context.contentContext.space.id !== block.data.ref.space; - const kind = block?.data?.ref?.kind; - if ((resolved.active && kind === 'space') || isContentInOtherSpace) { - return ; - } - - return ( - - ); -} - -async function SpaceRefCard( - props: { resolved: ResolvedContentRef } & BlockProps -) { - const { context, style, resolved } = props; - const spaceId = context.contentContext?.space.id; - - if (!spaceId) { - return null; - } - - return ( - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/Blocks.tsx b/packages/gitbook/src/components/DocumentView/Blocks.tsx deleted file mode 100644 index fcd6b292ee..0000000000 --- a/packages/gitbook/src/components/DocumentView/Blocks.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import type { DocumentBlock, JSONDocument } from '@gitbook/api'; - -import { type ClassValue, tcls } from '@/lib/tailwind'; - -import { Block } from './Block'; -import type { DocumentContextProps } from './DocumentView'; -import { isBlockOffscreen } from './utils'; - -/** - * Renders a list of blocks with a wrapper element. - */ -export function Blocks ( - props: UnwrappedBlocksProps & { - /** HTML tag to use for the wrapper */ - tag?: Tag; - - /** Style passed to the wrapper */ - style?: ClassValue; - - /** Props to pass to the wrapper element */ - wrapperProps?: React.ComponentProps ; - } -) { - const { tag: Tag = 'div', style, wrapperProps, ...blocksProps } = props; - - return ( - - - ); -} - -type UnwrappedBlocksProps- = DocumentContextProps & { - /** Blocks to render */ - nodes: TBlock[]; - - /** Document being rendered */ - document: JSONDocument; - - /** Ancestors of the blocks */ - ancestorBlocks: DocumentBlock[]; - - /** Style passed to all blocks */ - blockStyle?: ClassValue; - - /** True if all blocks should be considered offscreen */ - isOffscreen?: boolean; -}; - -/* Blocks that can be full width are automatically expanded on full-width pages. - * Ideally we'd rely on the block type to determine if it can be full width, but - * the block's `fullWidth` property does not differentiate between `undefined` and `false`. - * So instead we hardcode a list of blocks that can be full width. */ -const FULL_WIDTH_BLOCKS: DocumentBlock['type'][] = [ - 'table', - 'tabs', - 'integration', - 'openapi-operation', - 'openapi-schemas', - 'openapi-webhook', - 'images', - 'embed', - 'columns', - 'code', - 'content-ref', - 'hint', -]; - -const LIST_BLOCKS: DocumentBlock['type'][] = ['list-ordered', 'list-tasks', 'list-unordered']; - -/** - * Renders a list of blocks without a wrapper element. - */ -export function UnwrappedBlocks (props: UnwrappedBlocksProps ) { - const { nodes, blockStyle, isOffscreen: defaultIsOffscreen = false, ...contextProps } = props; - - let isOffscreen = defaultIsOffscreen; - return nodes.map((node, index) => { - isOffscreen = - isOffscreen || - isBlockOffscreen({ - document: props.document, - block: node, - ancestorBlocks: props.ancestorBlocks, - }); - - return ( - - ); - }); -} diff --git a/packages/gitbook/src/components/DocumentView/Caption.tsx b/packages/gitbook/src/components/DocumentView/Caption.tsx deleted file mode 100644 index a3e60a23a4..0000000000 --- a/packages/gitbook/src/components/DocumentView/Caption.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import type { - DocumentBlockDrawing, - DocumentBlockEmbed, - DocumentBlockFile, - DocumentBlockImage, - JSONDocument, -} from '@gitbook/api'; - -import { getNodeFragmentByName, isNodeEmpty } from '@/lib/document'; -import { type ClassValue, tcls } from '@/lib/tailwind'; - -import type { DocumentContextProps } from './DocumentView'; -import { Inlines } from './Inlines'; - -/** - * Wrap a content of a block that has a potential caption. - */ -export function Caption( - props: { - children: React.ReactNode; - document: JSONDocument; - style?: ClassValue; - fit?: boolean; - wrapperStyle?: ClassValue; - block: DocumentBlockImage | DocumentBlockDrawing | DocumentBlockEmbed | DocumentBlockFile; - withBorder?: boolean; - withFrame?: boolean; - } & DocumentContextProps -) { - const { - children, - document, - block, - context, - fit = false, - withBorder = false, - withFrame = false, - wrapperStyle = [ - 'relative', - 'overflow-hidden', - 'after:block', - 'after:absolute', - 'after:-inset-0', - 'after:pointer-events-none', - fit ? 'w-fit' : null, - withBorder - ? 'rounded-corners:rounded-sm circular-corners:rounded-2xl after:border-tint-subtle after:border after:rounded circular-corners:after:rounded-2xl rounded-corners:after:rounded-sm dark:after:mix-blend-plus-lighter after:pointer-events-none' - : null, - withFrame && 'p-2', - ], - style, - } = props; - - const caption = getNodeFragmentByName(block, 'caption'); - const captionParagraph = caption?.nodes[0]; - - if ( - !captionParagraph || - captionParagraph.type !== 'paragraph' || - isNodeEmpty(captionParagraph) - ) { - return {children}; - } - - return ( -- - ); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx deleted file mode 100644 index b9d79be41d..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx +++ /dev/null @@ -1,202 +0,0 @@ -'use client'; - -import type { DocumentBlockCode } from '@gitbook/api'; -import { useEffect, useId, useMemo, useRef, useState } from 'react'; - -import { useAdaptiveVisitor } from '@/components/Adaptive'; -import { useInViewportListener } from '@/components/hooks/useInViewportListener'; -import { useScrollListener } from '@/components/hooks/useScrollListener'; -import { Button } from '@/components/primitives'; -import { t, useLanguage } from '@/intl/client'; -import { tcls } from '@/lib/tailwind'; -import { useDebounceCallback } from 'usehooks-ts'; -import type { BlockProps } from '../Block'; -import { type InlineExpressionVariables, useEvaluateInlineExpression } from '../InlineExpression'; -import { CodeBlockRenderer } from './CodeBlockRenderer'; -import type { HighlightLine, RenderedInline } from './highlight'; -import { plainHighlight } from './plain-highlight'; - -type ClientBlockProps = Pick{children}-- -- , 'block' | 'style'> & { - inlines: RenderedInline[]; - inlineExprVariables: InlineExpressionVariables; - mode: BlockProps ['context']['mode']; -}; - -export const CODE_BLOCK_DEFAULT_COLLAPSED_LINE_COUNT = 10; - -/** - * Render a code-block client-side by loading the highlighter asynchronously. - * It allows us to defer some load to avoid blocking the rendering of the whole page with block highlighting. - */ -export function ClientCodeBlock(props: ClientBlockProps) { - const { block, mode, style, inlines, inlineExprVariables } = props; - const blockRef = useRef (null); - const isInViewportRef = useRef(false); - const [isInViewport, setIsInViewport] = useState(false); - - const getAdaptiveVisitorClaims = useAdaptiveVisitor(); - const visitorClaims = getAdaptiveVisitorClaims(); - const evaluateInlineExpression = useEvaluateInlineExpression({ - visitorClaims, - variables: inlineExprVariables, - }); - const plainLines = useMemo( - () => plainHighlight(block, inlines, { evaluateInlineExpression }), - [block, inlines, evaluateInlineExpression] - ); - const [lines, setLines] = useState (null); - const [highlighting, setHighlighting] = useState(false); - - // Preload the highlighter when the block is mounted. - useEffect(() => { - import('./highlight').then(({ preloadHighlight }) => preloadHighlight(block)); - }, [block]); - - // When user scrolls, we need to wait for the scroll to finish before running the highlight - const isScrollingRef = useRef(false); - const onFinishScrolling = useDebounceCallback(() => { - isScrollingRef.current = false; - - // If the block is in the viewport after the scroll, we need to run the highlight - if (isInViewportRef.current) { - setIsInViewport(true); - } - }, 100); - useScrollListener( - () => { - isScrollingRef.current = true; - onFinishScrolling(); - }, - useRef(typeof window !== 'undefined' ? window : null) - ); - - // Detect when the block is in viewport - useInViewportListener( - blockRef, - (isInViewport, disconnect) => { - isInViewportRef.current = isInViewport; - if (isScrollingRef.current) { - // If the user is scrolling, we don't want to run the highlight - // because it will be run when the scroll is finished - return; - } - - if (isInViewport) { - // Disconnect once in viewport - disconnect(); - setIsInViewport(true); - } - }, - { rootMargin: '200px' } - ); - - // When the block is visible or updated, we need to re-run the highlight - useEffect(() => { - if (isInViewport) { - // If the block is in viewport, we need to run the highlight - let cancelled = false; - - if (typeof window !== 'undefined') { - setHighlighting(true); - import('./highlight').then(({ highlight }) => { - highlight(block, inlines, { evaluateInlineExpression }).then((lines) => { - if (cancelled) { - return; - } - - setLines(lines); - setHighlighting(false); - }); - }); - } - - return () => { - cancelled = true; - }; - } - - // Otherwise if the block is not in viewport, we reset to the plain lines - setLines(null); - }, [isInViewport, block, inlines, evaluateInlineExpression]); - - const expandable = block.data.expandable; - - const numberOfLinesOfCode = lines?.length ?? plainLines.length; - const collapsedLineCount = - block.data.collapsedLineCount || CODE_BLOCK_DEFAULT_COLLAPSED_LINE_COUNT; - const isExpandable = Boolean( - expandable && mode !== 'print' && numberOfLinesOfCode > collapsedLineCount - ); - - const codeBlockBodyId = useId(); - - const renderer = ( - - ); - - return isExpandable ? ( - - {renderer} - - ) : ( - renderer - ); -} - -function CodeBlockExpandable(props: { - children: React.ReactNode; - lines: HighlightLine[]; - collapsedLineCount: number; - controls?: string; -}) { - const { children, controls, lines = [], collapsedLineCount } = props; - const [isExpanded, setIsExpanded] = useState(false); - const language = useLanguage(); - return ( --- ); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlock.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlock.tsx deleted file mode 100644 index 6ef4ee8cf2..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlock.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import * as React from 'react'; - -import type { DocumentBlockCode } from '@gitbook/api'; - -import { getNodeFragmentByType } from '@/lib/document'; - -import type { BlockProps } from '../Block'; -import { Blocks } from '../Blocks'; -import { ClientCodeBlock } from './ClientCodeBlock'; -import { CodeBlockRenderer } from './CodeBlockRenderer'; -import { type RenderedInline, getInlines, highlight } from './highlight'; - -/** - * Render a code block, can be client-side or server-side. - */ -export async function CodeBlock(props: BlockProps- {children} ----setIsExpanded(!isExpanded)} - className="pointer-events-auto z-1 my-2 text-primary text-sm opacity-0 focus:opacity-11 group-hover/codeblock-expandable:opacity-11" - aria-expanded={isExpanded} - aria-controls={controls} - > - {isExpanded - ? t(language, 'code_block_expanded') - : t(language, 'code_block_collapsed', lines.length)} - -) { - const { block, document, style, isEstimatedOffscreen, context } = props; - const inlines = getInlines(block); - - let hasInlineExpression = false; - - const richInlines: RenderedInline[] = inlines - // Exclude inline expressions from rendered inline as they are rendered as code text once evaluated - // and so need to be treated as plain code tokens. - .filter((inline) => { - if (inline.inline.type === 'expression') { - hasInlineExpression = true; - return false; - } - return true; - }) - .map((inline, index) => { - const body = (() => { - const fragment = getNodeFragmentByType(inline.inline, 'annotation-body'); - if (!fragment) { - return null; - } - return ( - - ); - })(); - - return { inline, body }; - }); - - if (!isEstimatedOffscreen && !hasInlineExpression && !block.data.expandable) { - // In v2, we render the code block server-side - const lines = await highlight(block, richInlines); - return ; - } - - const variables = context.contentContext - ? { - space: context.contentContext?.revision.variables, - page: - 'page' in context.contentContext - ? context.contentContext.page.variables - : undefined, - } - : {}; - - return ( - - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlockRenderer.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlockRenderer.tsx deleted file mode 100644 index e50e874eb8..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlockRenderer.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import type { DocumentBlockCode } from '@gitbook/api'; -import assertNever from 'assert-never'; -import { forwardRef, useId } from 'react'; - -import { tcls } from '@/lib/tailwind'; - -import { AnnotationPopover } from '../Annotation/AnnotationPopover'; -import type { BlockProps } from '../Block'; -import { CopyCodeButton } from './CopyCodeButton'; -import type { HighlightLine, HighlightToken } from './highlight'; - -type CodeBlockRendererProps = Pick- , 'block' | 'style'> & { - lines: HighlightLine[]; - 'aria-busy'?: boolean; - id?: string; -}; - -/** - * The logic of rendering a code block from lines. - */ -export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer( - props: CodeBlockRendererProps, - ref: React.ForwardedRef -) { - const { block, style, lines, 'aria-busy': ariaBusy } = props; - - const withLineNumbers = Boolean(block.data.lineNumbers) && block.nodes.length > 1; - const withWrap = block.data.overflow === 'wrap'; - const title = block.data.title; - - const id = useId(); - const codeId = props.id || id; - return ( - -- ); -}); - -function CodeHighlightLine(props: { - line: HighlightLine; - isLast: boolean; - withLineNumbers: boolean; -}) { - const { line, isLast, withLineNumbers } = props; - return ( - - {withLineNumbers && } - -- {title ? ( --- {title} -- ) : null} -- --- {lines.map((line, index) => ( --- ))} - - {!isLast && '\n'} - - - ); -} - -function CodeHighlightTokens(props: { tokens: HighlightToken[] }) { - const { tokens } = props; - return tokens.map((token, index) => ); -} - -function CodeHighlightToken(props: { token: HighlightToken }) { - const { token } = props; - - switch (token.type) { - case 'annotation': { - return ( - - - ); - } - case 'plain': { - return token.content; - } - case 'shiki': { - if (!token.token.color) { - return token.token.content; - } - - return {token.token.content}; - } - default: - assertNever(token); - } -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/CopyCodeButton.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/CopyCodeButton.tsx deleted file mode 100644 index ea86e0bd87..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/CopyCodeButton.tsx +++ /dev/null @@ -1,82 +0,0 @@ -'use client'; - -import React from 'react'; - -import { Button } from '@/components/primitives'; -import { t, useLanguage } from '@/intl/client'; -import { type ClassValue, tcls } from '@/lib/tailwind'; - -/** - * Client component to copy the code of a code block. - * To avoid passing large payload to the client, the code is computed from the DOM. - */ -export function CopyCodeButton(props: { codeId: string; style: ClassValue }) { - const { codeId, style } = props; - - const language = useLanguage(); - const [copied, setCopied] = React.useState(false); - - React.useEffect(() => { - if (!copied) { - return; - } - - const timeout = setTimeout(() => { - setCopied(false); - }, 1000); - - return () => { - clearTimeout(timeout); - }; - }, [copied]); - - const onClick = () => { - const element = document.getElementById(codeId); - if (!element) { - return; - } - - navigator.clipboard.writeText(getCodeText(element)); - - setCopied(true); - }; - - return ( -- - {t(language, copied ? 'code_copied' : 'code_copy')} - - ); -} - -/** - * Compute the code text from the DOM, - * ignoring the empty white space we use for empty lines (represented with a class "ew"). - */ -function getCodeText(code: HTMLElement): string { - let text = ''; - - const iterate = (node: Node) => { - if (node instanceof HTMLBRElement) { - text += '\n'; - } else if (node instanceof HTMLSpanElement) { - if (node.classList.contains('ew')) { - text += '\n'; - } else { - text += node.innerText; - } - } else if (node instanceof HTMLElement) { - node.childNodes.forEach(iterate); - } else { - text += node.textContent; - } - }; - - iterate(code); - - return text; -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/PlainCodeBlock.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/PlainCodeBlock.tsx deleted file mode 100644 index f303e50720..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/PlainCodeBlock.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import type { JSONDocument } from '@gitbook/api'; -import { useId } from 'react'; - -import { CodeBlock } from './CodeBlock'; -import { convertCodeStringToBlock } from './utils'; - -/** - * Plain code block with syntax highlighting. - * For simplicity, this is just a wrapper around the CodeBlock component, emulating a document. - */ -export function PlainCodeBlock(props: { code: string; syntax: string }) { - const { code, syntax } = props; - const id = useId(); - - const block = convertCodeStringToBlock({ key: id, code, syntax }); - - const document: JSONDocument = { - object: 'document', - data: {}, - nodes: [block], - }; - - return ( -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.test.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.test.ts deleted file mode 100644 index d330fda941..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.test.ts +++ /dev/null @@ -1,761 +0,0 @@ -import { expect, it } from 'bun:test'; -import type { DocumentBlockCode } from '@gitbook/api'; - -import { type RenderedInline, getInlines, highlight } from './highlight'; - -async function highlightWithInlines(block: DocumentBlockCode) { - const inlines: RenderedInline[] = getInlines(block).map((inline) => ({ - inline, - body: null, - })); - return highlight(block, inlines); -} - -it('should parse plain code', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - data: {}, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'console.log("Hello World")' }], - }, - ], - }, - ], - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'plain', - content: 'console.log("Hello World")', - }, - ], - }, - ]); -}); - -it('should parse different code in parallel', async () => { - await Promise.all( - ['shell', 'scss', 'scss', 'css', 'scss', 'yaml'].map(async (syntax) => - highlight( - { - object: 'block', - type: 'code', - data: { - syntax: syntax, - }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'Hello world' }], - }, - ], - }, - ], - }, - [] - ) - ) - ); -}); - -it('should parse a multilines plain code', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - data: {}, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'if (value === true) {' }], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [ - { object: 'leaf', marks: [], text: ' console.log("Hello World")' }, - ], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: '}' }], - }, - ], - }, - ], - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'plain', - content: 'if (value === true) {', - }, - ], - }, - { - highlighted: false, - tokens: [ - { - type: 'plain', - content: ' console.log("Hello World")', - }, - ], - }, - { - highlighted: false, - tokens: [ - { - type: 'plain', - content: '}', - }, - ], - }, - ]); -}); - -it('should parse code with an inline on a single line', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - data: { - syntax: 'javascript', - }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'console.' }], - }, - { - object: 'inline', - type: 'annotation', - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'log' }], - }, - ], - isVoid: false, - fragments: [], - }, - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: '("Hello World")' }], - }, - ], - }, - ], - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'console', - }, - }, - { - type: 'shiki', - token: { - content: '.', - }, - }, - { - type: 'annotation', - body: null, - children: [ - { - type: 'shiki', - token: { - content: 'log', - }, - }, - ], - }, - { - type: 'shiki', - token: { - content: '(', - }, - }, - { - type: 'shiki', - token: { - content: '"Hello World"', - }, - }, - { - type: 'shiki', - token: { - content: ')', - }, - }, - ], - }, - ]); -}); - -it('should parse code with an inline on a multiple line', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - data: { - syntax: 'javascript', - }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'let ' }], - }, - { - object: 'inline', - type: 'annotation', - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'message' }], - }, - ], - isVoid: false, - fragments: [], - }, - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: ';' }], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'console.' }], - }, - { - object: 'inline', - type: 'annotation', - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'log' }], - }, - ], - isVoid: false, - fragments: [], - }, - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: '("Hello World")' }], - }, - ], - }, - ], - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'let', - }, - }, - { - type: 'shiki', - token: { - content: ' ', - }, - }, - { - type: 'annotation', - body: null, - children: [ - { - type: 'shiki', - token: { - content: 'message', - }, - }, - ], - }, - { - type: 'shiki', - token: { - content: ';', - }, - }, - ], - }, - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'console', - }, - }, - { - type: 'shiki', - token: { - content: '.', - }, - }, - { - type: 'annotation', - body: null, - children: [ - { - type: 'shiki', - token: { - content: 'log', - }, - }, - ], - }, - { - type: 'shiki', - token: { - content: '(', - }, - }, - { - type: 'shiki', - token: { - content: '"Hello World"', - }, - }, - { - type: 'shiki', - token: { - content: ')', - }, - }, - ], - }, - ]); -}); - -it('should support code token finishing before the end of the annotation', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - isVoid: false, - data: { syntax: 'bash' }, - nodes: [ - { - object: 'block', - type: 'code-line', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: ' ', marks: [] }], - key: 'k1', - }, - { - object: 'inline', - type: 'annotation', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'sh ', marks: [] }], - key: 'k2', - }, - ], - key: 'k3', - fragments: [ - { - object: 'fragment', - nodes: [ - { - object: 'block', - type: 'paragraph', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [ - { - object: 'leaf', - text: '', - marks: [], - }, - ], - key: 'k4', - }, - ], - key: 'k5', - }, - ], - key: 'k6', - fragment: 'annotation-body', - type: 'annotation-body', - }, - ], - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: "'''", marks: [] }], - key: 'k7', - }, - ], - key: 'k8', - }, - ], - key: 'k9', - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: ' ', - start: 0, - end: 16, - }, - }, - { - type: 'annotation', - body: null, - children: [ - { - type: 'shiki', - token: { - content: 'sh', - start: 16, - end: 18, - }, - }, - { - type: 'shiki', - token: { - content: ' ', - start: 18, - end: 19, - }, - }, - ], - }, - { - type: 'shiki', - token: { - content: "'''", - start: 19, - end: 22, - }, - }, - ], - }, - ]); -}); - -it('should support multiple code tokens in an annotation', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - isVoid: false, - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'const a =', marks: [] }], - key: 'k1', - }, - { - object: 'inline', - type: 'annotation', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'hello.world(', marks: [] }], - key: 'k2', - }, - ], - key: 'k3', - fragments: [ - { - object: 'fragment', - nodes: [ - { - object: 'block', - type: 'paragraph', - isVoid: false, - data: {}, - nodes: [ - { - object: 'text', - leaves: [ - { - object: 'leaf', - text: 'Inner content', - marks: [], - }, - ], - key: 'k4', - }, - ], - key: 'k5', - }, - ], - key: 'k6', - fragment: 'annotation-body', - type: 'annotation-body', - }, - ], - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: ');', marks: [] }], - key: 'k7', - }, - ], - key: 'k8', - }, - ], - key: 'k9', - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'const', - }, - }, - { - type: 'shiki', - token: { - content: ' ', - }, - }, - { - type: 'shiki', - token: { - content: 'a', - }, - }, - { - type: 'shiki', - token: { - content: ' ', - }, - }, - { - type: 'shiki', - token: { - content: '=', - }, - }, - { - type: 'annotation', - body: null, - children: [ - { - type: 'shiki', - token: { - content: 'hello', - }, - }, - { - type: 'shiki', - token: { - content: '.world', - }, - }, - { - type: 'shiki', - token: { - content: '(', - }, - }, - ], - }, - { - type: 'shiki', - token: { - content: ');', - }, - }, - ], - }, - ]); -}); - -it('should handle \\r', async () => { - const tokens = await highlightWithInlines({ - object: 'block', - type: 'code', - data: { - syntax: 'javascript', - }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: 'console.log("Hello")' }], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', marks: [], text: '\rconsole.log("World")' }], - }, - ], - }, - ], - }); - - expect(tokens).toMatchObject([ - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'console', - }, - }, - { - type: 'shiki', - token: { - content: '.log', - }, - }, - { - type: 'shiki', - token: { - content: '(', - }, - }, - { - type: 'shiki', - token: { - content: '"Hello"', - }, - }, - { - type: 'shiki', - token: { - content: ')', - }, - }, - ], - }, - { - highlighted: false, - tokens: [ - { - type: 'shiki', - token: { - content: 'console', - }, - }, - { - type: 'shiki', - token: { - content: '.log', - }, - }, - { - type: 'shiki', - token: { - content: '(', - }, - }, - { - type: 'shiki', - token: { - content: '"World"', - }, - }, - { - type: 'shiki', - token: { - content: ')', - }, - }, - ], - }, - ]); -}); diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.ts deleted file mode 100644 index d20578fade..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/highlight.ts +++ /dev/null @@ -1,387 +0,0 @@ -import type { - DocumentBlockCode, - DocumentBlockCodeLine, - DocumentInlineAnnotation, -} from '@gitbook/api'; -import { - type ThemedToken, - createCssVariablesTheme, - createSingletonShorthands, - createdBundledHighlighter, -} from 'shiki/core'; -import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'; -import { type BundledLanguage, bundledLanguages } from 'shiki/langs'; - -import { nullIfNever } from '@/lib/typescript'; -import { plainHighlight } from './plain-highlight'; - -export type HighlightLine = { - highlighted: boolean; - tokens: HighlightToken[]; -}; - -export type HighlightToken = - | { type: 'plain'; content: string } - | { type: 'shiki'; token: ThemedToken } - | { type: 'annotation'; body: React.ReactNode; children: HighlightToken[] }; - -export type InlineIndexed = { inline: any; start: number; end: number }; - -type PositionedToken = ThemedToken & { start: number; end: number }; - -export type RenderedInline = { - inline: InlineIndexed; - body: React.ReactNode; -}; - -const isSafari = - typeof navigator !== 'undefined' && /^((?!chrome|android).)*safari/i.test(navigator.userAgent); -const theme = createCssVariablesTheme(); - -const { getSingletonHighlighter } = createSingletonShorthands( - createdBundledHighlighter ({ - langs: bundledLanguages, - themes: {}, - engine: () => createJavaScriptRegexEngine({ forgiving: true, target: 'ES2018' }), - }) -); - -/** - * Preload the highlighter for a code block. - */ -export async function preloadHighlight(block: DocumentBlockCode) { - const langName = getBlockLang(block); - if (langName) { - await getSingletonHighlighter({ - langs: [langName], - themes: [theme], - }); - } -} - -/** - * Highlight a code block while preserving inline elements. - */ -export async function highlight( - block: DocumentBlockCode, - inlines: RenderedInline[], - options?: { - evaluateInlineExpression?: (expr: string) => string; - } -): Promise { - const langName = getBlockLang(block); - - if (!langName || (isSafari && ['powershell', 'cpp'].includes(langName))) { - // Fallback to plain highlighting if - // - language is not found - // - TEMP : language is PowerShell or C++ and browser is Safari: - // RegExp#[Symbol.search] throws TypeError when `lastIndex` isn’t writable - // Fixed in upcoming Safari 18.6, remove when it'll be released - RND-7772 - return plainHighlight(block, inlines, options); - } - - const code = getPlainCodeBlock(block, undefined, options); - - const highlighter = await getSingletonHighlighter({ - langs: [langName], - themes: [theme], - }); - - let tokenizeMaxLineLength = 400; - // In some cases, people will use unindented code blocks with a single line. - // In this case, we can safely increase the max line length to avoid not highlighting the code. - if (block.nodes.length === 1) { - tokenizeMaxLineLength = 5000; - } - - const lines = highlighter.codeToTokensBase(code, { - lang: langName, - theme, - tokenizeMaxLineLength, - }); - - let currentIndex = 0; - return lines.map((tokens, index) => { - const lineBlock = block.nodes[index]; - const result: HighlightToken[] = []; - - const eatToken = (): PositionedToken | null => { - const token = tokens.shift(); - if (token) { - currentIndex += token.content.length; - } - return token - ? { ...token, start: currentIndex - token.content.length, end: currentIndex } - : null; - }; - - while (tokens.length > 0) { - result.push(...matchTokenAndInlines(eatToken, inlines)); - } - - currentIndex += 1; // for the \n - - return { - highlighted: Boolean(lineBlock?.data.highlighted), - tokens: result, - }; - }); -} - -/** - * Get the language of a code block. - */ -function getBlockLang(block: DocumentBlockCode): string | null { - return block.data.syntax ? getLanguageForSyntax(block.data.syntax) : null; -} - -const syntaxAliases: Record = { - // "Parser" language does not exist in Shiki, but it's used in GitBook - // The closest language is "Blade" - parser: 'blade', - - // From GitBook App we receive "objectivec" instead of "objective-c" - objectivec: 'objective-c', -}; - -function checkIsBundledLanguage(lang: string): lang is BundledLanguage { - return lang in bundledLanguages; -} - -/** - * Validate a language name. - */ -function getLanguageForSyntax(syntax: string): BundledLanguage | null { - // Normalize the syntax to lowercase. - syntax = syntax.toLowerCase(); - - // Check if the syntax is a bundled language. - if (checkIsBundledLanguage(syntax)) { - return syntax; - } - - // Check if there is a valid alias for the syntax. - const alias = syntaxAliases[syntax]; - if (alias && checkIsBundledLanguage(alias)) { - return alias; - } - - return null; -} - -export function getInlines(block: DocumentBlockCode) { - const inlines: InlineIndexed[] = []; - getPlainCodeBlock(block, inlines); - - inlines.sort((a, b) => a.start - b.start); - - return inlines; -} - -function matchTokenAndInlines( - eat: () => PositionedToken | null, - allInlines: RenderedInline[] -): HighlightToken[] { - const initialToken = eat(); - if (!initialToken) { - return []; - } - - const inlines = allInlines.filter( - ({ inline }) => inline.start >= initialToken.start && inline.start < initialToken.end - ); - let token = initialToken; - const result: HighlightToken[] = []; - - const matchAgainstInline = () => { - const inline = inlines.shift(); - if (!inline) { - result.push({ - type: 'shiki', - token, - }); - - return; - } - - const [before, afterBefore] = splitPositionedTokenAt(token, inline.inline.start); - if (before) { - result.push({ - type: 'shiki', - token: before, - }); - } - if (!afterBefore) { - throw new Error('expect afterBefore to not be empty'); - } - - token = afterBefore; - const children: HighlightToken[] = []; - - // If shiki token finished before the end of the annotation or the annotation contains multiple tokens - while (token.end < inline.inline.end) { - children.push({ - type: 'shiki', - token: token, - }); - - const next = eat(); - if (!next) { - throw new Error('expect token to not be empty'); - } - token = next; - } - - const [inside, after] = splitPositionedTokenAt(token, inline.inline.end); - if (!inside) { - throw new Error('expect inside to not be empty'); - } - - children.push({ - type: 'shiki', - token: inside, - }); - - result.push({ - type: 'annotation', - body: inline.body, - children, - }); - - if (after) { - token = after; - matchAgainstInline(); - } - }; - - matchAgainstInline(); - return result; -} - -function getPlainCodeBlock( - code: DocumentBlockCode, - inlines?: InlineIndexed[], - options?: { - evaluateInlineExpression?: (expr: string) => string; - } -): string { - let content = ''; - - code.nodes.forEach((node, index) => { - const lineContent = getPlainCodeBlockLine(node, content.length, inlines, options); - content += lineContent; - - if (index < code.nodes.length - 1) { - content += '\n'; - } - }); - - return content; -} - -function getPlainCodeBlockLine( - parent: DocumentBlockCodeLine | DocumentInlineAnnotation, - index: number, - inlines?: InlineIndexed[], - options?: { - evaluateInlineExpression?: (expr: string) => string; - } -): string { - let content = ''; - - for (const node of parent.nodes) { - if (node.object === 'text') { - content += cleanupLine(node.leaves.map((leaf) => leaf.text).join('')); - } else { - switch (node.type) { - case 'annotation': { - const start = index + content.length; - content += getPlainCodeBlockLine( - node, - index + content.length, - inlines, - options - ); - const end = index + content.length; - - if (inlines) { - inlines.push({ - inline: node, - start, - end, - }); - } - break; - } - case 'expression': { - const start = index + content.length; - const exprValue = - options?.evaluateInlineExpression?.(node.data.expression) ?? ''; - content += exprValue; - const end = start + exprValue.length; - - if (inlines) { - inlines.push({ - inline: node, - start, - end, - }); - } - break; - } - default: { - nullIfNever(node); - break; - } - } - } - } - - return content; -} - -function slicePositionedToken( - token: PositionedToken, - relativeStart: number, - relativeLength: number -): PositionedToken { - return { - ...token, - start: token.start + relativeStart, - end: token.start + relativeStart + relativeLength, - content: token.content.slice(relativeStart, relativeStart + relativeLength), - }; -} - -function splitPositionedTokenAt( - token: PositionedToken, - absoluteIndex: number -): [PositionedToken | null, PositionedToken | null] { - if (absoluteIndex < token.start || absoluteIndex > token.end) { - throw new Error(`index (${absoluteIndex}) out of bound (${token.start}:${token.end})`); - } - - const before = slicePositionedToken(token, 0, absoluteIndex - token.start); - const after = slicePositionedToken( - token, - absoluteIndex - token.start, - token.end - absoluteIndex - ); - - return [ - isEmptyPositionedToken(before) ? null : before, - isEmptyPositionedToken(after) ? null : after, - ]; -} - -function isEmptyPositionedToken(token: PositionedToken): boolean { - return token.start === token.end; -} - -/** - * Currently it's possible for some lines to contain \r characters, we need to remove them - * as they are considered as new lines by shikijs. - */ -function cleanupLine(line: string): string { - return line.replace(/\r/g, ''); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/index.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/index.ts deleted file mode 100644 index f322414c54..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './CodeBlock'; -export * from './PlainCodeBlock'; diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/plain-highlight.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/plain-highlight.ts deleted file mode 100644 index 433742d5dc..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/plain-highlight.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { DocumentBlockCode } from '@gitbook/api'; - -import { getNodeText } from '@/lib/document'; - -import type { HighlightLine, HighlightToken, RenderedInline } from './highlight'; - -/** - * Parse a code block without highlighting it. - */ -export function plainHighlight( - block: DocumentBlockCode, - inlines: RenderedInline[], - options?: { - evaluateInlineExpression?: (expr: string) => string; - } -): HighlightLine[] { - const inlinesCopy = Array.from(inlines); - - return block.nodes.map((lineBlock) => { - const tokens: HighlightToken[] = lineBlock.nodes.map((node) => { - if (node.object === 'text') { - return { - type: 'plain', - content: getNodeText(node), - }; - } - - if (node.type === 'expression') { - return { - type: 'plain', - content: options?.evaluateInlineExpression?.(node.data.expression) ?? '', - }; - } - - const inline = inlinesCopy.shift(); - return { - type: 'annotation', - body: inline?.body ?? null, - children: [ - { - type: 'plain', - content: getNodeText(node), - }, - ], - }; - }); - - return { - highlighted: Boolean(lineBlock.data.highlighted), - tokens, - }; - }); -} diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/utils.test.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/utils.test.ts deleted file mode 100644 index a071727855..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/utils.test.ts +++ /dev/null @@ -1,219 +0,0 @@ -import { describe, expect, it } from 'bun:test'; -import { convertCodeStringToBlock } from './utils'; - -describe('convertCodeStringToBlock', () => { - it('converts plain code string without placeholders', () => { - const result = convertCodeStringToBlock({ - key: 'test1', - code: 'console.log("hello");', - syntax: 'javascript', - }); - - expect(result).toEqual({ - key: 'test1', - object: 'block', - type: 'code', - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'console.log("hello");', marks: [] }], - }, - ], - }, - ], - }); - }); - - it('converts a single placeholder into an expression node', () => { - const result = convertCodeStringToBlock({ - key: 'test2', - code: 'const config = { API_KEY: "$$__X-GITBOOK-PREFILL[visitor.claims.apiKey ?? "YOUR_API_KEY"]__$$" }', - syntax: 'javascript', - }); - - expect(result).toEqual({ - key: 'test2', - object: 'block', - type: 'code', - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [ - { object: 'leaf', text: 'const config = { API_KEY: "', marks: [] }, - ], - }, - { - object: 'inline', - type: 'expression', - data: { expression: 'visitor.claims.apiKey ?? "YOUR_API_KEY"' }, - isVoid: true, - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: '" }', marks: [] }], - }, - ], - }, - ], - }); - }); - - it('handles multiple placeholders in one line', () => { - const result = convertCodeStringToBlock({ - key: 'test3', - code: 'let a = $$__X-GITBOOK-PREFILL[valA]__$$, b = $$__X-GITBOOK-PREFILL[valB]__$$;', - syntax: 'javascript', - }); - - expect(result).toEqual({ - key: 'test3', - object: 'block', - type: 'code', - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'let a = ', marks: [] }], - }, - { - object: 'inline', - type: 'expression', - data: { expression: 'valA' }, - isVoid: true, - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: ', b = ', marks: [] }], - }, - { - object: 'inline', - type: 'expression', - data: { expression: 'valB' }, - isVoid: true, - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: ';', marks: [] }], - }, - ], - }, - ], - }); - }); - - it('handles multiple placeholders across different lines', () => { - const result = convertCodeStringToBlock({ - key: 'test4', - code: [ - 'const name = "$$__X-GITBOOK-PREFILL[visitor.claims.userName]__$$";', - 'const age = $$__X-GITBOOK-PREFILL[visitor.claims.userAge]__$$;', - 'console.log(name, age);', - ].join('\n'), - syntax: 'javascript', - }); - - expect(result).toEqual({ - key: 'test4', - object: 'block', - type: 'code', - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'const name = "', marks: [] }], - }, - { - object: 'inline', - type: 'expression', - data: { expression: 'visitor.claims.userName' }, - isVoid: true, - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: '";', marks: [] }], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [{ object: 'leaf', text: 'const age = ', marks: [] }], - }, - { - object: 'inline', - type: 'expression', - data: { expression: 'visitor.claims.userAge' }, - isVoid: true, - }, - { - object: 'text', - leaves: [{ object: 'leaf', text: ';', marks: [] }], - }, - ], - }, - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [ - { - object: 'text', - leaves: [ - { object: 'leaf', text: 'console.log(name, age);', marks: [] }, - ], - }, - ], - }, - ], - }); - }); - - it('returns an empty code block for empty string', () => { - const result = convertCodeStringToBlock({ - key: 'test5', - code: '', - syntax: 'javascript', - }); - - expect(result).toEqual({ - key: 'test5', - object: 'block', - type: 'code', - data: { syntax: 'javascript' }, - nodes: [ - { - object: 'block', - type: 'code-line', - data: {}, - nodes: [], - }, - ], - }); - }); -}); diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/utils.ts b/packages/gitbook/src/components/DocumentView/CodeBlock/utils.ts deleted file mode 100644 index d59df74f5a..0000000000 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/utils.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { DocumentBlockCode, DocumentBlockCodeLine } from '@gitbook/api'; - -const PREFILL_WITH_EXPR_REGEX = /\$\$__X-GITBOOK-PREFILL\[(.+?)\]__\$\$/g; - -/** - * Convert a raw code string into a `DocumentBlockCode` object representation. - * - * Any placeholder of the form `$$__X-GITBOOK-PREFILL[ ]__$$` inside the code - * string is transformed into a DocumentInlineExpression node with its `data.expression` set to the - * extracted ` `. - */ -export function convertCodeStringToBlock(args: { - key: string; - code: string; - syntax: string; -}): DocumentBlockCode { - const { key, code, syntax } = args; - const lines = code.split('\n').map ((line) => { - const nodes: DocumentBlockCodeLine['nodes'] = []; - let lastIndex = 0; - - for (const match of line.matchAll(PREFILL_WITH_EXPR_REGEX)) { - const [placeholder, expression] = match; - const start = match.index ?? 0; - - if (start > lastIndex) { - nodes.push({ - object: 'text', - leaves: [{ object: 'leaf', text: line.slice(lastIndex, start), marks: [] }], - }); - } - - if (expression) { - nodes.push({ - object: 'inline', - type: 'expression', - data: { expression }, - isVoid: true, - }); - } - - lastIndex = start + placeholder.length; - } - - if (lastIndex < line.length) { - nodes.push({ - object: 'text', - leaves: [{ object: 'leaf', text: line.slice(lastIndex), marks: [] }], - }); - } - - return { - object: 'block', - type: 'code-line', - data: {}, - nodes, - }; - }); - - return { - key, - object: 'block', - type: 'code', - data: { syntax }, - nodes: lines, - }; -} diff --git a/packages/gitbook/src/components/DocumentView/Columns/Columns.tsx b/packages/gitbook/src/components/DocumentView/Columns/Columns.tsx deleted file mode 100644 index 97f64a2ab4..0000000000 --- a/packages/gitbook/src/components/DocumentView/Columns/Columns.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { tcls } from '@/lib/tailwind'; -import { type DocumentBlockColumns, type Length, VerticalAlignment } from '@gitbook/api'; -import React from 'react'; -import type { BlockProps } from '../Block'; -import { Blocks } from '../Blocks'; - -export function Columns(props: BlockProps ) { - const { block, style, ancestorBlocks, document, context } = props; - - const columnWidths = React.useMemo(() => { - const widths = block.nodes.map((block) => { - const width = block.data.width; - return width ? getFractionalWidth(width) : 0; - }); - - const totalWidth = widths.reduce ((acc, width) => acc + width, 0); - // If not all columns widths are set, distribute the remaining widths as equally as we can - if (totalWidth < 1.0 && widths.some((width) => width === 0)) { - const unsetWidths = widths.filter((width) => width === 0); - let remainingWidth = 1.0 - totalWidth; - let unsetWidthsLength = unsetWidths.length; - widths.forEach((width, index) => { - if (width === 0) { - const calculatedWidth = - Math.round((remainingWidth / unsetWidthsLength) * COLUMN_DIVISIONS) / - COLUMN_DIVISIONS; - widths[index] = calculatedWidth; // Assign width to empty columns - unsetWidthsLength--; - remainingWidth -= calculatedWidth; - } - }); - } - return widths; - }, [block.nodes]); - - return ( - - {block.nodes.map((columnBlock, index) => { - const columnWidth = columnWidths[index]; - return ( -- ); -} - -export function Column(props: { - children?: React.ReactNode; - width: Length; - verticalAlignment?: VerticalAlignment; -}) { - const { width, verticalAlignment } = props; - const { className, style } = transformLengthToCSS(width) ?? {}; - return ( -- - ); - })} -- - {props.children} -- ); -} - -const COLUMN_DIVISIONS = 12; - -export function transformLengthToCSS(length: Length) { - if (typeof length === 'number') { - return; // not implemented yet with non-percentage lengths - } - if (length.unit === '%') { - return { - className: 'md:flex-shrink-0 md:[grid-column:var(--grid-col)]', - style: { - '--grid-col': `auto / span ${Math.round(length.value * 0.01 * COLUMN_DIVISIONS)}`, - } as React.CSSProperties, - }; - } -} - -function getFractionalWidth(length: Length) { - if (typeof length === 'number') { - return 0; - } - return length.value / 100; -} diff --git a/packages/gitbook/src/components/DocumentView/Columns/index.ts b/packages/gitbook/src/components/DocumentView/Columns/index.ts deleted file mode 100644 index a8b4f25b41..0000000000 --- a/packages/gitbook/src/components/DocumentView/Columns/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Columns'; diff --git a/packages/gitbook/src/components/DocumentView/Divider.tsx b/packages/gitbook/src/components/DocumentView/Divider.tsx deleted file mode 100644 index 15302df475..0000000000 --- a/packages/gitbook/src/components/DocumentView/Divider.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import type { DocumentBlockDivider } from '@gitbook/api'; - -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; - -export function Divider(props: BlockProps) { - const { style } = props; - - return
; -} diff --git a/packages/gitbook/src/components/DocumentView/DocumentView.tsx b/packages/gitbook/src/components/DocumentView/DocumentView.tsx deleted file mode 100644 index 152bd6f78e..0000000000 --- a/packages/gitbook/src/components/DocumentView/DocumentView.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import type { GitBookAnyContext } from '@/lib/context'; -import type { ClassValue } from '@/lib/tailwind'; -import type { JSONDocument } from '@gitbook/api'; - -import { BlockSkeleton } from './Block'; -import { Blocks } from './Blocks'; - -export interface DocumentContext { - /** - * Mode to render the document in. - * This can be used to render the document in a different mode, such as "default" or "print". - */ - mode: 'default' | 'print'; - - /** - * Space content being rendered. - * If null, content refs cannot be resolved. - */ - contentContext?: GitBookAnyContext; - - /** - * Transform an ID to be added to the DOM. - */ - getId?: (id: string) => string; - - /** - * True if the blocks should be wrapped in suspense boundary for isolated loading skeletons. - * @default true - */ - wrapBlocksInSuspense?: boolean; - - /** - * True if link previews should be rendered. - * This is used to limit the number of link previews rendered in a document. - * If false, no link previews will be rendered. - * @default false - */ - withLinkPreviews?: boolean; -} - -export interface DocumentContextProps { - context: DocumentContext; -} - -/** - * Render an entire document. - */ -export function DocumentView( - props: DocumentContextProps & { - document: JSONDocument; - - /** Style passed to the container */ - style?: ClassValue; - - /** Style passed to all blocks */ - blockStyle?: ClassValue; - - /** True if the document should be considered offscreen */ - isOffscreen?: boolean; - } -) { - const { document, style, blockStyle = [], context, isOffscreen = false } = props; - - return ( -- ); -} - -/** - * Placeholder for the entire document layout. - */ -export function DocumentViewSkeleton(props: { document: JSONDocument; blockStyle: ClassValue }) { - const { document, blockStyle } = props; - - return ( - - {document.nodes.map((block) => ( -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Drawing.tsx b/packages/gitbook/src/components/DocumentView/Drawing.tsx deleted file mode 100644 index 25a9a8c03c..0000000000 --- a/packages/gitbook/src/components/DocumentView/Drawing.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import type { DocumentBlockDrawing } from '@gitbook/api'; - -import { resolveContentRef } from '@/lib/references'; - -import { Image } from '../utils'; -import type { BlockProps } from './Block'; -import { Caption } from './Caption'; -import { imageBlockSizes } from './Images'; - -export async function Drawing(props: BlockProps- ))} - ) { - const { block, context } = props; - - const resolved = - block.data.ref && context.contentContext - ? await resolveContentRef(block.data.ref, context.contentContext) - : null; - if (!resolved) { - return null; - } - - return ( - - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/Embed.tsx b/packages/gitbook/src/components/DocumentView/Embed.tsx deleted file mode 100644 index 3977d30af5..0000000000 --- a/packages/gitbook/src/components/DocumentView/Embed.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import type * as gitbookAPI from '@gitbook/api'; -import Script from 'next/script'; -import ReactDOM from 'react-dom'; - -import { Card } from '@/components/primitives'; -import { tcls } from '@/lib/tailwind'; - -import { getDataOrNull } from '@/lib/data'; -import { Image } from '../utils'; -import type { BlockProps } from './Block'; -import { Caption } from './Caption'; -import { IntegrationBlock } from './Integration'; - -export async function Embed(props: BlockProps- ) { - const { block, context, ...otherProps } = props; - - if (!context.contentContext) { - return null; - } - - ReactDOM.preload('https://cdn.iframe.ly/embed.js', { as: 'script' }); - - const embed = await getDataOrNull( - context.contentContext.dataFetcher.getEmbedByUrl({ - url: block.data.url, - spaceId: context.contentContext.space?.id, - }) - ); - - if (!embed) { - return null; - } - - return ( - - {embed.type === 'rich' ? ( - <> - - - > - ) : embed.type === 'integration' ? ( - - ); -} - -/** - * Create an integration block with an unfurl action from the GitBook Embed response. - */ -function createIntegrationBlock( - url: string, - integration: string, - block: gitbookAPI.IntegrationBlock -): gitbookAPI.DocumentBlockIntegration { - return { - object: 'block', - type: 'integration', - isVoid: true, - data: { - integration, - block: block.id, - props: {}, - action: { - action: '@link.unfurl', - url, - }, - url, - }, - }; -} diff --git a/packages/gitbook/src/components/DocumentView/Emoji.tsx b/packages/gitbook/src/components/DocumentView/Emoji.tsx deleted file mode 100644 index e076032469..0000000000 --- a/packages/gitbook/src/components/DocumentView/Emoji.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import type { DocumentInlineEmoji } from '@gitbook/api'; - -import { Emoji as EmojiPrimitive } from '@/components/primitives'; - -import type { InlineProps } from './Inline'; - -export function Emoji(props: InlineProps- ) : ( - - ) : null - } - href={block.data.url} - title={embed.title} - postTitle={embed.site} - /> - )} - ) { - const { inline } = props; - - return ; -} diff --git a/packages/gitbook/src/components/DocumentView/Expandable/Details.tsx b/packages/gitbook/src/components/DocumentView/Expandable/Details.tsx deleted file mode 100644 index 8fd4d35708..0000000000 --- a/packages/gitbook/src/components/DocumentView/Expandable/Details.tsx +++ /dev/null @@ -1,74 +0,0 @@ -'use client'; - -import React from 'react'; - -import { useHash } from '@/components/hooks'; -import { type ClassValue, tcls } from '@/lib/tailwind'; - -/** - * Details component rendered on client so it can expand dependent on url hash changes. - */ -export function Details(props: { - children: React.ReactNode; - id: string; - contentIds?: string[]; - open?: boolean; - className?: ClassValue; -}) { - const { children, id, className } = props; - - const ref = React.useRef (null); - - const [openFromHash, setOpenFromHash] = React.useState(false); - - const hash = useHash(); - - /** - * Open the details element if the url hash refers to the id of the details element - * or the id of some element contained within the details element. - */ - React.useEffect(() => { - if (!hash || !ref.current) { - return; - } - - if (hash === id) { - setOpenFromHash(true); - return; - } - - const activeElement = document.getElementById(hash); - const isOpen = Boolean(activeElement && ref.current.contains(activeElement)); - setOpenFromHash(isOpen); - }, [hash, id]); - - return ( - - {children} -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Expandable/Expandable.tsx b/packages/gitbook/src/components/DocumentView/Expandable/Expandable.tsx deleted file mode 100644 index 8a3de8f413..0000000000 --- a/packages/gitbook/src/components/DocumentView/Expandable/Expandable.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import type { DocumentBlockExpandable } from '@gitbook/api'; -import { Icon } from '@gitbook/icons'; - -import { getNodeFragmentByType } from '@/lib/document'; -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from '../Block'; -import { Blocks } from '../Blocks'; -import { Inlines } from '../Inlines'; -import { Details } from './Details'; - -export function Expandable(props: BlockProps) { - const { block, style, ancestorBlocks, document, context } = props; - - const title = getNodeFragmentByType(block, 'expandable-title'); - const body = getNodeFragmentByType(block, 'expandable-body'); - - const titleParagraph = title?.nodes[0]; - - if (!title || !body || titleParagraph?.type !== 'paragraph') { - return null; - } - - let id = block.meta?.id ?? ''; - id = context.getId ? context.getId(id) : id; - - return ( - -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Expandable/index.ts b/packages/gitbook/src/components/DocumentView/Expandable/index.ts deleted file mode 100644 index de59564f38..0000000000 --- a/packages/gitbook/src/components/DocumentView/Expandable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Expandable'; diff --git a/packages/gitbook/src/components/DocumentView/File.tsx b/packages/gitbook/src/components/DocumentView/File.tsx deleted file mode 100644 index 7ddf6ecaf6..0000000000 --- a/packages/gitbook/src/components/DocumentView/File.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { type DocumentBlockFile, SiteInsightsLinkPosition } from '@gitbook/api'; - -import { t } from '@/intl/translate'; -import { getSimplifiedContentType } from '@/lib/files'; -import { resolveContentRef } from '@/lib/references'; - -import { getSpaceLanguage } from '@/intl/server'; -import { Button, Link } from '../primitives'; -import { DownloadButton } from '../primitives/DownloadButton'; -import type { BlockProps } from './Block'; -import { Caption } from './Caption'; -import { FileIcon } from './FileIcon'; - -export async function File(props: BlockProps-
-- - - - - - ) { - const { block, context } = props; - - if (!context.contentContext) { - return null; - } - - const contentRef = await resolveContentRef(block.data.ref, context.contentContext); - const file = contentRef?.file; - - if (!file) { - return null; - } - - const language = getSpaceLanguage(context.contentContext); - const contentType = getSimplifiedContentType(file.contentType); - const insights = { - type: 'link_click' as const, - link: { - target: block.data.ref, - position: SiteInsightsLinkPosition.Content, - }, - }; - - return ( - - - ); -} - -const ONE_KB = 1024; -const ONE_MB = ONE_KB * 1024; - -/** - * Return a file size as human readable formatted string. - */ -function getHumanFileSize(size: number): string { - if (size > ONE_MB) { - const mbSize = size / ONE_MB; - return `${mbSize.toFixed(0)}MB`; - } - if (size > ONE_KB) { - const kbSize = size / ONE_KB; - return `${kbSize.toFixed(0)}KB`; - } - - return `${size}B`; -} diff --git a/packages/gitbook/src/components/DocumentView/FileIcon.tsx b/packages/gitbook/src/components/DocumentView/FileIcon.tsx deleted file mode 100644 index 61d38700e5..0000000000 --- a/packages/gitbook/src/components/DocumentView/FileIcon.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Icon } from '@gitbook/icons'; - -import type { SimplifiedFileType } from '@/lib/files'; - -/** - * Render an appropriate icon for a file. - */ -export function FileIcon(props: { contentType: SimplifiedFileType | null; className: string }) { - const { contentType, className } = props; - - switch (contentType) { - case 'PDF': - return----- {getHumanFileSize(file.size)}---- - {file.name} - --{contentType}---- {t(language, 'download')} - -- {t(language, 'open')} - -; - case 'image': - return ; - case 'archive': - return ; - default: - return ; - } -} diff --git a/packages/gitbook/src/components/DocumentView/HashLinkButton.tsx b/packages/gitbook/src/components/DocumentView/HashLinkButton.tsx deleted file mode 100644 index 3f6f42f3d0..0000000000 --- a/packages/gitbook/src/components/DocumentView/HashLinkButton.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { type ClassValue, tcls } from '@/lib/tailwind'; -import type { DocumentBlockHeading, DocumentBlockTabs } from '@gitbook/api'; -import { Icon } from '@gitbook/icons'; -import { Link } from '../primitives'; -import { getBlockTextStyle } from './spacing'; - -/** - * A hash icon which adds the block or active block item's ID in the URL hash. - * The button needs to be wrapped in a container with `hashLinkButtonWrapperStyles`. - */ -export const hashLinkButtonWrapperStyles = tcls('relative', 'group/hash'); - -export function HashLinkButton(props: { - id: string; - block: DocumentBlockTabs | DocumentBlockHeading; - label?: string; - className?: ClassValue; - iconClassName?: ClassValue; -}) { - const { id, block, className, iconClassName, label = 'Direct link to block' } = props; - const textStyle = getBlockTextStyle(block); - return ( - - -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Heading.tsx b/packages/gitbook/src/components/DocumentView/Heading.tsx deleted file mode 100644 index 534d49186b..0000000000 --- a/packages/gitbook/src/components/DocumentView/Heading.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import type { DocumentBlockHeading } from '@gitbook/api'; - -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import { HashLinkButton, hashLinkButtonWrapperStyles } from './HashLinkButton'; -import { Inlines } from './Inlines'; -import { getBlockTextStyle } from './spacing'; -import { getTextAlignment } from './utils'; - -export function Heading(props: BlockProps- - ) { - const { block, style, context, ...rest } = props; - - const textStyle = getBlockTextStyle(block); - - const Tag = TAGS[block.type]; - - let id = block.meta?.id ?? ''; - id = context.getId ? context.getId(id) : id; - - return ( - - - ); -} - -const TAGS: { [type in DocumentBlockHeading['type']]: React.ElementType } = { - // The h1 is reserved for the page title - 'heading-1': 'h2', - 'heading-2': 'h3', - 'heading-3': 'h4', -}; diff --git a/packages/gitbook/src/components/DocumentView/Hint.tsx b/packages/gitbook/src/components/DocumentView/Hint.tsx deleted file mode 100644 index 21272489a7..0000000000 --- a/packages/gitbook/src/components/DocumentView/Hint.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import type { DocumentBlockHint } from '@gitbook/api'; -import { Icon, type IconName } from '@gitbook/icons'; - -import { type ClassValue, tcls } from '@/lib/tailwind'; - -import { getSpaceLanguage, tString } from '@/intl/server'; -import { languages } from '@/intl/translations'; -import { Block, type BlockProps } from './Block'; -import { Blocks } from './Blocks'; -import { getBlockTextStyle } from './spacing'; - -export function Hint({ - block, - style, - ancestorBlocks, - ...contextProps -}: BlockProps- - --- ) { - const hintStyle = HINT_STYLES[block.data.style] ?? HINT_STYLES.info; - const firstNode = block.nodes[0]!; - const firstLine = getBlockTextStyle(firstNode); - const hasHeading = ['heading-1', 'heading-2', 'heading-3'].includes(firstNode.type); - - const language = contextProps.context.contentContext - ? getSpaceLanguage(contextProps.context.contentContext) - : languages.en; - - const label = tString(language, `hint_${block.data.style}`); - - return ( - -- ); -} - -const HINT_STYLES: { - [style in DocumentBlockHint['data']['style']]: { - icon: IconName; - iconColor?: ClassValue; - body?: ClassValue; - header?: ClassValue; - container?: ClassValue; - containerWithHeader?: ClassValue; - }; -} = { - info: { - icon: 'circle-info', - iconColor: 'text-info-subtle contrast-more:text-info', - header: 'bg-info-active', - body: [ - 'text-neutral-strong', - '[&_.can-override-bg]:bg-neutral-active', - '[&_.can-override-text]:text-neutral-strong', - ], - container: - 'bg-info border-info theme-muted-tint:bg-info-solid/2 [html.sidebar-filled.theme-bold.tint_&]:bg-info-solid/2', - containerWithHeader: 'border-info-solid bg-info-subtle', - }, - warning: { - icon: 'circle-exclamation', - iconColor: 'text-warning-subtle contrast-more:text-warning', - header: 'bg-warning-active', - body: [ - 'text-neutral-strong', - 'links-default:[&_a]:text-warning', - 'links-default:[&_a:hover]:text-warning-strong', - 'links-default:[&_a]:decoration-warning/6', - 'links-accent:[&_a]:decoration-warning', - 'decoration-warning/6', - '[&_.can-override-bg]:bg-warning-active', - '[&_.can-override-text]:text-warning-strong', - ], - container: 'bg-warning border-warning', - containerWithHeader: 'border-warning-solid bg-warning-subtle', - }, - danger: { - icon: 'triangle-exclamation', - iconColor: 'text-danger-subtle contrast-more:text-danger', - header: 'bg-danger-active', - body: [ - 'text-neutral-strong', - 'links-default:[&_a]:text-danger', - 'links-default:[&_a:hover]:text-danger-strong', - 'links-default:[&_a]:decoration-danger/6', - 'links-accent:[&_a]:decoration-danger', - 'decoration-danger/6', - '[&_.can-override-bg]:bg-danger-active', - '[&_.can-override-text]:text-danger-strong', - ], - container: 'bg-danger border-danger', - containerWithHeader: 'border-danger-solid bg-danger-subtle', - }, - success: { - icon: 'circle-check', - iconColor: 'text-success-subtle contrast-more:text-success', - header: 'bg-success-active', - body: [ - 'text-neutral-strong', - 'links-default:[&_a]:text-success', - 'links-default:[&_a:hover]:text-success-strong', - 'links-default:[&_a]:decoration-success/6', - 'links-accent:[&_a]:decoration-success', - 'decoration-success/6', - '[&_.can-override-bg]:bg-success-active', - '[&_.can-override-text]:text-success-strong', - ], - container: 'bg-success border-success', - containerWithHeader: 'border-success-solid bg-success-subtle', - }, -}; diff --git a/packages/gitbook/src/components/DocumentView/Images.tsx b/packages/gitbook/src/components/DocumentView/Images.tsx deleted file mode 100644 index 632ae75fa4..0000000000 --- a/packages/gitbook/src/components/DocumentView/Images.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import type { DocumentBlockImage, DocumentBlockImages, JSONDocument, Length } from '@gitbook/api'; - -import { Image, type ImageResponsiveSize } from '@/components/utils'; -import { resolveContentRef } from '@/lib/references'; -import { type ClassValue, tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import { Caption } from './Caption'; -import type { DocumentContext } from './DocumentView'; - -export function Images(props: BlockProps-- {hasHeading ? ( -- - ) : null} - - ) { - const { document, block, style, context, isEstimatedOffscreen } = props; - - const hasMultipleImages = block.nodes.length > 1; - const { align = 'center', withFrame } = block.data; - - return ( - -- ); -} - -/** - * Sizes for image blocks. - */ -export const imageBlockSizes: ImageResponsiveSize[] = [ - { - media: '(max-width: 640px)', - width: 400, - }, - { - width: 768, - }, -]; - -async function ImageBlock(props: { - block: DocumentBlockImage; - document: JSONDocument; - style: ClassValue; - context: DocumentContext; - siblings: number; - isEstimatedOffscreen: boolean; - withFrame?: boolean; -}) { - const { block, context, isEstimatedOffscreen, withFrame } = props; - - const [src, darkSrc] = await Promise.all([ - context.contentContext ? resolveContentRef(block.data.ref, context.contentContext) : null, - block.data.refDark && context.contentContext - ? resolveContentRef(block.data.refDark, context.contentContext) - : null, - ]); - - if (!src) { - return null; - } - - return ( -- {block.nodes.map((node: any, _i: number) => ( --- ))} - - {/* Frame grid */} - {withFrame && ( - - )} - - {/* Shadow overlay */} - {withFrame && ( - - )} - -- ); -} - -/** - * This function converts a dimension value to a string representation with 'px' as the unit, - * or returns the default value if the dimension is not valid. - * When using absolute values, the converted dimension will be the actual size in pixels. - * When using relative values, the converted dimension will be relative to the parent element's size. - */ -function getImageDimension- -- ( - dimension: Length | undefined, - defaultValue: DefaultValue -): string | DefaultValue { - if (typeof dimension === 'number') { - return `${dimension}px`; - } - if (dimension?.unit === 'px') { - return `${dimension.value}${dimension.unit}`; - } - return defaultValue; -} diff --git a/packages/gitbook/src/components/DocumentView/Inline.tsx b/packages/gitbook/src/components/DocumentView/Inline.tsx deleted file mode 100644 index 01a722a72f..0000000000 --- a/packages/gitbook/src/components/DocumentView/Inline.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import type { DocumentInline, JSONDocument } from '@gitbook/api'; - -import { nullIfNever } from '@/lib/typescript'; -import { Annotation } from './Annotation/Annotation'; -import type { DocumentContextProps } from './DocumentView'; -import { Emoji } from './Emoji'; -import { InlineButton } from './InlineButton'; -import { InlineExpression } from './InlineExpression'; -import { InlineIcon } from './InlineIcon'; -import { InlineImage } from './InlineImage'; -import { InlineLink } from './InlineLink'; -import { InlineMath } from './Math'; -import { Mention } from './Mention'; - -export interface InlineProps extends DocumentContextProps { - inline: T; - - /** - * Document being rendered. - */ - document: JSONDocument; - - /** - * Inline ancestors of the current inline. - */ - ancestorInlines: DocumentInline[]; - - /** - * If defined, replace the content of the inline. - */ - children?: React.ReactNode; -} - -export function Inline (props: InlineProps ) { - const { inline, ...contextProps } = props; - - switch (inline.type) { - case 'link': - return ; - case 'inline-math': - return ; - case 'annotation': - return ; - case 'emoji': - return ; - case 'mention': - return ; - case 'inline-image': - return ; - case 'button': - return ; - case 'icon': - return ; - case 'expression': - return ; - default: - return nullIfNever(inline); - } -} diff --git a/packages/gitbook/src/components/DocumentView/InlineButton.tsx b/packages/gitbook/src/components/DocumentView/InlineButton.tsx deleted file mode 100644 index 0f2672ec9b..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineButton.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { resolveContentRef } from '@/lib/references'; -import * as api from '@gitbook/api'; -import type { IconName } from '@gitbook/icons'; -import { Button } from '../primitives'; -import type { InlineProps } from './Inline'; - -export async function InlineButton(props: InlineProps ) { - const { inline, context } = props; - - if (!context.contentContext) { - throw new Error('InlineButton requires a contentContext'); - } - - const resolved = await resolveContentRef(inline.data.ref, context.contentContext); - - if (!resolved) { - return null; - } - - return ( - // Set the leading to have some vertical space between adjacent buttons - - - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpression.tsx b/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpression.tsx deleted file mode 100644 index 2c38f684b1..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpression.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import * as React from 'react'; - -import type { DocumentInlineExpression } from '@gitbook/api'; -import type { InlineProps } from '../Inline'; -import { InlineExpressionValue } from './InlineExpressionValue'; - -/** - * Render an inline expression. - */ -export function InlineExpression(props: InlineProps ) { - const { context, inline } = props; - - const { data } = inline; - - const variables = context.contentContext - ? { - space: context.contentContext?.revision.variables, - page: - 'page' in context.contentContext - ? context.contentContext.page.variables - : undefined, - } - : {}; - - return ( - - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpressionValue.tsx b/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpressionValue.tsx deleted file mode 100644 index 9684e667cd..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineExpression/InlineExpressionValue.tsx +++ /dev/null @@ -1,26 +0,0 @@ -'use client'; -import { useAdaptiveVisitor } from '@/components/Adaptive'; -import { useMemo } from 'react'; -import type { InlineExpressionVariables } from './types'; -import { useEvaluateInlineExpression } from './useEvaluateInlineExpression'; - -export function InlineExpressionValue(props: { - expression: string; - variables: InlineExpressionVariables; -}) { - const { expression, variables } = props; - - const getAdaptiveVisitorClaims = useAdaptiveVisitor(); - const visitorClaims = getAdaptiveVisitorClaims(); - const evaluateInlineExpression = useEvaluateInlineExpression({ - visitorClaims, - variables, - }); - - const result = useMemo( - () => evaluateInlineExpression(expression), - [expression, evaluateInlineExpression] - ); - - return <>{result}>; -} diff --git a/packages/gitbook/src/components/DocumentView/InlineExpression/index.ts b/packages/gitbook/src/components/DocumentView/InlineExpression/index.ts deleted file mode 100644 index 59dec96a78..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineExpression/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './InlineExpression'; -export * from './types'; -export * from './useEvaluateInlineExpression'; diff --git a/packages/gitbook/src/components/DocumentView/InlineExpression/types.ts b/packages/gitbook/src/components/DocumentView/InlineExpression/types.ts deleted file mode 100644 index 831831b8b5..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineExpression/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Variables } from '@gitbook/api'; - -export interface InlineExpressionVariables { - space?: Variables; - page?: Variables; -} diff --git a/packages/gitbook/src/components/DocumentView/InlineExpression/useEvaluateInlineExpression.ts b/packages/gitbook/src/components/DocumentView/InlineExpression/useEvaluateInlineExpression.ts deleted file mode 100644 index 758c9b252a..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineExpression/useEvaluateInlineExpression.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as React from 'react'; - -import { - type AdaptiveVisitorClaims, - createExpressionEvaluationContext, -} from '@/components/Adaptive'; -import type { Variables } from '@gitbook/api'; -import { ExpressionRuntime, formatExpressionResult } from '@gitbook/expr'; - -/** - * Hook that returns a callback to evaluate an inline expression with visitor data - * and space/page variables as context. - */ -export function useEvaluateInlineExpression(args: { - visitorClaims: AdaptiveVisitorClaims | null; - variables: { - space?: Variables; - page?: Variables; - }; -}) { - const { visitorClaims, variables } = args; - const evaluateInlineExpression = React.useMemo(() => { - const runtime = new ExpressionRuntime(); - const evaluationContext = createExpressionEvaluationContext({ - visitorClaims, - variables, - }); - - return (expression: string) => { - try { - return formatExpressionResult( - runtime.evaluate(expression, evaluationContext) ?? '' - ); - } catch (err) { - console.error('Failed to evaluate expression:', expression, err); - return `{{${expression}}}`; - } - }; - }, [variables, visitorClaims]); - - return evaluateInlineExpression; -} diff --git a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx b/packages/gitbook/src/components/DocumentView/InlineIcon.tsx deleted file mode 100644 index 18ff08dff7..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import type { DocumentInlineIcon } from '@gitbook/api'; - -import { tcls } from '@/lib/tailwind'; -import { Icon, type IconName } from '@gitbook/icons'; -import type { InlineProps } from './Inline'; -import { textColorToStyle } from './utils/colors'; - -export async function InlineIcon(props: InlineProps- ) { - const { inline } = props; - const { color, icon } = inline.data; - - return ( - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/InlineImage.tsx b/packages/gitbook/src/components/DocumentView/InlineImage.tsx deleted file mode 100644 index 2fe6d8111f..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineImage.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import type { GitBookBaseContext } from '@/lib/context'; -import type { DocumentInlineImage } from '@gitbook/api'; -import assertNever from 'assert-never'; - -import { type ResolvedContentRef, resolveContentRef } from '@/lib/references'; -import { tcls } from '@/lib/tailwind'; - -import { Image } from '../utils'; -import type { InlineProps } from './Inline'; - -export async function InlineImage(props: InlineProps ) { - const { inline, context, ancestorInlines } = props; - const { size = 'original' } = inline.data; - - const [src, darkSrc] = await Promise.all([ - context.contentContext ? resolveContentRef(inline.data.ref, context.contentContext) : null, - inline.data.refDark && context.contentContext - ? resolveContentRef(inline.data.refDark, context.contentContext) - : null, - ]); - - if (!src) { - return null; - } - - const isInLink = ancestorInlines.some((ancestor) => ancestor.type === 'link'); - const sizes = await getImageSizes(context.contentContext, size, src); - - return ( - /* Ensure images dont expand to the size of the container where this Image may be nested in. Now it's always nested in a size-restricted container */ - - - - ); -} - -async function getImageSizes( - context: GitBookBaseContext | undefined, - size: 'original' | 'line', - src: ResolvedContentRef -) { - switch (size) { - case 'line': { - const imageSize = - src.file?.dimensions ?? - (await context?.imageResizer?.getImageSize(src.href, { - dpr: 3, - })); - // We estimate that the maximum height of the line will be 40px - // and from the aspect-ratio, we can deduce the width - const lineHeight = 40; - - const aspectRatio = imageSize ? imageSize.width / imageSize.height : 1; - - return [ - { - width: Math.floor(lineHeight * aspectRatio), - }, - ]; - } - case 'original': { - // The max-width is 300px - return [ - { - // if we know the image size and it is smaller than 300px use its width - width: 300, - }, - ]; - } - default: - assertNever(size); - } -} diff --git a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx b/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx deleted file mode 100644 index 940b42e891..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx +++ /dev/null @@ -1,148 +0,0 @@ -import { type DocumentInlineLink, SiteInsightsLinkPosition } from '@gitbook/api'; - -import { getSpaceLanguage, tString } from '@/intl/server'; -import { type TranslationLanguage, languages } from '@/intl/translations'; -import { type ResolvedContentRef, resolveContentRef } from '@/lib/references'; -import { Icon } from '@gitbook/icons'; -import { HoverCard, HoverCardRoot, HoverCardTrigger, StyledLink } from '../../primitives'; -import type { InlineProps } from '../Inline'; -import { Inlines } from '../Inlines'; -import { InlineLinkTooltip } from './InlineLinkTooltip'; - -export async function InlineLink(props: InlineProps ) { - const { inline, document, context, ancestorInlines } = props; - - const resolved = context.contentContext - ? await resolveContentRef(inline.data.ref, context.contentContext, { - // We don't want to resolve the anchor text here, as it can be very expensive and will block rendering if there is a lot of anchors link. - resolveAnchorText: false, - }) - : null; - const { contentContext } = context; - - const language = contentContext ? getSpaceLanguage(contentContext) : languages.en; - - if (!contentContext || !resolved) { - return ( - - - ); - } - const isExternal = inline.data.ref.kind === 'url'; - const isMailto = resolved.href.startsWith('mailto:'); - const content = ( -- - -- - - ---- {tString(language, 'notfound_title')}
-{tString(language, 'notfound_link')}
-- - ); - - if (context.withLinkPreviews) { - return ( -- {isMailto ? ( - - ) : isExternal ? ( - - ) : null} - - {content} - - ); - } - - return content; -} - -/** - * An SSR component that renders a link with a tooltip. - * Essentially it pulls the minimum amount of props from the context to render the tooltip. - */ -function InlineLinkTooltipWrapper(props: { - inline: DocumentInlineLink; - children: React.ReactNode; - resolved: ResolvedContentRef; - language: TranslationLanguage; -}) { - const { inline, language, resolved, children } = props; - - let breadcrumbs = resolved.ancestors ?? []; - const isMailto = resolved.href.startsWith('mailto:'); - const isExternal = inline.data.ref.kind === 'url'; - const isSamePage = inline.data.ref.kind === 'anchor' && inline.data.ref.page === undefined; - - if (isMailto) { - resolved.text = resolved.text.split('mailto:')[1] ?? resolved.text; - breadcrumbs = [ - { - label: tString(language, 'link_tooltip_email'), - }, - ]; - } else if (isExternal) { - breadcrumbs = [ - { - label: tString(language, 'link_tooltip_external_link'), - }, - ]; - } else if (isSamePage) { - breadcrumbs = [ - { - label: tString(language, 'link_tooltip_page_anchor'), - icon:, - }, - ]; - resolved.subText = undefined; - } - - return ( - - {children} - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLinkTooltip.tsx b/packages/gitbook/src/components/DocumentView/InlineLink/InlineLinkTooltip.tsx deleted file mode 100644 index 5f548e085c..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLinkTooltip.tsx +++ /dev/null @@ -1,95 +0,0 @@ -'use client'; -import { tcls } from '@/lib/tailwind'; -import { Icon } from '@gitbook/icons'; -import { Fragment } from 'react'; -import { Button, HoverCard, HoverCardRoot, HoverCardTrigger, StyledLink } from '../../primitives'; - -export function InlineLinkTooltip(props: { - isSamePage: boolean; - isExternal: boolean; - breadcrumbs: Array<{ href?: string; label: string; icon?: React.ReactNode }>; - target: { - href: string; - text: string; - subText?: string; - icon?: React.ReactNode; - }; - openInNewTabLabel: string; - children: React.ReactNode; -}) { - const { isSamePage, isExternal, openInNewTabLabel, target, breadcrumbs, children } = props; - - return ( -- - ); -} diff --git a/packages/gitbook/src/components/DocumentView/InlineLink/index.ts b/packages/gitbook/src/components/DocumentView/InlineLink/index.ts deleted file mode 100644 index 1d7f30120b..0000000000 --- a/packages/gitbook/src/components/DocumentView/InlineLink/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './InlineLink'; diff --git a/packages/gitbook/src/components/DocumentView/Inlines.tsx b/packages/gitbook/src/components/DocumentView/Inlines.tsx deleted file mode 100644 index 45200414ce..0000000000 --- a/packages/gitbook/src/components/DocumentView/Inlines.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import type { DocumentInline, DocumentText, JSONDocument } from '@gitbook/api'; - -import type { DocumentContextProps } from './DocumentView'; -import { Inline } from './Inline'; -import { Text } from './Text'; - -export function Inlines{children} -- --- {target.subText ?- {breadcrumbs && breadcrumbs.length > 0 ? ( -- {!isSamePage && target.href ? ( -- {breadcrumbs.map((crumb, index) => { - const Tag = crumb.href ? StyledLink : 'div'; - - return ( -- ) : null} -- {index !== 0 ? ( - - ); - })} -- ) : null} - - {crumb.icon ? ( - - {crumb.icon} - - ) : null} - {crumb.label} - -- {target.icon ? ( --- {target.icon} -- ) : null} -{target.text}
-- ) : null} - {target.subText}
: null} -( - props: DocumentContextProps & { - /** - * Document being rendered. - */ - document: JSONDocument; - - /** - * Ancestors of the current inline. - */ - ancestorInlines: DocumentInline[]; - - /** - * Nodes to render - */ - nodes: T[]; - } -) { - const { nodes, document, ancestorInlines, ...contextProps } = props; - - return nodes.map((node, index) => { - const key = node.key || `key-${index}`; - - if (node.object === 'text') { - return ; - } - - return ( - - ); - }); -} diff --git a/packages/gitbook/src/components/DocumentView/Integration/IntegrationBlock.tsx b/packages/gitbook/src/components/DocumentView/Integration/IntegrationBlock.tsx deleted file mode 100644 index 8e44f2b1ff..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/IntegrationBlock.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { GITBOOK_INTEGRATIONS_HOST } from '@/lib/env'; -import { tcls } from '@/lib/tailwind'; -import type { DocumentBlockIntegration, RenderIntegrationUI } from '@gitbook/api'; -import { ContentKit, ContentKitOutput } from '@gitbook/react-contentkit'; - -import type { BlockProps } from '../Block'; -import './contentkit.css'; -import { contentKitServerContext } from './contentkit'; -import { fetchSafeIntegrationUI } from './render'; -import { renderIntegrationUi } from './server-actions'; - -export async function IntegrationBlock(props: BlockProps ) { - const { block, context, style } = props; - - if (!context.contentContext?.space) { - throw new Error('integration block requires a content.spaceId'); - } - - const initialInput: RenderIntegrationUI = { - componentId: block.data.block, - props: block.data.props, - action: block.data.action, - context: { - type: 'document', - spaceId: context.contentContext?.space.id, - editable: false, - theme: 'light', // TODO: how to handle this without moving rendering to the client side? - }, - }; - - const initialResponse = await fetchSafeIntegrationUI(context.contentContext, { - integrationName: block.data.integration, - request: initialInput, - }); - - if (initialResponse.error) { - if (initialResponse.error.code === 404) { - return null; - } - - return ( - -- ); - } - const initialOutput = initialResponse.data; - if (initialOutput.type === 'complete') { - return null; - } - - return ( -- Unexpected error with integration {block.data.integration}:{' '} - {initialResponse.error.message} ---- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Integration/contentkit.css b/packages/gitbook/src/components/DocumentView/Integration/contentkit.css deleted file mode 100644 index 9002303ea0..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/contentkit.css +++ /dev/null @@ -1,214 +0,0 @@ -@reference '../../RootLayout/globals.css'; - -/** Stacks */ -.contentkit-stack { - @apply flex gap-4; -} - -/** Add margin bottom to all stacks that are not the last child and have a form */ -.contentkit-stack:not(:last-child):has(.contentkit-form) { - @apply mb-4; -} - -.contentkit-hstack { - @apply flex-row gap-3 items-center; -} -.contentkit-hstack.contentkit-stack-align-center { - @apply justify-center; -} -.contentkit-hstack.contentkit-stack-align-end { - @apply justify-end; -} - -.contentkit-vstack { - @apply flex-col gap-4; -} -.contentkit-vstack.contentkit-stack-align-center { - @apply items-center; -} -.contentkit-vstack.contentkit-stack-align-end { - @apply items-end; -} - -/** Text */ -.contentkit-text.contentkit-text-bold { - @apply font-bold; -} - -.contentkit-text.contentkit-text-italic { - @apply italic; -} - -.contentkit-text.contentkit-text-code { - @apply font-mono; -} - -.contentkit-text.contentkit-text-strikethrough { - @apply line-through; -} - -/** Webframe */ -.contentkit-webframe { - @apply relative; -} - -/** Card */ -.contentkit-card { - @apply flex flex-col border rounded border-tint-subtle; -} -.contentkit-card.contentkit-card-pressable { - @apply cursor-pointer hover:border-tint-hover; -} - -.contentkit-card-header { - @apply flex flex-row gap-4 px-4 py-2 items-center; -} - -.contentkit-card-header-content { - @apply flex-1; -} - -.contentkit-card-title { - @apply text-base font-medium text-tint-strong; -} - -.contentkit-card-icon { - /* unstyled */ -} - -.contentkit-card-buttons { - @apply flex flex-row gap-2; -} - -.contentkit-card-body { - @apply m-4; -} - -.contentkit-card-header + .contentkit-card-body { - @apply mt-2; -} - -/** Image */ -.contentkit-image { - @apply w-4 h-4 object-cover; -} - -/** Buttons */ -.contentkit-button { - @apply text-sm px-3 h-8 text-center inline-block py-1.5 rounded-md straight-corners:rounded-none place-self-start ring-1 ring-tint hover:ring-tint-hover shadow-sm shadow-tint dark:shadow-tint-1 hover:shadow-md active:shadow-none contrast-more:ring-tint-12 contrast-more:hover:ring-2 contrast-more:hover:ring-tint-12 hover:scale-105 active:scale-100 transition-all grow-0 shrink-0 truncate w-full; -} - -.contentkit-button-style-primary { - @apply bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover hover:text-contrast-primary-solid-hover ring-0 contrast-more:ring-1; -} - -.contentkit-button-style-secondary { - @apply bg-tint text-tint hover:bg-tint-hover hover:text-primary contrast-more:bg-tint-subtle; -} - -.contentkit-button .contentkit-icon { - @apply w-4 h-4; -} - -.contentkit-button-loading { - @apply size-5 flex mx-auto animate-spin; -} - -/** Modals */ -.contentkit-modal-backdrop { - @apply fixed inset-0 z-40 px-7 pb-11 pt-4 md:pt-[min(8vw,6rem)] flex items-start justify-center backdrop-blur-2xl bg-tint-12/4 dark:bg-tint-1/6; -} -.contentkit-modal { - @apply flex flex-col gap-6 relative z-50 bg-tint - rounded shadow-lg opacity-0 transition-opacity duration-300 border border-tint - w-full max-w-[768px] max-h-[90vh] overflow-y-auto; -} -.contentkit-modal.contentkit-modal-opened { - @apply opacity-[1]; -} - -.contentkit-modal-header { - @apply flex flex-col gap-2 px-4 py-2; -} - -.contentkit-modal-title { - @apply text-2xl font-medium text-tint-strong; -} - -.contentkit-modal-body { - @apply px-4 py-4; -} - -.contentkit-modal-header + .contentkit-modal-body { - @apply pt-0; -} - -/** Markdown */ -.contentkit-markdown { - @apply prose dark:prose-invert prose-sm; -} -.contentkit-markdown > *:first-child { - @apply mt-0; -} -.contentkit-markdown > *:last-child { - @apply mb-0; -} - -/** Text input */ -.contentkit-textinput { - @apply w-full rounded border border-tint text-tint-strong placeholder:text-tint flex resize-none flex-1 px-2 py-1.5 text-sm bg-transparent whitespace-pre-line; - @apply focus:outline-primary focus:border-primary; -} - -/** Form */ -.contentkit-form { - @apply flex flex-col gap-1; -} - -.contentkit-form:not(:first-of-type) { - @apply mt-4; -} - -.contentkit-label { - @apply text-sm font-medium text-tint-strong; -} - -/** Dividers */ -.contentkit-divider { - @apply border-tint-subtle; -} - -.contentkit-vstack > .contentkit-divider { - @apply border-t h-0 w-full; -} -.contentkit-vstack > .contentkit-divider-small { - @apply my-0; -} -.contentkit-vstack > .contentkit-divider-large { - @apply my-4; -} - -.contentkit-hstack > .contentkit-divider { - @apply border-l h-full w-0; -} -.contentkit-hstack > .contentkit-divider-small { - @apply mx-0; -} -.contentkit-hstack > .contentkit-divider-large { - @apply mx-4; -} - -/** Confirmation modal */ - -.contentkit-modal-confirm { - @apply p-4; -} -.contentkit-modal-confirm .contentkit-modal-footer { - @apply flex gap-2 justify-end; -} -.contentkit-button-confirm { - @apply w-auto flex-grow-0 flex-shrink-0; -} -.contentkit-button-style-danger { - @apply bg-danger text-danger hover:bg-danger-hover hover:text-danger-strong contrast-more:bg-tint-subtle; -} diff --git a/packages/gitbook/src/components/DocumentView/Integration/contentkit.tsx b/packages/gitbook/src/components/DocumentView/Integration/contentkit.tsx deleted file mode 100644 index 3d1f691116..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/contentkit.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { parseMarkdown } from '@/lib/markdown'; -import { Icon } from '@gitbook/icons'; -import type { ContentKitServerContext } from '@gitbook/react-contentkit'; -import { PlainCodeBlock } from '../CodeBlock'; - -export const contentKitServerContext: ContentKitServerContext = { - icons: { - maximize: (props) =>- -- , - edit: (props) => , - github: (props) => , - gitlab: (props) => , - close: (props) => , - email: (props) => , - settings: (props) => , - search: (props) => , - delete: (props) => , - star: (props) => , - warning: (props) => , - link: (props) => , - 'link-external': (props) => , - eye: (props) => , - lock: (props) => , - check: (props) => , - 'check-circle': (props) => , - 'eye-off': (props) => , - }, - codeBlock: (props) => { - return ; - }, - markdown: async ({ className, markdown }) => { - const parsed = await parseMarkdown(markdown); - return ; - }, -}; diff --git a/packages/gitbook/src/components/DocumentView/Integration/index.ts b/packages/gitbook/src/components/DocumentView/Integration/index.ts deleted file mode 100644 index 00c41e8e11..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './IntegrationBlock'; diff --git a/packages/gitbook/src/components/DocumentView/Integration/render.ts b/packages/gitbook/src/components/DocumentView/Integration/render.ts deleted file mode 100644 index 86c42d1a6a..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/render.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { GitBookBaseContext } from '@/lib/context'; -import { ignoreDataFetcherErrors } from '@/lib/data'; -import type { RenderIntegrationUI } from '@gitbook/api'; - -/** - * Render an integration UI while ignoring some errors. - */ -export async function fetchSafeIntegrationUI( - context: GitBookBaseContext, - { - integrationName, - request, - }: { - integrationName: string; - request: RenderIntegrationUI; - } -) { - const output = await ignoreDataFetcherErrors( - context.dataFetcher.renderIntegrationUi({ - integrationName, - request, - }), - - // The API can respond with certain errors that are expected to happen. - [ - 404, // Integration has been uninstalled - 400, // Integration is rejecting its own request - 422, // Integration is triggering an invalid request, failing at the validation step - 502, // Integration is failing in an unexpected way - ] - ); - - return output; -} diff --git a/packages/gitbook/src/components/DocumentView/Integration/server-actions.tsx b/packages/gitbook/src/components/DocumentView/Integration/server-actions.tsx deleted file mode 100644 index 27689c837c..0000000000 --- a/packages/gitbook/src/components/DocumentView/Integration/server-actions.tsx +++ /dev/null @@ -1,41 +0,0 @@ -'use server'; - -import { getServerActionBaseContext } from '@/lib/server-actions'; -import { traceErrorOnly } from '@/lib/tracing'; -import type { RenderIntegrationUI } from '@gitbook/api'; -import { ContentKitOutput } from '@gitbook/react-contentkit'; -import { contentKitServerContext } from './contentkit'; -import { fetchSafeIntegrationUI } from './render'; - -/** - * Server action to render an integration UI request from . - * See `render` prop in for more details. - */ -export async function renderIntegrationUi({ - renderContext, - request, -}: { - renderContext: { - integrationName: string; - }; - request: RenderIntegrationUI; -}) { - return traceErrorOnly('DocumentView.renderIntegrationUi', async () => { - const serverAction = await getServerActionBaseContext(); - const output = await fetchSafeIntegrationUI(serverAction, { - integrationName: renderContext.integrationName, - request, - }); - - if (output.error) { - return { - error: output.error.message, - }; - } - - return { - children: , - output: output.data, - }; - }); -} diff --git a/packages/gitbook/src/components/DocumentView/List.tsx b/packages/gitbook/src/components/DocumentView/List.tsx deleted file mode 100644 index 7464b1da86..0000000000 --- a/packages/gitbook/src/components/DocumentView/List.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import type { - DocumentBlockListOrdered, - DocumentBlockListTasks, - DocumentBlockListUnordered, -} from '@gitbook/api'; -import assertNever from 'assert-never'; - -import type { BlockProps } from './Block'; -import { Blocks } from './Blocks'; - -export function List( - props: BlockProps< - DocumentBlockListUnordered | DocumentBlockListOrdered | DocumentBlockListTasks - > -) { - const { block, style, ancestorBlocks, ...contextProps } = props; - - return ( - - ); -} - -function getListTag( - type: - | DocumentBlockListUnordered['type'] - | DocumentBlockListOrdered['type'] - | DocumentBlockListTasks['type'] -) { - switch (type) { - case 'list-ordered': - return 'ol'; - case 'list-unordered': - case 'list-tasks': - return 'ul'; - default: - assertNever(type); - } -} diff --git a/packages/gitbook/src/components/DocumentView/ListItem.tsx b/packages/gitbook/src/components/DocumentView/ListItem.tsx deleted file mode 100644 index fd24ab2f96..0000000000 --- a/packages/gitbook/src/components/DocumentView/ListItem.tsx +++ /dev/null @@ -1,231 +0,0 @@ -import type { - DocumentBlock, - DocumentBlockListItem, - DocumentBlockListOrdered, - DocumentBlockListUnordered, -} from '@gitbook/api'; -import assertNever from 'assert-never'; -import { assert } from 'ts-essentials'; - -import { Checkbox } from '@/components/primitives'; -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import { Blocks } from './Blocks'; -import { getBlockTextStyle } from './spacing'; - -export function ListItem(props: BlockProps ) { - const { block, ancestorBlocks, ...contextProps } = props; - - const parent = ancestorBlocks[ancestorBlocks.length - 1]; - assert( - parent?.type === 'list-ordered' || - parent?.type === 'list-unordered' || - parent?.type === 'list-tasks', - 'Invalid parent list type' - ); - - const blocksElement = ( - - ); - - switch (parent.type) { - case 'list-tasks': - return ( - - - ); - case 'list-ordered': - return ( -- - - -- - - ); - case 'list-unordered': - return ( -- - {blocksElement} -- - - ); - default: - assertNever(parent); - } -} - -function getListItemDepth(input: { - ancestorBlocks: DocumentBlock[]; - type: DocumentBlockListOrdered['type'] | DocumentBlockListUnordered['type']; -}): number { - const { ancestorBlocks, type } = input; - - let depth = -1; - - for (let i = ancestorBlocks.length - 1; i >= 0; i--) { - const block = ancestorBlocks[i]; - if (block?.type === type) { - depth = depth + 1; - continue; - } - if (block?.type === 'list-item') { - continue; - } - break; - } - - return depth; -} - -function ListItemLI(props: { block: DocumentBlockListItem; children: React.ReactNode }) { - const textStyle = getBlockTextStyle(props.block); - return- - {blocksElement} -- {props.children} ; -} - -function ListItemPrefix(props: { block: DocumentBlockListItem; children: React.ReactNode }) { - const textStyle = getBlockTextStyle(props.block); - return ( -- {props.children} -- ); -} - -function getUnorderedListItemsPrefixContent(input: { depth: number }): string { - switch (input.depth % 3) { - case 0: - return '•'; - case 1: - return '◦'; - case 2: - return '▪'; - default: - return '•'; - } -} - -function PseudoBefore(props: { - style?: React.CSSProperties; - content: string; - fontFamily?: string; -}) { - return ( - - ); -} - -function getOrderedListItemPrefixContent(input: { - depth: number; - parent: DocumentBlockListOrdered; - block: DocumentBlockListItem; -}): string { - const { parent, block } = input; - const start = parent.data.start ?? 1; - const index = parent.nodes.findIndex((node) => node.key === block.key) ?? 0; - const value = index + start; - switch (input.depth % 3) { - // Use numbers - case 0: { - return `${value}.`; - } - // Use letters - case 1: { - const letters = 'abcdefghijklmnopqrstuvwxyz'; - return `${letters[(value - 1) % letters.length]}.`; - } - // Use roman numbers - case 2: { - return `${toRoman(value).toLowerCase()}.`; - } - default: - return '•'; - } -} - -function toRoman(input: number): string { - const lookup = { - M: 1000, - CM: 900, - D: 500, - CD: 400, - C: 100, - XC: 90, - L: 50, - XL: 40, - X: 10, - IX: 9, - V: 5, - IV: 4, - I: 1, - }; - let roman = ''; - let number = input; - for (const i in lookup) { - while (number >= lookup[i as keyof typeof lookup]) { - roman += i; - number -= lookup[i as keyof typeof lookup]; - } - } - return roman; -} diff --git a/packages/gitbook/src/components/DocumentView/Math.tsx b/packages/gitbook/src/components/DocumentView/Math.tsx deleted file mode 100644 index d6b20b3799..0000000000 --- a/packages/gitbook/src/components/DocumentView/Math.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import type { DocumentBlockMath, DocumentInlineMath } from '@gitbook/api'; -import { MathFormula } from '@gitbook/react-math'; - -import { getAssetURL } from '@/lib/assets'; -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import type { InlineProps } from './Inline'; - -const assetsUrl = getAssetURL('math'); - -export async function BlockMath(props: BlockProps) { - const { block, style } = props; - - return ( - - ); -} - -export async function InlineMath(props: InlineProps ) { - const { inline } = props; - - return ; -} diff --git a/packages/gitbook/src/components/DocumentView/Mention.tsx b/packages/gitbook/src/components/DocumentView/Mention.tsx deleted file mode 100644 index 7d4db51786..0000000000 --- a/packages/gitbook/src/components/DocumentView/Mention.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { type DocumentInlineMention, SiteInsightsLinkPosition } from '@gitbook/api'; - -import { StyledLink } from '@/components/primitives'; -import { resolveContentRef } from '@/lib/references'; - -import type { InlineProps } from './Inline'; - -export async function Mention(props: InlineProps ) { - const { inline, context } = props; - - const resolved = context.contentContext - ? await resolveContentRef(inline.data.ref, context.contentContext, { - resolveAnchorText: true, - }) - : null; - - if (!resolved) { - return null; - } - - return ( - - {resolved.text} - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx deleted file mode 100644 index 539bbba2cf..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { OpenAPIOperation as BaseOpenAPIOperation } from '@gitbook/react-openapi'; - -import { resolveOpenAPIOperationBlock } from '@/lib/openapi/resolveOpenAPIOperationBlock'; -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from '../Block'; - -import './scalar.css'; -import './style.css'; -import type { AnyOpenAPIOperationsBlock } from '@/lib/openapi/types'; -import { getOpenAPIContext } from './context'; - -/** - * Render an openapi block or an openapi-operation block. - */ -export async function OpenAPIOperation(props: BlockProps) { - const { style } = props; - return ( - -- ); -} - -async function OpenAPIOperationBody(props: BlockProps- ) { - const { block, context, style } = props; - - if (!context.contentContext) { - return null; - } - - const { data, specUrl, error } = await resolveOpenAPIOperationBlock({ - block, - context: context.contentContext, - }); - - if (error) { - return ( - - Error while loading OpenAPI operation — {error.message} -
- ); - } - - if (!data || !specUrl) { - return null; - } - - return ( -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx deleted file mode 100644 index 06023a89ce..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { resolveOpenAPISchemasBlock } from '@/lib/openapi/resolveOpenAPISchemasBlock'; -import { tcls } from '@/lib/tailwind'; -import { OpenAPISchemas as BaseOpenAPISchemas } from '@gitbook/react-openapi'; - -import type { BlockProps } from '../Block'; - -import './scalar.css'; -import './style.css'; -import type { OpenAPISchemasBlock } from '@/lib/openapi/types'; -import { getOpenAPIContext } from './context'; - -/** - * Render an openapi-schemas block. - */ -export async function OpenAPISchemas(props: BlockProps ) { - const { style } = props; - return ( - -- ); -} - -async function OpenAPISchemasBody(props: BlockProps- ) { - const { block, context } = props; - - if (!context.contentContext) { - return null; - } - - const { data, specUrl, error } = await resolveOpenAPISchemasBlock({ - block, - context: context.contentContext, - }); - - if (error) { - return ( - -- ); - } - - if (!data || !specUrl) { - return null; - } - - return ( -- Error with {specUrl}: {error.message} -
-- ); -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIWebhook.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIWebhook.tsx deleted file mode 100644 index 3453cf8d77..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIWebhook.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { OpenAPIWebhook as BaseOpenAPIWebhook } from '@gitbook/react-openapi'; - -import { resolveOpenAPIWebhookBlock } from '@/lib/openapi/resolveOpenAPIWebhookBlock'; -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from '../Block'; - -import './scalar.css'; -import './style.css'; -import type { OpenAPIWebhookBlock } from '@/lib/openapi/types'; -import { getOpenAPIContext } from './context'; - -/** - * Render an openapi block or an openapi-webhook block. - */ -export async function OpenAPIWebhook(props: BlockProps ) { - const { style } = props; - return ( - -- ); -} - -async function OpenAPIWebhookBody(props: BlockProps- ) { - const { block, context } = props; - - if (!context.contentContext) { - return null; - } - - const { data, specUrl, error } = await resolveOpenAPIWebhookBlock({ - block, - context: context.contentContext, - }); - - if (error) { - return ( - -- ); - } - - if (!data || !specUrl) { - return null; - } - - return ( -- Error with {specUrl}: {error.message} -
-- ); -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/context.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/context.tsx deleted file mode 100644 index e1b6b9a63f..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/context.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import type { JSONDocument } from '@gitbook/api'; -import { Icon } from '@gitbook/icons'; -import { type OpenAPIContextInput, checkIsValidLocale } from '@gitbook/react-openapi'; - -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from '../Block'; -import { PlainCodeBlock } from '../CodeBlock'; -import { DocumentView } from '../DocumentView'; -import { Heading } from '../Heading'; - -import './scalar.css'; -import './style.css'; -import { DEFAULT_LOCALE, getSpaceLocale } from '@/intl/server'; -import type { GitBookAnyContext } from '@/lib/context'; -import type { - AnyOpenAPIOperationsBlock, - OpenAPISchemasBlock, - OpenAPIWebhookBlock, -} from '@/lib/openapi/types'; - -/** - * Get the OpenAPI context to render a block. - */ -export function getOpenAPIContext(args: { - props: BlockProps ; - specUrl: string; - context: GitBookAnyContext | undefined; -}): OpenAPIContextInput { - const { props, specUrl, context } = args; - const { block } = props; - - const customizationLocale = context ? getSpaceLocale(context) : DEFAULT_LOCALE; - const locale = checkIsValidLocale(customizationLocale) ? customizationLocale : DEFAULT_LOCALE; - - return { - specUrl, - icons: { - chevronDown: , - chevronRight: , - plus: , - copy: , - check: , - lock: , - }, - renderCodeBlock: (codeProps) => , - renderDocument: (documentProps) => ( - - ), - renderHeading: (headingProps) => ( - div]:pt-0' - : undefined, - ])} - block={{ - object: 'block', - key: `${block.key}-heading`, - meta: block.meta, - data: {}, - type: 'heading-2', - nodes: [ - { - key: `${block.key}-heading-text`, - object: 'text', - leaves: [{ text: headingProps.title, object: 'leaf', marks: [] }], - }, - ], - }} - /> - ), - defaultInteractiveOpened: props.context.mode === 'print', - id: block.meta?.id, - blockKey: block.key, - locale, - }; -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/index.ts b/packages/gitbook/src/components/DocumentView/OpenAPI/index.ts deleted file mode 100644 index a0b24ee1a6..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './OpenAPIOperation'; -export * from './OpenAPISchemas'; -export * from './OpenAPIWebhook'; diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/scalar.css b/packages/gitbook/src/components/DocumentView/OpenAPI/scalar.css deleted file mode 100644 index a335e97f68..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/scalar.css +++ /dev/null @@ -1,354 +0,0 @@ -@import "@scalar/api-client-react/style.css"; -@reference "../../RootLayout/globals.css"; - -html, -body { - /** Override Scalar's overscroll-behavior */ - @apply !overscroll-auto; -} - -.light .scalar-modal-layout, -.light .scalar-app, -.light .scalar { - --scalar-color-1: color-mix( - in srgb, - rgb(var(--tint-color-300, 180 180 180)), - rgb(var(--tint-12, 23 23 23)) 96% - ); - --scalar-color-2: color-mix( - in srgb, - var(--scalar-color-1), - transparent calc(100% - 100% * 0.72) - ); - --scalar-color-3: color-mix(in srgb, var(--scalar-color-1), transparent calc(100% - 100% * 0.4)); - --scalar-color-accent: #007d9c; - - --scalar-background-1: rgb(var(--tint-1, 255 255 255)); - --scalar-background-2: color-mix( - in srgb, - rgb(var(--tint-color-800, 30 30 30)), - var(--scalar-background-1) 96% - ); - --scalar-background-3: color-mix( - in srgb, - rgb(var(--tint-color-800, 30 30 30)), - var(--scalar-background-1) 90% - ); - --scalar-background-accent: #007d9c1f; - --scalar-code-language-color-supersede: var(--scalar-color-1); - --scalar-code-languages-background-supersede: var(--scalar-background-1); - --scalar-border-color: color-mix( - in srgb, - var(--scalar-color-1), - transparent calc(100% - 100% * 0.08) - ); - - --scalar-color-green: #0a6355; - --scalar-color-red: #dc1b19; - --scalar-color-yellow: #ffc90d; - --scalar-color-blue: rgb(var(--primary-9, 52 109 219)); - --scalar-color-orange: #ff8d4d; - --scalar-color-purple: #8250df; - - --scalar-scrollbar-color: rgba(255, 255, 255, 0.24); - --scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48); - - --scalar-button-1: rgb(49 53 56); - --scalar-button-1-color: #fff; - --scalar-button-1-hover: rgb(28 31 33); - - --scalar-shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.11); - --scalar-shadow-2: rgba(0, 0, 0, 0.08) 0px 13px 20px 0px, rgba(0, 0, 0, 0.08) 0px 3px 8px 0px, - #eeeeed 0px 0 0 1px; - - --scalar-selection-background: rgba(96, 175, 255, 0.4); - --scalar-selection-color: rgb(var(--tint-12, 22 22 22)); -} -.dark .scalar-modal-layout, -.dark .scalar-app, -.dark .scalar { - --scalar-color-1: color-mix( - in srgb, - rgb(var(--tint-color-700, 70 70 70)), - rgb(var(--tint-12, 255 255 255)) 100% - ); - --scalar-color-2: color-mix( - in srgb, - var(--scalar-color-1), - transparent calc(100% - 100% * 0.64) - ); - --scalar-color-3: color-mix(in srgb, var(--scalar-color-1), transparent calc(100% - 100% * 0.4)); - --scalar-color-accent: #50b7e0; - - --scalar-background-1: rgb(var(--tint-1, 22 22 22)); - --scalar-background-2: color-mix( - in srgb, - rgb(var(--tint-color-200, 200 200 200)), - var(--scalar-background-1) 92% - ); - --scalar-background-3: color-mix( - in srgb, - rgb(var(--tint-color-200, 200 200 200)), - var(--scalar-background-1) 88% - ); - --scalar-background-accent: #8ab4f81f; - --scalar-code-languages-background-supersede: var(--scalar-background-1); - --scalar-border-color: color-mix( - in srgb, - var(--scalar-color-1), - transparent calc(100% - 100% * 0.08) - ); - - --scalar-color-green: #56b6c2; - --scalar-color-red: rgb(245 124 97); - --scalar-color-yellow: #edbe20; - --scalar-color-blue: rgb(var(--primary-9, 93 138 226)); - --scalar-color-orange: #d19a66; - --scalar-color-purple: #5203d1; - - --scalar-scrollbar-color: rgba(0, 0, 0, 0.18); - --scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36); - - --scalar-button-1: #f6f6f6; - --scalar-button-1-color: #000; - --scalar-button-1-hover: #e7e7e7; - - --scalar-shadow-1: 0 1px 3px 0 rgb(0, 0, 0, 0.1); - --scalar-shadow-2: rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px, 0 0 0 - 1px rgba(255, 255, 255, 0.1); - - --scalar-selection-background: rgba(96, 175, 255, 0.4); - --scalar-selection-color: rgb(var(--tint-12, 255 255 255)); -} -.scalar-modal-layout, -.scalar-app, -.scalar { - --scalar-font: initial; - --scalar-font-code: var(--font-mono); - - --scalar-paragraph: 16px; - --scalar-small: 14px; - --scalar-mini: 13px; - --scalar-micro: 12px; - - --scalar-bold: 600; - --scalar-semibold: 500; - --scalar-regular: 400; - - /* Font sizes for interactive applications (not rendered text content) */ - --scalar-font-size-1: 24px; - --scalar-font-size-2: 16px; - --scalar-font-size-3: 14px; - --scalar-font-size-4: 13px; - --scalar-font-size-5: 12px; - - --scalar-line-height-1: 32px; - --scalar-line-height-2: 24px; - --scalar-line-height-3: 20px; - --scalar-line-height-4: 18px; - --scalar-line-height-5: 16px; - - --scalar-app-header-height: 35px; -} -.scalar input::placeholder { - color: var(--scalar-color-3); -} -.scalar .scalar-app-header { - width: 100%; - z-index: 1000; - padding: 6px 12px 6px 12px; - border-radius: 0.25rem 0.25rem 0 0; - font-size: 14px; - height: var(--scalar-app-header-height); - display: flex; - align-items: center; - flex-shrink: 0; - gap: 6px; -} -.scalar .scalar-api-client { - max-height: calc(100dvh - (100px + var(--scalar-app-header-height))) !important; - border-radius: 8px; -} -.scalar-api-client__close { - appearance: none; - border: none; - outline: none; - display: flex; - align-items: center; - background: transparent; - color: var(--scalar-color-1); - font-size: var(--scalar-small); - font-weight: var(--scalar-semibold); -} -.scalar-api-client__close:hover { - cursor: pointer; -} -.scalar .scalar-app-layout { - background: var(--scalar-background-3); - height: calc(100dvh - 100px); - max-width: 1280px; - width: 100%; - margin: auto; - opacity: 0; - animation: scalarapiclientfadein 0.35s forwards; - z-index: 1002; - position: relative; - overflow: hidden; - border-radius: 8px; - display: flex; - flex-direction: column; -} -@keyframes scalarapiclientfadein { - from { - transform: translate3d(0, 20px, 0) scale(0.985); - opacity: 0; - } - to { - transform: translate3d(0, 0, 0) scale(1); - opacity: 1; - } -} -.scalar .scalar-app-exit { - position: fixed; - top: 0; - left: 0; - width: 100vw; - height: 100vh; - background: rgba(0, 0, 0, 0.62); - transition: all 0.3s ease-in-out; - z-index: 1000; - cursor: pointer; - animation: scalardrawerexitfadein 0.35s forwards; -} -@keyframes scalardrawerexitfadein { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -.scalar-container { - overflow: hidden; - visibility: visible; - position: fixed; - bottom: 0; - left: 0; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 1001; - display: flex; - align-items: center; - justify-content: center; -} - -.scalar .url-form-input { - min-height: auto !important; -} - -.scalar .scalar-container { - line-height: normal; -} -.scalar .scalar-app-header span { - color: var(--scalar-color-3); -} -.scalar .scalar-app-header a { - color: var(--scalar-color-1); -} -.scalar .scalar-app-header a:hover { - text-decoration: underline; -} -.scalar-activate { - width: fit-content; - line-height: 24px; - font-size: 0.75rem; - cursor: pointer; - font-size: 0.875rem; - display: flex; - align-items: center; - gap: 6px; -} -.scalar-activate-button { - @apply flex gap-2 items-center; - @apply bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover hover:text-contrast-primary-solid-hover contrast-more:ring-1 rounded-md straight-corners:rounded-none circular-corners:rounded-full circular-corners:px-3 place-self-start; - @apply shadow-sm shadow-primary dark:shadow-primary-1 hover:shadow-md active:shadow-none; - @apply contrast-more:ring-tint-12 contrast-more:hover:ring-2 contrast-more:hover:ring-tint-12; - @apply hover:scale-105 active:scale-100 transition-all; - @apply grow-0 shrink-0 truncate; - @apply text-[13px] px-2 py-0.5 font-mono font-medium [word-spacing:-2px]; -} - -.scalar-activate-button svg { - @apply size-2.5; -} - -.scalar-app-loading { - flex: 1; - display: flex; - align-items: center; - justify-content: center; -} -.scalar .request-method { - white-space: nowrap; -} -/* Use :where to lower specificity to 0 */ -.scalar .custom-scroll { - overflow-y: auto; - scrollbar-color: transparent transparent; - scrollbar-width: thin; - -webkit-overflow-scrolling: touch; -} -.scalar .custom-scroll:hover { - scrollbar-color: rgba(0, 0, 0, 0.24) transparent; -} -.dark .scalar .custom-scroll:hover { - scrollbar-color: rgba(255, 255, 255, 0.24) transparent; -} -.scalar .custom-scroll:hover::-webkit-scrollbar-thumb { - background: var(--scalar-scrollbar-color, var(--default-theme-scrollbar-color)); - background-clip: content-box; - border: 3px solid transparent; -} -.scalar .custom-scroll::-webkit-scrollbar-thumb:active { - background: var(--scalar-scrollbar-color-active, var(--default-theme-scrollbar-color-active)); - background-clip: content-box; - border: 3px solid transparent; -} -.scalar .custom-scroll::-webkit-scrollbar-corner { - background: transparent; -} -.scalar .custom-scroll::-webkit-scrollbar { - height: 12px; - width: 12px; -} -.scalar .custom-scroll::-webkit-scrollbar-track { - background: transparent; -} -.scalar .custom-scroll::-webkit-scrollbar-thumb { - border-radius: 20px; - background: transparent; - background-clip: content-box; - border: 3px solid transparent; -} -@media (pointer: coarse) { - .scalar .custom-scroll { - padding-right: 12px; - } -} -.dark .scalar .client-wrapper-bg-color { - background: linear-gradient( - color-mix(in srgb, var(--tw-bg-base) 6%, transparent) 1%, - color-mix(in srgb, var(--scalar-background-1) 30%, black) 9% - ); -} -.light .scalar .client-wrapper-bg-color { - background-color: var(--scalar-background-2) !important; -} -.scalar .gitbook-show { - display: block !important; -} -.scalar .gitbook-hidden { - display: none !important; -} diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css deleted file mode 100644 index 53602c41df..0000000000 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css +++ /dev/null @@ -1,1039 +0,0 @@ -@reference "../../RootLayout/globals.css"; - -/* Layout Components */ -.openapi-operation, -.openapi-schemas, -.openapi-webhook { - @apply flex-1 flex flex-col gap-8 mb-14 min-w-0; -} - -.openapi-schemas { - @apply flex flex-col mb-14 gap-0 flex-1; -} - -.openapi-schemas-title { - @apply tabular-nums text-[0.813rem] leading-4 font-mono shrink-0 font-medium text-tint-strong; -} - -.openapi-columns { - @apply grid grid-cols-1 lg:grid-cols-2 gap-6 print-mode:grid-cols-1 justify-stretch; -} - -/* Introduction */ -.openapi-intro { - @apply flex flex-col gap-3; -} - -.openapi-summary { - @apply flex flex-col items-start justify-start gap-3 scroll-m-12; -} - -.openapi-summary-tags { - @apply flex flex-row gap-2 mt-[0.75em]; -} - -.openapi-deprecated, -.openapi-stability { - @apply py-0.5 px-1.5 min-w-[1.625rem] font-normal w-fit justify-center items-center ring-1 ring-inset ring-tint bg-tint rounded straight-corners:rounded-none circular-corners:rounded-sm text-sm leading-[calc(max(1.20em,1.25rem))] before:content-none! after:!content-none; -} - -.openapi-stability-alpha { - @apply text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/6 ring-amber-500/5; -} - -.openapi-stability-beta { - @apply text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/6 ring-blue-500/5; -} - -.openapi-stability-experimental { - @apply text-violet-700 dark:text-violet-300 bg-violet-50 dark:bg-violet-900/6 ring-violet-500/5; -} - -.openapi-deprecated-sunset-date { - @apply font-semibold font-mono truncate; -} - -.openapi-description.openapi-markdown, -.openapi-description.openapi-markdown code { - @apply prose-sm; -} - -/* Markdown Elements */ -.openapi-markdown blockquote { - @apply !ps-3; -} - -.openapi-markdown blockquote > * { - @apply not-italic; -} - -.openapi-markdown blockquote > p { - @apply before:content-none after:content-none !font-normal; -} - -.openapi-markdown code { - @apply py-px px-1 min-w-[1.625rem] font-normal w-fit justify-center items-center ring-1 ring-inset ring-tint bg-tint rounded straight-corners:rounded-none circular-corners:rounded-md text-sm leading-[calc(max(1.20em,1.25rem))] before:content-none! after:!content-none; -} - -.openapi-markdown pre code { - @apply bg-transparent ring-transparent; -} - -/* Markdown Base */ -.openapi-markdown { - @apply prose text-tint-strong prose-p:my-2! dark:prose-invert max-w-none whitespace-normal; -} - -.openapi-markdown > *:first-child { - @apply !mt-0; -} - -.openapi-markdown > *:last-child { - @apply !mb-0; -} - -/* Method Tags */ -.openapi-method, -.openapi-statuscode { - @apply rounded straight-corners:rounded-none circular-corners:rounded-md uppercase font-mono items-center shrink-0 font-semibold text-[0.813rem] px-1 py-0.5 mr-2 text-tint-12/8 leading-tight align-middle inline-flex ring-1 ring-inset ring-tint-12/1 dark:ring-tint-1/1 whitespace-nowrap; -} - -.openapi-method-get, -.openapi-statuscode-success { - @apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100; -} - -.openapi-method-post, -.openapi-statuscode-redirection { - @apply bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-100; -} - -.openapi-method-put, -.openapi-statuscode-informational { - @apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-100; -} - -.openapi-method-patch { - @apply bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-100; -} - -.openapi-method-delete, -.openapi-statuscode-error { - @apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100; -} - -.openapi-method-head, -.openapi-method-options, -.openapi-method-trace { - @apply bg-tint; -} - -/* URL */ -.openapi-url { - @apply font-mono text-sm text-tint; -} - -.openapi-url-var { - @apply text-tint underline underline-offset-2 decoration-tint-subtle; -} - -/* Column Layout */ -.openapi-column-spec { - @apply flex flex-col gap-8 flex-1; -} - -.openapi-column-preview { - @apply flex flex-col flex-1 xl:max-2xl:pt-20 lg:py-6 sticky max-h-[calc(100vh-var(--toc-top-offset))] top-(--toc-top-offset); -} - -.openapi-column-preview-body { - @apply flex flex-col shrink overflow-hidden gap-4 print-mode:static; -} - -.openapi-column-preview pre { - @apply max-h-96 print-mode:max-h-none; -} - -/* Schema Structure */ -.openapi-schema-root { - /* unstyled */ -} - -.openapi-schema-root-description.openapi-markdown { - @apply prose-sm text-balance mt-1.5 text-[0.813rem]! text-tint overflow-hidden font-normal! select-text prose-strong:font-semibold prose-strong:text-inherit; -} - -.openapi-section-schemas > .openapi-section-body > .openapi-schema-root-description { - @apply px-2.5 pt-2.5 mt-0 !text-sm; -} - -.openapi-schema-properties { - @apply flex flex-col; -} - -.openapi-schema, -.openapi-disclosure { - @apply py-2.5 flex flex-col gap-2; -} - -.openapi-schema-properties .openapi-schema:last-child { - @apply border-b-0; -} - -/* Schema Presentation */ -.openapi-schema-presentation { - @apply flex flex-col gap-1 font-normal; -} - -.openapi-schema-properties:last-child { - @apply pb-0; -} - -.openapi-schema-name { - /* To make double click on the property name select only the name, - we disable selection on the parent and re-enable it on the children. */ - @apply select-none text-sm text-balance *:whitespace-nowrap flex flex-wrap gap-y-1.5 gap-x-2.5 items-center; -} - -.openapi-schema-name .openapi-deprecated { - @apply text-xs; -} - -.openapi-schema-propertyname { - @apply select-all font-mono font-semibold text-tint-strong; -} - -.openapi-schema-propertyname[data-deprecated="true"] { - @apply line-through opacity-9; -} - -.openapi-schema-discriminator { - @apply text-primary-subtle/9 text-[0.813rem] lowercase; -} - -.openapi-schema-required { - @apply text-warning-subtle text-[0.813rem] lowercase; -} - -.openapi-schema-optional { - @apply text-tint-subtle text-[0.813rem] lowercase; -} - -.openapi-schema-readonly { - @apply text-primary-subtle/9 text-[0.813rem] lowercase; -} - -.openapi-schema-writeonly { - @apply text-success dark:text-success-subtle/9 text-[0.813rem] lowercase; -} - -.openapi-schema-types { - @apply flex items-baseline flex-wrap gap-1; -} - -.openapi-schema-type { - @apply text-tint select-text text-[0.813rem] font-mono [word-spacing:-0.25rem]; -} - -.openapi-schema-type:only-child { - @apply ml-0; -} - -/* Schema Header */ -.openapi-schema-header { - @apply flex flex-row items-center; -} - -.openapi-schema-intro { - @apply flex-1; -} - -.openapi-schema-circular { - @apply text-xs text-tint; -} - -.openapi-schema-circular a { - @apply underline; -} - -.openapi-schema-circular-glyph { - @apply text-base; -} - -/* Schema Enum */ -.openapi-schema-enum { - @apply text-sm leading-relaxed max-w-full text-tint; -} - -.openapi-schema-enum-value { - @apply text-sm mr-1.5; -} - -.openapi-schema-enum-value:first-child { - @apply rounded-l straight-corners:rounded-none circular-corners:rounded-l-md ml-0; -} - -.openapi-schema-enum-value:last-child { - @apply rounded-r straight-corners:rounded-none circular-corners:rounded-r-md; -} - -/* Schema Description */ -.openapi-schema-description.openapi-markdown { - @apply prose-sm text-tint overflow-hidden text-pretty font-normal! select-text prose-strong:font-semibold prose-strong:text-inherit; -} - -.openapi-schema-description.openapi-markdown pre:has(code) { - @apply overflow-x-auto flex-1 w-fit max-w-full h-fit whitespace-pre; - scrollbar-width: none; - -ms-overflow-style: none; -} - -.openapi-schema-description.openapi-markdown pre::-webkit-scrollbar { - display: none; -} - -.openapi-schema-description.openapi-markdown pre code { - font-weight: inherit !important; - @apply text-xs !py-0; -} - -/* Schema Examples */ -.openapi-schema-example, -.openapi-schema-pattern, -.openapi-schema-default { - @apply prose-sm text-tint; -} - -.openapi-schema-example code, -.openapi-schema-pattern code, -.openapi-schema-enum-value code, -.openapi-schema-default code { - @apply py-px px-1 min-w-[1.625rem] text-tint-strong font-normal w-fit justify-center items-center ring-1 ring-inset ring-tint-subtle bg-tint rounded straight-corners:rounded-none circular-corners:rounded-md text-xs leading-[calc(max(1.20em,1.25rem))] before:content-none! after:!content-none; -} - -/* Authentication */ -.openapi-securities-header { - @apply py-2 border-b border-tint-subtle max-w-full flex-1; -} - -.openapi-securities-oauth-flows { - @apply flex flex-col gap-3; -} - -.openapi-securities-oauth-content, -.openapi-securities-scopes { - @apply prose *:!prose-sm *:text-tint; -} - -.openapi-securities-oauth-content { - @apply flex flex-col gap-1 mt-1; -} - -.openapi-securities-oauth-content.openapi-markdown code { - @apply text-xs; -} - -.openapi-securities-scopes ul { - @apply !my-0 ml-4 pl-0; -} - -.openapi-securities-url { - @apply ml-0.5 px-0.5 rounded straight-corners:rounded-none circular-corners:rounded-md hover:bg-tint dark:hover:bg-tint-hover transition-colors; -} - -.openapi-securities-body { - @apply flex flex-col gap-2; -} - -.openapi-securities-description.openapi-markdown { - @apply prose-sm text-tint font-normal! select-text text-pretty prose-strong:font-semibold prose-strong:text-inherit; -} - -.openapi-securities-label { - @apply font-medium text-sm text-tint-strong; -} - -/* Parameters */ -.openapi-parameters-header { - @apply py-2 border-b border-tint-subtle max-w-full flex-1; -} - -.openapi-parameters-header-content { - /* unstyled */ -} - -/* Request Body */ -.openapi-requestbody-header { - @apply py-2 border-b border-tint-subtle max-w-full flex-1; -} - -.openapi-requestbody-header-content { - /* unstyled */ - @apply flex flex-row items-center gap-2.5; -} - -.openapi-requestbody-header-type { - @apply text-tint select-text text-[0.813rem] font-mono font-normal [word-spacing:-0.25rem]; -} - -.openapi-requestbody-description.openapi-markdown { - @apply prose-sm text-tint font-normal! text-pretty select-text prose-strong:font-semibold prose-strong:text-inherit; -} - -/* Responses */ -.openapi-responses-header { - @apply py-2 max-w-full flex-1; -} - -.openapi-responses-header-content { - /* unstyled */ -} - -.openapi-response-tab-content { - @apply flex items-baseline truncate grow shrink max-w-max basis-full mr-auto; - @apply text-left text-pretty relative leading-tight text-tint select-text; -} - -.openapi-response-description.openapi-markdown { - @apply text-left prose-sm text-sm leading-tight text-tint select-text prose-strong:font-semibold prose-strong:text-inherit; -} - -.openapi-disclosure-group-trigger[aria-expanded="false"] .openapi-response-description.openapi-markdown { - @apply truncate; - @apply [&>*:not(:first-child)]:hidden *:truncate *:!p-0 *:!m-0; -} - -.openapi-disclosure-group-trigger[aria-expanded="false"] .openapi-response-tab-content { - @apply basis-[60%]; -} - -.openapi-response-body { - @apply flex flex-col; -} - -/* Response Body and Headers */ -.openapi-responsebody .openapi-schema-name { - @apply mb-0; -} - -.openapi-responsebody .openapi-schema-presentation { - @apply py-0; -} - -.openapi-responsebody-header, -.openapi-responseheaders-header { - @apply px-3 py-1; -} - -/* Code Sample */ -.openapi-codesample-header { - @apply flex flex-row items-center; -} - -.openapi-response-media-types-examples-footer-content { - @apply flex flex-row items-center gap-2.5; -} - -.openapi-panel-heading, -.openapi-codesample-header, -.openapi-response-examples-header { - @apply border-b border-tint-subtle; -} - -.openapi-response-examples-header .openapi-select > button { - @apply max-w-full overflow-hidden shrink pl-0.5 py-0.5; -} - -.openapi-response-examples-header .openapi-select > button .openapi-statuscode { - @apply h-full; -} - -.openapi-codesample-header-content { - @apply flex flex-row items-center justify-between h-fit p-2.5; -} - -.openapi-codesample-header-content .openapi-path { - @apply flex items-center font-mono text-[0.813rem] gap-1 h-fit *:truncate overflow-x-auto min-w-0 max-w-full font-normal text-tint-strong; -} - -.openapi-codesample-header-content .openapi-path-title { - @apply block; -} - -.openapi-codesample-header-content .openapi-path .openapi-path-variable { - @apply text-[0.813rem]; -} - -.openapi-codesample-footer { - @apply flex gap-3 w-full justify-between flex-wrap; -} - -.openapi-codesample-selectors { - @apply flex flex-row items-center gap-3 flex-wrap; -} - -/* Path */ -.openapi-path { - @apply flex items-center text-sm gap-2 h-fit overflow-x-auto min-w-0 max-w-full; - scrollbar-width: none; - -ms-overflow-style: none; -} - -.openapi-path-variable { - @apply p-px min-w-[1.625rem] text-tint-strong font-normal w-fit justify-center items-center ring-1 ring-inset ring-tint bg-tint rounded straight-corners:rounded-none circular-corners:rounded-md text-sm leading-none before:content-none! after:!content-none; -} - -.openapi-path-server { - @apply text-tint inline; -} - -.openapi-summary .openapi-path .openapi-method { - @apply m-0 items-center flex px-2 py-1 h-6; -} - -.openapi-path-title { - @apply flex-1 relative font-normal items-center gap-y-1 flex flex-wrap text-left overflow-x-auto font-mono text-tint-strong/10; - @apply whitespace-nowrap md:whitespace-normal; - scrollbar-width: none; - -ms-overflow-style: none; -} - -.openapi-path-title-row{ - @apply flex flex-row items-center; -} - -.openapi-path-title[data-deprecated="true"] { - @apply line-through; -} - -.openapi-path-title::-webkit-scrollbar { - display: none; -} - -.openapi-path-title em { - @apply not-italic text-primary font-medium; -} - -.openapi-path-separator { - @apply text-tint; -} - -.openapi-path-overlay { - @apply flex flex-row items-center py-2 px-3 justify-end border-t border-tint-subtle; -} - -/* Panel */ -.openapi-panel, -.openapi-codesample, -.openapi-response-examples { - @apply border shrink min-h-40 overflow-hidden rounded-lg straight-corners:rounded-none circular-corners:rounded-xl bg-tint-subtle border-tint-subtle shadow-sm; -} - -.openapi-response-examples-panel { - @apply flex flex-col shrink overflow-hidden; -} - -.openapi-codesample-panel { - @apply flex flex-col shrink overflow-hidden; -} - -.openapi-panel pre, -.openapi-codesample pre, -.openapi-response-examples pre { - @apply bg-transparent border-none rounded-none shrink shadow-none; -} - -.openapi-panel-heading { - @apply font-medium px-4 py-2 text-xs uppercase; -} - -.openapi-panel-body { - @apply relative; -} - -.openapi-panel-footer, -.openapi-codesample-footer { - @apply px-3 py-2 pt-2.5 border-t border-tint-subtle text-[0.813rem] text-tint empty:hidden; -} - -.openapi-panel-footer .openapi-markdown { - @apply text-[0.813rem] text-tint; -} - -/* Example */ -.openapi-response-examples-header { - @apply flex flex-row items-center p-2.5; -} - -.openapi-response-examples-header-content { - @apply max-w-full overflow-hidden truncate; -} - -.openapi-response-examples-statuscode-title { - @apply flex items-center; -} - -.openapi-response-examples-header .openapi-select > button, -.openapi-response-examples-header .openapi-markdown, -.openapi-response-examples-statuscode-title { - @apply text-[0.813rem] truncate text-tint font-normal; -} - -.openapi-response-examples-statuscode-label { - @apply truncate; -} - -.openapi-response-examples-panel, -.openapi-codesample-panel { - @apply flex-1 text-sm relative focus-visible:outline-none; -} - -.openapi-example-empty { - @apply relative text-tint min-h-20 flex flex-col justify-center items-center text-sm; -} - -/* Common Elements */ -.openapi-select { - @apply w-auto max-w-full; -} - -/* Prevent react-aria popover from setting overflow:auto on body */ -body:has(.openapi-select-popover) { - overflow: unset !important; -} - -.openapi-select > button { - @apply flex items-center font-normal cursor-pointer *:truncate gap-1.5 p-1.5 border border-tint-subtle text-tint-strong rounded straight-corners:rounded-none circular-corners:rounded-md leading-none; - @apply hover:bg-tint dark:hover:bg-tint-hover transition-all; -} - -.openapi-select:not(.openapi-select-unstyled) > button { - @apply border border-tint-subtle bg-tint text-xs; -} - -.openapi-select-unstyled > button { - @apply p-1 *:truncate max-w-full; -} - -.openapi-select > button[data-focused="true"] { - @apply outline-primary -outline-offset-1 outline; -} - -.openapi-select > button > span.react-aria-SelectValue { - @apply shrink truncate flex items-center; -} - -.openapi-select > button > .react-aria-SelectValue [slot="description"] { - display: none; -} - -.openapi-select > button .openapi-markdown { - @apply *:leading-none; -} - -.openapi-select > button .gb-icon { - @apply size-2.5 shrink-0; -} - -.openapi-select-popover { - @apply min-w-32 z-10 max-w-[max(20rem,var(--trigger-width))] overflow-x-hidden max-h-52 overflow-y-auto p-1.5 border border-tint-subtle bg-tint-base backdrop-blur-xl rounded-md straight-corners:rounded-none circular-corners:rounded-xl; - @apply shadow-md shadow-tint-12/1 dark:shadow-tint-1/1; -} - -.openapi-select-popover[data-entering] { - animation: popover-enter 0.2s ease-in-out; -} - -.openapi-select-popover[data-exiting] { - animation: popover-leave 0.2s ease-in-out; -} - -.openapi-select-item { - @apply text-sm flex items-center cursor-pointer px-1.5 overflow-hidden py-1 text-tint ring-0 border-none rounded straight-corners:rounded-none circular-corners:rounded-md !outline-none; - @apply hover:bg-tint-hover hover:theme-gradient:bg-tint-12/1 hover:text-tint-strong contrast-more:hover:ring-1 contrast-more:hover:ring-inset contrast-more:hover:ring-current; -} - -.openapi-select-item.openapi-select-item-column { - @apply flex flex-col gap-1 justify-start items-start; -} - -.openapi-select-item [slot="description"] { - @apply text-xs text-tint-subtle; -} - -.openapi-select button .openapi-markdown, -.openapi-select-item .openapi-markdown { - @apply text-[0.813rem] *:truncate *:!p-0 *:!m-0 [&>*:not(:first-child)]:hidden; -} - -.openapi-select-item-selected, -.openapi-select-item-selected .openapi-markdown { - @apply text-primary-subtle hover:text-primary hover:bg-primary-hover; - @apply hover:theme-muted:bg-primary-active hover:theme-gradient:bg-primary-active tint:font-semibold; - @apply contrast-more:text-primary contrast-more:hover:text-primary-strong contrast-more:font-semibold; -} - -.openapi-select-listbox { - @apply flex flex-col gap-1 focus:ring-0 focus:outline-none; -} - -.openapi-select:focus { - width: auto; -} - -/* Section Components */ -.openapi-section { - @apply flex flex-col overflow-hidden; -} - -.openapi-section-body { - @apply flex flex-col shrink overflow-hidden; -} - -.openapi-section-header { - @apply flex flex-row items-center; -} - -.openapi-section-header-content { - @apply flex-1 overflow-hidden text-base gap-1.5 flex w-full font-medium text-tint-strong; -} - -.openapi-section-header-controls { - @apply flex flex-row items-center gap-2; -} - -.openapi-section-header-content:has(.openapi-section-toggle) { - @apply cursor-pointer; -} - -.openapi-section-header-content:hover .openapi-section-toggle { - @apply text-tint; -} - -.openapi-section-footer { - @apply flex flex-row items-center p-2.5 gap-2.5 text-sm text-tint-strong border-t border-tint-subtle; -} - -.openapi-section-footer-content { - @apply text-sm text-tint-strong; -} - -.openapi-section-toggle { - @apply text-tint-subtle contrast-more:text-tint-strong; -} - -.openapi-section-toggle > svg { - @apply transition-all; -} - -.openapi-section-toggle[aria-expanded="true"] > svg { - @apply rotate-90; -} - -.openapi-section-toggle:focus-visible { - @apply text-primary; -} - -.openapi-section-toggle svg { - @apply size-3; -} - -/* Tabs */ -.openapi-panel-header, -.openapi-tabs-list { - @apply flex flex-row gap-1.5 py-1.5 px-2.5 w-full overflow-x-auto no-scrollbar; -} - -.openapi-tabs-tab { - @apply hover:bg-primary-hover whitespace-nowrap font-mono font-normal tabular-nums hover:text-primary cursor-pointer transition-all relative text-[0.813rem] text-tint px-1 border border-transparent rounded straight-corners:rounded-none circular-corners:rounded-md; -} - -.openapi-tabs-tab[aria-selected="true"] { - @apply text-primary-subtle! after:absolute after:-bottom-[calc(0.375rem+1px)] after:z-20 after:left-0 after:w-full after:h-px after:bg-primary-solid after:transition-all; -} - -.openapi-tabs-panel { - @apply flex-1 text-sm relative focus-visible:outline-none; - @apply before:w-full before:h-px before:absolute before:bg-tint-6 before:-top-px before:z-10; -} - -/* Disclosure group */ -.openapi-disclosure-group { - @apply border-tint-subtle transition-all border-b border-x overflow-auto last:rounded-b-md straight-corners:last:rounded-none circular-corners:last:rounded-b-xl first:rounded-t-md straight-corners:first:rounded-none circular-corners:first:rounded-t-xl first:border-t relative; -} - -.openapi-disclosure-group:has(.openapi-disclosure-group-trigger:hover) { - @apply bg-tint-subtle; -} - -.openapi-disclosure-group:has(.openapi-disclosure-group-trigger:hover):has(.openapi-select:hover) { - @apply !bg-transparent; -} - -.openapi-disclosure-group-trigger { - @apply flex w-full cursor-pointer items-baseline gap-3 transition-all relative flex-1 p-3 -outline-offset-1; -} - -.openapi-disclosure-group-label { - @apply flex flex-wrap items-baseline gap-x-3 gap-y-1 flex-1 truncate; -} - -.openapi-disclosure-group-trigger[aria-disabled="true"] { - @apply cursor-default hover:bg-inherit; -} - -.openapi-disclosure-group-trigger[aria-disabled="true"] .openapi-disclosure-group-icon { - @apply invisible; -} - -.openapi-disclosure-group-icon > svg { - @apply size-3 text-tint-subtle transition-all duration-300; -} - -.openapi-disclosure-group-trigger:hover > .openapi-disclosure-group-icon svg { - @apply text-tint-strong; -} - -.openapi-disclosure-group-panel { - @apply px-3 transition-all; -} - -.openapi-disclosure-group-trigger[aria-expanded="true"] > .openapi-disclosure-group-label { - @apply font-medium; -} - -.openapi-disclosure-group-trigger[aria-expanded="true"] > .openapi-disclosure-group-icon > svg { - @apply rotate-90; -} - -.openapi-disclosure-group-mediatype:not(:has(.openapi-select)) { - @apply text-[0.625rem] font-mono shrink-0 grow-0 text-tint-subtle contrast-more:text-tint; -} - -/* Disclosure */ -.openapi-schemas-disclosure { - @apply border-t border-x last:border-b border-tint-subtle !ring-0 first:!rounded-t-xl last:!rounded-b-xl !rounded-none; -} - -.openapi-schemas-disclosure > .openapi-disclosure-trigger { - @apply flex items-center font-mono transition-all font-normal text-tint-strong !text-sm hover:bg-tint-subtle dark:hover:bg-tint-hover relative flex-1 gap-2.5 p-5 truncate -outline-offset-1; -} - -.openapi-schemas-disclosure > .openapi-disclosure-trigger, -.openapi-schemas-disclosure .openapi-disclosure-panel { - @apply straight-corners:!rounded-none circular-corners:!rounded-md; -} - -.openapi-disclosure-panel { - @apply ml-1.5 pl-3 border-l border-tint-subtle; -} - -.openapi-schema .openapi-schema-properties .openapi-schema { - animation: fadeIn 0.2s ease-in-out both; -} - -.openapi-schemas-disclosure > .openapi-disclosure-trigger[aria-expanded="true"] > svg { - @apply rotate-90; -} - -.openapi-disclosure-trigger { - @apply flex flex-row justify-between flex-wrap relative items-start gap-2 text-left -mx-3 px-3 -my-2.5 py-2.5 pr-10; -} - -.openapi-disclosure { - @apply -mx-3 px-3 py-2.5 transition-all flex flex-col ring-tint-subtle; -} - -.openapi-disclosure:not( - .openapi-disclosure-group .openapi-disclosure, - .openapi-schema-alternatives .openapi-disclosure, - .openapi-schemas-disclosure .openapi-schema.openapi-disclosure - ) { - @apply rounded-md circular-corners:rounded-xl straight-corners:rounded-none; -} - -.openapi-disclosure .openapi-schemas-disclosure .openapi-schema.openapi-disclosure { - @apply !rounded-none; -} - -.openapi-disclosure:has(> .openapi-disclosure-trigger:hover) { - @apply bg-tint-subtle overflow-hidden; -} - -.openapi-disclosure[data-expanded="true"] { - @apply ring-1 shadow-sm; -} - -.openapi-disclosure[data-expanded="true"]:not(.openapi-schemas-disclosure,.openapi-required-scopes):not(:first-child) { - @apply mt-2; -} -.openapi-disclosure[data-expanded="true"]:not(.openapi-schemas-disclosure,.openapi-required-scopes):not(:last-child) { - @apply mb-2; -} - -.openapi-disclosure-trigger-label { - @apply absolute right-3 mr-px px-2 h-5 justify-end shrink-0 ring-tint-subtle truncate text-tint duration-300 transition-all rounded straight-corners:rounded-none circular-corners:rounded-xl flex flex-row gap-1 items-center text-xs; -} - -.openapi-disclosure-trigger-label span { - @apply hidden; -} - -.openapi-disclosure-trigger-label svg { - @apply size-3 shrink-0 transition-transform duration-300 text-tint-subtle; -} - -.openapi-disclosure-trigger:hover > .openapi-disclosure-trigger-label, -.openapi-disclosure-trigger[aria-expanded="true"] > .openapi-disclosure-trigger-label { - @apply shadow ring-1 bg-tint-base; -} - -.openapi-disclosure-trigger:hover > .openapi-disclosure-trigger-label span, -.openapi-disclosure-trigger[aria-expanded="true"] > .openapi-disclosure-trigger-label span { - @apply block; - animation: fadeIn 0.2s ease-in-out both; -} - -@media (hover: none) { - /* Make button label always visible on non-hover devices like phones */ - .openapi-disclosure-trigger-label { - @apply relative ring-1 bg-tint-base right-0; - } - .openapi-disclosure-trigger-label span { - @apply block; - } - .openapi-disclosure-trigger { - @apply pr-3; - } -} - -.openapi-disclosure-trigger[aria-expanded="true"] svg { - @apply rotate-45; -} - -.openapi-disclosure-trigger[aria-expanded="false"] { - @apply w-auto; -} - -.openapi-section-body.openapi-schema.openapi-schema-root { - @apply space-y-2.5; -} - -.openapi-section-schemas > .openapi-section-body > .openapi-schema-properties > .openapi-schema, -.openapi-section-schemas > .openapi-section-body > .openapi-schema-root { - @apply p-2.5; -} - -.openapi-schema-alternatives { - @apply ml-1.5 pl-3 border-l border-tint-subtle; -} -.openapi-schema-alternative { - @apply relative; -} -.openapi-schema-alternative-separator { - @apply p-0.5 tracking-wide leading-none uppercase text-[0.625rem] text-tint-subtle whitespace-nowrap absolute -left-3 -bottom-2.5 -translate-x-1/2 z-10 bg-tint-base border-y border-tint-subtle -rotate-6; -} - -.openapi-tooltip { - @apply flex items-center gap-1 bg-tint-base border border-tint-subtle text-tint-strong rounded-md straight-corners:rounded-none circular-corners:rounded-lg font-medium px-1.5 py-0.5 shadow-sm text-[13px]; -} - -.openapi-tooltip svg { - @apply size-3 text-tint-strong; -} - -.openapi-tooltip[data-entering] { - animation: tooltip-enter 0.2s ease-in-out forwards; -} - -.openapi-tooltip[data-exiting] { - animation: tooltip-leave 0.2s ease-in-out forwards; -} - -@keyframes tooltip-enter { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} - -@keyframes tooltip-leave { - 0% { - opacity: 1; - } - 100% { - opacity: 0; - } -} - -@keyframes popover-enter { - 0% { - opacity: 0; - transform: translateY(4px) scale(0.95); - } - 100% { - opacity: 1; - transform: translateY(0) scale(1); - } -} - -@keyframes popover-leave { - from { - opacity: 1; - transform: translateY(0) scale(1); - } - to { - opacity: 0; - transform: translateY(4px) scale(0.95); - } -} - -.openapi-copy-button { - @apply hover:brightness-95 cursor-pointer; -} - -.openapi-copy-button[data-disabled="true"] { - @apply cursor-default; -} - -.openapi-path-copy-button { - @apply p-1 flex rounded-md straight-corners:rounded-none; - @apply hover:bg-tint dark:hover:bg-tint-hover; -} - -.openapi-path-copy-button-icon { - @apply size-6 opacity-0 transition-all hidden sm:flex; -} - -.openapi-path:hover .openapi-path-copy-button-icon { - @apply opacity-100; -} - -.openapi-path-copy-button-icon svg { - @apply text-tint size-4; -} - -.openapi-required-scopes { - @apply border text-base rounded-md straight-corners:rounded-none circular-corners:rounded-md font-medium mx-0; -} - -.openapi-required-scopes .openapi-required-scopes-header { - @apply flex items-center gap-3; -} - -.openapi-required-scopes .openapi-required-scopes-header svg { - @apply size-3.5 text-tint-subtle rotate-none; -} - -.openapi-required-scopes .openapi-disclosure-group-panel { - @apply px-3 pb-3; -} -.openapi-required-scopes .openapi-securities-scopes { - @apply ml-6 font-normal *:!text-[0.8125rem]; -} - -.openapi-required-scopes .openapi-required-scopes-description { - @apply text-xs !text-tint font-normal mb-2; -} \ No newline at end of file diff --git a/packages/gitbook/src/components/DocumentView/Paragraph.tsx b/packages/gitbook/src/components/DocumentView/Paragraph.tsx deleted file mode 100644 index e96a8aa7b0..0000000000 --- a/packages/gitbook/src/components/DocumentView/Paragraph.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import type { DocumentBlockParagraph } from '@gitbook/api'; - -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import { Inlines } from './Inlines'; -import { getTextAlignment } from './utils'; - -export function Paragraph(props: BlockProps ) { - const { block, style, ...contextProps } = props; - - return ( - -
- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Quote.tsx b/packages/gitbook/src/components/DocumentView/Quote.tsx deleted file mode 100644 index 6b3b0de3d4..0000000000 --- a/packages/gitbook/src/components/DocumentView/Quote.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import type { DocumentBlockQuote } from '@gitbook/api'; - -import type { BlockProps } from './Block'; -import { Blocks } from './Blocks'; - -export function Quote(props: BlockProps- ) { - const { block, style, ancestorBlocks, ...contextProps } = props; - - return ( - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/ReusableContent.tsx b/packages/gitbook/src/components/DocumentView/ReusableContent.tsx deleted file mode 100644 index 5ef0b10009..0000000000 --- a/packages/gitbook/src/components/DocumentView/ReusableContent.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import type { DocumentBlockReusableContent } from '@gitbook/api'; - -import { getDataOrNull } from '@/lib/data'; -import { resolveContentRef } from '@/lib/references'; -import type { BlockProps } from './Block'; -import { UnwrappedBlocks } from './Blocks'; - -export async function ReusableContent(props: BlockProps ) { - const { block, context, ancestorBlocks } = props; - - if (!context.contentContext) { - throw new Error('Expected a content context to render a reusable content block'); - } - - const dataFetcher = block.meta?.token - ? context.contentContext.dataFetcher.withToken({ apiToken: block.meta.token }) - : context.contentContext.dataFetcher; - - const resolved = await resolveContentRef(block.data.ref, { - ...context.contentContext, - dataFetcher, - }); - - if (!resolved) { - return null; - } - - const { reusableContent } = resolved; - if (!reusableContent) { - return null; - } - - const document = await getDataOrNull( - dataFetcher.getRevisionReusableContentDocument({ - spaceId: reusableContent.context.space.id, - revisionId: reusableContent.context.revisionId, - reusableContentId: reusableContent.revisionReusableContent.id, - }) - ); - - if (!document) { - return null; - } - - return ( - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/Stepper.tsx b/packages/gitbook/src/components/DocumentView/Stepper.tsx deleted file mode 100644 index 49ea5967a4..0000000000 --- a/packages/gitbook/src/components/DocumentView/Stepper.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import type { DocumentBlockStepper } from '@gitbook/api'; - -import type { BlockProps } from './Block'; -import { Blocks } from './Blocks'; - -export function Stepper(props: BlockProps ) { - const { block, style, ancestorBlocks, ...contextProps } = props; - - return ( - - ); -} diff --git a/packages/gitbook/src/components/DocumentView/StepperStep.tsx b/packages/gitbook/src/components/DocumentView/StepperStep.tsx deleted file mode 100644 index 2c16ab9237..0000000000 --- a/packages/gitbook/src/components/DocumentView/StepperStep.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import type { DocumentBlockStepperStep } from '@gitbook/api'; -import { assert } from 'ts-essentials'; - -import { tcls } from '@/lib/tailwind'; - -import type { BlockProps } from './Block'; -import { Blocks } from './Blocks'; - -export function StepperStep(props: BlockProps ) { - const { block, style, ancestorBlocks, ...contextProps } = props; - - const ancestor = ancestorBlocks[ancestorBlocks.length - 1]; - assert(ancestor?.type === 'stepper', 'Ancestor block must be a stepper'); - - const index = ancestor.nodes.indexOf(block); - - const firstChild = block.nodes[0]; - const marginAdjustClassName = (() => { - if (!firstChild) { - return ''; - } - switch (firstChild.type) { - case 'heading-1': - return '-mt-9'; - case 'heading-2': - return '-mt-[calc(1.25rem+1px)]'; - case 'heading-3': - return '-mt-[calc(0.50rem+1px)]'; - default: - return ''; - } - })(); - - return ( - -- ); -} diff --git a/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx b/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx deleted file mode 100644 index 93bff135b0..0000000000 --- a/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx +++ /dev/null @@ -1,225 +0,0 @@ -import { LinkBox, LinkOverlay } from '@/components/primitives'; -import { Image } from '@/components/utils'; -import { type ResolvedContentRef, resolveContentRef } from '@/lib/references'; -import { tcls } from '@/lib/tailwind'; -import { - CardsImageObjectFit, - type ContentRef, - type DocumentTableViewCards, - SiteInsightsLinkPosition, -} from '@gitbook/api'; -import { RecordColumnValue } from './RecordColumnValue'; -import type { TableRecordKV, TableViewProps } from './Table'; -import { RecordCardStyles } from './styles'; -import { getRecordCardCovers } from './utils'; - -export async function RecordCard( - props: TableViewProps--- {index + 1} -- -*+*]:mt-5', marginAdjustClassName]} - /> - & { - record: TableRecordKV; - } -) { - const { view, record, context, block, isOffscreen } = props; - - const { dark, light } = getRecordCardCovers(record[1], view); - const targetRef = view.targetDefinition - ? (record[1].values[view.targetDefinition] as ContentRef) - : null; - - const [lightCover, darkCover, target] = await Promise.all([ - light.contentRef && context.contentContext - ? resolveContentRef(light.contentRef, context.contentContext) - : null, - dark.contentRef && context.contentContext - ? resolveContentRef(dark.contentRef, context.contentContext) - : null, - targetRef && context.contentContext - ? resolveContentRef(targetRef, context.contentContext) - : null, - ]); - - const darkCoverIsSquareOrPortrait = isSquareOrPortrait(darkCover); - const lightCoverIsSquareOrPortrait = isSquareOrPortrait(lightCover); - - const darkObjectFit = `dark:${getObjectFitClass(dark.objectFit)}`; - const lightObjectFit = getObjectFitClass(light.objectFit); - const objectFits = `${lightObjectFit} ${darkObjectFit}`; - - const body = ( - div:first-child]:hidden', - '[&_.heading>div]:text-[.8em]', - '@xl:[&_.heading>div]:text-[1em]', - '[&_.blocks:first-child_.heading]:pt-0', // Remove padding-top on first heading in card - - // On mobile, check if we can display the cover responsively or not: - // - If the file has a landscape aspect ratio, we display it normally - // - If the file is square or portrait, we display it left with 40% of the card width - lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait - ? [ - lightCoverIsSquareOrPortrait - ? '@sm:grid-cols-none grid-cols-[40%__1fr] @sm:grid-rows-[auto_1fr]' - : '', - darkCoverIsSquareOrPortrait - ? 'dark:@sm:grid-cols-none dark:grid-cols-[40%__1fr] dark:@sm:grid-rows-[auto_1fr]' - : '', - ].filter(Boolean) - : 'grid-rows-[auto_1fr]' - )} - > - {lightCover ? ( -- ) : null} - - {view.columns.map((column) => { - const definition = block.data.definition[column]; - - if (!definition) { - return null; - } - - if (!view.hideColumnTitle && definition.title) { - const ariaLabelledBy = `${block.key}-${column}-title`; - return ( -