mirror of
https://github.com/ankit-kapur/obsidian-kanban-status-updater-plugin.git
synced 2026-07-22 05:42:29 +00:00
v0.0.1 not working but close
This commit is contained in:
commit
9b2d69fbbb
1153 changed files with 1335616 additions and 0 deletions
544
main.js
Normal file
544
main.js
Normal file
File diff suppressed because one or more lines are too long
602
main.ts
Normal file
602
main.ts
Normal file
|
|
@ -0,0 +1,602 @@
|
|||
import {
|
||||
App,
|
||||
Editor,
|
||||
MarkdownView,
|
||||
Modal,
|
||||
Notice,
|
||||
Plugin,
|
||||
PluginSettingTab,
|
||||
Setting,
|
||||
TFile,
|
||||
FrontMatterCache,
|
||||
parseYaml,
|
||||
stringifyYaml,
|
||||
WorkspaceLeaf
|
||||
} from 'obsidian';
|
||||
|
||||
interface KanbanStatusUpdaterSettings {
|
||||
statusPropertyName: string;
|
||||
showNotifications: boolean;
|
||||
debugMode: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: KanbanStatusUpdaterSettings = {
|
||||
statusPropertyName: 'status',
|
||||
showNotifications: true,
|
||||
debugMode: true
|
||||
}
|
||||
|
||||
export default class KanbanStatusUpdaterPlugin extends Plugin {
|
||||
settings: KanbanStatusUpdaterSettings;
|
||||
|
||||
// Process flags to avoid infinite loops
|
||||
private processingMutation: boolean = false;
|
||||
private pendingCardUpdates: Map<string, {card: HTMLElement, column: HTMLElement}> = new Map();
|
||||
private mutationDebounceTimeout: NodeJS.Timeout = null;
|
||||
debugLog: (message: string) => void;
|
||||
statusBarItem: any;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
// Set up debug logging with rate limiting
|
||||
let lastLogTime = Date.now();
|
||||
let logCount = 0;
|
||||
this.debugLog = (message: string) => {
|
||||
if (this.settings.debugMode) {
|
||||
// Rate limit logs to prevent console flooding
|
||||
const now = Date.now();
|
||||
if (now - lastLogTime > 5000) {
|
||||
// Reset counter after 5 seconds
|
||||
logCount = 0;
|
||||
lastLogTime = now;
|
||||
}
|
||||
|
||||
if (logCount < 50) { // Limit to 50 logs per 5 seconds
|
||||
console.log(`[Kanban Status Updater] ${message}`);
|
||||
logCount++;
|
||||
|
||||
if (this.statusBarItem) {
|
||||
this.statusBarItem.setText(`[KSU] ${message.substring(0, 40)}${message.length > 40 ? '...' : ''}`);
|
||||
// Reset after 5 seconds
|
||||
setTimeout(() => {
|
||||
if (this.statusBarItem) {
|
||||
this.statusBarItem.setText('Kanban Status Updater Active');
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
} else if (logCount === 50) {
|
||||
console.log(`[Kanban Status Updater] Too many logs, throttling until ${new Date(lastLogTime + 5000).toLocaleTimeString()}`);
|
||||
logCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Display startup notification
|
||||
new Notice('Kanban Status Updater plugin activated');
|
||||
this.debugLog('Plugin loaded and activated');
|
||||
|
||||
// Hook into DOM events to detect Kanban card movements
|
||||
this.registerDomEvent(document, 'dragend', this.handleDragEnd.bind(this));
|
||||
this.debugLog('Registered drag event listener');
|
||||
|
||||
// Register for mutation events to catch non-drag updates - with optimizations
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
// Skip processing if we're already handling a mutation
|
||||
if (this.processingMutation) return;
|
||||
|
||||
// Debounce mutation processing to avoid too many updates
|
||||
if (this.mutationDebounceTimeout) {
|
||||
clearTimeout(this.mutationDebounceTimeout);
|
||||
}
|
||||
|
||||
this.mutationDebounceTimeout = setTimeout(() => {
|
||||
this.handleDOMMutations(mutations);
|
||||
this.mutationDebounceTimeout = null;
|
||||
}, 500); // Wait 500ms before processing
|
||||
});
|
||||
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
// Find Kanban board containers to observe more specifically
|
||||
const kanbanBoards = document.querySelectorAll('.kanban-plugin__board');
|
||||
|
||||
if (kanbanBoards && kanbanBoards.length > 0) {
|
||||
// Observe each Kanban board specifically rather than the entire document
|
||||
kanbanBoards.forEach(board => {
|
||||
observer.observe(board, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: false // Don't need attribute changes, just structure
|
||||
});
|
||||
});
|
||||
this.debugLog(`MutationObserver attached to ${kanbanBoards.length} Kanban boards`);
|
||||
} else {
|
||||
// Fallback to a more targeted observation if no boards found
|
||||
const workspace = document.querySelector('.workspace');
|
||||
if (workspace) {
|
||||
observer.observe(workspace, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: false
|
||||
});
|
||||
this.debugLog('MutationObserver attached to workspace (no Kanban boards found yet)');
|
||||
} else {
|
||||
// Last resort - observe body with more restrictions
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: false
|
||||
});
|
||||
this.debugLog('MutationObserver attached to document body (fallback mode)');
|
||||
}
|
||||
}
|
||||
|
||||
// Set up a periodic check for new Kanban boards (in case they're added later)
|
||||
setInterval(() => {
|
||||
const currentBoards = document.querySelectorAll('.kanban-plugin__board');
|
||||
if (currentBoards && currentBoards.length > 0) {
|
||||
currentBoards.forEach(board => {
|
||||
if (!board.hasAttribute('data-ksu-observed')) {
|
||||
observer.observe(board, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: false
|
||||
});
|
||||
board.setAttribute('data-ksu-observed', 'true');
|
||||
this.debugLog('Added observer to new Kanban board');
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 10000); // Check every 10 seconds
|
||||
});
|
||||
|
||||
// Add settings tab
|
||||
this.addSettingTab(new KanbanStatusUpdaterSettingTab(this.app, this));
|
||||
|
||||
// Add a status bar item to show the plugin is active
|
||||
this.statusBarItem = this.addStatusBarItem();
|
||||
this.statusBarItem.setText('Kanban Status Updater Active');
|
||||
this.statusBarItem.addClass('plugin-kanban-status-updater');
|
||||
|
||||
// Check if Kanban plugin is loaded - using safer approach
|
||||
try {
|
||||
// @ts-ignore - Check if kanban plugin exists using app.plugins (may not be in type definitions)
|
||||
const kanbanLoaded = this.app.plugins &&
|
||||
// @ts-ignore
|
||||
((this.app.plugins.plugins && this.app.plugins.plugins['obsidian-kanban']) ||
|
||||
// @ts-ignore
|
||||
(this.app.plugins.enabledPlugins && this.app.plugins.enabledPlugins.has('obsidian-kanban')));
|
||||
|
||||
if (!kanbanLoaded) {
|
||||
new Notice('⚠️ Warning: Kanban plugin might not be enabled. Kanban Status Updater requires it.', 10000);
|
||||
this.debugLog('WARNING: Kanban plugin not detected!');
|
||||
} else {
|
||||
this.debugLog('Kanban plugin detected');
|
||||
}
|
||||
} catch (e) {
|
||||
// If we can't detect it, just log and continue
|
||||
this.debugLog(`Couldn't verify Kanban plugin: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
onunload() {
|
||||
this.debugLog('Plugin unloaded');
|
||||
new Notice('Kanban Status Updater plugin deactivated');
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
handleDragEnd(evt: DragEvent) {
|
||||
// Check if this was a Kanban card being dragged
|
||||
const target = evt.target as HTMLElement;
|
||||
if (!target) {
|
||||
this.debugLog('Drag event had no target');
|
||||
return;
|
||||
}
|
||||
|
||||
this.debugLog(`Drag event detected on element: ${target.tagName}${target.className ? ' with class ' + target.className : ''}`);
|
||||
|
||||
const kanbanCard = target.closest('.kanban-card');
|
||||
if (!kanbanCard) {
|
||||
this.debugLog('Element is not or does not contain a Kanban card');
|
||||
return;
|
||||
}
|
||||
|
||||
this.debugLog('Kanban card found in drag event');
|
||||
|
||||
// Get the column the card was dropped in
|
||||
const column = kanbanCard.closest('.kanban-column');
|
||||
if (!column) {
|
||||
this.debugLog('Could not find parent Kanban column');
|
||||
return;
|
||||
}
|
||||
|
||||
this.debugLog('Card was moved to a column, processing movement');
|
||||
|
||||
// Process the card movement
|
||||
this.processCardMovement(kanbanCard as HTMLElement, column as HTMLElement);
|
||||
}
|
||||
|
||||
handleDOMMutations(mutations: MutationRecord[]) {
|
||||
if (this.processingMutation) {
|
||||
this.debugLog('Already processing mutations, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
// Process only a sample of mutations if there are too many
|
||||
const mutationsToProcess = mutations.length > 10 ?
|
||||
mutations.slice(0, 10) : mutations;
|
||||
|
||||
this.debugLog(`Processing ${mutationsToProcess.length} mutations (of ${mutations.length} total)`);
|
||||
|
||||
// Set flag to prevent recursive processing
|
||||
this.processingMutation = true;
|
||||
|
||||
try {
|
||||
// Clear the pending updates map
|
||||
this.pendingCardUpdates.clear();
|
||||
|
||||
// Check for relevant mutations (card being added to a column)
|
||||
for (const mutation of mutationsToProcess) {
|
||||
if (mutation.type === 'childList') {
|
||||
// Only log if there are actually Kanban-related nodes
|
||||
let foundKanbanElements = false;
|
||||
|
||||
this.debugLog(`mutation.type === 'childList'`);
|
||||
|
||||
for (const node of Array.from(mutation.addedNodes)) {
|
||||
if (node instanceof HTMLElement) {
|
||||
// Check if this is or contains Kanban card elements
|
||||
const isKanbanElement =
|
||||
node.classList.contains('kanban-card') ||
|
||||
node.classList.contains('kanban-column') ||
|
||||
node.querySelector('.kanban-card') !== null;
|
||||
|
||||
|
||||
this.debugLog(`node.classList: ${node.classList}`);
|
||||
this.debugLog(`node.tagName: ${node.tagName}`);
|
||||
this.debugLog(`node.className: ${node.className}`);
|
||||
|
||||
this.debugLog(`isKanbanElement -------------------- ${isKanbanElement}`);
|
||||
|
||||
if (isKanbanElement) {
|
||||
foundKanbanElements = true;
|
||||
|
||||
// Only now log details
|
||||
this.debugLog(`Relevant mutation: ${node.tagName}${node.className ? ' with class ' + node.className : ''}`);
|
||||
|
||||
// Look for Kanban cards
|
||||
const kanbanCards = node.classList.contains('kanban-card')
|
||||
? [node]
|
||||
: Array.from(node.querySelectorAll('.kanban-card'));
|
||||
|
||||
for (const card of kanbanCards) {
|
||||
const column = card.closest('.kanban-column');
|
||||
if (column) {
|
||||
// Create a unique ID for this card to avoid duplicates
|
||||
const cardText = card.textContent?.trim();
|
||||
const cardId = cardText?.substring(0, 50) || card.id || 'unknown';
|
||||
|
||||
this.debugLog(`Added card to pendingCardUpdates: ${cardText}`);
|
||||
this.debugLog(`Column: ${column.textContent}`);
|
||||
|
||||
// Add to pending updates map, this way if same card appears in multiple
|
||||
// mutations, we only process the last one
|
||||
this.pendingCardUpdates.set(cardId, {
|
||||
card: card as HTMLElement,
|
||||
column: column as HTMLElement
|
||||
});
|
||||
|
||||
this.debugLog(`Queued card update: ${cardId.substring(0, 20)}...`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only log for mutations with Kanban elements
|
||||
if (foundKanbanElements) {
|
||||
this.debugLog(`Processed mutation with ${mutation.addedNodes.length} nodes`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process all pending updates
|
||||
if (this.pendingCardUpdates.size > 0) {
|
||||
this.debugLog(`Processing ${this.pendingCardUpdates.size} card updates`);
|
||||
|
||||
// Process each card update (with a slight delay between them to avoid overloading)
|
||||
let index = 0;
|
||||
for (const [cardId, {card, column}] of this.pendingCardUpdates.entries()) {
|
||||
// Stagger processing to avoid too much at once
|
||||
setTimeout(() => {
|
||||
this.processCardMovement(card, column);
|
||||
}, index * 100); // 100ms between each card
|
||||
index++;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.debugLog(`Error processing mutations: ${e.message}`);
|
||||
} finally {
|
||||
// Clear the flag when done
|
||||
setTimeout(() => {
|
||||
this.processingMutation = false;
|
||||
this.debugLog('Mutation processing complete');
|
||||
}, 1000); // Ensure a minimum cool-down period between mutation processing
|
||||
}
|
||||
}
|
||||
|
||||
processCardMovement(card: HTMLElement, column: HTMLElement) {
|
||||
// Get the column name (new status)
|
||||
const headerElement = column.querySelector('.kanban-column-header');
|
||||
if (!headerElement) {
|
||||
this.debugLog('Could not find column header element');
|
||||
return;
|
||||
}
|
||||
|
||||
const newStatus = headerElement.textContent.trim();
|
||||
this.debugLog(`Column name (new status): "${newStatus}"`);
|
||||
|
||||
// Get the card content and look for the first link
|
||||
const cardContentElement = card.querySelector('.kanban-card-text, .kanban-card-content');
|
||||
if (!cardContentElement) {
|
||||
this.debugLog('Could not find card content element');
|
||||
return;
|
||||
}
|
||||
|
||||
const cardContent = cardContentElement.textContent;
|
||||
this.debugLog(`Card content: "${cardContent.substring(0, 50)}${cardContent.length > 50 ? '...' : ''}"`);
|
||||
|
||||
// Look for wiki-links [[Link]] or [[Link|Display Text]]
|
||||
const linkMatch = cardContent.match(/\[\[(.*?)(?:\|.*?)?\]\]/);
|
||||
|
||||
if (!linkMatch || !linkMatch[1]) {
|
||||
this.debugLog(`No link found in card: ${cardContent}`);
|
||||
new Notice('⚠️ No link found in Kanban card', 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
const linkPath = linkMatch[1].trim();
|
||||
this.debugLog(`Found link to: "${linkPath}"`);
|
||||
|
||||
// Show visual confirmation that we're updating
|
||||
new Notice(`Updating ${this.settings.statusPropertyName} to "${newStatus}" for "${linkPath}"...`, 2000);
|
||||
|
||||
this.updateLinkedNoteStatus(linkPath, newStatus);
|
||||
}
|
||||
|
||||
async updateLinkedNoteStatus(linkPath: string, newStatus: string) {
|
||||
// Find the linked file
|
||||
const file = this.app.metadataCache.getFirstLinkpathDest(linkPath, '');
|
||||
|
||||
if (!file) {
|
||||
this.debugLog(`Linked file not found: ${linkPath}`);
|
||||
new Notice(`⚠️ Error: File "${linkPath}" not found`, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
this.debugLog(`Found linked file: ${file.path}`);
|
||||
|
||||
try {
|
||||
// Read the file content
|
||||
const content = await this.app.vault.read(file);
|
||||
this.debugLog(`File content loaded (${content.length} chars)`);
|
||||
|
||||
// Check if the file has frontmatter
|
||||
const frontmatterRegex = /^---\n([\s\S]*?)\n---/;
|
||||
const frontmatterMatch = content.match(frontmatterRegex);
|
||||
|
||||
let newContent;
|
||||
let oldStatus = 'none';
|
||||
let action = 'created';
|
||||
|
||||
if (frontmatterMatch) {
|
||||
this.debugLog('File has frontmatter');
|
||||
// File has frontmatter
|
||||
const frontmatterText = frontmatterMatch[1];
|
||||
let frontmatterObj;
|
||||
|
||||
try {
|
||||
// Try to parse the frontmatter
|
||||
frontmatterObj = parseYaml(frontmatterText);
|
||||
this.debugLog('Frontmatter parsed successfully');
|
||||
|
||||
// Check if status property already exists
|
||||
if (frontmatterObj[this.settings.statusPropertyName]) {
|
||||
oldStatus = frontmatterObj[this.settings.statusPropertyName];
|
||||
action = 'updated';
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
this.debugLog(`Error parsing frontmatter: ${e.message}`);
|
||||
new Notice(`⚠️ Warning: Invalid frontmatter in ${file.basename}, creating new frontmatter`, 5000);
|
||||
frontmatterObj = {};
|
||||
}
|
||||
|
||||
// Update the status property
|
||||
frontmatterObj[this.settings.statusPropertyName] = newStatus;
|
||||
|
||||
// Generate the new frontmatter text
|
||||
const newFrontmatterText = stringifyYaml(frontmatterObj);
|
||||
this.debugLog('New frontmatter generated');
|
||||
|
||||
// Replace the frontmatter in the content
|
||||
newContent = content.replace(frontmatterRegex, `---\n${newFrontmatterText}---`);
|
||||
} else {
|
||||
this.debugLog('File has no frontmatter, creating new frontmatter');
|
||||
// File has no frontmatter, create it
|
||||
const frontmatterObj = {
|
||||
[this.settings.statusPropertyName]: newStatus
|
||||
};
|
||||
const frontmatterText = stringifyYaml(frontmatterObj);
|
||||
newContent = `---\n${frontmatterText}---\n\n${content}`;
|
||||
}
|
||||
|
||||
// Save the modified content
|
||||
await this.app.vault.modify(file, newContent);
|
||||
this.debugLog('File modified successfully');
|
||||
|
||||
// Show notification with more details
|
||||
const banner = createFragment(el => {
|
||||
el.createDiv({
|
||||
text: `✅ ${this.settings.statusPropertyName} ${action}:`,
|
||||
cls: 'status-updated-banner-title'
|
||||
});
|
||||
el.createDiv({
|
||||
cls: 'status-updated-banner-details'
|
||||
}, div => {
|
||||
div.createSpan({ text: 'File: ' });
|
||||
div.createSpan({
|
||||
text: file.basename,
|
||||
cls: 'status-updated-filename'
|
||||
});
|
||||
div.createEl('br');
|
||||
if (action === 'updated') {
|
||||
div.createSpan({ text: 'Changed from: ' });
|
||||
div.createSpan({
|
||||
text: `"${oldStatus}"`,
|
||||
cls: 'status-updated-old-value'
|
||||
});
|
||||
div.createEl('br');
|
||||
}
|
||||
div.createSpan({ text: 'New value: ' });
|
||||
div.createSpan({
|
||||
text: `"${newStatus}"`,
|
||||
cls: 'status-updated-new-value'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Always show the detailed banner
|
||||
new Notice(banner, 5000);
|
||||
|
||||
// Update status bar
|
||||
this.statusBarItem.setText(`Updated: ${file.basename} → ${newStatus}`);
|
||||
setTimeout(() => {
|
||||
this.statusBarItem.setText('Kanban Status Updater Active');
|
||||
}, 5000);
|
||||
|
||||
this.debugLog(`Success: ${this.settings.statusPropertyName} for ${file.basename} ${action} from "${oldStatus}" to "${newStatus}"`);
|
||||
} catch (error) {
|
||||
this.debugLog(`Error updating note status: ${error.message}`);
|
||||
new Notice(`⚠️ Error updating ${this.settings.statusPropertyName} for ${file.basename}: ${error.message}`, 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings Tab
|
||||
class KanbanStatusUpdaterSettingTab extends PluginSettingTab {
|
||||
plugin: KanbanStatusUpdaterPlugin;
|
||||
|
||||
constructor(app: App, plugin: KanbanStatusUpdaterPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const {containerEl} = this;
|
||||
|
||||
containerEl.empty();
|
||||
containerEl.createEl('h2', {text: 'Kanban Status Updater Settings'});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Status Property Name')
|
||||
.setDesc('The name of the property to update when a card is moved')
|
||||
.addText(text => text
|
||||
.setPlaceholder('status')
|
||||
.setValue(this.plugin.settings.statusPropertyName)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.statusPropertyName = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Show Notifications')
|
||||
.setDesc('Show a notification when a status is updated')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.showNotifications)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showNotifications = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Debug Mode')
|
||||
.setDesc('Enable detailed logging to console and status bar updates')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.debugMode)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.debugMode = value;
|
||||
await this.plugin.saveSettings();
|
||||
new Notice(`Debug mode ${value ? 'enabled' : 'disabled'}`);
|
||||
}));
|
||||
|
||||
// Add a button to trigger a test update
|
||||
new Setting(containerEl)
|
||||
.setName('Test Plugin')
|
||||
.setDesc('Run a test to verify plugin functionality')
|
||||
.addButton(button => button
|
||||
.setButtonText('Run Test')
|
||||
.onClick(() => {
|
||||
new Notice('Test function running - check console for logs');
|
||||
this.plugin.debugLog('Test function triggered from settings');
|
||||
|
||||
// Show an example of what a successful update would look like
|
||||
const banner = createFragment(el => {
|
||||
el.createDiv({
|
||||
text: `✅ ${this.plugin.settings.statusPropertyName} updated:`,
|
||||
cls: 'status-updated-banner-title'
|
||||
});
|
||||
el.createDiv({
|
||||
cls: 'status-updated-banner-details'
|
||||
}, div => {
|
||||
div.createSpan({ text: 'File: ' });
|
||||
div.createSpan({
|
||||
text: 'Example Note',
|
||||
cls: 'status-updated-filename'
|
||||
});
|
||||
div.createEl('br');
|
||||
div.createSpan({ text: 'Changed from: ' });
|
||||
div.createSpan({
|
||||
text: '"In Progress"',
|
||||
cls: 'status-updated-old-value'
|
||||
});
|
||||
div.createEl('br');
|
||||
div.createSpan({ text: 'New value: ' });
|
||||
div.createSpan({
|
||||
text: '"Completed"',
|
||||
cls: 'status-updated-new-value'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Notice(banner, 5000);
|
||||
}));
|
||||
|
||||
containerEl.createEl('h3', {text: 'Troubleshooting'});
|
||||
|
||||
containerEl.createEl('p', {
|
||||
text: 'If the plugin is not working, check the following:'
|
||||
});
|
||||
|
||||
const troubleshootingList = containerEl.createEl('ul');
|
||||
|
||||
troubleshootingList.createEl('li', {
|
||||
text: 'Ensure the Kanban plugin is installed and enabled'
|
||||
});
|
||||
|
||||
troubleshootingList.createEl('li', {
|
||||
text: 'Verify your Kanban cards contain wiki-links (e.g., [[Note Title]])'
|
||||
});
|
||||
|
||||
troubleshootingList.createEl('li', {
|
||||
text: 'Try enabling Debug Mode to see detailed logs in the developer console (Ctrl+Shift+I)'
|
||||
});
|
||||
}
|
||||
}
|
||||
10
manifest.json
Normal file
10
manifest.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"id": "kanban-status-updater",
|
||||
"name": "Kanban Status Updater",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Automatically updates a 'status' property in a note when its card is moved on a Kanban board",
|
||||
"author": "Ankit K",
|
||||
"authorUrl": "https://github.com/yourusername",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
1
node_modules/.bin/resolve
generated
vendored
Symbolic link
1
node_modules/.bin/resolve
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../resolve/bin/resolve
|
||||
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../rollup/dist/bin/rollup
|
||||
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../typescript/bin/tsc
|
||||
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../typescript/bin/tsserver
|
||||
563
node_modules/.package-lock.json
generated
vendored
Normal file
563
node_modules/.package-lock.json
generated
vendored
Normal file
|
|
@ -0,0 +1,563 @@
|
|||
{
|
||||
"name": "obsidian-kanban-status-updater",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@codemirror/state": {
|
||||
"version": "6.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.2.tgz",
|
||||
"integrity": "sha512-FVqsPqtPWKVVL3dPSxy8wEF/ymIEuVzF1PK3VbUgrxXpJUSHQWWZz4JMToquRxnkw+36LTamCZG2iua2Ptq0fA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.36.4",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.36.4.tgz",
|
||||
"integrity": "sha512-ZQ0V5ovw/miKEXTvjgzRyjnrk9TwriUB1k4R5p7uNnHR9Hus+D1SXHGdJshijEzPFjU25xea/7nhIeSqYFKdbA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@marijn/find-cluster-break": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
|
||||
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "22.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.2.tgz",
|
||||
"integrity": "sha512-//NdP6iIwPbMTcazYsiBMbJW7gfmpHom33u1beiIoHDEM0Q9clvtQB1T0efvMqHeKsGohiHo97BCPCkBXdscwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"commondir": "^1.0.1",
|
||||
"estree-walker": "^2.0.1",
|
||||
"glob": "^7.1.6",
|
||||
"is-reference": "^1.2.1",
|
||||
"magic-string": "^0.25.7",
|
||||
"resolve": "^1.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.68.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-node-resolve": {
|
||||
"version": "13.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz",
|
||||
"integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"@types/resolve": "1.17.1",
|
||||
"deepmerge": "^4.2.2",
|
||||
"is-builtin-module": "^3.1.0",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.19.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.42.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-typescript": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
|
||||
"integrity": "sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"resolve": "^1.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.14.0",
|
||||
"tslib": "*",
|
||||
"typescript": ">=3.7.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"tslib": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/pluginutils": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
|
||||
"integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "0.0.39",
|
||||
"estree-walker": "^1.0.1",
|
||||
"picomatch": "^2.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/pluginutils/node_modules/estree-walker": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
|
||||
"integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/codemirror": {
|
||||
"version": "0.0.108",
|
||||
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.108.tgz",
|
||||
"integrity": "sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/tern": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "17.0.45",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz",
|
||||
"integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
|
||||
"integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/tern": {
|
||||
"version": "0.23.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz",
|
||||
"integrity": "sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/builtin-modules": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
|
||||
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/commondir": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
|
||||
"integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/deepmerge": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
||||
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"deprecated": "Glob versions prior to v9 are no longer supported",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
||||
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/is-builtin-module": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz",
|
||||
"integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"builtin-modules": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/is-core-module": {
|
||||
"version": "2.16.1",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
|
||||
"integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
|
||||
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-reference": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
|
||||
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.25.9",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
|
||||
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sourcemap-codec": "^1.4.8"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.4",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/obsidian": {
|
||||
"version": "0.15.9",
|
||||
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.15.9.tgz",
|
||||
"integrity": "sha512-w3JL/IM3/U61rjFSFIFDSv+pcHn3mH1EIRN40kBkC/lGYqjFSPbr6daQe08QkskBz/GAYIeBoaKQIcgU9vV3LQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/codemirror": "0.0.108",
|
||||
"moment": "2.29.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-parse": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.22.10",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz",
|
||||
"integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-core-module": "^2.16.0",
|
||||
"path-parse": "^1.0.7",
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"resolve": "bin/resolve"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "2.79.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz",
|
||||
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/sourcemap-codec": {
|
||||
"version": "1.4.8",
|
||||
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
|
||||
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
||||
"deprecated": "Please use @jridgewell/sourcemap-codec instead",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/style-mod": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
|
||||
"integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/supports-preserve-symlinks-flag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
||||
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/state/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/state/.github/workflows/dispatch.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
286
node_modules/@codemirror/state/CHANGELOG.md
generated
vendored
Normal file
286
node_modules/@codemirror/state/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
## 6.5.2 (2025-02-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where reconfiguring a field with a new `init` value didn't update the value of the field.
|
||||
|
||||
## 6.5.1 (2025-01-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`countColumn` no longer loops infinitely when given a `to` that's higher than the input string's length.
|
||||
|
||||
## 6.5.0 (2024-12-09)
|
||||
|
||||
### New features
|
||||
|
||||
`RangeSet.compare` now supports a `boundChange` callback that is called when there's a change in the way ranges are split.
|
||||
|
||||
## 6.4.1 (2024-02-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that caused widgets at the end of a mark decoration to be rendered in their own separate mark DOM element.
|
||||
|
||||
## 6.4.0 (2023-12-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When multiple ranges in a single range set overlap, put the smaller ones inside the bigger ones, so that overlapping decorations don't break up each other's elements when coming from the same source.
|
||||
|
||||
### New features
|
||||
|
||||
Selection and selection range `eq` methods now support an optional argument that makes them also compare by cursor associativity.
|
||||
|
||||
The `RangeSet.join` function can be used to join multiple range sets together.
|
||||
|
||||
## 6.3.3 (2023-12-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `Text.slice` and `Text.replace` could return objects with incorrect `length` when the given `from`/`to` values were out of range for the text.
|
||||
|
||||
## 6.3.2 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure transactions cannot add multiple selections when `allowMultipleSelections` is false.
|
||||
|
||||
Fix a bug that caused `Text.iterLines` to not return empty lines at the end of the iterated ranges.
|
||||
|
||||
## 6.3.1 (2023-10-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give the tag property on `FacetReader` the type of the output type parameter to force TypeScript to infer the proper type when converting from `Facet` to `FacetReader`.
|
||||
|
||||
## 6.3.0 (2023-10-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `FacetReader` type provides a way to export a read-only handle to a `Facet`.
|
||||
|
||||
## 6.2.1 (2023-05-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that could cause `RangeSet.compare` to miss changes in the set of active ranges around a point range.
|
||||
|
||||
## 6.2.0 (2022-12-26)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.range` now accepts an optional 4th argument to specify the bidi level of the range's head position.
|
||||
|
||||
## 6.1.4 (2022-11-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused the `openStart` value passed to span iterators to be incorrect around widgets in some circumstances.
|
||||
|
||||
## 6.1.3 (2022-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid unnecessary calls to computed facet getters when a state is reconfigured but no dependencies of the computed facet change.
|
||||
|
||||
Fix an infinite loop in `RangeSet.eq` when the `to` parameter isn't given.
|
||||
|
||||
## 6.1.2 (2022-09-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where, when multiple transaction extenders took effect, only the highest-precedence one was actually included in the transaction.
|
||||
|
||||
## 6.1.1 (2022-08-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in range set span iteration that would cause decorations to be inappropriately split in some situations.
|
||||
|
||||
## 6.1.0 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Refine change mapping to preserve insertions made by concurrent changes.
|
||||
|
||||
### New features
|
||||
|
||||
The `enables` option to `Facet.define` may now take a function, which will be called with the facet value to create the extensions.
|
||||
|
||||
## 6.0.1 (2022-06-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a problem that caused effects' `map` methods to be called with an incorrect change set when filtering changes.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.1 (2022-06-02)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorView.phrase` now accepts additional arguments, which it will interpolate into the phrase in the place of `$` markers.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The deprecated precedence names `fallback`, `extend`, and `override` were removed from the library.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where, if an extension value occurs multiple times, its lowest, rather than highest precedence is used.
|
||||
|
||||
Fix an issue where facets with computed inputs would unneccesarily have their outputs recreated on state reconfiguration.
|
||||
|
||||
Fix a bug in the order in which new values for state fields and facets were computed, which could cause dynamic facets to hold the wrong value in some situations.
|
||||
|
||||
### New features
|
||||
|
||||
The exports from @codemirror/rangeset now live in this package.
|
||||
|
||||
The exports from @codemirror/text now live in this package.
|
||||
|
||||
## 0.19.9 (2022-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Mapping a non-empty selection range now always puts any newly inserted text on the sides of the range outside of the mapped version.
|
||||
|
||||
## 0.19.8 (2022-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where facet values with computed inputs could incorrectly retain their old value on reconfiguration.
|
||||
|
||||
## 0.19.7 (2022-02-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid recomputing facets on state reconfiguration if that facet's inputs stayed precisely the same.
|
||||
|
||||
Selection ranges created with `EditorSelection.range` will now have an assoc pointing at their anchor, when non-empty.
|
||||
|
||||
## 0.19.6 (2021-11-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused facet compare functions to be called with an invalid value in some situations.
|
||||
|
||||
Fix a bug that caused dynamic facet values to be incorrectly kept unchanged when reconfiguration changed one of their dependencies.
|
||||
|
||||
## 0.19.5 (2021-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would cause dynamic facet values influenced by a state reconfiguration to not properly recompute.
|
||||
|
||||
## 0.19.4 (2021-11-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When reconfiguring a state, effects from the reconfiguring transaction can now be seen by newly added state fields.
|
||||
|
||||
## 0.19.3 (2021-11-03)
|
||||
|
||||
### New features
|
||||
|
||||
The precedence levels (under `Prec`) now have more generic names, because their 'meaningful' names were entirely inappropriate in many situations.
|
||||
|
||||
## 0.19.2 (2021-09-13)
|
||||
|
||||
### New features
|
||||
|
||||
The editor state now has a `readOnly` property with a matching facet to control its value.
|
||||
|
||||
## 0.19.1 (2021-08-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `wordAt` never returned a useful result.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
User event strings now work differently—the events emitted by the core packages follow a different system, and hierarchical event tags can be created by separating the words with dots.
|
||||
|
||||
### New features
|
||||
|
||||
`languageDataAt` now takes an optional `side` argument to specificy which side of the position you're interested in.
|
||||
|
||||
It is now possible to add a user event annotation with a direct `userEvent` property on a transaction spec.
|
||||
|
||||
Transactions now have an `isUserEvent` method that can be used to check if it is (a subtype of) some user event type.
|
||||
|
||||
## 0.18.7 (2021-05-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where state fields might be initialized with a state that they aren't actually part of during reconfiguration.
|
||||
|
||||
## 0.18.6 (2021-04-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorState.wordAt` method finds the word at a given position.
|
||||
|
||||
## 0.18.5 (2021-04-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue in the compiled output that would break the code when minified with terser.
|
||||
|
||||
## 0.18.4 (2021-04-06)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Transaction.remote` annotation can be used to mark and recognize transactions created by other actors.
|
||||
|
||||
## 0.18.3 (2021-03-23)
|
||||
|
||||
### New features
|
||||
|
||||
The `ChangeDesc` class now has `toJSON` and `fromJSON` methods.
|
||||
|
||||
## 0.18.2 (2021-03-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix unintended ES2020 output (the package contains ES6 code again).
|
||||
|
||||
## 0.18.1 (2021-03-10)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Compartment.get` method can be used to get the content of a compartment in a given state.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`tagExtension` and the `reconfigure` transaction spec property have been replaced with the concept of configuration compartments and reconfiguration effects (see `Compartment`, `StateEffect.reconfigure`, and `StateEffect.appendConfig`).
|
||||
|
||||
## 0.17.2 (2021-02-19)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.map` and `SelectionRange.map` now take an optional second argument to indicate which direction to map to.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/state/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/state/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
18
node_modules/@codemirror/state/README.md
generated
vendored
Normal file
18
node_modules/@codemirror/state/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# @codemirror/state [](https://www.npmjs.org/package/@codemirror/state)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#state) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/state/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the editor state data structures for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/state/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
3911
node_modules/@codemirror/state/dist/index.cjs
generated
vendored
Normal file
3911
node_modules/@codemirror/state/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1703
node_modules/@codemirror/state/dist/index.d.cts
generated
vendored
Normal file
1703
node_modules/@codemirror/state/dist/index.d.cts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1703
node_modules/@codemirror/state/dist/index.d.ts
generated
vendored
Normal file
1703
node_modules/@codemirror/state/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3881
node_modules/@codemirror/state/dist/index.js
generated
vendored
Normal file
3881
node_modules/@codemirror/state/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
38
node_modules/@codemirror/state/package.json
generated
vendored
Normal file
38
node_modules/@codemirror/state/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "@codemirror/state",
|
||||
"version": "6.5.2",
|
||||
"description": "Editor state data structures for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/state.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/view/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/view/.github/workflows/dispatch.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
1972
node_modules/@codemirror/view/CHANGELOG.md
generated
vendored
Normal file
1972
node_modules/@codemirror/view/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
21
node_modules/@codemirror/view/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/view/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
37
node_modules/@codemirror/view/README.md
generated
vendored
Normal file
37
node_modules/@codemirror/view/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# @codemirror/view [](https://www.npmjs.org/package/@codemirror/view)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#view) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/view/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the DOM view component for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/view/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {EditorView} from "@codemirror/view"
|
||||
import {basicSetup} from "codemirror"
|
||||
|
||||
const view = new EditorView({
|
||||
parent: document.querySelector("#some-node"),
|
||||
doc: "Content text",
|
||||
extensions: [basicSetup /* ... */]
|
||||
})
|
||||
```
|
||||
|
||||
Add additional extensions, such as a [language
|
||||
mode](https://codemirror.net/#languages), to configure the editor.
|
||||
Call
|
||||
[`view.dispatch`](https://codemirror.net/docs/ref/#view.EditorView.dispatch)
|
||||
to update the editor's state.
|
||||
11215
node_modules/@codemirror/view/dist/index.cjs
generated
vendored
Normal file
11215
node_modules/@codemirror/view/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2226
node_modules/@codemirror/view/dist/index.d.cts
generated
vendored
Normal file
2226
node_modules/@codemirror/view/dist/index.d.cts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2226
node_modules/@codemirror/view/dist/index.d.ts
generated
vendored
Normal file
2226
node_modules/@codemirror/view/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
11167
node_modules/@codemirror/view/dist/index.js
generated
vendored
Normal file
11167
node_modules/@codemirror/view/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
40
node_modules/@codemirror/view/package.json
generated
vendored
Normal file
40
node_modules/@codemirror/view/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@codemirror/view",
|
||||
"version": "6.36.4",
|
||||
"description": "DOM view component for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/view.git"
|
||||
}
|
||||
}
|
||||
21
node_modules/@marijn/find-cluster-break/LICENSE
generated
vendored
Normal file
21
node_modules/@marijn/find-cluster-break/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2024 by Marijn Haverbeke <marijn@haverbeke.berlin>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
28
node_modules/@marijn/find-cluster-break/README.md
generated
vendored
Normal file
28
node_modules/@marijn/find-cluster-break/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# @marijn/find-cluster-break
|
||||
|
||||
Small JavaScript module for finding grapheme cluster breaks in
|
||||
strings, scanning from a given position.
|
||||
|
||||
```javascript
|
||||
import {findClusterBreak} from "@marijn/find-cluster-break"
|
||||
console.log(findClusterBreak("💪🏽🦋", 0))
|
||||
// → 4
|
||||
```
|
||||
|
||||
This code is open source, released under an MIT license.
|
||||
|
||||
## Documentation
|
||||
|
||||
**`findClusterBreak`**`(str: string, pos: number, forward = true, includeExtending = true): number`
|
||||
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
|
||||
**`isExtendingChar`**`(code: number): boolean`
|
||||
|
||||
Query whether the given character has a `Grapheme_Cluster_Break` value
|
||||
of `Extend` in Unicode.
|
||||
85
node_modules/@marijn/find-cluster-break/dist/index.cjs
generated
vendored
Normal file
85
node_modules/@marijn/find-cluster-break/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
'use strict';
|
||||
|
||||
// These are filled with ranges (rangeFrom[i] up to but not including
|
||||
// rangeTo[i]) of code points that count as extending characters.
|
||||
let rangeFrom = [], rangeTo = []
|
||||
|
||||
;(() => {
|
||||
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
||||
// information from
|
||||
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
||||
// Each pair of elements represents a range, as an offet from the
|
||||
// previous range and a length. Numbers are in base-36, with the empty
|
||||
// string being a shorthand for 1.
|
||||
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
|
||||
for (let i = 0, n = 0; i < numbers.length; i++)
|
||||
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
|
||||
})();
|
||||
|
||||
function isExtendingChar(code) {
|
||||
if (code < 768) return false
|
||||
for (let from = 0, to = rangeFrom.length;;) {
|
||||
let mid = (from + to) >> 1;
|
||||
if (code < rangeFrom[mid]) to = mid;
|
||||
else if (code >= rangeTo[mid]) from = mid + 1;
|
||||
else return true
|
||||
if (from == to) return false
|
||||
}
|
||||
}
|
||||
|
||||
function isRegionalIndicator(code) {
|
||||
return code >= 0x1F1E6 && code <= 0x1F1FF
|
||||
}
|
||||
|
||||
const ZWJ = 0x200d;
|
||||
|
||||
function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
||||
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
||||
}
|
||||
|
||||
function nextClusterBreak(str, pos, includeExtending) {
|
||||
if (pos == str.length) return pos
|
||||
// If pos is in the middle of a surrogate pair, move to its start
|
||||
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--;
|
||||
let prev = codePointAt(str, pos);
|
||||
pos += codePointSize(prev);
|
||||
while (pos < str.length) {
|
||||
let next = codePointAt(str, pos);
|
||||
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
||||
pos += codePointSize(next);
|
||||
prev = next;
|
||||
} else if (isRegionalIndicator(next)) {
|
||||
let countBefore = 0, i = pos - 2;
|
||||
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2; }
|
||||
if (countBefore % 2 == 0) break
|
||||
else pos += 2;
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
function prevClusterBreak(str, pos, includeExtending) {
|
||||
while (pos > 0) {
|
||||
let found = nextClusterBreak(str, pos - 2, includeExtending);
|
||||
if (found < pos) return found
|
||||
pos--;
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function codePointAt(str, pos) {
|
||||
let code0 = str.charCodeAt(pos);
|
||||
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
||||
let code1 = str.charCodeAt(pos + 1);
|
||||
if (!surrogateLow(code1)) return code0
|
||||
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
||||
}
|
||||
|
||||
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
||||
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
||||
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
||||
|
||||
exports.findClusterBreak = findClusterBreak;
|
||||
exports.isExtendingChar = isExtendingChar;
|
||||
15
node_modules/@marijn/find-cluster-break/dist/index.d.cts
generated
vendored
Normal file
15
node_modules/@marijn/find-cluster-break/dist/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Query whether the given character has a `Grapheme_Cluster_Break`
|
||||
value of `Extend` in Unicode.
|
||||
*/
|
||||
export declare function isExtendingChar(code: number): boolean
|
||||
|
||||
/**
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
*/
|
||||
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
||||
35
node_modules/@marijn/find-cluster-break/package.json
generated
vendored
Normal file
35
node_modules/@marijn/find-cluster-break/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "@marijn/find-cluster-break",
|
||||
"version": "1.0.2",
|
||||
"type": "module",
|
||||
"description": "Find the position of grapheme cluster breaks in a string",
|
||||
"main": "src/index.js",
|
||||
"exports": {
|
||||
"import": "./src/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.js",
|
||||
"prepare": "rollup -c"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/marijnh/find-cluster-break.git"
|
||||
},
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"grapheme",
|
||||
"cluster",
|
||||
"break"
|
||||
],
|
||||
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/marijnh/find-cluster-break/issues"
|
||||
},
|
||||
"homepage": "https://github.com/marijnh/find-cluster-break#readme",
|
||||
"devDependencies": {
|
||||
"mocha": "^10.7.3",
|
||||
"rollup": "^4.28.1"
|
||||
}
|
||||
}
|
||||
7
node_modules/@marijn/find-cluster-break/rollup.config.js
generated
vendored
Normal file
7
node_modules/@marijn/find-cluster-break/rollup.config.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export default {
|
||||
input: "src/index.js",
|
||||
output: {
|
||||
file: "dist/index.cjs",
|
||||
format: "cjs"
|
||||
}
|
||||
}
|
||||
15
node_modules/@marijn/find-cluster-break/src/index.d.ts
generated
vendored
Normal file
15
node_modules/@marijn/find-cluster-break/src/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Query whether the given character has a `Grapheme_Cluster_Break`
|
||||
value of `Extend` in Unicode.
|
||||
*/
|
||||
export declare function isExtendingChar(code: number): boolean
|
||||
|
||||
/**
|
||||
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
||||
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
||||
further cluster break is available in the string. Moves across
|
||||
surrogate pairs, extending characters (when `includeExtending` is
|
||||
true, which is the default), characters joined with zero-width joiners,
|
||||
and flag emoji.
|
||||
*/
|
||||
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
||||
87
node_modules/@marijn/find-cluster-break/src/index.js
generated
vendored
Normal file
87
node_modules/@marijn/find-cluster-break/src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// These are filled with ranges (rangeFrom[i] up to but not including
|
||||
// rangeTo[i]) of code points that count as extending characters.
|
||||
let rangeFrom = [], rangeTo = []
|
||||
|
||||
;(() => {
|
||||
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
||||
// information from
|
||||
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
||||
// Each pair of elements represents a range, as an offet from the
|
||||
// previous range and a length. Numbers are in base-36, with the empty
|
||||
// string being a shorthand for 1.
|
||||
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1)
|
||||
for (let i = 0, n = 0; i < numbers.length; i++)
|
||||
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])
|
||||
})()
|
||||
|
||||
export function isExtendingChar(code) {
|
||||
if (code < 768) return false
|
||||
for (let from = 0, to = rangeFrom.length;;) {
|
||||
let mid = (from + to) >> 1
|
||||
if (code < rangeFrom[mid]) to = mid
|
||||
else if (code >= rangeTo[mid]) from = mid + 1
|
||||
else return true
|
||||
if (from == to) return false
|
||||
}
|
||||
}
|
||||
|
||||
function isRegionalIndicator(code) {
|
||||
return code >= 0x1F1E6 && code <= 0x1F1FF
|
||||
}
|
||||
|
||||
function check(code) {
|
||||
for (let i = 0; i < rangeFrom.length; i++) {
|
||||
if (rangeTo[i] > code) return rangeFrom[i] <= code
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const ZWJ = 0x200d
|
||||
|
||||
export function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
||||
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
||||
}
|
||||
|
||||
function nextClusterBreak(str, pos, includeExtending) {
|
||||
if (pos == str.length) return pos
|
||||
// If pos is in the middle of a surrogate pair, move to its start
|
||||
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--
|
||||
let prev = codePointAt(str, pos)
|
||||
pos += codePointSize(prev)
|
||||
while (pos < str.length) {
|
||||
let next = codePointAt(str, pos)
|
||||
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
||||
pos += codePointSize(next)
|
||||
prev = next
|
||||
} else if (isRegionalIndicator(next)) {
|
||||
let countBefore = 0, i = pos - 2
|
||||
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }
|
||||
if (countBefore % 2 == 0) break
|
||||
else pos += 2
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
function prevClusterBreak(str, pos, includeExtending) {
|
||||
while (pos > 0) {
|
||||
let found = nextClusterBreak(str, pos - 2, includeExtending)
|
||||
if (found < pos) return found
|
||||
pos--
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function codePointAt(str, pos) {
|
||||
let code0 = str.charCodeAt(pos)
|
||||
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
||||
let code1 = str.charCodeAt(pos + 1)
|
||||
if (!surrogateLow(code1)) return code0
|
||||
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
||||
}
|
||||
|
||||
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
||||
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
||||
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
||||
30
node_modules/@marijn/find-cluster-break/test/test-cluster.js
generated
vendored
Normal file
30
node_modules/@marijn/find-cluster-break/test/test-cluster.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import {findClusterBreak} from "../src/index.js"
|
||||
|
||||
function assertEq(a, b) {
|
||||
if (a !== b) throw new Error(`${a} !== ${b}`)
|
||||
}
|
||||
|
||||
describe("findClusterBreak", () => {
|
||||
function test(spec) {
|
||||
it(spec, () => {
|
||||
let breaks = [], next
|
||||
while ((next = spec.indexOf("|")) > -1) {
|
||||
breaks.push(next)
|
||||
spec = spec.slice(0, next) + spec.slice(next + 1)
|
||||
}
|
||||
let found = []
|
||||
for (let i = 0;;) {
|
||||
let next = findClusterBreak(spec, i)
|
||||
if (next == spec.length) break
|
||||
found.push(i = next)
|
||||
}
|
||||
assertEq(found.join(","), breaks.join(","))
|
||||
})
|
||||
}
|
||||
|
||||
test("a|b|c|d")
|
||||
test("a|é̠|ő|x")
|
||||
test("😎|🙉")
|
||||
test("👨🎤|💪🏽|👩👩👧👦|❤")
|
||||
test("🇩🇪|🇫🇷|🇪🇸|x|🇮🇹")
|
||||
})
|
||||
21
node_modules/@rollup/plugin-commonjs/LICENSE
generated
vendored
Normal file
21
node_modules/@rollup/plugin-commonjs/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
440
node_modules/@rollup/plugin-commonjs/README.md
generated
vendored
Normal file
440
node_modules/@rollup/plugin-commonjs/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-commonjs
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-commonjs
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-commonjs
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-commonjs
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/plugin-commonjs
|
||||
|
||||
🍣 A Rollup plugin to convert CommonJS modules to ES6, so they can be included in a Rollup bundle
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v12.0.0+) and Rollup v2.68.0+. If you are using [`@rollup/plugin-node-resolve`](https://github.com/rollup/plugins/tree/master/packages/node-resolve), it should be v13.0.6+.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```bash
|
||||
npm install @rollup/plugin-commonjs --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
||||
|
||||
```js
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
dir: 'output',
|
||||
format: 'cjs'
|
||||
},
|
||||
plugins: [commonjs()]
|
||||
};
|
||||
```
|
||||
|
||||
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
|
||||
|
||||
When used together with the node-resolve plugin
|
||||
|
||||
## Options
|
||||
|
||||
### `strictRequires`
|
||||
|
||||
Type: `"auto" | boolean | "debug" | string[]`<br>
|
||||
Default: `"auto"`
|
||||
|
||||
By default, this plugin will try to hoist `require` statements as imports to the top of each file. While this works well for many code bases and allows for very efficient ESM output, it does not perfectly capture CommonJS semantics as the initialisation order of required modules will be different. The resultant side effects can include log statements being emitted in a different order, and some code that is dependent on the initialisation order of polyfills in require statements may not work. But it is especially problematic when there are circular `require` calls between CommonJS modules as those often rely on the lazy execution of nested `require` calls.
|
||||
|
||||
Setting this option to `true` will wrap all CommonJS files in functions which are executed when they are required for the first time, preserving NodeJS semantics. This is the safest setting and should be used if the generated code does not work correctly with `"auto"`. Note that `strictRequires: true` can have a small impact on the size and performance of generated code, but less so if the code is minified.
|
||||
|
||||
The default value of `"auto"` will only wrap CommonJS files when they are part of a CommonJS dependency cycle, e.g. an index file that is required by some of its dependencies, or if they are only required in a potentially "conditional" way like from within an if-statement or a function. All other CommonJS files are hoisted. This is the recommended setting for most code bases. Note that the detection of conditional requires can be subject to race conditions if there are both conditional and unconditional requires of the same file, which in edge cases may result in inconsistencies between builds. If you think this is a problem for you, you can avoid this by using any value other than `"auto"` or `"debug"`.
|
||||
|
||||
`false` will entirely prevent wrapping and hoist all files. This may still work depending on the nature of cyclic dependencies but will often cause problems.
|
||||
|
||||
You can also provide a [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, to only specify a subset of files which should be wrapped in functions for proper `require` semantics.
|
||||
|
||||
`"debug"` works like `"auto"` but after bundling, it will display a warning containing a list of ids that have been wrapped which can be used as minimatch pattern for fine-tuning or to avoid the potential race conditions mentioned for `"auto"`.
|
||||
|
||||
### `dynamicRequireTargets`
|
||||
|
||||
Type: `string | string[]`<br>
|
||||
Default: `[]`
|
||||
|
||||
_Note: In previous versions, this option would spin up a rather comprehensive mock environment that was capable of handling modules that manipulate `require.cache`. This is no longer supported. If you rely on this e.g. when using request-promise-native, use version 21 of this plugin._
|
||||
|
||||
Some modules contain dynamic `require` calls, or require modules that contain circular dependencies, which are not handled well by static imports.
|
||||
Including those modules as `dynamicRequireTargets` will simulate a CommonJS (NodeJS-like) environment for them with support for dynamic dependencies. It also enables `strictRequires` for those modules, see above.
|
||||
|
||||
_Note: In extreme cases, this feature may result in some paths being rendered as absolute in the final bundle. The plugin tries to avoid exposing paths from the local machine, but if you are `dynamicRequirePaths` with paths that are far away from your project's folder, that may require replacing strings like `"/Users/John/Desktop/foo-project/"` -> `"/"`._
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
commonjs({
|
||||
dynamicRequireTargets: [
|
||||
// include using a glob pattern (either a string or an array of strings)
|
||||
'node_modules/logform/*.js',
|
||||
|
||||
// exclude files that are known to not be required dynamically, this allows for better optimizations
|
||||
'!node_modules/logform/index.js',
|
||||
'!node_modules/logform/format.js',
|
||||
'!node_modules/logform/levels.js',
|
||||
'!node_modules/logform/browser.js'
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### `dynamicRequireRoot`
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/` may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your home directory name. By default it uses the current working directory.
|
||||
|
||||
### `exclude`
|
||||
|
||||
Type: `string | string[]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. By default, all files with extensions other than those in `extensions` or `".cjs"` are ignored, but you can exclude additional files. See also the `include` option.
|
||||
|
||||
### `include`
|
||||
|
||||
Type: `string | string[]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default, all files with extension `".cjs"` or those in `extensions` are included, but you can narrow this list by only including specific files. These files will be analyzed and transpiled if either the analysis does not find ES module specific statements or `transformMixedEsModules` is `true`.
|
||||
|
||||
### `extensions`
|
||||
|
||||
Type: `string[]`<br>
|
||||
Default: `['.js']`
|
||||
|
||||
For extensionless imports, search for extensions other than .js in the order specified. Note that you need to make sure that non-JavaScript files are transpiled by another plugin first.
|
||||
|
||||
### `ignoreGlobal`
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If true, uses of `global` won't be dealt with by this plugin.
|
||||
|
||||
### `sourceMap`
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
If false, skips source map generation for CommonJS modules. This will improve performance.
|
||||
|
||||
### `transformMixedEsModules`
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Instructs the plugin whether to enable mixed module transformations. This is useful in scenarios with modules that contain a mix of ES `import` statements and CommonJS `require` expressions. Set to `true` if `require` calls should be transformed to imports in mixed modules, or `false` if the `require` expressions should survive the transformation. The latter can be important if the code contains environment detection, or you are coding for an environment with special treatment for `require` calls such as [ElectronJS](https://www.electronjs.org/). See also the "ignore" option.
|
||||
|
||||
### `ignore`
|
||||
|
||||
Type: `string[] | ((id: string) => boolean)`<br>
|
||||
Default: `[]`
|
||||
|
||||
Sometimes you have to leave require statements unconverted. Pass an array containing the IDs or an `id => boolean` function.
|
||||
|
||||
### `ignoreTryCatch`
|
||||
|
||||
Type: `boolean | 'remove' | string[] | ((id: string) => boolean)`<br>
|
||||
Default: `true`
|
||||
|
||||
In most cases, where `require` calls to external dependencies are inside a `try-catch` clause, they should be left unconverted as it requires an optional dependency that may or may not be installed beside the rolled up package.
|
||||
Due to the conversion of `require` to a static `import` - the call is hoisted to the top of the file, outside of the `try-catch` clause.
|
||||
|
||||
- `true`: All external `require` calls inside a `try` will be left unconverted.
|
||||
- `false`: All external `require` calls inside a `try` will be converted as if the `try-catch` clause is not there.
|
||||
- `remove`: Remove all external `require` calls from inside any `try` block.
|
||||
- `string[]`: Pass an array containing the IDs to left unconverted.
|
||||
- `((id: string) => boolean|'remove')`: Pass a function that control individual IDs.
|
||||
|
||||
Note that non-external requires will not be ignored by this option.
|
||||
|
||||
### `ignoreDynamicRequires`
|
||||
|
||||
Type: `boolean`
|
||||
Default: false
|
||||
|
||||
Some `require` calls cannot be resolved statically to be translated to imports, e.g.
|
||||
|
||||
```js
|
||||
function wrappedRequire(target) {
|
||||
return require(target);
|
||||
}
|
||||
wrappedRequire('foo');
|
||||
wrappedRequire('bar');
|
||||
```
|
||||
|
||||
When this option is set to `false`, the generated code will either directly throw an error when such a call is encountered or, when `dynamicRequireTargets` is used, when such a call cannot be resolved with a configured dynamic require target.
|
||||
|
||||
Setting this option to `true` will instead leave the `require` call in the code or use it as a fallback for `dynamicRequireTargets`.
|
||||
|
||||
### `esmExternals`
|
||||
|
||||
Type: `boolean | string[] | ((id: string) => boolean)`
|
||||
Default: `false`
|
||||
|
||||
Controls how to render imports from external dependencies. By default, this plugin assumes that all external dependencies are CommonJS. This means they are rendered as default imports to be compatible with e.g. NodeJS where ES modules can only import a default export from a CommonJS dependency:
|
||||
|
||||
```js
|
||||
// input
|
||||
const foo = require('foo');
|
||||
|
||||
// output
|
||||
import foo from 'foo';
|
||||
```
|
||||
|
||||
This is likely not desired for ES module dependencies: Here `require` should usually return the namespace to be compatible with how bundled modules are handled.
|
||||
|
||||
If you set `esmExternals` to `true`, this plugins assumes that all external dependencies are ES modules and will adhere to the `requireReturnsDefault` option. If that option is not set, they will be rendered as namespace imports.
|
||||
|
||||
You can also supply an array of ids to be treated as ES modules, or a function that will be passed each external id to determine if it is an ES module.
|
||||
|
||||
### `defaultIsModuleExports`
|
||||
|
||||
Type: `boolean | "auto"`<br>
|
||||
Default: `"auto"`
|
||||
|
||||
Controls what is the default export when importing a CommonJS file from an ES module.
|
||||
|
||||
- `true`: The value of the default export is `module.exports`. This currently matches the behavior of Node.js when importing a CommonJS file.
|
||||
```js
|
||||
// mod.cjs
|
||||
exports.default = 3;
|
||||
```
|
||||
```js
|
||||
import foo from './mod.cjs';
|
||||
console.log(foo); // { default: 3 }
|
||||
```
|
||||
- `false`: The value of the default export is `exports.default`.
|
||||
```js
|
||||
// mod.cjs
|
||||
exports.default = 3;
|
||||
```
|
||||
```js
|
||||
import foo from './mod.cjs';
|
||||
console.log(foo); // 3
|
||||
```
|
||||
- `"auto"`: The value of the default export is `exports.default` if the CommonJS file has an `exports.__esModule === true` property; otherwise it's `module.exports`. This makes it possible to import
|
||||
the default export of ES modules compiled to CommonJS as if they were not compiled.
|
||||
```js
|
||||
// mod.cjs
|
||||
exports.default = 3;
|
||||
```
|
||||
```js
|
||||
// mod-compiled.cjs
|
||||
exports.__esModule = true;
|
||||
exports.default = 3;
|
||||
```
|
||||
```js
|
||||
import foo from './mod.cjs';
|
||||
import bar from './mod-compiled.cjs';
|
||||
console.log(foo); // { default: 3 }
|
||||
console.log(bar); // 3
|
||||
```
|
||||
|
||||
### `requireReturnsDefault`
|
||||
|
||||
Type: `boolean | "namespace" | "auto" | "preferred" | ((id: string) => boolean | "auto" | "preferred")`<br>
|
||||
Default: `false`
|
||||
|
||||
Controls what is returned when requiring an ES module from a CommonJS file. When using the `esmExternals` option, this will also apply to external modules. By default, this plugin will render those imports as namespace imports, i.e.
|
||||
|
||||
```js
|
||||
// input
|
||||
const foo = require('foo');
|
||||
|
||||
// output
|
||||
import * as foo from 'foo';
|
||||
```
|
||||
|
||||
This is in line with how other bundlers handle this situation and is also the most likely behaviour in case Node should ever support this. However there are some situations where this may not be desired:
|
||||
|
||||
- There is code in an external dependency that cannot be changed where a `require` statement expects the default export to be returned from an ES module.
|
||||
- If the imported module is in the same bundle, Rollup will generate a namespace object for the imported module which can increase bundle size unnecessarily:
|
||||
|
||||
```js
|
||||
// input: main.js
|
||||
const dep = require('./dep.js');
|
||||
console.log(dep.default);
|
||||
|
||||
// input: dep.js
|
||||
export default 'foo';
|
||||
|
||||
// output
|
||||
var dep = 'foo';
|
||||
|
||||
var dep$1 = /*#__PURE__*/ Object.freeze({
|
||||
__proto__: null,
|
||||
default: dep
|
||||
});
|
||||
|
||||
console.log(dep$1.default);
|
||||
```
|
||||
|
||||
For these situations, you can change Rollup's behaviour either globally or per module. To change it globally, set the `requireReturnsDefault` option to one of the following values:
|
||||
|
||||
- `false`: This is the default, requiring an ES module returns its namespace. This is the only option that will also add a marker `__esModule: true` to the namespace to support interop patterns in CommonJS modules that are transpiled ES modules.
|
||||
|
||||
```js
|
||||
// input
|
||||
const dep = require('dep');
|
||||
console.log(dep);
|
||||
|
||||
// output
|
||||
import * as dep$1 from 'dep';
|
||||
|
||||
function getAugmentedNamespace(n) {
|
||||
var a = Object.defineProperty({}, '__esModule', { value: true });
|
||||
Object.keys(n).forEach(function (k) {
|
||||
var d = Object.getOwnPropertyDescriptor(n, k);
|
||||
Object.defineProperty(
|
||||
a,
|
||||
k,
|
||||
d.get
|
||||
? d
|
||||
: {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return n[k];
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
var dep = /*@__PURE__*/ getAugmentedNamespace(dep$1);
|
||||
|
||||
console.log(dep);
|
||||
```
|
||||
|
||||
- `"namespace"`: Like `false`, requiring an ES module returns its namespace, but the plugin does not add the `__esModule` marker and thus creates more efficient code. For external dependencies when using `esmExternals: true`, no additional interop code is generated.
|
||||
|
||||
```js
|
||||
// output
|
||||
import * as dep from 'dep';
|
||||
|
||||
console.log(dep);
|
||||
```
|
||||
|
||||
- `"auto"`: This is complementary to how [`output.exports`](https://rollupjs.org/guide/en/#outputexports): `"auto"` works in Rollup: If a module has a default export and no named exports, requiring that module returns the default export. In all other cases, the namespace is returned. For external dependencies when using `esmExternals: true`, a corresponding interop helper is added:
|
||||
|
||||
```js
|
||||
// output
|
||||
import * as dep$1 from 'dep';
|
||||
|
||||
function getDefaultExportFromNamespaceIfNotNamed(n) {
|
||||
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1
|
||||
? n['default']
|
||||
: n;
|
||||
}
|
||||
|
||||
var dep = getDefaultExportFromNamespaceIfNotNamed(dep$1);
|
||||
|
||||
console.log(dep);
|
||||
```
|
||||
|
||||
- `"preferred"`: If a module has a default export, requiring that module always returns the default export, no matter whether additional named exports exist. This is similar to how previous versions of this plugin worked. Again for external dependencies when using `esmExternals: true`, an interop helper is added:
|
||||
|
||||
```js
|
||||
// output
|
||||
import * as dep$1 from 'dep';
|
||||
|
||||
function getDefaultExportFromNamespaceIfPresent(n) {
|
||||
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
|
||||
}
|
||||
|
||||
var dep = getDefaultExportFromNamespaceIfPresent(dep$1);
|
||||
|
||||
console.log(dep);
|
||||
```
|
||||
|
||||
- `true`: This will always try to return the default export on require without checking if it actually exists. This can throw at build time if there is no default export. This is how external dependencies are handled when `esmExternals` is not used. The advantage over the other options is that, like `false`, this does not add an interop helper for external dependencies, keeping the code lean:
|
||||
|
||||
```js
|
||||
// output
|
||||
import dep from 'dep';
|
||||
|
||||
console.log(dep);
|
||||
```
|
||||
|
||||
To change this for individual modules, you can supply a function for `requireReturnsDefault` instead. This function will then be called once for each required ES module or external dependency with the corresponding id and allows you to return different values for different modules.
|
||||
|
||||
## Using with @rollup/plugin-node-resolve
|
||||
|
||||
Since most CommonJS packages you are importing are probably dependencies in `node_modules`, you may need to use [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve):
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default {
|
||||
input: 'main.js',
|
||||
output: {
|
||||
file: 'bundle.js',
|
||||
format: 'iife',
|
||||
name: 'MyModule'
|
||||
},
|
||||
plugins: [commonjs(), resolve()]
|
||||
};
|
||||
```
|
||||
|
||||
## Usage with symlinks
|
||||
|
||||
Symlinks are common in monorepos and are also created by the `npm link` command. Rollup with `@rollup/plugin-node-resolve` resolves modules to their real paths by default. So `include` and `exclude` paths should handle real paths rather than symlinked paths (e.g. `../common/node_modules/**` instead of `node_modules/**`). You may also use a regular expression for `include` that works regardless of base path. Try this:
|
||||
|
||||
```js
|
||||
commonjs({
|
||||
include: /node_modules/
|
||||
});
|
||||
```
|
||||
|
||||
Whether symlinked module paths are [realpathed](http://man7.org/linux/man-pages/man3/realpath.3.html) or preserved depends on Rollup's `preserveSymlinks` setting, which is false by default, matching Node.js' default behavior. Setting `preserveSymlinks` to true in your Rollup config will cause `import` and `export` to match based on symlinked paths instead.
|
||||
|
||||
## Strict mode
|
||||
|
||||
ES modules are _always_ parsed in strict mode. That means that certain non-strict constructs (like octal literals) will be treated as syntax errors when Rollup parses modules that use them. Some older CommonJS modules depend on those constructs, and if you depend on them your bundle will blow up. There's basically nothing we can do about that.
|
||||
|
||||
Luckily, there is absolutely no good reason _not_ to use strict mode for everything — so the solution to this problem is to lobby the authors of those modules to update them.
|
||||
|
||||
## Inter-plugin-communication
|
||||
|
||||
This plugin exposes the result of its CommonJS file type detection for other plugins to use. You can access it via `this.getModuleInfo` or the `moduleParsed` hook:
|
||||
|
||||
```js
|
||||
function cjsDetectionPlugin() {
|
||||
return {
|
||||
name: 'cjs-detection',
|
||||
moduleParsed({
|
||||
id,
|
||||
meta: {
|
||||
commonjs: { isCommonJS }
|
||||
}
|
||||
}) {
|
||||
console.log(`File ${id} is CommonJS: ${isCommonJS}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
2238
node_modules/@rollup/plugin-commonjs/dist/cjs/index.js
generated
vendored
Normal file
2238
node_modules/@rollup/plugin-commonjs/dist/cjs/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@rollup/plugin-commonjs/dist/cjs/index.js.map
generated
vendored
Normal file
1
node_modules/@rollup/plugin-commonjs/dist/cjs/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2229
node_modules/@rollup/plugin-commonjs/dist/es/index.js
generated
vendored
Normal file
2229
node_modules/@rollup/plugin-commonjs/dist/es/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@rollup/plugin-commonjs/dist/es/index.js.map
generated
vendored
Normal file
1
node_modules/@rollup/plugin-commonjs/dist/es/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@rollup/plugin-commonjs/dist/es/package.json
generated
vendored
Normal file
1
node_modules/@rollup/plugin-commonjs/dist/es/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"type":"module"}
|
||||
89
node_modules/@rollup/plugin-commonjs/package.json
generated
vendored
Normal file
89
node_modules/@rollup/plugin-commonjs/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"name": "@rollup/plugin-commonjs",
|
||||
"version": "22.0.2",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Convert CommonJS modules to ES2015",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/commonjs"
|
||||
},
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/commonjs/#readme",
|
||||
"bugs": "https://github.com/rollup/plugins/issues",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"module": "./dist/es/index.js",
|
||||
"exports": {
|
||||
"require": "./dist/cjs/index.js",
|
||||
"import": "./dist/es/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm build && pnpm lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build",
|
||||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"npm",
|
||||
"modules",
|
||||
"commonjs",
|
||||
"require"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.68.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"commondir": "^1.0.1",
|
||||
"estree-walker": "^2.0.1",
|
||||
"glob": "^7.1.6",
|
||||
"is-reference": "^1.2.1",
|
||||
"magic-string": "^0.25.7",
|
||||
"resolve": "^1.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.1.0",
|
||||
"locate-character": "^2.0.5",
|
||||
"require-relative": "^0.8.7",
|
||||
"rollup": "^2.68.0",
|
||||
"shx": "^0.3.2",
|
||||
"source-map": "^0.7.3",
|
||||
"source-map-support": "^0.5.19",
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"ava": {
|
||||
"babel": {
|
||||
"compileEnhancements": false
|
||||
},
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
233
node_modules/@rollup/plugin-commonjs/types/index.d.ts
generated
vendored
Normal file
233
node_modules/@rollup/plugin-commonjs/types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { Plugin } from 'rollup';
|
||||
|
||||
type RequireReturnsDefaultOption = boolean | 'auto' | 'preferred' | 'namespace';
|
||||
type DefaultIsModuleExportsOption = boolean | 'auto';
|
||||
|
||||
interface RollupCommonJSOptions {
|
||||
/**
|
||||
* A minimatch pattern, or array of patterns, which specifies the files in
|
||||
* the build the plugin should operate on. By default, all files with
|
||||
* extension `".cjs"` or those in `extensions` are included, but you can
|
||||
* narrow this list by only including specific files. These files will be
|
||||
* analyzed and transpiled if either the analysis does not find ES module
|
||||
* specific statements or `transformMixedEsModules` is `true`.
|
||||
* @default undefined
|
||||
*/
|
||||
include?: FilterPattern;
|
||||
/**
|
||||
* A minimatch pattern, or array of patterns, which specifies the files in
|
||||
* the build the plugin should _ignore_. By default, all files with
|
||||
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
||||
* can exclude additional files. See also the `include` option.
|
||||
* @default undefined
|
||||
*/
|
||||
exclude?: FilterPattern;
|
||||
/**
|
||||
* For extensionless imports, search for extensions other than .js in the
|
||||
* order specified. Note that you need to make sure that non-JavaScript files
|
||||
* are transpiled by another plugin first.
|
||||
* @default [ '.js' ]
|
||||
*/
|
||||
extensions?: ReadonlyArray<string>;
|
||||
/**
|
||||
* If true then uses of `global` won't be dealt with by this plugin
|
||||
* @default false
|
||||
*/
|
||||
ignoreGlobal?: boolean;
|
||||
/**
|
||||
* If false, skips source map generation for CommonJS modules. This will
|
||||
* improve performance.
|
||||
* @default true
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
/**
|
||||
* Some `require` calls cannot be resolved statically to be translated to
|
||||
* imports.
|
||||
* When this option is set to `false`, the generated code will either
|
||||
* directly throw an error when such a call is encountered or, when
|
||||
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
||||
* configured dynamic require target.
|
||||
* Setting this option to `true` will instead leave the `require` call in the
|
||||
* code or use it as a fallback for `dynamicRequireTargets`.
|
||||
* @default false
|
||||
*/
|
||||
ignoreDynamicRequires?: boolean;
|
||||
/**
|
||||
* Instructs the plugin whether to enable mixed module transformations. This
|
||||
* is useful in scenarios with modules that contain a mix of ES `import`
|
||||
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
||||
* calls should be transformed to imports in mixed modules, or `false` if the
|
||||
* `require` expressions should survive the transformation. The latter can be
|
||||
* important if the code contains environment detection, or you are coding
|
||||
* for an environment with special treatment for `require` calls such as
|
||||
* ElectronJS. See also the `ignore` option.
|
||||
* @default false
|
||||
*/
|
||||
transformMixedEsModules?: boolean;
|
||||
/**
|
||||
* By default, this plugin will try to hoist `require` statements as imports
|
||||
* to the top of each file. While this works well for many code bases and
|
||||
* allows for very efficient ESM output, it does not perfectly capture
|
||||
* CommonJS semantics as the order of side effects like log statements may
|
||||
* change. But it is especially problematic when there are circular `require`
|
||||
* calls between CommonJS modules as those often rely on the lazy execution of
|
||||
* nested `require` calls.
|
||||
*
|
||||
* Setting this option to `true` will wrap all CommonJS files in functions
|
||||
* which are executed when they are required for the first time, preserving
|
||||
* NodeJS semantics. Note that this can have an impact on the size and
|
||||
* performance of the generated code.
|
||||
*
|
||||
* The default value of `"auto"` will only wrap CommonJS files when they are
|
||||
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
||||
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
||||
* recommended setting for most code bases.
|
||||
*
|
||||
* `false` will entirely prevent wrapping and hoist all files. This may still
|
||||
* work depending on the nature of cyclic dependencies but will often cause
|
||||
* problems.
|
||||
*
|
||||
* You can also provide a minimatch pattern, or array of patterns, to only
|
||||
* specify a subset of files which should be wrapped in functions for proper
|
||||
* `require` semantics.
|
||||
*
|
||||
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
||||
* containing a list of ids that have been wrapped which can be used as
|
||||
* minimatch pattern for fine-tuning.
|
||||
* @default "auto"
|
||||
*/
|
||||
strictRequires?: boolean | FilterPattern;
|
||||
/**
|
||||
* Sometimes you have to leave require statements unconverted. Pass an array
|
||||
* containing the IDs or a `id => boolean` function.
|
||||
* @default []
|
||||
*/
|
||||
ignore?: ReadonlyArray<string> | ((id: string) => boolean);
|
||||
/**
|
||||
* In most cases, where `require` calls are inside a `try-catch` clause,
|
||||
* they should be left unconverted as it requires an optional dependency
|
||||
* that may or may not be installed beside the rolled up package.
|
||||
* Due to the conversion of `require` to a static `import` - the call is
|
||||
* hoisted to the top of the file, outside of the `try-catch` clause.
|
||||
*
|
||||
* - `true`: All `require` calls inside a `try` will be left unconverted.
|
||||
* - `false`: All `require` calls inside a `try` will be converted as if the
|
||||
* `try-catch` clause is not there.
|
||||
* - `remove`: Remove all `require` calls from inside any `try` block.
|
||||
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
||||
* - `((id: string) => boolean|'remove')`: Pass a function that control
|
||||
* individual IDs.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
ignoreTryCatch?:
|
||||
| boolean
|
||||
| 'remove'
|
||||
| ReadonlyArray<string>
|
||||
| ((id: string) => boolean | 'remove');
|
||||
/**
|
||||
* Controls how to render imports from external dependencies. By default,
|
||||
* this plugin assumes that all external dependencies are CommonJS. This
|
||||
* means they are rendered as default imports to be compatible with e.g.
|
||||
* NodeJS where ES modules can only import a default export from a CommonJS
|
||||
* dependency.
|
||||
*
|
||||
* If you set `esmExternals` to `true`, this plugins assumes that all
|
||||
* external dependencies are ES modules and respect the
|
||||
* `requireReturnsDefault` option. If that option is not set, they will be
|
||||
* rendered as namespace imports.
|
||||
*
|
||||
* You can also supply an array of ids to be treated as ES modules, or a
|
||||
* function that will be passed each external id to determine if it is an ES
|
||||
* module.
|
||||
* @default false
|
||||
*/
|
||||
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean);
|
||||
/**
|
||||
* Controls what is returned when requiring an ES module from a CommonJS file.
|
||||
* When using the `esmExternals` option, this will also apply to external
|
||||
* modules. By default, this plugin will render those imports as namespace
|
||||
* imports i.e.
|
||||
*
|
||||
* ```js
|
||||
* // input
|
||||
* const foo = require('foo');
|
||||
*
|
||||
* // output
|
||||
* import * as foo from 'foo';
|
||||
* ```
|
||||
*
|
||||
* However there are some situations where this may not be desired.
|
||||
* For these situations, you can change Rollup's behaviour either globally or
|
||||
* per module. To change it globally, set the `requireReturnsDefault` option
|
||||
* to one of the following values:
|
||||
*
|
||||
* - `false`: This is the default, requiring an ES module returns its
|
||||
* namespace. This is the only option that will also add a marker
|
||||
* `__esModule: true` to the namespace to support interop patterns in
|
||||
* CommonJS modules that are transpiled ES modules.
|
||||
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
||||
* namespace, but the plugin does not add the `__esModule` marker and thus
|
||||
* creates more efficient code. For external dependencies when using
|
||||
* `esmExternals: true`, no additional interop code is generated.
|
||||
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
||||
* Rollup: If a module has a default export and no named exports, requiring
|
||||
* that module returns the default export. In all other cases, the namespace
|
||||
* is returned. For external dependencies when using `esmExternals: true`, a
|
||||
* corresponding interop helper is added.
|
||||
* - `"preferred"`: If a module has a default export, requiring that module
|
||||
* always returns the default export, no matter whether additional named
|
||||
* exports exist. This is similar to how previous versions of this plugin
|
||||
* worked. Again for external dependencies when using `esmExternals: true`,
|
||||
* an interop helper is added.
|
||||
* - `true`: This will always try to return the default export on require
|
||||
* without checking if it actually exists. This can throw at build time if
|
||||
* there is no default export. This is how external dependencies are handled
|
||||
* when `esmExternals` is not used. The advantage over the other options is
|
||||
* that, like `false`, this does not add an interop helper for external
|
||||
* dependencies, keeping the code lean.
|
||||
*
|
||||
* To change this for individual modules, you can supply a function for
|
||||
* `requireReturnsDefault` instead. This function will then be called once for
|
||||
* each required ES module or external dependency with the corresponding id
|
||||
* and allows you to return different values for different modules.
|
||||
* @default false
|
||||
*/
|
||||
requireReturnsDefault?:
|
||||
| RequireReturnsDefaultOption
|
||||
| ((id: string) => RequireReturnsDefaultOption);
|
||||
|
||||
/**
|
||||
* @default "auto"
|
||||
*/
|
||||
defaultIsModuleExports?:
|
||||
| DefaultIsModuleExportsOption
|
||||
| ((id: string) => DefaultIsModuleExportsOption);
|
||||
/**
|
||||
* Some modules contain dynamic `require` calls, or require modules that
|
||||
* contain circular dependencies, which are not handled well by static
|
||||
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
||||
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
||||
* dependencies. It also enables `strictRequires` for those modules.
|
||||
*
|
||||
* Note: In extreme cases, this feature may result in some paths being
|
||||
* rendered as absolute in the final bundle. The plugin tries to avoid
|
||||
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
||||
* with paths that are far away from your project's folder, that may require
|
||||
* replacing strings like `"/Users/John/Desktop/foo-project/"` -> `"/"`.
|
||||
*/
|
||||
dynamicRequireTargets?: string | ReadonlyArray<string>;
|
||||
/**
|
||||
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
||||
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
||||
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
||||
* home directory name. By default it uses the current working directory.
|
||||
*/
|
||||
dynamicRequireRoot?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CommonJS modules to ES6, so they can be included in a Rollup bundle
|
||||
*/
|
||||
export default function commonjs(options?: RollupCommonJSOptions): Plugin;
|
||||
552
node_modules/@rollup/plugin-node-resolve/CHANGELOG.md
generated
vendored
Executable file
552
node_modules/@rollup/plugin-node-resolve/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,552 @@
|
|||
# @rollup/plugin-node-resolve ChangeLog
|
||||
|
||||
## v13.3.0
|
||||
|
||||
_2022-05-02_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: support `node:` protocol (#1124)
|
||||
|
||||
## v13.2.2
|
||||
|
||||
_2022-05-02_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: Respect if other plugins resolve the resolution to a different id (#1181)
|
||||
- fix: Revert respect if other plugins resolve the resolution to a different id (ae59ceb)
|
||||
- fix: Respect if other plugins resolve the resolution to a different id (f8d4c44)
|
||||
|
||||
## v13.2.1
|
||||
|
||||
_2022-04-15_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: update side effects logic to be deep when glob doesn’t contain `/` (#1148)
|
||||
|
||||
## v13.2.0
|
||||
|
||||
_2022-04-11_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: Add the ability to pass a function into resolveOnly (#1152)
|
||||
|
||||
## v13.1.3
|
||||
|
||||
_2022-01-05_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: use correct version when published (#1063)
|
||||
|
||||
## v13.1.2
|
||||
|
||||
_2021-12-31_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: forward meta-information from other plugins (#1062)
|
||||
|
||||
## v13.1.1
|
||||
|
||||
_2021-12-13_
|
||||
|
||||
### Updates
|
||||
|
||||
- test: add tests for mixing custom `exportConditions` with `browser: true` (#1043)
|
||||
|
||||
## v13.1.0
|
||||
|
||||
_2021-12-13_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: expose plugin version (#1050)
|
||||
|
||||
## v13.0.6
|
||||
|
||||
_2021-10-19_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: pass on isEntry flag (#1016)
|
||||
|
||||
## v13.0.5
|
||||
|
||||
_2021-09-21_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: fix readme heading depth (#999)
|
||||
|
||||
## v13.0.4
|
||||
|
||||
_2021-07-24_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: Fix bug where JS import was converted to a TS import, resulting in an error when using export maps (#921)
|
||||
|
||||
## v13.0.3
|
||||
|
||||
_2021-07-24_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: handle browser-mapped paths correctly in nested contexts (#920)
|
||||
|
||||
## v13.0.2
|
||||
|
||||
_2021-07-15_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: handle "package.json" being in path (#927)
|
||||
|
||||
## v13.0.1
|
||||
|
||||
_2021-07-15_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: Document how to get Node.js exports resolution (#884)
|
||||
|
||||
## v13.0.0
|
||||
|
||||
_2021-05-04_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- fix!: mark module as external if resolved module is external (#799)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: Follow up to #843, refining exports and browser field interaction (#866)
|
||||
|
||||
## v12.0.0
|
||||
|
||||
_2021-05-04_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- fix!: mark module as external if resolved module is external (#799)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: Follow up to #843, refining exports and browser field interaction (#866)
|
||||
|
||||
## v11.2.1
|
||||
|
||||
_2021-03-26_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: fs.exists is incorrectly promisified (#835)
|
||||
|
||||
## v11.2.0
|
||||
|
||||
_2021-02-14_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add `ignoreSideEffectsForRoot` option (#694)
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: mark `url` as an external and throw on warning (#783)
|
||||
- docs: clearer "Resolving Built-Ins" doc (#782)
|
||||
|
||||
## v11.1.1
|
||||
|
||||
_2021-01-29_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: only log last resolve error (#750)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: add clarification on the order of package entrypoints (#768)
|
||||
|
||||
## v11.1.0
|
||||
|
||||
_2021-01-15_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: support pkg imports and export array (#693)
|
||||
|
||||
## v11.0.1
|
||||
|
||||
_2020-12-14_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: export map specificity (#675)
|
||||
- fix: add missing type import (#668)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: corrected word "yse" to "use" (#723)
|
||||
|
||||
## v11.0.0
|
||||
|
||||
_2020-11-30_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- refactor!: simplify builtins and remove `customResolveOptions` (#656)
|
||||
- feat!: Mark built-ins as external (#627)
|
||||
- feat!: support package entry points (#540)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: refactor handling builtins, do not log warning if no local version (#637)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: fix import statements in examples in README.md (#646)
|
||||
|
||||
## v10.0.0
|
||||
|
||||
_2020-10-27_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- fix!: resolve hash in path (#588)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: do not ignore exceptions (#564)
|
||||
|
||||
## v9.0.0
|
||||
|
||||
_2020-08-13_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- chore: update dependencies (e632469)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: remove deep-freeze from dependencies (#529)
|
||||
- chore: clean up changelog (84dfddb)
|
||||
|
||||
## v8.4.0
|
||||
|
||||
_2020-07-12_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: preserve search params and hashes (#487)
|
||||
- feat: support .js imports in TypeScript (#480)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: fix named export use in readme (#456)
|
||||
- docs: correct mainFields valid values (#469)
|
||||
|
||||
## v8.1.0
|
||||
|
||||
_2020-06-22_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add native node es modules support (#413)
|
||||
|
||||
## v8.0.1
|
||||
|
||||
_2020-06-05_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: handle nested entry modules with the resolveOnly option (#430)
|
||||
|
||||
## v8.0.0
|
||||
|
||||
_2020-05-20_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- feat: Add default export (#361)
|
||||
- feat: export defaults (#301)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve local files if `resolveOption` is set (#337)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: correct misspelling (#343)
|
||||
|
||||
## v7.1.3
|
||||
|
||||
_2020-04-12_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve symlinked entry point properly (#291)
|
||||
|
||||
## v7.1.2
|
||||
|
||||
_2020-04-12_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: fix url (#289)
|
||||
|
||||
## v7.1.1
|
||||
|
||||
_2020-02-03_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: main fields regression (#196)
|
||||
|
||||
## v7.1.0
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: clean codebase and fix external warnings (#155)
|
||||
|
||||
## v7.0.0
|
||||
|
||||
_2020-01-07_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- feat: dedupe by package name (#99)
|
||||
|
||||
## v6.1.0
|
||||
|
||||
_2020-01-04_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: allow deduplicating custom module dirs (#101)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add rootDir option (#98)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: improve doc related to mainFields (#138)
|
||||
|
||||
## 6.0.0
|
||||
|
||||
_2019-11-25_
|
||||
|
||||
- **Breaking:** Minimum compatible Rollup version is 1.20.0
|
||||
- **Breaking:** Minimum supported Node version is 8.0.0
|
||||
- Published as @rollup/plugin-node-resolve
|
||||
|
||||
## 5.2.1 (unreleased)
|
||||
|
||||
- add missing MIT license file ([#233](https://github.com/rollup/rollup-plugin-node-resolve/pull/233) by @kenjiO)
|
||||
- Fix incorrect example of config ([#239](https://github.com/rollup/rollup-plugin-node-resolve/pull/240) by @myshov)
|
||||
- Fix typo in readme ([#240](https://github.com/rollup/rollup-plugin-node-resolve/pull/240) by @LinusU)
|
||||
|
||||
## 5.2.0 (2019-06-29)
|
||||
|
||||
- dedupe accepts a function ([#225](https://github.com/rollup/rollup-plugin-node-resolve/pull/225) by @manucorporat)
|
||||
|
||||
## 5.1.1 (2019-06-29)
|
||||
|
||||
- Move Rollup version check to buildStart hook to avoid issues ([#232](https://github.com/rollup/rollup-plugin-node-resolve/pull/232) by @lukastaegert)
|
||||
|
||||
## 5.1.0 (2019-06-22)
|
||||
|
||||
- Fix path fragment inputs ([#229](https://github.com/rollup/rollup-plugin-node-resolve/pull/229) by @bterlson)
|
||||
|
||||
## 5.0.4 (2019-06-22)
|
||||
|
||||
- Treat sideEffects array as inclusion list ([#227](https://github.com/rollup/rollup-plugin-node-resolve/pull/227) by @mikeharder)
|
||||
|
||||
## 5.0.3 (2019-06-16)
|
||||
|
||||
- Make empty.js a virtual module ([#224](https://github.com/rollup/rollup-plugin-node-resolve/pull/224) by @manucorporat)
|
||||
|
||||
## 5.0.2 (2019-06-13)
|
||||
|
||||
- Support resolve 1.11.1, add built-in test ([#223](https://github.com/rollup/rollup-plugin-node-resolve/pull/223) by @bterlson)
|
||||
|
||||
## 5.0.1 (2019-05-31)
|
||||
|
||||
- Update to resolve@1.11.0 for better performance ([#220](https://github.com/rollup/rollup-plugin-node-resolve/pull/220) by @keithamus)
|
||||
|
||||
## 5.0.0 (2019-05-15)
|
||||
|
||||
- Replace bublé with babel, update dependencies ([#216](https://github.com/rollup/rollup-plugin-node-resolve/pull/216) by @mecurc)
|
||||
- Handle module side-effects ([#219](https://github.com/rollup/rollup-plugin-node-resolve/pull/219) by @lukastaegert)
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Requires at least rollup@1.11.0 to work (v1.12.0 for module side-effects to be respected)
|
||||
- If used with rollup-plugin-commonjs, it should be at least v10.0.0
|
||||
|
||||
## 4.2.4 (2019-05-11)
|
||||
|
||||
- Add note on builtins to Readme ([#215](https://github.com/rollup/rollup-plugin-node-resolve/pull/215) by @keithamus)
|
||||
- Add issue templates ([#217](https://github.com/rollup/rollup-plugin-node-resolve/pull/217) by @mecurc)
|
||||
- Improve performance by caching `isDir` ([#218](https://github.com/rollup/rollup-plugin-node-resolve/pull/218) by @keithamus)
|
||||
|
||||
## 4.2.3 (2019-04-11)
|
||||
|
||||
- Fix ordering of jsnext:main when using the jsnext option ([#209](https://github.com/rollup/rollup-plugin-node-resolve/pull/209) by @lukastaegert)
|
||||
|
||||
## 4.2.2 (2019-04-10)
|
||||
|
||||
- Fix TypeScript typings (rename and export Options interface) ([#206](https://github.com/rollup/rollup-plugin-node-resolve/pull/206) by @Kocal)
|
||||
- Fix mainfields typing ([#207](https://github.com/rollup/rollup-plugin-node-resolve/pull/207) by @nicolashenry)
|
||||
|
||||
## 4.2.1 (2019-04-06)
|
||||
|
||||
- Respect setting the deprecated fields "module", "main", and "jsnext" ([#204](https://github.com/rollup/rollup-plugin-node-resolve/pull/204) by @nick-woodward)
|
||||
|
||||
## 4.2.0 (2019-04-06)
|
||||
|
||||
- Add new mainfields option ([#182](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @keithamus)
|
||||
- Added dedupe option to prevent bundling the same package multiple times ([#201](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @sormy)
|
||||
|
||||
## 4.1.0 (2019-04-05)
|
||||
|
||||
- Add TypeScript typings ([#189](https://github.com/rollup/rollup-plugin-node-resolve/pull/189) by @NotWoods)
|
||||
- Update dependencies ([#202](https://github.com/rollup/rollup-plugin-node-resolve/pull/202) by @lukastaegert)
|
||||
|
||||
## 4.0.1 (2019-02-22)
|
||||
|
||||
- Fix issue when external modules are specified in `package.browser` ([#143](https://github.com/rollup/rollup-plugin-node-resolve/pull/143) by @keithamus)
|
||||
- Fix `package.browser` mapping issue when `false` is specified ([#183](https://github.com/rollup/rollup-plugin-node-resolve/pull/183) by @allex)
|
||||
|
||||
## 4.0.0 (2018-12-09)
|
||||
|
||||
This release will support rollup@1.0
|
||||
|
||||
### Features
|
||||
|
||||
- Resolve modules used to define manual chunks ([#185](https://github.com/rollup/rollup-plugin-node-resolve/pull/185) by @mcshaman)
|
||||
- Update dependencies and plugin hook usage ([#187](https://github.com/rollup/rollup-plugin-node-resolve/pull/187) by @lukastaegert)
|
||||
|
||||
## 3.4.0 (2018-09-04)
|
||||
|
||||
This release now supports `.mjs` files by default
|
||||
|
||||
### Features
|
||||
|
||||
- feat: Support .mjs files by default (https://github.com/rollup/rollup-plugin-node-resolve/pull/151, by @leebyron)
|
||||
|
||||
## 3.3.0 (2018-03-17)
|
||||
|
||||
This release adds the `only` option
|
||||
|
||||
### New Features
|
||||
|
||||
- feat: add `only` option (#83; @arantes555)
|
||||
|
||||
### Docs
|
||||
|
||||
- docs: correct description of `jail` option (#120; @GeorgeTaveras1231)
|
||||
|
||||
## 3.2.0 (2018-03-07)
|
||||
|
||||
This release caches reading/statting of files, to improve speed.
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
- perf: cache file stats/reads (#126; @keithamus)
|
||||
|
||||
## 3.0.4 (unreleased)
|
||||
|
||||
- Update lockfile [#137](https://github.com/rollup/rollup-plugin-node-resolve/issues/137)
|
||||
- Update rollup dependency [#138](https://github.com/rollup/rollup-plugin-node-resolve/issues/138)
|
||||
- Enable installation from Github [#142](https://github.com/rollup/rollup-plugin-node-resolve/issues/142)
|
||||
|
||||
## 3.0.3
|
||||
|
||||
- Fix [#130](https://github.com/rollup/rollup-plugin-node-resolve/issues/130) and [#131](https://github.com/rollup/rollup-plugin-node-resolve/issues/131)
|
||||
|
||||
## 3.0.2
|
||||
|
||||
- Ensure `pkg.browser` is an object if necessary ([#129](https://github.com/rollup/rollup-plugin-node-resolve/pull/129))
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- Remove `browser-resolve` dependency ([#127](https://github.com/rollup/rollup-plugin-node-resolve/pull/127))
|
||||
|
||||
## 3.0.0
|
||||
|
||||
- [BREAKING] Remove `options.skip` ([#90](https://github.com/rollup/rollup-plugin-node-resolve/pull/90))
|
||||
- Add `modulesOnly` option ([#96](https://github.com/rollup/rollup-plugin-node-resolve/pull/96))
|
||||
|
||||
## 2.1.1
|
||||
|
||||
- Prevent `jail` from breaking builds on Windows ([#93](https://github.com/rollup/rollup-plugin-node-resolve/issues/93))
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- Add `jail` option ([#53](https://github.com/rollup/rollup-plugin-node-resolve/pull/53))
|
||||
- Add `customResolveOptions` option ([#79](https://github.com/rollup/rollup-plugin-node-resolve/pull/79))
|
||||
- Support symlinked packages ([#82](https://github.com/rollup/rollup-plugin-node-resolve/pull/82))
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- Add support `module` field in package.json as an official alternative to jsnext
|
||||
|
||||
## 1.7.3
|
||||
|
||||
- Error messages are more descriptive ([#50](https://github.com/rollup/rollup-plugin-node-resolve/issues/50))
|
||||
|
||||
## 1.7.2
|
||||
|
||||
- Allow entry point paths beginning with ./
|
||||
|
||||
## 1.7.1
|
||||
|
||||
- Return a `name`
|
||||
|
||||
## 1.7.0
|
||||
|
||||
- Allow relative IDs to be external ([#32](https://github.com/rollup/rollup-plugin-node-resolve/pull/32))
|
||||
|
||||
## 1.6.0
|
||||
|
||||
- Skip IDs containing null character
|
||||
|
||||
## 1.5.0
|
||||
|
||||
- Prefer built-in options, but allow opting out ([#28](https://github.com/rollup/rollup-plugin-node-resolve/pull/28))
|
||||
|
||||
## 1.4.0
|
||||
|
||||
- Pass `options.extensions` through to `node-resolve`
|
||||
|
||||
## 1.3.0
|
||||
|
||||
- `skip: true` skips all packages that don't satisfy the `main` or `jsnext` options ([#16](https://github.com/rollup/rollup-plugin-node-resolve/pull/16))
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- Support scoped packages in `skip` option ([#15](https://github.com/rollup/rollup-plugin-node-resolve/issues/15))
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Support `browser` field ([#8](https://github.com/rollup/rollup-plugin-node-resolve/issues/8))
|
||||
- Get tests to pass on Windows
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Use node-resolve to handle various corner cases
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Add ES6 build, use Rollup 0.20.0
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- First release
|
||||
21
node_modules/@rollup/plugin-node-resolve/LICENSE
generated
vendored
Normal file
21
node_modules/@rollup/plugin-node-resolve/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
234
node_modules/@rollup/plugin-node-resolve/README.md
generated
vendored
Executable file
234
node_modules/@rollup/plugin-node-resolve/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,234 @@
|
|||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-node-resolve
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-node-resolve
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-node-resolve
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/plugin-node-resolve
|
||||
|
||||
🍣 A Rollup plugin which locates modules using the [Node resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together), for using third party modules in `node_modules`
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```console
|
||||
npm install @rollup/plugin-node-resolve --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
||||
|
||||
```js
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
dir: 'output',
|
||||
format: 'cjs'
|
||||
},
|
||||
plugins: [nodeResolve()]
|
||||
};
|
||||
```
|
||||
|
||||
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
|
||||
|
||||
## Package entrypoints
|
||||
|
||||
This plugin supports the package entrypoints feature from node js, specified in the `exports` or `imports` field of a package. Check the [official documentation](https://nodejs.org/api/packages.html#packages_package_entry_points) for more information on how this works. This is the default behavior. In the abscence of these fields, the fields in `mainFields` will be the ones to be used.
|
||||
|
||||
## Options
|
||||
|
||||
### `exportConditions`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `[]`
|
||||
|
||||
Additional conditions of the package.json exports field to match when resolving modules. By default, this plugin looks for the `['default', 'module', 'import']` conditions when resolving imports.
|
||||
|
||||
When using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the `['default', 'module', 'require']` conditions when resolving require statements.
|
||||
|
||||
Setting this option will add extra conditions on top of the default conditions. See https://nodejs.org/api/packages.html#packages_conditional_exports for more information.
|
||||
|
||||
In order to get the [resolution behavior of Node.js](https://nodejs.org/api/packages.html#packages_conditional_exports), set this to `['node']`.
|
||||
|
||||
### `browser`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If `true`, instructs the plugin to use the browser module resolutions in `package.json` and adds `'browser'` to `exportConditions` if it is not present so browser conditionals in `exports` are applied. If `false`, any browser properties in package files will be ignored. Alternatively, a value of `'browser'` can be added to both the `mainFields` and `exportConditions` options, however this option takes precedence over `mainFields`.
|
||||
|
||||
> This option does not work when a package is using [package entrypoints](https://nodejs.org/api/packages.html#packages_package_entry_points)
|
||||
|
||||
### `moduleDirectories`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `['node_modules']`
|
||||
|
||||
One or more directories in which to recursively look for modules.
|
||||
|
||||
### `dedupe`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `[]`
|
||||
|
||||
An `Array` of modules names, which instructs the plugin to force resolving for the specified modules to the root `node_modules`. Helps to prevent bundling the same package multiple times if package is imported from dependencies.
|
||||
|
||||
```js
|
||||
dedupe: ['my-package', '@namespace/my-package'];
|
||||
```
|
||||
|
||||
This will deduplicate bare imports such as:
|
||||
|
||||
```js
|
||||
import 'my-package';
|
||||
import '@namespace/my-package';
|
||||
```
|
||||
|
||||
And it will deduplicate deep imports such as:
|
||||
|
||||
```js
|
||||
import 'my-package/foo.js';
|
||||
import '@namespace/my-package/bar.js';
|
||||
```
|
||||
|
||||
### `extensions`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `['.mjs', '.js', '.json', '.node']`
|
||||
|
||||
Specifies the extensions of files that the plugin will operate on.
|
||||
|
||||
### `jail`
|
||||
|
||||
Type: `String`<br>
|
||||
Default: `'/'`
|
||||
|
||||
Locks the module search within specified path (e.g. chroot). Modules defined outside this path will be ignored by this plugin.
|
||||
|
||||
### `mainFields`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `['module', 'main']`<br>
|
||||
Valid values: `['browser', 'jsnext:main', 'module', 'main']`
|
||||
|
||||
Specifies the properties to scan within a `package.json`, used to determine the bundle entry point. The order of property names is significant, as the first-found property is used as the resolved entry point. If the array contains `'browser'`, key/values specified in the `package.json` `browser` property will be used.
|
||||
|
||||
### `preferBuiltins`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `true` (with warnings if a builtin module is used over a local version. Set to `true` to disable warning.)
|
||||
|
||||
If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`, the plugin will look for locally installed modules of the same name.
|
||||
|
||||
### `modulesOnly`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If `true`, inspect resolved files to assert that they are ES2015 modules.
|
||||
|
||||
### `resolveOnly`
|
||||
|
||||
Type: `Array[...String|RegExp] | (module: string) => boolean`<br>
|
||||
Default: `null`
|
||||
|
||||
An `Array` which instructs the plugin to limit module resolution to those whose names match patterns in the array. _Note: Modules not matching any patterns will be marked as external._
|
||||
|
||||
Alternatively, you may pass in a function that returns a boolean to confirm whether the module should be included or not.
|
||||
|
||||
Examples:
|
||||
|
||||
- `resolveOnly: ['batman', /^@batcave\/.*$/]`
|
||||
- `resolveOnly: module => !module.includes('joker')`
|
||||
|
||||
### `rootDir`
|
||||
|
||||
Type: `String`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Specifies the root directory from which to resolve modules. Typically used when resolving entry-point imports, and when resolving deduplicated modules. Useful when executing rollup in a package of a mono-repository.
|
||||
|
||||
```
|
||||
// Set the root directory to be the parent folder
|
||||
rootDir: path.join(process.cwd(), '..')
|
||||
```
|
||||
|
||||
### `ignoreSideEffectsForRoot`
|
||||
|
||||
If you use the `sideEffects` property in the package.json, by default this is respected for files in the root package. Set to `true` to ignore the `sideEffects` configuration for the root package.
|
||||
|
||||
## Preserving symlinks
|
||||
|
||||
This plugin honours the rollup [`preserveSymlinks`](https://rollupjs.org/guide/en/#preservesymlinks) option.
|
||||
|
||||
## Using with @rollup/plugin-commonjs
|
||||
|
||||
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs):
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default {
|
||||
input: 'main.js',
|
||||
output: {
|
||||
file: 'bundle.js',
|
||||
format: 'iife',
|
||||
name: 'MyModule'
|
||||
},
|
||||
plugins: [nodeResolve(), commonjs()]
|
||||
};
|
||||
```
|
||||
|
||||
## Resolving Built-Ins (like `fs`)
|
||||
|
||||
By default this plugin will prefer built-ins over local modules, marking them as external.
|
||||
|
||||
See [`preferBuiltins`](#preferbuiltins).
|
||||
|
||||
To provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) and set `preferBuiltins` to `false`. e.g.
|
||||
|
||||
```js
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import nodePolyfills from 'rollup-plugin-node-polyfills';
|
||||
export default ({
|
||||
input: ...,
|
||||
plugins: [
|
||||
nodePolyfills(),
|
||||
nodeResolve({ preferBuiltins: false })
|
||||
],
|
||||
external: builtins,
|
||||
output: ...
|
||||
})
|
||||
```
|
||||
|
||||
## Resolving require statements
|
||||
|
||||
According to [NodeJS module resolution](https://nodejs.org/api/packages.html#packages_package_entry_points) `require` statements should resolve using the `require` condition in the package exports field, while es modules should use the `import` condition.
|
||||
|
||||
The node resolve plugin uses `import` by default, you can opt into using the `require` semantics by passing an extra option to the resolve function:
|
||||
|
||||
```js
|
||||
this.resolve(importee, importer, {
|
||||
skipSelf: true,
|
||||
custom: { 'node-resolve': { isRequire: true } }
|
||||
});
|
||||
```
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
1219
node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js
generated
vendored
Normal file
1219
node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1204
node_modules/@rollup/plugin-node-resolve/dist/es/index.js
generated
vendored
Normal file
1204
node_modules/@rollup/plugin-node-resolve/dist/es/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@rollup/plugin-node-resolve/dist/es/package.json
generated
vendored
Normal file
1
node_modules/@rollup/plugin-node-resolve/dist/es/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"type":"module"}
|
||||
88
node_modules/@rollup/plugin-node-resolve/package.json
generated
vendored
Normal file
88
node_modules/@rollup/plugin-node-resolve/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
"name": "@rollup/plugin-node-resolve",
|
||||
"version": "13.3.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Locate and bundle third-party dependencies in node_modules",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/node-resolve"
|
||||
},
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme",
|
||||
"bugs": "https://github.com/rollup/plugins/issues",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"module": "./dist/es/index.js",
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
"require": "./dist/cjs/index.js",
|
||||
"import": "./dist/es/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm build && pnpm lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build",
|
||||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
||||
"test": "ava && pnpm test:ts",
|
||||
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"es2015",
|
||||
"npm",
|
||||
"modules"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.42.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"@types/resolve": "1.17.1",
|
||||
"deepmerge": "^4.2.2",
|
||||
"is-builtin-module": "^3.1.0",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.19.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.5",
|
||||
"@babel/plugin-transform-typescript": "^7.10.5",
|
||||
"@rollup/plugin-babel": "^5.1.0",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"es5-ext": "^0.10.53",
|
||||
"rollup": "^2.67.3",
|
||||
"source-map": "^0.7.3",
|
||||
"string-capitalize": "^1.0.1"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"ava": {
|
||||
"babel": {
|
||||
"compileEnhancements": false
|
||||
},
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
98
node_modules/@rollup/plugin-node-resolve/types/index.d.ts
generated
vendored
Executable file
98
node_modules/@rollup/plugin-node-resolve/types/index.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
import { Plugin } from 'rollup';
|
||||
|
||||
export const DEFAULTS: {
|
||||
customResolveOptions: {};
|
||||
dedupe: [];
|
||||
extensions: ['.mjs', '.js', '.json', '.node'];
|
||||
resolveOnly: [];
|
||||
};
|
||||
|
||||
export interface RollupNodeResolveOptions {
|
||||
/**
|
||||
* Additional conditions of the package.json exports field to match when resolving modules.
|
||||
* By default, this plugin looks for the `'default', 'module', 'import']` conditions when resolving imports.
|
||||
*
|
||||
* When using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the
|
||||
* `['default', 'module', 'import']` conditions when resolving require statements.
|
||||
*
|
||||
* Setting this option will add extra conditions on top of the default conditions.
|
||||
* See https://nodejs.org/api/packages.html#packages_conditional_exports for more information.
|
||||
*/
|
||||
exportConditions?: string[];
|
||||
|
||||
/**
|
||||
* If `true`, instructs the plugin to use the `"browser"` property in `package.json`
|
||||
* files to specify alternative files to load for bundling. This is useful when
|
||||
* bundling for a browser environment. Alternatively, a value of `'browser'` can be
|
||||
* added to the `mainFields` option. If `false`, any `"browser"` properties in
|
||||
* package files will be ignored. This option takes precedence over `mainFields`.
|
||||
* @default false
|
||||
*/
|
||||
browser?: boolean;
|
||||
|
||||
/**
|
||||
* One or more directories in which to recursively look for modules.
|
||||
* @default ['node_modules']
|
||||
*/
|
||||
moduleDirectories?: string[];
|
||||
|
||||
/**
|
||||
* An `Array` of modules names, which instructs the plugin to force resolving for the
|
||||
* specified modules to the root `node_modules`. Helps to prevent bundling the same
|
||||
* package multiple times if package is imported from dependencies.
|
||||
*/
|
||||
dedupe?: string[] | ((importee: string) => boolean);
|
||||
|
||||
/**
|
||||
* Specifies the extensions of files that the plugin will operate on.
|
||||
* @default [ '.mjs', '.js', '.json', '.node' ]
|
||||
*/
|
||||
extensions?: readonly string[];
|
||||
|
||||
/**
|
||||
* Locks the module search within specified path (e.g. chroot). Modules defined
|
||||
* outside this path will be marked as external.
|
||||
* @default '/'
|
||||
*/
|
||||
jail?: string;
|
||||
|
||||
/**
|
||||
* Specifies the properties to scan within a `package.json`, used to determine the
|
||||
* bundle entry point.
|
||||
* @default ['module', 'main']
|
||||
*/
|
||||
mainFields?: readonly string[];
|
||||
|
||||
/**
|
||||
* If `true`, inspect resolved files to assert that they are ES2015 modules.
|
||||
* @default false
|
||||
*/
|
||||
modulesOnly?: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`,
|
||||
* the plugin will look for locally installed modules of the same name.
|
||||
* @default true
|
||||
*/
|
||||
preferBuiltins?: boolean;
|
||||
|
||||
/**
|
||||
* An `Array` which instructs the plugin to limit module resolution to those whose
|
||||
* names match patterns in the array.
|
||||
* @default []
|
||||
*/
|
||||
resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
|
||||
|
||||
/**
|
||||
* Specifies the root directory from which to resolve modules. Typically used when
|
||||
* resolving entry-point imports, and when resolving deduplicated modules.
|
||||
* @default process.cwd()
|
||||
*/
|
||||
rootDir?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate modules using the Node resolution algorithm, for using third party modules in node_modules
|
||||
*/
|
||||
export function nodeResolve(options?: RollupNodeResolveOptions): Plugin;
|
||||
export default nodeResolve;
|
||||
355
node_modules/@rollup/plugin-typescript/README.md
generated
vendored
Normal file
355
node_modules/@rollup/plugin-typescript/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-typescript
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-typescript
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-typescript
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-typescript
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/plugin-typescript
|
||||
|
||||
🍣 A Rollup plugin for seamless integration between Rollup and Typescript.
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+. This plugin also requires at least [TypeScript 3.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html).
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```console
|
||||
npm install @rollup/plugin-typescript --save-dev
|
||||
```
|
||||
|
||||
Note that both `typescript` and `tslib` are peer dependencies of this plugin that need to be installed separately.
|
||||
|
||||
## Why?
|
||||
|
||||
See [@rollup/plugin-babel](https://github.com/rollup/plugins/tree/master/packages/babel).
|
||||
|
||||
## Usage
|
||||
|
||||
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
dir: 'output',
|
||||
format: 'cjs'
|
||||
},
|
||||
plugins: [typescript()]
|
||||
};
|
||||
```
|
||||
|
||||
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
|
||||
|
||||
## Options
|
||||
|
||||
The plugin loads any [`compilerOptions`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) from the `tsconfig.json` file by default. Passing options to the plugin directly overrides those options:
|
||||
|
||||
```js
|
||||
...
|
||||
export default {
|
||||
input: './main.ts',
|
||||
plugins: [
|
||||
typescript({ compilerOptions: {lib: ["es5", "es6", "dom"], target: "es5"}})
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The following options are unique to `rollup-plugin-typescript`:
|
||||
|
||||
### `exclude`
|
||||
|
||||
Type: `String` | `Array[...String]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. By default no files are ignored.
|
||||
|
||||
### `include`
|
||||
|
||||
Type: `String` | `Array[...String]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default all `.ts` and `.tsx` files are targeted.
|
||||
|
||||
### `filterRoot`
|
||||
|
||||
Type: `String` | `Boolean`<br>
|
||||
Default: `rootDir` ?? `tsConfig.compilerOptions.rootDir` ?? `process.cwd()`
|
||||
|
||||
Optionally resolves the include and exclude patterns against a directory other than `process.cwd()`. If a String is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `false`, then the patterns will not be resolved against any directory.
|
||||
|
||||
By default, patterns resolve against the rootDir set in your TS config file.
|
||||
|
||||
This can fix plugin errors when parsing files outside the current working directory (process.cwd()).
|
||||
|
||||
### `tsconfig`
|
||||
|
||||
Type: `String` | `Boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
When set to false, ignores any options specified in the config file. If set to a string that corresponds to a file path, the specified file will be used as config file.
|
||||
|
||||
### `typescript`
|
||||
|
||||
Type: `import('typescript')`<br>
|
||||
Default: _peer dependency_
|
||||
|
||||
Overrides the TypeScript module used for transpilation.
|
||||
|
||||
```js
|
||||
typescript({
|
||||
typescript: require('some-fork-of-typescript')
|
||||
});
|
||||
```
|
||||
|
||||
### `tslib`
|
||||
|
||||
Type: `String`<br>
|
||||
Default: _peer dependency_
|
||||
|
||||
Overrides the injected TypeScript helpers with a custom version.
|
||||
|
||||
```js
|
||||
typescript({
|
||||
tslib: require.resolve('some-fork-of-tslib')
|
||||
});
|
||||
```
|
||||
|
||||
### `transformers`
|
||||
|
||||
Type: `{ [before | after | afterDeclarations]: TransformerFactory[] }`<br>
|
||||
Default: `undefined`
|
||||
|
||||
Allows registration of TypeScript custom transformers at any of the supported stages:
|
||||
|
||||
- **before**: transformers will execute before the TypeScript's own transformers on raw TypeScript files
|
||||
- **after**: transformers will execute after the TypeScript transformers on transpiled code
|
||||
- **afterDeclarations**: transformers will execute after declaration file generation allowing to modify existing declaration files
|
||||
|
||||
Supported transformer factories:
|
||||
|
||||
- all **built-in** TypeScript custom transformer factories:
|
||||
|
||||
- `import('typescript').TransformerFactory` annotated **TransformerFactory** bellow
|
||||
- `import('typescript').CustomTransformerFactory` annotated **CustomTransformerFactory** bellow
|
||||
|
||||
- **ProgramTransformerFactory** represents a transformer factory allowing the resulting transformer to grab a reference to the **Program** instance
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'program',
|
||||
factory: (program: Program) => TransformerFactory | CustomTransformerFactory
|
||||
}
|
||||
```
|
||||
|
||||
- **TypeCheckerTransformerFactory** represents a transformer factory allowing the resulting transformer to grab a reference to the **TypeChecker** instance
|
||||
```js
|
||||
{
|
||||
type: 'typeChecker',
|
||||
factory: (typeChecker: TypeChecker) => TransformerFactory | CustomTransformerFactory
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
typescript({
|
||||
transformers: {
|
||||
before: [
|
||||
{
|
||||
// Allow the transformer to get a Program reference in it's factory
|
||||
type: 'program',
|
||||
factory: (program) => {
|
||||
return ProgramRequiringTransformerFactory(program);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'typeChecker',
|
||||
factory: (typeChecker) => {
|
||||
// Allow the transformer to get a TypeChecker reference in it's factory
|
||||
return TypeCheckerRequiringTransformerFactory(typeChecker);
|
||||
}
|
||||
}
|
||||
],
|
||||
after: [
|
||||
// You can use normal transformers directly
|
||||
require('custom-transformer-based-on-Context')
|
||||
],
|
||||
afterDeclarations: [
|
||||
// Or even define in place
|
||||
function fixDeclarationFactory(context) {
|
||||
return function fixDeclaration(source) {
|
||||
function visitor(node) {
|
||||
// Do real work here
|
||||
|
||||
return ts.visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
return ts.visitEachChild(source, visitor, context);
|
||||
};
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### `cacheDir`
|
||||
|
||||
Type: `String`<br>
|
||||
Default: _.rollup.cache_
|
||||
|
||||
When compiling with `incremental` or `composite` options the plugin will
|
||||
store compiled files in this folder. This allows the use of incremental
|
||||
compilation.
|
||||
|
||||
```js
|
||||
typescript({
|
||||
cacheDir: '.rollup.tscache'
|
||||
});
|
||||
```
|
||||
|
||||
### `noForceEmit`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Earlier version of `@rollup/plugin-typescript` required that the `compilerOptions` `noEmit` and `emitDeclarationOnly` both false to guarantee that source code was fed into the next plugin/output. This is no longer true. This option disables the plugin forcing the values of those options and instead defers to the values set in `tsconfig.json`.
|
||||
|
||||
`noForceEmit` can be very useful if you use with `@rollup/plugin-babel` and `@babel/preset-typescript`. Having `@rollup/plugin-typescript` only do typechecking / declarations with `"emitDeclarationOnly": true` while deferring to `@rollup/plugin-babel` for transpilation can dramatically reduce `rollup` build times for large projects.
|
||||
|
||||
### Typescript compiler options
|
||||
|
||||
Some of Typescript's [CompilerOptions](https://www.typescriptlang.org/docs/handbook/compiler-options.html) affect how Rollup builds files.
|
||||
|
||||
#### `noEmitOnError`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
If a type error is detected, the Rollup build is aborted when this option is set to true.
|
||||
|
||||
#### `files`, `include`, `exclude`
|
||||
|
||||
Type: `Array[...String]`<br>
|
||||
Default: `[]`
|
||||
|
||||
Declaration files are automatically included if they are listed in the `files` field in your `tsconfig.json` file. Source files in these fields are ignored as Rollup's configuration is used instead.
|
||||
|
||||
#### Ignored options
|
||||
|
||||
These compiler options are ignored by Rollup:
|
||||
|
||||
- `noEmitHelpers`, `importHelpers`: The `tslib` helper module always must be used.
|
||||
- `noEmit`, `emitDeclarationOnly`: Typescript needs to emit code for the plugin to work with.
|
||||
- _Note: While this was true for early iterations of `@rollup/plugin-typescript`, it is no longer. To override this behavior, and defer to `tsconfig.json` for these options, see the [`noForceEmit`](#noForceEmit) option_
|
||||
- `noResolve`: Preventing Typescript from resolving code may break compilation
|
||||
|
||||
### Importing CommonJS
|
||||
|
||||
Though it is not recommended, it is possible to configure this plugin to handle imports of CommonJS files from TypeScript. For this, you need to specify `CommonJS` as the module format and add [`@rollup/plugin-commonjs`](https://github.com/rollup/plugins/tree/master/packages/commonjs) to transpile the CommonJS output generated by TypeScript to ES Modules so that rollup can process it.
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default {
|
||||
input: './main.ts',
|
||||
plugins: [
|
||||
typescript({ compilerOptions: { module: 'CommonJS' } }),
|
||||
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
Note that this will often result in less optimal output.
|
||||
|
||||
### Preserving JSX output
|
||||
|
||||
Whenever choosing to preserve JSX output to be further consumed by another transform step via `tsconfig` `compilerOptions` by setting `jsx: 'preserve'` or [overriding options](#options), please bear in mind that, by itself, this plugin won't be able to preserve JSX output, usually failing with:
|
||||
|
||||
```sh
|
||||
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
|
||||
file.tsx (1:15)
|
||||
1: export default <span>Foobar</span>
|
||||
^
|
||||
```
|
||||
|
||||
To prevent that, make sure to use the acorn plugin, namely `acorn-jsx`, which will make Rollup's parser acorn handle JSX tokens. (See https://rollupjs.org/guide/en/#acorninjectplugins)
|
||||
|
||||
After adding `acorn-jsx` plugin, your Rollup config would look like the following, correctly preserving your JSX output.
|
||||
|
||||
```js
|
||||
import jsx from 'acorn-jsx';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
|
||||
export default {
|
||||
// … other options …
|
||||
acornInjectPlugins: [jsx()],
|
||||
plugins: [typescript({ compilerOptions: { jsx: 'preserve' } })]
|
||||
};
|
||||
```
|
||||
|
||||
### Faster compiling
|
||||
|
||||
Previous versions of this plugin used Typescript's `transpileModule` API, which is faster but does not perform typechecking and does not support cross-file features like `const enum`s and emit-less types. If you want this behaviour, you can use [@rollup/plugin-sucrase](https://github.com/rollup/plugins/tree/master/packages/sucrase) instead.
|
||||
|
||||
### Declaration Output With `output.file`
|
||||
|
||||
When instructing Rollup to output a specific file name via the `output.file` Rollup configuration, and TypeScript to output declaration files, users may encounter a situation where the declarations are nested improperly. And additionally when attempting to fix the improper nesting via use of `outDir` or `declarationDir` result in further TypeScript errors.
|
||||
|
||||
Consider the following `rollup.config.js` file:
|
||||
|
||||
```js
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
file: 'dist/index.mjs'
|
||||
},
|
||||
plugins: [typescript()]
|
||||
};
|
||||
```
|
||||
|
||||
And accompanying `tsconfig.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"include": ["*"],
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"declaration": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This setup will produce `dist/index.mjs` and `dist/src/index.d.ts`. To correctly place the declaration file, add an `exclude` setting in `tsconfig` and modify the `declarationDir` setting in `compilerOptions` to resemble:
|
||||
|
||||
```json
|
||||
{
|
||||
"include": ["*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"declaration": true,
|
||||
"declarationDir": "."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This will result in the correct output of `dist/index.mjs` and `dist/index.d.ts`.
|
||||
|
||||
_For reference, please see the workaround this section is based on [here](https://github.com/microsoft/bistring/commit/7e57116c812ae2c01f383c234f3b447f733b5d0c)_
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
853
node_modules/@rollup/plugin-typescript/dist/index.es.js
generated
vendored
Normal file
853
node_modules/@rollup/plugin-typescript/dist/index.es.js
generated
vendored
Normal file
|
|
@ -0,0 +1,853 @@
|
|||
import * as path from 'path';
|
||||
import path__default, { resolve as resolve$1, dirname, relative } from 'path';
|
||||
import { createFilter } from '@rollup/pluginutils';
|
||||
import * as defaultTs from 'typescript';
|
||||
import { ModuleKind, ModuleResolutionKind, DiagnosticCategory } from 'typescript';
|
||||
import resolve from 'resolve';
|
||||
import fs, { readFileSync, promises } from 'fs';
|
||||
|
||||
/**
|
||||
* Create a format diagnostics host to use with the Typescript type checking APIs.
|
||||
* Typescript hosts are used to represent the user's system,
|
||||
* with an API for checking case sensitivity etc.
|
||||
* @param compilerOptions Typescript compiler options. Affects functions such as `getNewLine`.
|
||||
* @see https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
|
||||
*/
|
||||
function createFormattingHost(ts, compilerOptions) {
|
||||
return {
|
||||
/** Returns the compiler options for the project. */
|
||||
getCompilationSettings: () => compilerOptions,
|
||||
/** Returns the current working directory. */
|
||||
getCurrentDirectory: () => process.cwd(),
|
||||
/** Returns the string that corresponds with the selected `NewLineKind`. */
|
||||
getNewLine() {
|
||||
switch (compilerOptions.newLine) {
|
||||
case ts.NewLineKind.CarriageReturnLineFeed:
|
||||
return '\r\n';
|
||||
case ts.NewLineKind.LineFeed:
|
||||
return '\n';
|
||||
default:
|
||||
return ts.sys.newLine;
|
||||
}
|
||||
},
|
||||
/** Returns a lower case name on case insensitive systems, otherwise the original name. */
|
||||
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a helper for resolving modules using Typescript.
|
||||
* @param host Typescript host that extends `ModuleResolutionHost`
|
||||
* with methods for sanitizing filenames and getting compiler options.
|
||||
*/
|
||||
function createModuleResolver(ts, host) {
|
||||
const compilerOptions = host.getCompilationSettings();
|
||||
const cache = ts.createModuleResolutionCache(process.cwd(), host.getCanonicalFileName, compilerOptions);
|
||||
const moduleHost = Object.assign(Object.assign({}, ts.sys), host);
|
||||
return (moduleName, containingFile, redirectedReference, mode) => {
|
||||
const resolved = ts.resolveModuleName(moduleName, containingFile, compilerOptions, moduleHost, cache, redirectedReference, mode);
|
||||
return resolved.resolvedModule;
|
||||
};
|
||||
}
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
// const resolveIdAsync = (file: string, opts: AsyncOpts) =>
|
||||
// new Promise<string>((fulfil, reject) =>
|
||||
// resolveId(file, opts, (err, contents) =>
|
||||
// err || typeof contents === 'undefined' ? reject(err) : fulfil(contents)
|
||||
// )
|
||||
// );
|
||||
const resolveId = (file, opts) => resolve.sync(file, opts);
|
||||
/**
|
||||
* Returns code asynchronously for the tslib helper library.
|
||||
*/
|
||||
const getTsLibPath = () => {
|
||||
// Note: This isn't preferable, but we've no other way to test this bit. Removing the tslib devDep
|
||||
// during the test run doesn't work due to the nature of the pnpm flat node_modules, and
|
||||
// other workspace dependencies that depenend upon tslib.
|
||||
try {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
return resolveId(process.env.__TSLIB_TEST_PATH__ || 'tslib/tslib.es6.js', {
|
||||
basedir: __dirname
|
||||
});
|
||||
}
|
||||
catch (_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Separate the Rollup plugin options from the Typescript compiler options,
|
||||
* and normalize the Rollup options.
|
||||
* @returns Object with normalized options:
|
||||
* - `filter`: Checks if a file should be included.
|
||||
* - `tsconfig`: Path to a tsconfig, or directive to ignore tsconfig.
|
||||
* - `compilerOptions`: Custom Typescript compiler options that override tsconfig.
|
||||
* - `typescript`: Instance of Typescript library (possibly custom).
|
||||
* - `tslib`: ESM code from the tslib helper library (possibly custom).
|
||||
*/
|
||||
const getPluginOptions = (options) => {
|
||||
const { cacheDir, exclude, include, filterRoot, noForceEmit, transformers, tsconfig, tslib, typescript, outputToFilesystem, compilerOptions } = options,
|
||||
// previously was compilerOptions
|
||||
extra = __rest(options, ["cacheDir", "exclude", "include", "filterRoot", "noForceEmit", "transformers", "tsconfig", "tslib", "typescript", "outputToFilesystem", "compilerOptions"]);
|
||||
return {
|
||||
cacheDir,
|
||||
include,
|
||||
exclude,
|
||||
filterRoot,
|
||||
noForceEmit: noForceEmit || false,
|
||||
tsconfig,
|
||||
compilerOptions: Object.assign(Object.assign({}, extra), compilerOptions),
|
||||
typescript: typescript || defaultTs,
|
||||
tslib: tslib || getTsLibPath(),
|
||||
transformers,
|
||||
outputToFilesystem
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Typescript type error into an equivalent Rollup warning object.
|
||||
*/
|
||||
function diagnosticToWarning(ts, host, diagnostic) {
|
||||
const pluginCode = `TS${diagnostic.code}`;
|
||||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||
// Build a Rollup warning object from the diagnostics object.
|
||||
const warning = {
|
||||
pluginCode,
|
||||
message: `@rollup/plugin-typescript ${pluginCode}: ${message}`
|
||||
};
|
||||
if (diagnostic.file) {
|
||||
// Add information about the file location
|
||||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
warning.loc = {
|
||||
column: character + 1,
|
||||
line: line + 1,
|
||||
file: diagnostic.file.fileName
|
||||
};
|
||||
if (host) {
|
||||
// Extract a code frame from Typescript
|
||||
const formatted = ts.formatDiagnosticsWithColorAndContext([diagnostic], host);
|
||||
// Typescript only exposes this formatter as a string prefixed with the flattened message.
|
||||
// We need to remove it here since Rollup treats the properties as separate parts.
|
||||
let frame = formatted.slice(formatted.indexOf(message) + message.length);
|
||||
const newLine = host.getNewLine();
|
||||
if (frame.startsWith(newLine)) {
|
||||
frame = frame.slice(frame.indexOf(newLine) + newLine.length);
|
||||
}
|
||||
warning.frame = frame;
|
||||
}
|
||||
}
|
||||
return warning;
|
||||
}
|
||||
|
||||
const DEFAULT_COMPILER_OPTIONS = {
|
||||
module: 'esnext',
|
||||
skipLibCheck: true
|
||||
};
|
||||
const OVERRIDABLE_EMIT_COMPILER_OPTIONS = {
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: false
|
||||
};
|
||||
const FORCED_COMPILER_OPTIONS = {
|
||||
// Always use tslib
|
||||
noEmitHelpers: true,
|
||||
importHelpers: true,
|
||||
// Preventing Typescript from resolving code may break compilation
|
||||
noResolve: false
|
||||
};
|
||||
|
||||
/* eslint-disable no-param-reassign */
|
||||
const DIRECTORY_PROPS = ['outDir', 'declarationDir'];
|
||||
/**
|
||||
* Mutates the compiler options to convert paths from relative to absolute.
|
||||
* This should be used with compiler options passed through the Rollup plugin options,
|
||||
* not those found from loading a tsconfig.json file.
|
||||
* @param compilerOptions Compiler options to _mutate_.
|
||||
* @param relativeTo Paths are resolved relative to this path.
|
||||
*/
|
||||
function makePathsAbsolute(compilerOptions, relativeTo) {
|
||||
for (const pathProp of DIRECTORY_PROPS) {
|
||||
if (compilerOptions[pathProp]) {
|
||||
compilerOptions[pathProp] = resolve$1(relativeTo, compilerOptions[pathProp]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Mutates the compiler options to normalize some values for Rollup.
|
||||
* @param compilerOptions Compiler options to _mutate_.
|
||||
* @returns True if the source map compiler option was not initially set.
|
||||
*/
|
||||
function normalizeCompilerOptions(ts, compilerOptions) {
|
||||
let autoSetSourceMap = false;
|
||||
if (compilerOptions.inlineSourceMap) {
|
||||
// Force separate source map files for Rollup to work with.
|
||||
compilerOptions.sourceMap = true;
|
||||
compilerOptions.inlineSourceMap = false;
|
||||
}
|
||||
else if (typeof compilerOptions.sourceMap !== 'boolean') {
|
||||
// Default to using source maps.
|
||||
// If the plugin user sets sourceMap to false we keep that option.
|
||||
compilerOptions.sourceMap = true;
|
||||
// Using inlineSources to make sure typescript generate source content
|
||||
// instead of source path.
|
||||
compilerOptions.inlineSources = true;
|
||||
autoSetSourceMap = true;
|
||||
}
|
||||
switch (compilerOptions.module) {
|
||||
case ts.ModuleKind.ES2015:
|
||||
case ts.ModuleKind.ESNext:
|
||||
case ts.ModuleKind.Node16:
|
||||
case ts.ModuleKind.NodeNext:
|
||||
case ts.ModuleKind.CommonJS:
|
||||
// OK module type
|
||||
return autoSetSourceMap;
|
||||
case ts.ModuleKind.None:
|
||||
case ts.ModuleKind.AMD:
|
||||
case ts.ModuleKind.UMD:
|
||||
case ts.ModuleKind.System: {
|
||||
// Invalid module type
|
||||
const moduleType = ts.ModuleKind[compilerOptions.module];
|
||||
throw new Error(`@rollup/plugin-typescript: The module kind should be 'ES2015', 'ESNext', 'node16' or 'nodenext', found: '${moduleType}'`);
|
||||
}
|
||||
default:
|
||||
// Unknown or unspecified module type, force ESNext
|
||||
compilerOptions.module = ts.ModuleKind.ESNext;
|
||||
}
|
||||
return autoSetSourceMap;
|
||||
}
|
||||
|
||||
function makeForcedCompilerOptions(noForceEmit) {
|
||||
return Object.assign(Object.assign({}, FORCED_COMPILER_OPTIONS), (noForceEmit ? {} : OVERRIDABLE_EMIT_COMPILER_OPTIONS));
|
||||
}
|
||||
/**
|
||||
* Finds the path to the tsconfig file relative to the current working directory.
|
||||
* @param relativePath Relative tsconfig path given by the user.
|
||||
* If `false` is passed, then a null path is returned.
|
||||
* @returns The absolute path, or null if the file does not exist.
|
||||
*/
|
||||
function getTsConfigPath(ts, relativePath) {
|
||||
if (relativePath === false)
|
||||
return null;
|
||||
// Resolve path to file. `tsConfigOption` defaults to 'tsconfig.json'.
|
||||
const tsConfigPath = resolve$1(process.cwd(), relativePath || 'tsconfig.json');
|
||||
if (!ts.sys.fileExists(tsConfigPath)) {
|
||||
if (relativePath) {
|
||||
// If an explicit path was provided but no file was found, throw
|
||||
throw new Error(`Could not find specified tsconfig.json at ${tsConfigPath}`);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return tsConfigPath;
|
||||
}
|
||||
/**
|
||||
* Tries to read the tsconfig file at `tsConfigPath`.
|
||||
* @param tsConfigPath Absolute path to tsconfig JSON file.
|
||||
* @param explicitPath If true, the path was set by the plugin user.
|
||||
* If false, the path was computed automatically.
|
||||
*/
|
||||
function readTsConfigFile(ts, tsConfigPath) {
|
||||
const { config, error } = ts.readConfigFile(tsConfigPath, (path) => readFileSync(path, 'utf8'));
|
||||
if (error) {
|
||||
throw Object.assign(Error(), diagnosticToWarning(ts, null, error));
|
||||
}
|
||||
return config || {};
|
||||
}
|
||||
/**
|
||||
* Returns true if any of the `compilerOptions` contain an enum value (i.e.: ts.ScriptKind) rather than a string.
|
||||
* This indicates that the internal CompilerOptions type is used rather than the JsonCompilerOptions.
|
||||
*/
|
||||
function containsEnumOptions(compilerOptions) {
|
||||
const enums = [
|
||||
'module',
|
||||
'target',
|
||||
'jsx',
|
||||
'moduleResolution',
|
||||
'newLine'
|
||||
];
|
||||
return enums.some((prop) => prop in compilerOptions && typeof compilerOptions[prop] === 'number');
|
||||
}
|
||||
/**
|
||||
* The module resolution kind is a function of the resolved `compilerOptions.module`.
|
||||
* This needs to be set explicitly for `resolveModuleName` to select the correct resolution method
|
||||
*/
|
||||
function setModuleResolutionKind(parsedConfig) {
|
||||
const moduleKind = parsedConfig.options.module;
|
||||
const moduleResolution = moduleKind === ModuleKind.Node16
|
||||
? ModuleResolutionKind.Node16
|
||||
: moduleKind === ModuleKind.NodeNext
|
||||
? ModuleResolutionKind.NodeNext
|
||||
: ModuleResolutionKind.NodeJs;
|
||||
return Object.assign(Object.assign({}, parsedConfig), { options: Object.assign(Object.assign({}, parsedConfig.options), { moduleResolution }) });
|
||||
}
|
||||
const configCache = new Map();
|
||||
/**
|
||||
* Parse the Typescript config to use with the plugin.
|
||||
* @param ts Typescript library instance.
|
||||
* @param tsconfig Path to the tsconfig file, or `false` to ignore the file.
|
||||
* @param compilerOptions Options passed to the plugin directly for Typescript.
|
||||
*
|
||||
* @returns Parsed tsconfig.json file with some important properties:
|
||||
* - `options`: Parsed compiler options.
|
||||
* - `fileNames` Type definition files that should be included in the build.
|
||||
* - `errors`: Any errors from parsing the config file.
|
||||
*/
|
||||
function parseTypescriptConfig(ts, tsconfig, compilerOptions, noForceEmit) {
|
||||
/* eslint-disable no-undefined */
|
||||
const cwd = process.cwd();
|
||||
makePathsAbsolute(compilerOptions, cwd);
|
||||
let parsedConfig;
|
||||
// Resolve path to file. If file is not found, pass undefined path to `parseJsonConfigFileContent`.
|
||||
// eslint-disable-next-line no-undefined
|
||||
const tsConfigPath = getTsConfigPath(ts, tsconfig) || undefined;
|
||||
const tsConfigFile = tsConfigPath ? readTsConfigFile(ts, tsConfigPath) : {};
|
||||
const basePath = tsConfigPath ? dirname(tsConfigPath) : cwd;
|
||||
// If compilerOptions has enums, it represents an CompilerOptions object instead of parsed JSON.
|
||||
// This determines where the data is passed to the parser.
|
||||
if (containsEnumOptions(compilerOptions)) {
|
||||
parsedConfig = setModuleResolutionKind(ts.parseJsonConfigFileContent(Object.assign(Object.assign({}, tsConfigFile), { compilerOptions: Object.assign(Object.assign({}, DEFAULT_COMPILER_OPTIONS), tsConfigFile.compilerOptions) }), ts.sys, basePath, Object.assign(Object.assign({}, compilerOptions), makeForcedCompilerOptions(noForceEmit)), tsConfigPath, undefined, undefined, configCache));
|
||||
}
|
||||
else {
|
||||
parsedConfig = setModuleResolutionKind(ts.parseJsonConfigFileContent(Object.assign(Object.assign({}, tsConfigFile), { compilerOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_COMPILER_OPTIONS), tsConfigFile.compilerOptions), compilerOptions) }), ts.sys, basePath, makeForcedCompilerOptions(noForceEmit), tsConfigPath, undefined, undefined, configCache));
|
||||
}
|
||||
const autoSetSourceMap = normalizeCompilerOptions(ts, parsedConfig.options);
|
||||
return Object.assign(Object.assign({}, parsedConfig), { autoSetSourceMap });
|
||||
}
|
||||
/**
|
||||
* If errors are detected in the parsed options,
|
||||
* display all of them as warnings then emit an error.
|
||||
*/
|
||||
function emitParsedOptionsErrors(ts, context, parsedOptions) {
|
||||
if (parsedOptions.errors.length > 0) {
|
||||
parsedOptions.errors.forEach((error) => context.warn(diagnosticToWarning(ts, null, error)));
|
||||
context.error(`@rollup/plugin-typescript: Couldn't process compiler options`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the `compilerOptions.sourceMap` option matches `outputOptions.sourcemap`.
|
||||
* @param context Rollup plugin context used to emit warnings.
|
||||
* @param compilerOptions Typescript compiler options.
|
||||
* @param outputOptions Rollup output options.
|
||||
* @param autoSetSourceMap True if the `compilerOptions.sourceMap` property was set to `true`
|
||||
* by the plugin, not the user.
|
||||
*/
|
||||
function validateSourceMap(context, compilerOptions, outputOptions, autoSetSourceMap) {
|
||||
if (compilerOptions.sourceMap && !outputOptions.sourcemap && !autoSetSourceMap) {
|
||||
context.warn(`@rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.`);
|
||||
}
|
||||
else if (!compilerOptions.sourceMap && outputOptions.sourcemap) {
|
||||
context.warn(`@rollup/plugin-typescript: Typescript 'sourceMap' compiler option must be set to generate source maps.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validate that the out directory used by Typescript can be controlled by Rollup.
|
||||
* @param context Rollup plugin context used to emit errors.
|
||||
* @param compilerOptions Typescript compiler options.
|
||||
* @param outputOptions Rollup output options.
|
||||
*/
|
||||
function validatePaths(context, compilerOptions, outputOptions) {
|
||||
if (compilerOptions.out) {
|
||||
context.error(`@rollup/plugin-typescript: Deprecated Typescript compiler option 'out' is not supported. Use 'outDir' instead.`);
|
||||
}
|
||||
else if (compilerOptions.outFile) {
|
||||
context.error(`@rollup/plugin-typescript: Typescript compiler option 'outFile' is not supported. Use 'outDir' instead.`);
|
||||
}
|
||||
for (const dirProperty of DIRECTORY_PROPS) {
|
||||
if (compilerOptions[dirProperty] && outputOptions.dir) {
|
||||
// Checks if the given path lies within Rollup output dir
|
||||
const fromRollupDirToTs = relative(outputOptions.dir, compilerOptions[dirProperty]);
|
||||
if (fromRollupDirToTs.startsWith('..')) {
|
||||
context.error(`@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside Rollup 'dir' option.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (compilerOptions.declaration || compilerOptions.declarationMap || compilerOptions.composite) {
|
||||
if (DIRECTORY_PROPS.every((dirProperty) => !compilerOptions[dirProperty])) {
|
||||
context.error(`@rollup/plugin-typescript: You are using one of Typescript's compiler options 'declaration', 'declarationMap' or 'composite'. ` +
|
||||
`In this case 'outDir' or 'declarationDir' must be specified to generate declaration files.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given OutputFile represents some code
|
||||
*/
|
||||
function isCodeOutputFile(name) {
|
||||
return !isMapOutputFile(name) && !name.endsWith('.d.ts');
|
||||
}
|
||||
/**
|
||||
* Checks if the given OutputFile represents some source map
|
||||
*/
|
||||
function isMapOutputFile(name) {
|
||||
return name.endsWith('.map');
|
||||
}
|
||||
/**
|
||||
* Returns the content of a filename either from the current
|
||||
* typescript compiler instance or from the cached content.
|
||||
* @param fileName The filename for the contents to retrieve
|
||||
* @param emittedFiles The files emitted in the current typescript instance
|
||||
* @param tsCache A cache to files cached by Typescript
|
||||
*/
|
||||
function getEmittedFile(fileName, emittedFiles, tsCache) {
|
||||
let code;
|
||||
if (fileName) {
|
||||
if (emittedFiles.has(fileName)) {
|
||||
code = emittedFiles.get(fileName);
|
||||
}
|
||||
else {
|
||||
code = tsCache.getCached(fileName);
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
/**
|
||||
* Finds the corresponding emitted Javascript files for a given Typescript file.
|
||||
* @param id Path to the Typescript file.
|
||||
* @param emittedFiles Map of file names to source code,
|
||||
* containing files emitted by the Typescript compiler.
|
||||
*/
|
||||
function findTypescriptOutput(ts, parsedOptions, id, emittedFiles, tsCache) {
|
||||
const emittedFileNames = ts.getOutputFileNames(parsedOptions, id, !ts.sys.useCaseSensitiveFileNames);
|
||||
const codeFile = emittedFileNames.find(isCodeOutputFile);
|
||||
const mapFile = emittedFileNames.find(isMapOutputFile);
|
||||
return {
|
||||
code: getEmittedFile(codeFile, emittedFiles, tsCache),
|
||||
map: getEmittedFile(mapFile, emittedFiles, tsCache),
|
||||
declarations: emittedFileNames.filter((name) => name !== codeFile && name !== mapFile)
|
||||
};
|
||||
}
|
||||
function normalizePath(fileName) {
|
||||
return fileName.split(path.win32.sep).join(path.posix.sep);
|
||||
}
|
||||
async function emitFile({ dir }, outputToFilesystem, context, filePath, fileSource) {
|
||||
const normalizedFilePath = normalizePath(filePath);
|
||||
// const normalizedPath = normalizePath(filePath);
|
||||
// Note: `dir` can be a value like `dist` in which case, `path.relative` could result in a value
|
||||
// of something like `'../.tsbuildinfo'. Our else-case below needs to mimic `path.relative`
|
||||
// returning a dot-notated relative path, so the first if-then branch is entered into
|
||||
const relativePath = dir ? path.relative(dir, normalizedFilePath) : '..';
|
||||
// legal paths do not start with . nor .. : https://github.com/rollup/rollup/issues/3507#issuecomment-616495912
|
||||
if (relativePath.startsWith('..')) {
|
||||
if (outputToFilesystem == null) {
|
||||
context.warn(`@rollup/plugin-typescript: outputToFilesystem option is defaulting to true.`);
|
||||
}
|
||||
if (outputToFilesystem !== false) {
|
||||
await promises.mkdir(path.dirname(normalizedFilePath), { recursive: true });
|
||||
await promises.writeFile(normalizedFilePath, fileSource);
|
||||
}
|
||||
}
|
||||
else {
|
||||
context.emitFile({
|
||||
type: 'asset',
|
||||
fileName: relativePath,
|
||||
source: fileSource
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const pluginName = '@rollup/plugin-typescript';
|
||||
const moduleErrorMessage = `
|
||||
${pluginName}: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a
|
||||
"module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext"
|
||||
in the target tsconfig.json file or plugin options.`.replace(/\n/g, '');
|
||||
const tsLibErrorMessage = `${pluginName}: Could not find module 'tslib', which is required by this plugin. Is it installed?`;
|
||||
let undef;
|
||||
const validModules = [
|
||||
ModuleKind.ES2015,
|
||||
ModuleKind.ES2020,
|
||||
ModuleKind.ESNext,
|
||||
ModuleKind.Node16,
|
||||
ModuleKind.NodeNext,
|
||||
undef
|
||||
];
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
const preflight = ({ config, context, rollupOptions, tslib }) => {
|
||||
if (!validModules.includes(config.options.module)) {
|
||||
context.warn(moduleErrorMessage);
|
||||
}
|
||||
if (!rollupOptions.preserveModules && tslib === null) {
|
||||
context.error(tsLibErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
// `Cannot compile modules into 'es6' when targeting 'ES5' or lower.`
|
||||
const CANNOT_COMPILE_ESM = 1204;
|
||||
/**
|
||||
* Emit a Rollup warning or error for a Typescript type error.
|
||||
*/
|
||||
function emitDiagnostic(ts, context, host, diagnostic) {
|
||||
if (diagnostic.code === CANNOT_COMPILE_ESM)
|
||||
return;
|
||||
const { noEmitOnError } = host.getCompilationSettings();
|
||||
// Build a Rollup warning object from the diagnostics object.
|
||||
const warning = diagnosticToWarning(ts, host, diagnostic);
|
||||
// Errors are fatal. Otherwise emit warnings.
|
||||
if (noEmitOnError && diagnostic.category === ts.DiagnosticCategory.Error) {
|
||||
context.error(warning);
|
||||
}
|
||||
else {
|
||||
context.warn(warning);
|
||||
}
|
||||
}
|
||||
function buildDiagnosticReporter(ts, context, host) {
|
||||
return function reportDiagnostics(diagnostic) {
|
||||
emitDiagnostic(ts, context, host, diagnostic);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges all received custom transformer definitions into a single CustomTransformers object
|
||||
*/
|
||||
function mergeTransformers(builder, ...input) {
|
||||
// List of all transformer stages
|
||||
const transformerTypes = ['after', 'afterDeclarations', 'before'];
|
||||
const accumulator = {
|
||||
after: [],
|
||||
afterDeclarations: [],
|
||||
before: []
|
||||
};
|
||||
let program;
|
||||
let typeChecker;
|
||||
input.forEach((transformers) => {
|
||||
if (!transformers) {
|
||||
// Skip empty arguments lists
|
||||
return;
|
||||
}
|
||||
transformerTypes.forEach((stage) => {
|
||||
getTransformers(transformers[stage]).forEach((transformer) => {
|
||||
if (!transformer) {
|
||||
// Skip empty
|
||||
return;
|
||||
}
|
||||
if ('type' in transformer) {
|
||||
if (typeof transformer.factory === 'function') {
|
||||
// Allow custom factories to grab the extra information required
|
||||
program = program || builder.getProgram();
|
||||
typeChecker = typeChecker || program.getTypeChecker();
|
||||
let factory;
|
||||
if (transformer.type === 'program') {
|
||||
program = program || builder.getProgram();
|
||||
factory = transformer.factory(program);
|
||||
}
|
||||
else {
|
||||
program = program || builder.getProgram();
|
||||
typeChecker = typeChecker || program.getTypeChecker();
|
||||
factory = transformer.factory(typeChecker);
|
||||
}
|
||||
// Forward the requested reference to the custom transformer factory
|
||||
if (factory) {
|
||||
accumulator[stage].push(factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add normal transformer factories as is
|
||||
accumulator[stage].push(transformer);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
function getTransformers(transformers) {
|
||||
return transformers || [];
|
||||
}
|
||||
|
||||
// @see https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
|
||||
// eslint-disable-next-line no-shadow
|
||||
var DiagnosticCode;
|
||||
(function (DiagnosticCode) {
|
||||
DiagnosticCode[DiagnosticCode["FILE_CHANGE_DETECTED"] = 6032] = "FILE_CHANGE_DETECTED";
|
||||
DiagnosticCode[DiagnosticCode["FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES"] = 6193] = "FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES";
|
||||
DiagnosticCode[DiagnosticCode["FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES"] = 6194] = "FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES";
|
||||
})(DiagnosticCode || (DiagnosticCode = {}));
|
||||
function createDeferred(timeout) {
|
||||
let promise;
|
||||
let resolve = () => { };
|
||||
if (timeout) {
|
||||
promise = Promise.race([
|
||||
new Promise((r) => setTimeout(r, timeout, true)),
|
||||
new Promise((r) => (resolve = r))
|
||||
]);
|
||||
}
|
||||
else {
|
||||
promise = new Promise((r) => (resolve = r));
|
||||
}
|
||||
return { promise, resolve };
|
||||
}
|
||||
/**
|
||||
* Typescript watch program helper to sync Typescript watch status with Rollup hooks.
|
||||
*/
|
||||
class WatchProgramHelper {
|
||||
constructor() {
|
||||
this._startDeferred = null;
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
watch(timeout = 1000) {
|
||||
// Race watcher start promise against a timeout in case Typescript and Rollup change detection is not in sync.
|
||||
this._startDeferred = createDeferred(timeout);
|
||||
this._finishDeferred = createDeferred();
|
||||
}
|
||||
handleStatus(diagnostic) {
|
||||
// Fullfil deferred promises by Typescript diagnostic message codes.
|
||||
if (diagnostic.category === DiagnosticCategory.Message) {
|
||||
switch (diagnostic.code) {
|
||||
case DiagnosticCode.FILE_CHANGE_DETECTED:
|
||||
this.resolveStart();
|
||||
break;
|
||||
case DiagnosticCode.FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES:
|
||||
case DiagnosticCode.FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES:
|
||||
this.resolveFinish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
resolveStart() {
|
||||
if (this._startDeferred) {
|
||||
this._startDeferred.resolve(false);
|
||||
this._startDeferred = null;
|
||||
}
|
||||
}
|
||||
resolveFinish() {
|
||||
if (this._finishDeferred) {
|
||||
this._finishDeferred.resolve(false);
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
}
|
||||
async wait() {
|
||||
var _a;
|
||||
if (this._startDeferred) {
|
||||
const timeout = await this._startDeferred.promise;
|
||||
// If there is no file change detected by Typescript skip deferred promises.
|
||||
if (timeout) {
|
||||
this._startDeferred = null;
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
await ((_a = this._finishDeferred) === null || _a === void 0 ? void 0 : _a.promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a language service host to use with the Typescript compiler & type checking APIs.
|
||||
* Typescript hosts are used to represent the user's system,
|
||||
* with an API for reading files, checking directories and case sensitivity etc.
|
||||
* @see https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
|
||||
*/
|
||||
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, status, resolveModule, transformers }) {
|
||||
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
|
||||
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost), status, parsedOptions.projectReferences);
|
||||
return Object.assign(Object.assign({}, baseHost), {
|
||||
/** Override the created program so an in-memory emit is used */
|
||||
afterProgramCreate(program) {
|
||||
const origEmit = program.emit;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
program.emit = (targetSourceFile, _, ...args) => origEmit(targetSourceFile, writeFile,
|
||||
// cancellationToken
|
||||
args[0],
|
||||
// emitOnlyDtsFiles
|
||||
args[1], mergeTransformers(program, transformers, args[2]));
|
||||
return baseHost.afterProgramCreate(program);
|
||||
},
|
||||
/** Add helper to deal with module resolution */
|
||||
resolveModuleNames(moduleNames, containingFile, _reusedNames, redirectedReference, _optionsOnlyWithNewerTsVersions, containingSourceFile) {
|
||||
return moduleNames.map((moduleName, i) => {
|
||||
var _a;
|
||||
const mode = containingSourceFile
|
||||
? (_a = ts.getModeForResolutionAtIndex) === null || _a === void 0 ? void 0 : _a.call(ts, containingSourceFile, i)
|
||||
: undefined; // eslint-disable-line no-undefined
|
||||
return resolveModule(moduleName, containingFile, redirectedReference, mode);
|
||||
});
|
||||
} });
|
||||
}
|
||||
function createWatchProgram(ts, context, options) {
|
||||
return ts.createWatchProgram(createWatchHost(ts, context, options));
|
||||
}
|
||||
|
||||
/** Creates the folders needed given a path to a file to be saved*/
|
||||
const createFileFolder = (filePath) => {
|
||||
const folderPath = path__default.dirname(filePath);
|
||||
fs.mkdirSync(folderPath, { recursive: true });
|
||||
};
|
||||
class TSCache {
|
||||
constructor(cacheFolder = '.rollup.cache') {
|
||||
this._cacheFolder = cacheFolder;
|
||||
}
|
||||
/** Returns the path to the cached file */
|
||||
cachedFilename(fileName) {
|
||||
return path__default.join(this._cacheFolder, fileName.replace(/^([a-zA-Z]+):/, '$1'));
|
||||
}
|
||||
/** Emits a file in the cache folder */
|
||||
cacheCode(fileName, code) {
|
||||
const cachedPath = this.cachedFilename(fileName);
|
||||
createFileFolder(cachedPath);
|
||||
fs.writeFileSync(cachedPath, code);
|
||||
}
|
||||
/** Checks if a file is in the cache */
|
||||
isCached(fileName) {
|
||||
return fs.existsSync(this.cachedFilename(fileName));
|
||||
}
|
||||
/** Read a file from the cache given the output name*/
|
||||
getCached(fileName) {
|
||||
let code;
|
||||
if (this.isCached(fileName)) {
|
||||
code = fs.readFileSync(this.cachedFilename(fileName), { encoding: 'utf-8' });
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
function typescript(options = {}) {
|
||||
const { cacheDir, compilerOptions, exclude, filterRoot, include, outputToFilesystem, noForceEmit, transformers, tsconfig, tslib, typescript: ts } = getPluginOptions(options);
|
||||
const tsCache = new TSCache(cacheDir);
|
||||
const emittedFiles = new Map();
|
||||
const watchProgramHelper = new WatchProgramHelper();
|
||||
const parsedOptions = parseTypescriptConfig(ts, tsconfig, compilerOptions, noForceEmit);
|
||||
const filter = createFilter(include || '{,**/}*.(cts|mts|ts|tsx)', exclude, {
|
||||
resolve: filterRoot !== null && filterRoot !== void 0 ? filterRoot : parsedOptions.options.rootDir
|
||||
});
|
||||
parsedOptions.fileNames = parsedOptions.fileNames.filter(filter);
|
||||
const formatHost = createFormattingHost(ts, parsedOptions.options);
|
||||
const resolveModule = createModuleResolver(ts, formatHost);
|
||||
let program = null;
|
||||
return {
|
||||
name: 'typescript',
|
||||
buildStart(rollupOptions) {
|
||||
emitParsedOptionsErrors(ts, this, parsedOptions);
|
||||
preflight({ config: parsedOptions, context: this, rollupOptions, tslib });
|
||||
// Fixes a memory leak https://github.com/rollup/plugins/issues/322
|
||||
if (this.meta.watchMode !== true) {
|
||||
// eslint-disable-next-line
|
||||
program === null || program === void 0 ? void 0 : program.close();
|
||||
}
|
||||
if (!program) {
|
||||
program = createWatchProgram(ts, this, {
|
||||
formatHost,
|
||||
resolveModule,
|
||||
parsedOptions,
|
||||
writeFile(fileName, data) {
|
||||
if (parsedOptions.options.composite || parsedOptions.options.incremental) {
|
||||
tsCache.cacheCode(fileName, data);
|
||||
}
|
||||
emittedFiles.set(fileName, data);
|
||||
},
|
||||
status(diagnostic) {
|
||||
watchProgramHelper.handleStatus(diagnostic);
|
||||
},
|
||||
transformers
|
||||
});
|
||||
}
|
||||
},
|
||||
watchChange(id) {
|
||||
if (!filter(id))
|
||||
return;
|
||||
watchProgramHelper.watch();
|
||||
},
|
||||
buildEnd() {
|
||||
if (this.meta.watchMode !== true) {
|
||||
// ESLint doesn't understand optional chaining
|
||||
// eslint-disable-next-line
|
||||
program === null || program === void 0 ? void 0 : program.close();
|
||||
}
|
||||
},
|
||||
renderStart(outputOptions) {
|
||||
validateSourceMap(this, parsedOptions.options, outputOptions, parsedOptions.autoSetSourceMap);
|
||||
validatePaths(this, parsedOptions.options, outputOptions);
|
||||
},
|
||||
resolveId(importee, importer) {
|
||||
if (importee === 'tslib') {
|
||||
return tslib;
|
||||
}
|
||||
if (!importer)
|
||||
return null;
|
||||
// Convert path from windows separators to posix separators
|
||||
const containingFile = normalizePath(importer);
|
||||
// when using node16 or nodenext module resolution, we need to tell ts if
|
||||
// we are resolving to a commonjs or esnext module
|
||||
const mode = typeof ts.getImpliedNodeFormatForFile === 'function'
|
||||
? ts.getImpliedNodeFormatForFile(
|
||||
// @ts-expect-error
|
||||
containingFile, undefined, Object.assign(Object.assign({}, ts.sys), formatHost), parsedOptions.options)
|
||||
: undefined; // eslint-disable-line no-undefined
|
||||
// eslint-disable-next-line no-undefined
|
||||
const resolved = resolveModule(importee, containingFile, undefined, mode);
|
||||
if (resolved) {
|
||||
if (/\.d\.[cm]?ts/.test(resolved.extension))
|
||||
return null;
|
||||
return path.normalize(resolved.resolvedFileName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
async load(id) {
|
||||
if (!filter(id))
|
||||
return null;
|
||||
await watchProgramHelper.wait();
|
||||
const fileName = normalizePath(id);
|
||||
if (!parsedOptions.fileNames.includes(fileName)) {
|
||||
// Discovered new file that was not known when originally parsing the TypeScript config
|
||||
parsedOptions.fileNames.push(fileName);
|
||||
}
|
||||
const output = findTypescriptOutput(ts, parsedOptions, id, emittedFiles, tsCache);
|
||||
return output.code != null ? output : null;
|
||||
},
|
||||
async generateBundle(outputOptions) {
|
||||
parsedOptions.fileNames.forEach((fileName) => {
|
||||
const output = findTypescriptOutput(ts, parsedOptions, fileName, emittedFiles, tsCache);
|
||||
output.declarations.forEach((id) => {
|
||||
const code = getEmittedFile(id, emittedFiles, tsCache);
|
||||
let baseDir = outputOptions.dir ||
|
||||
(parsedOptions.options.declaration
|
||||
? parsedOptions.options.declarationDir || parsedOptions.options.outDir
|
||||
: null);
|
||||
if (!baseDir && tsconfig) {
|
||||
baseDir = tsconfig.substring(0, tsconfig.lastIndexOf('/'));
|
||||
}
|
||||
if (!code || !baseDir)
|
||||
return;
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: normalizePath(path.relative(baseDir, id)),
|
||||
source: code
|
||||
});
|
||||
});
|
||||
});
|
||||
const tsBuildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(parsedOptions.options);
|
||||
if (tsBuildInfoPath) {
|
||||
const tsBuildInfoSource = emittedFiles.get(tsBuildInfoPath);
|
||||
// https://github.com/rollup/plugins/issues/681
|
||||
if (tsBuildInfoSource) {
|
||||
await emitFile(outputOptions, outputToFilesystem, this, tsBuildInfoPath, tsBuildInfoSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { typescript as default };
|
||||
879
node_modules/@rollup/plugin-typescript/dist/index.js
generated
vendored
Normal file
879
node_modules/@rollup/plugin-typescript/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,879 @@
|
|||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var pluginutils = require('@rollup/pluginutils');
|
||||
var defaultTs = require('typescript');
|
||||
var resolve = require('resolve');
|
||||
var fs = require('fs');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
||||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
||||
var defaultTs__namespace = /*#__PURE__*/_interopNamespace(defaultTs);
|
||||
var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
|
||||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
||||
|
||||
/**
|
||||
* Create a format diagnostics host to use with the Typescript type checking APIs.
|
||||
* Typescript hosts are used to represent the user's system,
|
||||
* with an API for checking case sensitivity etc.
|
||||
* @param compilerOptions Typescript compiler options. Affects functions such as `getNewLine`.
|
||||
* @see https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
|
||||
*/
|
||||
function createFormattingHost(ts, compilerOptions) {
|
||||
return {
|
||||
/** Returns the compiler options for the project. */
|
||||
getCompilationSettings: () => compilerOptions,
|
||||
/** Returns the current working directory. */
|
||||
getCurrentDirectory: () => process.cwd(),
|
||||
/** Returns the string that corresponds with the selected `NewLineKind`. */
|
||||
getNewLine() {
|
||||
switch (compilerOptions.newLine) {
|
||||
case ts.NewLineKind.CarriageReturnLineFeed:
|
||||
return '\r\n';
|
||||
case ts.NewLineKind.LineFeed:
|
||||
return '\n';
|
||||
default:
|
||||
return ts.sys.newLine;
|
||||
}
|
||||
},
|
||||
/** Returns a lower case name on case insensitive systems, otherwise the original name. */
|
||||
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a helper for resolving modules using Typescript.
|
||||
* @param host Typescript host that extends `ModuleResolutionHost`
|
||||
* with methods for sanitizing filenames and getting compiler options.
|
||||
*/
|
||||
function createModuleResolver(ts, host) {
|
||||
const compilerOptions = host.getCompilationSettings();
|
||||
const cache = ts.createModuleResolutionCache(process.cwd(), host.getCanonicalFileName, compilerOptions);
|
||||
const moduleHost = Object.assign(Object.assign({}, ts.sys), host);
|
||||
return (moduleName, containingFile, redirectedReference, mode) => {
|
||||
const resolved = ts.resolveModuleName(moduleName, containingFile, compilerOptions, moduleHost, cache, redirectedReference, mode);
|
||||
return resolved.resolvedModule;
|
||||
};
|
||||
}
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
// const resolveIdAsync = (file: string, opts: AsyncOpts) =>
|
||||
// new Promise<string>((fulfil, reject) =>
|
||||
// resolveId(file, opts, (err, contents) =>
|
||||
// err || typeof contents === 'undefined' ? reject(err) : fulfil(contents)
|
||||
// )
|
||||
// );
|
||||
const resolveId = (file, opts) => resolve__default["default"].sync(file, opts);
|
||||
/**
|
||||
* Returns code asynchronously for the tslib helper library.
|
||||
*/
|
||||
const getTsLibPath = () => {
|
||||
// Note: This isn't preferable, but we've no other way to test this bit. Removing the tslib devDep
|
||||
// during the test run doesn't work due to the nature of the pnpm flat node_modules, and
|
||||
// other workspace dependencies that depenend upon tslib.
|
||||
try {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
return resolveId(process.env.__TSLIB_TEST_PATH__ || 'tslib/tslib.es6.js', {
|
||||
basedir: __dirname
|
||||
});
|
||||
}
|
||||
catch (_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Separate the Rollup plugin options from the Typescript compiler options,
|
||||
* and normalize the Rollup options.
|
||||
* @returns Object with normalized options:
|
||||
* - `filter`: Checks if a file should be included.
|
||||
* - `tsconfig`: Path to a tsconfig, or directive to ignore tsconfig.
|
||||
* - `compilerOptions`: Custom Typescript compiler options that override tsconfig.
|
||||
* - `typescript`: Instance of Typescript library (possibly custom).
|
||||
* - `tslib`: ESM code from the tslib helper library (possibly custom).
|
||||
*/
|
||||
const getPluginOptions = (options) => {
|
||||
const { cacheDir, exclude, include, filterRoot, noForceEmit, transformers, tsconfig, tslib, typescript, outputToFilesystem, compilerOptions } = options,
|
||||
// previously was compilerOptions
|
||||
extra = __rest(options, ["cacheDir", "exclude", "include", "filterRoot", "noForceEmit", "transformers", "tsconfig", "tslib", "typescript", "outputToFilesystem", "compilerOptions"]);
|
||||
return {
|
||||
cacheDir,
|
||||
include,
|
||||
exclude,
|
||||
filterRoot,
|
||||
noForceEmit: noForceEmit || false,
|
||||
tsconfig,
|
||||
compilerOptions: Object.assign(Object.assign({}, extra), compilerOptions),
|
||||
typescript: typescript || defaultTs__namespace,
|
||||
tslib: tslib || getTsLibPath(),
|
||||
transformers,
|
||||
outputToFilesystem
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Typescript type error into an equivalent Rollup warning object.
|
||||
*/
|
||||
function diagnosticToWarning(ts, host, diagnostic) {
|
||||
const pluginCode = `TS${diagnostic.code}`;
|
||||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||
// Build a Rollup warning object from the diagnostics object.
|
||||
const warning = {
|
||||
pluginCode,
|
||||
message: `@rollup/plugin-typescript ${pluginCode}: ${message}`
|
||||
};
|
||||
if (diagnostic.file) {
|
||||
// Add information about the file location
|
||||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
warning.loc = {
|
||||
column: character + 1,
|
||||
line: line + 1,
|
||||
file: diagnostic.file.fileName
|
||||
};
|
||||
if (host) {
|
||||
// Extract a code frame from Typescript
|
||||
const formatted = ts.formatDiagnosticsWithColorAndContext([diagnostic], host);
|
||||
// Typescript only exposes this formatter as a string prefixed with the flattened message.
|
||||
// We need to remove it here since Rollup treats the properties as separate parts.
|
||||
let frame = formatted.slice(formatted.indexOf(message) + message.length);
|
||||
const newLine = host.getNewLine();
|
||||
if (frame.startsWith(newLine)) {
|
||||
frame = frame.slice(frame.indexOf(newLine) + newLine.length);
|
||||
}
|
||||
warning.frame = frame;
|
||||
}
|
||||
}
|
||||
return warning;
|
||||
}
|
||||
|
||||
const DEFAULT_COMPILER_OPTIONS = {
|
||||
module: 'esnext',
|
||||
skipLibCheck: true
|
||||
};
|
||||
const OVERRIDABLE_EMIT_COMPILER_OPTIONS = {
|
||||
noEmit: false,
|
||||
emitDeclarationOnly: false
|
||||
};
|
||||
const FORCED_COMPILER_OPTIONS = {
|
||||
// Always use tslib
|
||||
noEmitHelpers: true,
|
||||
importHelpers: true,
|
||||
// Preventing Typescript from resolving code may break compilation
|
||||
noResolve: false
|
||||
};
|
||||
|
||||
/* eslint-disable no-param-reassign */
|
||||
const DIRECTORY_PROPS = ['outDir', 'declarationDir'];
|
||||
/**
|
||||
* Mutates the compiler options to convert paths from relative to absolute.
|
||||
* This should be used with compiler options passed through the Rollup plugin options,
|
||||
* not those found from loading a tsconfig.json file.
|
||||
* @param compilerOptions Compiler options to _mutate_.
|
||||
* @param relativeTo Paths are resolved relative to this path.
|
||||
*/
|
||||
function makePathsAbsolute(compilerOptions, relativeTo) {
|
||||
for (const pathProp of DIRECTORY_PROPS) {
|
||||
if (compilerOptions[pathProp]) {
|
||||
compilerOptions[pathProp] = path.resolve(relativeTo, compilerOptions[pathProp]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Mutates the compiler options to normalize some values for Rollup.
|
||||
* @param compilerOptions Compiler options to _mutate_.
|
||||
* @returns True if the source map compiler option was not initially set.
|
||||
*/
|
||||
function normalizeCompilerOptions(ts, compilerOptions) {
|
||||
let autoSetSourceMap = false;
|
||||
if (compilerOptions.inlineSourceMap) {
|
||||
// Force separate source map files for Rollup to work with.
|
||||
compilerOptions.sourceMap = true;
|
||||
compilerOptions.inlineSourceMap = false;
|
||||
}
|
||||
else if (typeof compilerOptions.sourceMap !== 'boolean') {
|
||||
// Default to using source maps.
|
||||
// If the plugin user sets sourceMap to false we keep that option.
|
||||
compilerOptions.sourceMap = true;
|
||||
// Using inlineSources to make sure typescript generate source content
|
||||
// instead of source path.
|
||||
compilerOptions.inlineSources = true;
|
||||
autoSetSourceMap = true;
|
||||
}
|
||||
switch (compilerOptions.module) {
|
||||
case ts.ModuleKind.ES2015:
|
||||
case ts.ModuleKind.ESNext:
|
||||
case ts.ModuleKind.Node16:
|
||||
case ts.ModuleKind.NodeNext:
|
||||
case ts.ModuleKind.CommonJS:
|
||||
// OK module type
|
||||
return autoSetSourceMap;
|
||||
case ts.ModuleKind.None:
|
||||
case ts.ModuleKind.AMD:
|
||||
case ts.ModuleKind.UMD:
|
||||
case ts.ModuleKind.System: {
|
||||
// Invalid module type
|
||||
const moduleType = ts.ModuleKind[compilerOptions.module];
|
||||
throw new Error(`@rollup/plugin-typescript: The module kind should be 'ES2015', 'ESNext', 'node16' or 'nodenext', found: '${moduleType}'`);
|
||||
}
|
||||
default:
|
||||
// Unknown or unspecified module type, force ESNext
|
||||
compilerOptions.module = ts.ModuleKind.ESNext;
|
||||
}
|
||||
return autoSetSourceMap;
|
||||
}
|
||||
|
||||
function makeForcedCompilerOptions(noForceEmit) {
|
||||
return Object.assign(Object.assign({}, FORCED_COMPILER_OPTIONS), (noForceEmit ? {} : OVERRIDABLE_EMIT_COMPILER_OPTIONS));
|
||||
}
|
||||
/**
|
||||
* Finds the path to the tsconfig file relative to the current working directory.
|
||||
* @param relativePath Relative tsconfig path given by the user.
|
||||
* If `false` is passed, then a null path is returned.
|
||||
* @returns The absolute path, or null if the file does not exist.
|
||||
*/
|
||||
function getTsConfigPath(ts, relativePath) {
|
||||
if (relativePath === false)
|
||||
return null;
|
||||
// Resolve path to file. `tsConfigOption` defaults to 'tsconfig.json'.
|
||||
const tsConfigPath = path.resolve(process.cwd(), relativePath || 'tsconfig.json');
|
||||
if (!ts.sys.fileExists(tsConfigPath)) {
|
||||
if (relativePath) {
|
||||
// If an explicit path was provided but no file was found, throw
|
||||
throw new Error(`Could not find specified tsconfig.json at ${tsConfigPath}`);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return tsConfigPath;
|
||||
}
|
||||
/**
|
||||
* Tries to read the tsconfig file at `tsConfigPath`.
|
||||
* @param tsConfigPath Absolute path to tsconfig JSON file.
|
||||
* @param explicitPath If true, the path was set by the plugin user.
|
||||
* If false, the path was computed automatically.
|
||||
*/
|
||||
function readTsConfigFile(ts, tsConfigPath) {
|
||||
const { config, error } = ts.readConfigFile(tsConfigPath, (path) => fs.readFileSync(path, 'utf8'));
|
||||
if (error) {
|
||||
throw Object.assign(Error(), diagnosticToWarning(ts, null, error));
|
||||
}
|
||||
return config || {};
|
||||
}
|
||||
/**
|
||||
* Returns true if any of the `compilerOptions` contain an enum value (i.e.: ts.ScriptKind) rather than a string.
|
||||
* This indicates that the internal CompilerOptions type is used rather than the JsonCompilerOptions.
|
||||
*/
|
||||
function containsEnumOptions(compilerOptions) {
|
||||
const enums = [
|
||||
'module',
|
||||
'target',
|
||||
'jsx',
|
||||
'moduleResolution',
|
||||
'newLine'
|
||||
];
|
||||
return enums.some((prop) => prop in compilerOptions && typeof compilerOptions[prop] === 'number');
|
||||
}
|
||||
/**
|
||||
* The module resolution kind is a function of the resolved `compilerOptions.module`.
|
||||
* This needs to be set explicitly for `resolveModuleName` to select the correct resolution method
|
||||
*/
|
||||
function setModuleResolutionKind(parsedConfig) {
|
||||
const moduleKind = parsedConfig.options.module;
|
||||
const moduleResolution = moduleKind === defaultTs.ModuleKind.Node16
|
||||
? defaultTs.ModuleResolutionKind.Node16
|
||||
: moduleKind === defaultTs.ModuleKind.NodeNext
|
||||
? defaultTs.ModuleResolutionKind.NodeNext
|
||||
: defaultTs.ModuleResolutionKind.NodeJs;
|
||||
return Object.assign(Object.assign({}, parsedConfig), { options: Object.assign(Object.assign({}, parsedConfig.options), { moduleResolution }) });
|
||||
}
|
||||
const configCache = new Map();
|
||||
/**
|
||||
* Parse the Typescript config to use with the plugin.
|
||||
* @param ts Typescript library instance.
|
||||
* @param tsconfig Path to the tsconfig file, or `false` to ignore the file.
|
||||
* @param compilerOptions Options passed to the plugin directly for Typescript.
|
||||
*
|
||||
* @returns Parsed tsconfig.json file with some important properties:
|
||||
* - `options`: Parsed compiler options.
|
||||
* - `fileNames` Type definition files that should be included in the build.
|
||||
* - `errors`: Any errors from parsing the config file.
|
||||
*/
|
||||
function parseTypescriptConfig(ts, tsconfig, compilerOptions, noForceEmit) {
|
||||
/* eslint-disable no-undefined */
|
||||
const cwd = process.cwd();
|
||||
makePathsAbsolute(compilerOptions, cwd);
|
||||
let parsedConfig;
|
||||
// Resolve path to file. If file is not found, pass undefined path to `parseJsonConfigFileContent`.
|
||||
// eslint-disable-next-line no-undefined
|
||||
const tsConfigPath = getTsConfigPath(ts, tsconfig) || undefined;
|
||||
const tsConfigFile = tsConfigPath ? readTsConfigFile(ts, tsConfigPath) : {};
|
||||
const basePath = tsConfigPath ? path.dirname(tsConfigPath) : cwd;
|
||||
// If compilerOptions has enums, it represents an CompilerOptions object instead of parsed JSON.
|
||||
// This determines where the data is passed to the parser.
|
||||
if (containsEnumOptions(compilerOptions)) {
|
||||
parsedConfig = setModuleResolutionKind(ts.parseJsonConfigFileContent(Object.assign(Object.assign({}, tsConfigFile), { compilerOptions: Object.assign(Object.assign({}, DEFAULT_COMPILER_OPTIONS), tsConfigFile.compilerOptions) }), ts.sys, basePath, Object.assign(Object.assign({}, compilerOptions), makeForcedCompilerOptions(noForceEmit)), tsConfigPath, undefined, undefined, configCache));
|
||||
}
|
||||
else {
|
||||
parsedConfig = setModuleResolutionKind(ts.parseJsonConfigFileContent(Object.assign(Object.assign({}, tsConfigFile), { compilerOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_COMPILER_OPTIONS), tsConfigFile.compilerOptions), compilerOptions) }), ts.sys, basePath, makeForcedCompilerOptions(noForceEmit), tsConfigPath, undefined, undefined, configCache));
|
||||
}
|
||||
const autoSetSourceMap = normalizeCompilerOptions(ts, parsedConfig.options);
|
||||
return Object.assign(Object.assign({}, parsedConfig), { autoSetSourceMap });
|
||||
}
|
||||
/**
|
||||
* If errors are detected in the parsed options,
|
||||
* display all of them as warnings then emit an error.
|
||||
*/
|
||||
function emitParsedOptionsErrors(ts, context, parsedOptions) {
|
||||
if (parsedOptions.errors.length > 0) {
|
||||
parsedOptions.errors.forEach((error) => context.warn(diagnosticToWarning(ts, null, error)));
|
||||
context.error(`@rollup/plugin-typescript: Couldn't process compiler options`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the `compilerOptions.sourceMap` option matches `outputOptions.sourcemap`.
|
||||
* @param context Rollup plugin context used to emit warnings.
|
||||
* @param compilerOptions Typescript compiler options.
|
||||
* @param outputOptions Rollup output options.
|
||||
* @param autoSetSourceMap True if the `compilerOptions.sourceMap` property was set to `true`
|
||||
* by the plugin, not the user.
|
||||
*/
|
||||
function validateSourceMap(context, compilerOptions, outputOptions, autoSetSourceMap) {
|
||||
if (compilerOptions.sourceMap && !outputOptions.sourcemap && !autoSetSourceMap) {
|
||||
context.warn(`@rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.`);
|
||||
}
|
||||
else if (!compilerOptions.sourceMap && outputOptions.sourcemap) {
|
||||
context.warn(`@rollup/plugin-typescript: Typescript 'sourceMap' compiler option must be set to generate source maps.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validate that the out directory used by Typescript can be controlled by Rollup.
|
||||
* @param context Rollup plugin context used to emit errors.
|
||||
* @param compilerOptions Typescript compiler options.
|
||||
* @param outputOptions Rollup output options.
|
||||
*/
|
||||
function validatePaths(context, compilerOptions, outputOptions) {
|
||||
if (compilerOptions.out) {
|
||||
context.error(`@rollup/plugin-typescript: Deprecated Typescript compiler option 'out' is not supported. Use 'outDir' instead.`);
|
||||
}
|
||||
else if (compilerOptions.outFile) {
|
||||
context.error(`@rollup/plugin-typescript: Typescript compiler option 'outFile' is not supported. Use 'outDir' instead.`);
|
||||
}
|
||||
for (const dirProperty of DIRECTORY_PROPS) {
|
||||
if (compilerOptions[dirProperty] && outputOptions.dir) {
|
||||
// Checks if the given path lies within Rollup output dir
|
||||
const fromRollupDirToTs = path.relative(outputOptions.dir, compilerOptions[dirProperty]);
|
||||
if (fromRollupDirToTs.startsWith('..')) {
|
||||
context.error(`@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside Rollup 'dir' option.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (compilerOptions.declaration || compilerOptions.declarationMap || compilerOptions.composite) {
|
||||
if (DIRECTORY_PROPS.every((dirProperty) => !compilerOptions[dirProperty])) {
|
||||
context.error(`@rollup/plugin-typescript: You are using one of Typescript's compiler options 'declaration', 'declarationMap' or 'composite'. ` +
|
||||
`In this case 'outDir' or 'declarationDir' must be specified to generate declaration files.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given OutputFile represents some code
|
||||
*/
|
||||
function isCodeOutputFile(name) {
|
||||
return !isMapOutputFile(name) && !name.endsWith('.d.ts');
|
||||
}
|
||||
/**
|
||||
* Checks if the given OutputFile represents some source map
|
||||
*/
|
||||
function isMapOutputFile(name) {
|
||||
return name.endsWith('.map');
|
||||
}
|
||||
/**
|
||||
* Returns the content of a filename either from the current
|
||||
* typescript compiler instance or from the cached content.
|
||||
* @param fileName The filename for the contents to retrieve
|
||||
* @param emittedFiles The files emitted in the current typescript instance
|
||||
* @param tsCache A cache to files cached by Typescript
|
||||
*/
|
||||
function getEmittedFile(fileName, emittedFiles, tsCache) {
|
||||
let code;
|
||||
if (fileName) {
|
||||
if (emittedFiles.has(fileName)) {
|
||||
code = emittedFiles.get(fileName);
|
||||
}
|
||||
else {
|
||||
code = tsCache.getCached(fileName);
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
/**
|
||||
* Finds the corresponding emitted Javascript files for a given Typescript file.
|
||||
* @param id Path to the Typescript file.
|
||||
* @param emittedFiles Map of file names to source code,
|
||||
* containing files emitted by the Typescript compiler.
|
||||
*/
|
||||
function findTypescriptOutput(ts, parsedOptions, id, emittedFiles, tsCache) {
|
||||
const emittedFileNames = ts.getOutputFileNames(parsedOptions, id, !ts.sys.useCaseSensitiveFileNames);
|
||||
const codeFile = emittedFileNames.find(isCodeOutputFile);
|
||||
const mapFile = emittedFileNames.find(isMapOutputFile);
|
||||
return {
|
||||
code: getEmittedFile(codeFile, emittedFiles, tsCache),
|
||||
map: getEmittedFile(mapFile, emittedFiles, tsCache),
|
||||
declarations: emittedFileNames.filter((name) => name !== codeFile && name !== mapFile)
|
||||
};
|
||||
}
|
||||
function normalizePath(fileName) {
|
||||
return fileName.split(path__namespace.win32.sep).join(path__namespace.posix.sep);
|
||||
}
|
||||
async function emitFile({ dir }, outputToFilesystem, context, filePath, fileSource) {
|
||||
const normalizedFilePath = normalizePath(filePath);
|
||||
// const normalizedPath = normalizePath(filePath);
|
||||
// Note: `dir` can be a value like `dist` in which case, `path.relative` could result in a value
|
||||
// of something like `'../.tsbuildinfo'. Our else-case below needs to mimic `path.relative`
|
||||
// returning a dot-notated relative path, so the first if-then branch is entered into
|
||||
const relativePath = dir ? path__namespace.relative(dir, normalizedFilePath) : '..';
|
||||
// legal paths do not start with . nor .. : https://github.com/rollup/rollup/issues/3507#issuecomment-616495912
|
||||
if (relativePath.startsWith('..')) {
|
||||
if (outputToFilesystem == null) {
|
||||
context.warn(`@rollup/plugin-typescript: outputToFilesystem option is defaulting to true.`);
|
||||
}
|
||||
if (outputToFilesystem !== false) {
|
||||
await fs.promises.mkdir(path__namespace.dirname(normalizedFilePath), { recursive: true });
|
||||
await fs.promises.writeFile(normalizedFilePath, fileSource);
|
||||
}
|
||||
}
|
||||
else {
|
||||
context.emitFile({
|
||||
type: 'asset',
|
||||
fileName: relativePath,
|
||||
source: fileSource
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const pluginName = '@rollup/plugin-typescript';
|
||||
const moduleErrorMessage = `
|
||||
${pluginName}: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a
|
||||
"module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext"
|
||||
in the target tsconfig.json file or plugin options.`.replace(/\n/g, '');
|
||||
const tsLibErrorMessage = `${pluginName}: Could not find module 'tslib', which is required by this plugin. Is it installed?`;
|
||||
let undef;
|
||||
const validModules = [
|
||||
defaultTs.ModuleKind.ES2015,
|
||||
defaultTs.ModuleKind.ES2020,
|
||||
defaultTs.ModuleKind.ESNext,
|
||||
defaultTs.ModuleKind.Node16,
|
||||
defaultTs.ModuleKind.NodeNext,
|
||||
undef
|
||||
];
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
const preflight = ({ config, context, rollupOptions, tslib }) => {
|
||||
if (!validModules.includes(config.options.module)) {
|
||||
context.warn(moduleErrorMessage);
|
||||
}
|
||||
if (!rollupOptions.preserveModules && tslib === null) {
|
||||
context.error(tsLibErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
// `Cannot compile modules into 'es6' when targeting 'ES5' or lower.`
|
||||
const CANNOT_COMPILE_ESM = 1204;
|
||||
/**
|
||||
* Emit a Rollup warning or error for a Typescript type error.
|
||||
*/
|
||||
function emitDiagnostic(ts, context, host, diagnostic) {
|
||||
if (diagnostic.code === CANNOT_COMPILE_ESM)
|
||||
return;
|
||||
const { noEmitOnError } = host.getCompilationSettings();
|
||||
// Build a Rollup warning object from the diagnostics object.
|
||||
const warning = diagnosticToWarning(ts, host, diagnostic);
|
||||
// Errors are fatal. Otherwise emit warnings.
|
||||
if (noEmitOnError && diagnostic.category === ts.DiagnosticCategory.Error) {
|
||||
context.error(warning);
|
||||
}
|
||||
else {
|
||||
context.warn(warning);
|
||||
}
|
||||
}
|
||||
function buildDiagnosticReporter(ts, context, host) {
|
||||
return function reportDiagnostics(diagnostic) {
|
||||
emitDiagnostic(ts, context, host, diagnostic);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges all received custom transformer definitions into a single CustomTransformers object
|
||||
*/
|
||||
function mergeTransformers(builder, ...input) {
|
||||
// List of all transformer stages
|
||||
const transformerTypes = ['after', 'afterDeclarations', 'before'];
|
||||
const accumulator = {
|
||||
after: [],
|
||||
afterDeclarations: [],
|
||||
before: []
|
||||
};
|
||||
let program;
|
||||
let typeChecker;
|
||||
input.forEach((transformers) => {
|
||||
if (!transformers) {
|
||||
// Skip empty arguments lists
|
||||
return;
|
||||
}
|
||||
transformerTypes.forEach((stage) => {
|
||||
getTransformers(transformers[stage]).forEach((transformer) => {
|
||||
if (!transformer) {
|
||||
// Skip empty
|
||||
return;
|
||||
}
|
||||
if ('type' in transformer) {
|
||||
if (typeof transformer.factory === 'function') {
|
||||
// Allow custom factories to grab the extra information required
|
||||
program = program || builder.getProgram();
|
||||
typeChecker = typeChecker || program.getTypeChecker();
|
||||
let factory;
|
||||
if (transformer.type === 'program') {
|
||||
program = program || builder.getProgram();
|
||||
factory = transformer.factory(program);
|
||||
}
|
||||
else {
|
||||
program = program || builder.getProgram();
|
||||
typeChecker = typeChecker || program.getTypeChecker();
|
||||
factory = transformer.factory(typeChecker);
|
||||
}
|
||||
// Forward the requested reference to the custom transformer factory
|
||||
if (factory) {
|
||||
accumulator[stage].push(factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add normal transformer factories as is
|
||||
accumulator[stage].push(transformer);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
function getTransformers(transformers) {
|
||||
return transformers || [];
|
||||
}
|
||||
|
||||
// @see https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
|
||||
// eslint-disable-next-line no-shadow
|
||||
var DiagnosticCode;
|
||||
(function (DiagnosticCode) {
|
||||
DiagnosticCode[DiagnosticCode["FILE_CHANGE_DETECTED"] = 6032] = "FILE_CHANGE_DETECTED";
|
||||
DiagnosticCode[DiagnosticCode["FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES"] = 6193] = "FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES";
|
||||
DiagnosticCode[DiagnosticCode["FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES"] = 6194] = "FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES";
|
||||
})(DiagnosticCode || (DiagnosticCode = {}));
|
||||
function createDeferred(timeout) {
|
||||
let promise;
|
||||
let resolve = () => { };
|
||||
if (timeout) {
|
||||
promise = Promise.race([
|
||||
new Promise((r) => setTimeout(r, timeout, true)),
|
||||
new Promise((r) => (resolve = r))
|
||||
]);
|
||||
}
|
||||
else {
|
||||
promise = new Promise((r) => (resolve = r));
|
||||
}
|
||||
return { promise, resolve };
|
||||
}
|
||||
/**
|
||||
* Typescript watch program helper to sync Typescript watch status with Rollup hooks.
|
||||
*/
|
||||
class WatchProgramHelper {
|
||||
constructor() {
|
||||
this._startDeferred = null;
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
watch(timeout = 1000) {
|
||||
// Race watcher start promise against a timeout in case Typescript and Rollup change detection is not in sync.
|
||||
this._startDeferred = createDeferred(timeout);
|
||||
this._finishDeferred = createDeferred();
|
||||
}
|
||||
handleStatus(diagnostic) {
|
||||
// Fullfil deferred promises by Typescript diagnostic message codes.
|
||||
if (diagnostic.category === defaultTs.DiagnosticCategory.Message) {
|
||||
switch (diagnostic.code) {
|
||||
case DiagnosticCode.FILE_CHANGE_DETECTED:
|
||||
this.resolveStart();
|
||||
break;
|
||||
case DiagnosticCode.FOUND_1_ERROR_WATCHING_FOR_FILE_CHANGES:
|
||||
case DiagnosticCode.FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES:
|
||||
this.resolveFinish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
resolveStart() {
|
||||
if (this._startDeferred) {
|
||||
this._startDeferred.resolve(false);
|
||||
this._startDeferred = null;
|
||||
}
|
||||
}
|
||||
resolveFinish() {
|
||||
if (this._finishDeferred) {
|
||||
this._finishDeferred.resolve(false);
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
}
|
||||
async wait() {
|
||||
var _a;
|
||||
if (this._startDeferred) {
|
||||
const timeout = await this._startDeferred.promise;
|
||||
// If there is no file change detected by Typescript skip deferred promises.
|
||||
if (timeout) {
|
||||
this._startDeferred = null;
|
||||
this._finishDeferred = null;
|
||||
}
|
||||
await ((_a = this._finishDeferred) === null || _a === void 0 ? void 0 : _a.promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a language service host to use with the Typescript compiler & type checking APIs.
|
||||
* Typescript hosts are used to represent the user's system,
|
||||
* with an API for reading files, checking directories and case sensitivity etc.
|
||||
* @see https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
|
||||
*/
|
||||
function createWatchHost(ts, context, { formatHost, parsedOptions, writeFile, status, resolveModule, transformers }) {
|
||||
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
|
||||
const baseHost = ts.createWatchCompilerHost(parsedOptions.fileNames, parsedOptions.options, ts.sys, createProgram, buildDiagnosticReporter(ts, context, formatHost), status, parsedOptions.projectReferences);
|
||||
return Object.assign(Object.assign({}, baseHost), {
|
||||
/** Override the created program so an in-memory emit is used */
|
||||
afterProgramCreate(program) {
|
||||
const origEmit = program.emit;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
program.emit = (targetSourceFile, _, ...args) => origEmit(targetSourceFile, writeFile,
|
||||
// cancellationToken
|
||||
args[0],
|
||||
// emitOnlyDtsFiles
|
||||
args[1], mergeTransformers(program, transformers, args[2]));
|
||||
return baseHost.afterProgramCreate(program);
|
||||
},
|
||||
/** Add helper to deal with module resolution */
|
||||
resolveModuleNames(moduleNames, containingFile, _reusedNames, redirectedReference, _optionsOnlyWithNewerTsVersions, containingSourceFile) {
|
||||
return moduleNames.map((moduleName, i) => {
|
||||
var _a;
|
||||
const mode = containingSourceFile
|
||||
? (_a = ts.getModeForResolutionAtIndex) === null || _a === void 0 ? void 0 : _a.call(ts, containingSourceFile, i)
|
||||
: undefined; // eslint-disable-line no-undefined
|
||||
return resolveModule(moduleName, containingFile, redirectedReference, mode);
|
||||
});
|
||||
} });
|
||||
}
|
||||
function createWatchProgram(ts, context, options) {
|
||||
return ts.createWatchProgram(createWatchHost(ts, context, options));
|
||||
}
|
||||
|
||||
/** Creates the folders needed given a path to a file to be saved*/
|
||||
const createFileFolder = (filePath) => {
|
||||
const folderPath = path__default["default"].dirname(filePath);
|
||||
fs__default["default"].mkdirSync(folderPath, { recursive: true });
|
||||
};
|
||||
class TSCache {
|
||||
constructor(cacheFolder = '.rollup.cache') {
|
||||
this._cacheFolder = cacheFolder;
|
||||
}
|
||||
/** Returns the path to the cached file */
|
||||
cachedFilename(fileName) {
|
||||
return path__default["default"].join(this._cacheFolder, fileName.replace(/^([a-zA-Z]+):/, '$1'));
|
||||
}
|
||||
/** Emits a file in the cache folder */
|
||||
cacheCode(fileName, code) {
|
||||
const cachedPath = this.cachedFilename(fileName);
|
||||
createFileFolder(cachedPath);
|
||||
fs__default["default"].writeFileSync(cachedPath, code);
|
||||
}
|
||||
/** Checks if a file is in the cache */
|
||||
isCached(fileName) {
|
||||
return fs__default["default"].existsSync(this.cachedFilename(fileName));
|
||||
}
|
||||
/** Read a file from the cache given the output name*/
|
||||
getCached(fileName) {
|
||||
let code;
|
||||
if (this.isCached(fileName)) {
|
||||
code = fs__default["default"].readFileSync(this.cachedFilename(fileName), { encoding: 'utf-8' });
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
function typescript(options = {}) {
|
||||
const { cacheDir, compilerOptions, exclude, filterRoot, include, outputToFilesystem, noForceEmit, transformers, tsconfig, tslib, typescript: ts } = getPluginOptions(options);
|
||||
const tsCache = new TSCache(cacheDir);
|
||||
const emittedFiles = new Map();
|
||||
const watchProgramHelper = new WatchProgramHelper();
|
||||
const parsedOptions = parseTypescriptConfig(ts, tsconfig, compilerOptions, noForceEmit);
|
||||
const filter = pluginutils.createFilter(include || '{,**/}*.(cts|mts|ts|tsx)', exclude, {
|
||||
resolve: filterRoot !== null && filterRoot !== void 0 ? filterRoot : parsedOptions.options.rootDir
|
||||
});
|
||||
parsedOptions.fileNames = parsedOptions.fileNames.filter(filter);
|
||||
const formatHost = createFormattingHost(ts, parsedOptions.options);
|
||||
const resolveModule = createModuleResolver(ts, formatHost);
|
||||
let program = null;
|
||||
return {
|
||||
name: 'typescript',
|
||||
buildStart(rollupOptions) {
|
||||
emitParsedOptionsErrors(ts, this, parsedOptions);
|
||||
preflight({ config: parsedOptions, context: this, rollupOptions, tslib });
|
||||
// Fixes a memory leak https://github.com/rollup/plugins/issues/322
|
||||
if (this.meta.watchMode !== true) {
|
||||
// eslint-disable-next-line
|
||||
program === null || program === void 0 ? void 0 : program.close();
|
||||
}
|
||||
if (!program) {
|
||||
program = createWatchProgram(ts, this, {
|
||||
formatHost,
|
||||
resolveModule,
|
||||
parsedOptions,
|
||||
writeFile(fileName, data) {
|
||||
if (parsedOptions.options.composite || parsedOptions.options.incremental) {
|
||||
tsCache.cacheCode(fileName, data);
|
||||
}
|
||||
emittedFiles.set(fileName, data);
|
||||
},
|
||||
status(diagnostic) {
|
||||
watchProgramHelper.handleStatus(diagnostic);
|
||||
},
|
||||
transformers
|
||||
});
|
||||
}
|
||||
},
|
||||
watchChange(id) {
|
||||
if (!filter(id))
|
||||
return;
|
||||
watchProgramHelper.watch();
|
||||
},
|
||||
buildEnd() {
|
||||
if (this.meta.watchMode !== true) {
|
||||
// ESLint doesn't understand optional chaining
|
||||
// eslint-disable-next-line
|
||||
program === null || program === void 0 ? void 0 : program.close();
|
||||
}
|
||||
},
|
||||
renderStart(outputOptions) {
|
||||
validateSourceMap(this, parsedOptions.options, outputOptions, parsedOptions.autoSetSourceMap);
|
||||
validatePaths(this, parsedOptions.options, outputOptions);
|
||||
},
|
||||
resolveId(importee, importer) {
|
||||
if (importee === 'tslib') {
|
||||
return tslib;
|
||||
}
|
||||
if (!importer)
|
||||
return null;
|
||||
// Convert path from windows separators to posix separators
|
||||
const containingFile = normalizePath(importer);
|
||||
// when using node16 or nodenext module resolution, we need to tell ts if
|
||||
// we are resolving to a commonjs or esnext module
|
||||
const mode = typeof ts.getImpliedNodeFormatForFile === 'function'
|
||||
? ts.getImpliedNodeFormatForFile(
|
||||
// @ts-expect-error
|
||||
containingFile, undefined, Object.assign(Object.assign({}, ts.sys), formatHost), parsedOptions.options)
|
||||
: undefined; // eslint-disable-line no-undefined
|
||||
// eslint-disable-next-line no-undefined
|
||||
const resolved = resolveModule(importee, containingFile, undefined, mode);
|
||||
if (resolved) {
|
||||
if (/\.d\.[cm]?ts/.test(resolved.extension))
|
||||
return null;
|
||||
return path__namespace.normalize(resolved.resolvedFileName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
async load(id) {
|
||||
if (!filter(id))
|
||||
return null;
|
||||
await watchProgramHelper.wait();
|
||||
const fileName = normalizePath(id);
|
||||
if (!parsedOptions.fileNames.includes(fileName)) {
|
||||
// Discovered new file that was not known when originally parsing the TypeScript config
|
||||
parsedOptions.fileNames.push(fileName);
|
||||
}
|
||||
const output = findTypescriptOutput(ts, parsedOptions, id, emittedFiles, tsCache);
|
||||
return output.code != null ? output : null;
|
||||
},
|
||||
async generateBundle(outputOptions) {
|
||||
parsedOptions.fileNames.forEach((fileName) => {
|
||||
const output = findTypescriptOutput(ts, parsedOptions, fileName, emittedFiles, tsCache);
|
||||
output.declarations.forEach((id) => {
|
||||
const code = getEmittedFile(id, emittedFiles, tsCache);
|
||||
let baseDir = outputOptions.dir ||
|
||||
(parsedOptions.options.declaration
|
||||
? parsedOptions.options.declarationDir || parsedOptions.options.outDir
|
||||
: null);
|
||||
if (!baseDir && tsconfig) {
|
||||
baseDir = tsconfig.substring(0, tsconfig.lastIndexOf('/'));
|
||||
}
|
||||
if (!code || !baseDir)
|
||||
return;
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: normalizePath(path__namespace.relative(baseDir, id)),
|
||||
source: code
|
||||
});
|
||||
});
|
||||
});
|
||||
const tsBuildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(parsedOptions.options);
|
||||
if (tsBuildInfoPath) {
|
||||
const tsBuildInfoSource = emittedFiles.get(tsBuildInfoPath);
|
||||
// https://github.com/rollup/plugins/issues/681
|
||||
if (tsBuildInfoSource) {
|
||||
await emitFile(outputOptions, outputToFilesystem, this, tsBuildInfoPath, tsBuildInfoSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = typescript;
|
||||
71
node_modules/@rollup/plugin-typescript/package.json
generated
vendored
Normal file
71
node_modules/@rollup/plugin-typescript/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"name": "@rollup/plugin-typescript",
|
||||
"version": "8.5.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Seamless integration between Rollup and TypeScript.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/typescript"
|
||||
},
|
||||
"author": "Oskar Segersvärd",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/typescript/#readme",
|
||||
"bugs": "https://github.com/rollup/plugins/issues",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.es.js",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm build && pnpm lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm test -- --verbose --serial",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build",
|
||||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"typescript",
|
||||
"es2015"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.14.0",
|
||||
"tslib": "*",
|
||||
"typescript": ">=3.7.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"tslib": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"resolve": "^1.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^11.1.0",
|
||||
"@rollup/plugin-typescript": "^5.0.2",
|
||||
"@types/node": "^10.0.0",
|
||||
"buble": "^0.20.0",
|
||||
"rollup": "^2.67.3",
|
||||
"typescript": "^4.7.3"
|
||||
},
|
||||
"types": "types/index.d.ts"
|
||||
}
|
||||
113
node_modules/@rollup/plugin-typescript/types/index.d.ts
generated
vendored
Normal file
113
node_modules/@rollup/plugin-typescript/types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/* eslint-disable no-use-before-define */
|
||||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { Plugin } from 'rollup';
|
||||
import {
|
||||
CompilerOptions,
|
||||
CompilerOptionsValue,
|
||||
CustomTransformers,
|
||||
Program,
|
||||
TsConfigSourceFile,
|
||||
TypeChecker
|
||||
} from 'typescript';
|
||||
|
||||
type ElementType<T extends Array<any> | undefined> = T extends (infer U)[] ? U : never;
|
||||
|
||||
export type TransformerStage = keyof CustomTransformers;
|
||||
type StagedTransformerFactory<T extends TransformerStage> = ElementType<CustomTransformers[T]>;
|
||||
type TransformerFactory<T extends TransformerStage> =
|
||||
| StagedTransformerFactory<T>
|
||||
| ProgramTransformerFactory<T>
|
||||
| TypeCheckerTransformerFactory<T>;
|
||||
|
||||
export type CustomTransformerFactories = {
|
||||
[stage in TransformerStage]?: Array<TransformerFactory<stage>>;
|
||||
};
|
||||
|
||||
interface ProgramTransformerFactory<T extends TransformerStage> {
|
||||
type: 'program';
|
||||
|
||||
factory(program: Program): StagedTransformerFactory<T>;
|
||||
}
|
||||
|
||||
interface TypeCheckerTransformerFactory<T extends TransformerStage> {
|
||||
type: 'typeChecker';
|
||||
|
||||
factory(typeChecker: TypeChecker): StagedTransformerFactory<T>;
|
||||
}
|
||||
|
||||
export interface RollupTypescriptPluginOptions {
|
||||
/**
|
||||
* If using incremental this is the folder where the cached
|
||||
* files will be created and kept for Typescript incremental
|
||||
* compilation.
|
||||
*/
|
||||
cacheDir?: string;
|
||||
/**
|
||||
* Determine which files are transpiled by Typescript (all `.ts` and
|
||||
* `.tsx` files by default).
|
||||
*/
|
||||
include?: FilterPattern;
|
||||
/**
|
||||
* Determine which files are ignored by Typescript
|
||||
*/
|
||||
exclude?: FilterPattern;
|
||||
/**
|
||||
* Sets the `resolve` value for the underlying filter function. If not set will use the `rootDir` property
|
||||
* @see {@link https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter} @rollup/pluginutils `createFilter`
|
||||
*/
|
||||
filterRoot?: string | false;
|
||||
/**
|
||||
* When set to false, ignores any options specified in the config file.
|
||||
* If set to a string that corresponds to a file path, the specified file
|
||||
* will be used as config file.
|
||||
*/
|
||||
tsconfig?: string | false;
|
||||
/**
|
||||
* Overrides TypeScript used for transpilation
|
||||
*/
|
||||
typescript?: typeof import('typescript');
|
||||
/**
|
||||
* Overrides the injected TypeScript helpers with a custom version.
|
||||
*/
|
||||
tslib?: Promise<string> | string;
|
||||
/**
|
||||
* TypeScript custom transformers
|
||||
*/
|
||||
transformers?: CustomTransformerFactories;
|
||||
/**
|
||||
* When set to false, force non-cached files to always be emitted in the output directory.output
|
||||
* If not set, will default to true with a warning.
|
||||
*/
|
||||
outputToFilesystem?: boolean;
|
||||
/**
|
||||
* Pass additional compiler options to the plugin.
|
||||
*/
|
||||
compilerOptions?: PartialCompilerOptions;
|
||||
/**
|
||||
* Override force setting of `noEmit` and `emitDeclarationOnly` and use what is defined in `tsconfig.json`
|
||||
*/
|
||||
noForceEmit?: boolean;
|
||||
}
|
||||
|
||||
export interface FlexibleCompilerOptions extends CompilerOptions {
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined | any;
|
||||
}
|
||||
|
||||
/** Properties of `CompilerOptions` that are normally enums */
|
||||
export type EnumCompilerOptions = 'module' | 'moduleResolution' | 'newLine' | 'jsx' | 'target';
|
||||
|
||||
/** JSON representation of Typescript compiler options */
|
||||
export type JsonCompilerOptions = Omit<FlexibleCompilerOptions, EnumCompilerOptions> &
|
||||
Record<EnumCompilerOptions, string>;
|
||||
|
||||
/** Compiler options set by the plugin user. */
|
||||
export type PartialCompilerOptions =
|
||||
| Partial<FlexibleCompilerOptions>
|
||||
| Partial<JsonCompilerOptions>;
|
||||
|
||||
export type RollupTypescriptOptions = RollupTypescriptPluginOptions & PartialCompilerOptions;
|
||||
|
||||
/**
|
||||
* Seamless integration between Rollup and Typescript.
|
||||
*/
|
||||
export default function typescript(options?: RollupTypescriptOptions): Plugin;
|
||||
315
node_modules/@rollup/pluginutils/CHANGELOG.md
generated
vendored
Executable file
315
node_modules/@rollup/pluginutils/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,315 @@
|
|||
# @rollup/pluginutils ChangeLog
|
||||
|
||||
## v3.1.0
|
||||
|
||||
_2020-06-05_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add native node es modules support (#419)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: replace micromatch with picomatch. (#306)
|
||||
- chore: Don't bundle micromatch (#220)
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.10
|
||||
|
||||
_2020-05-02_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: replace micromatch with picomatch. (#306)
|
||||
- chore: Don't bundle micromatch (#220)
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.9
|
||||
|
||||
_2020-04-12_
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: support Rollup v2
|
||||
|
||||
## v3.0.8
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.7
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.6
|
||||
|
||||
_2020-01-27_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
## v3.0.5
|
||||
|
||||
_2020-01-25_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: bring back named exports (#176)
|
||||
|
||||
## v3.0.4
|
||||
|
||||
_2020-01-10_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: keep for(const..) out of scope (#151)
|
||||
|
||||
## v3.0.3
|
||||
|
||||
_2020-01-07_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: createFilter Windows regression (#141)
|
||||
|
||||
### Updates
|
||||
|
||||
- test: fix windows path failure (0a0de65)
|
||||
- chore: fix test script (5eae320)
|
||||
|
||||
## v3.0.2
|
||||
|
||||
_2020-01-04_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: makeLegalIdentifier - potentially unsafe input for blacklisted identifier (#116)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: Fix documented type of createFilter's include/exclude (#123)
|
||||
- chore: update minor linting correction (bcbf9d2)
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- fix: Escape glob characters in folder (#84)
|
||||
|
||||
## 3.0.0
|
||||
|
||||
_2019-11-25_
|
||||
|
||||
- **Breaking:** Minimum compatible Rollup version is 1.20.0
|
||||
- **Breaking:** Minimum supported Node version is 8.0.0
|
||||
- Published as @rollup/plugins-image
|
||||
|
||||
## 2.8.2
|
||||
|
||||
_2019-09-13_
|
||||
|
||||
- Handle optional catch parameter in attachScopes ([#70](https://github.com/rollup/rollup-pluginutils/pulls/70))
|
||||
|
||||
## 2.8.1
|
||||
|
||||
_2019-06-04_
|
||||
|
||||
- Support serialization of many edge cases ([#64](https://github.com/rollup/rollup-pluginutils/issues/64))
|
||||
|
||||
## 2.8.0
|
||||
|
||||
_2019-05-30_
|
||||
|
||||
- Bundle updated micromatch dependency ([#60](https://github.com/rollup/rollup-pluginutils/issues/60))
|
||||
|
||||
## 2.7.1
|
||||
|
||||
_2019-05-17_
|
||||
|
||||
- Do not ignore files with a leading "." in createFilter ([#62](https://github.com/rollup/rollup-pluginutils/issues/62))
|
||||
|
||||
## 2.7.0
|
||||
|
||||
_2019-05-15_
|
||||
|
||||
- Add `resolve` option to createFilter ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
|
||||
|
||||
## 2.6.0
|
||||
|
||||
_2019-04-04_
|
||||
|
||||
- Add `extractAssignedNames` ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
|
||||
- Provide dedicated TypeScript typings file ([#58](https://github.com/rollup/rollup-pluginutils/issues/58))
|
||||
|
||||
## 2.5.0
|
||||
|
||||
_2019-03-18_
|
||||
|
||||
- Generalize dataToEsm type ([#55](https://github.com/rollup/rollup-pluginutils/issues/55))
|
||||
- Handle empty keys in dataToEsm ([#56](https://github.com/rollup/rollup-pluginutils/issues/56))
|
||||
|
||||
## 2.4.1
|
||||
|
||||
_2019-02-16_
|
||||
|
||||
- Remove unnecessary dependency
|
||||
|
||||
## 2.4.0
|
||||
|
||||
_2019-02-16_
|
||||
Update dependencies to solve micromatch vulnerability ([#53](https://github.com/rollup/rollup-pluginutils/issues/53))
|
||||
|
||||
## 2.3.3
|
||||
|
||||
_2018-09-19_
|
||||
|
||||
- Revert micromatch update ([#43](https://github.com/rollup/rollup-pluginutils/issues/43))
|
||||
|
||||
## 2.3.2
|
||||
|
||||
_2018-09-18_
|
||||
|
||||
- Bumb micromatch dependency ([#36](https://github.com/rollup/rollup-pluginutils/issues/36))
|
||||
- Bumb dependencies ([#41](https://github.com/rollup/rollup-pluginutils/issues/41))
|
||||
- Split up tests ([#40](https://github.com/rollup/rollup-pluginutils/issues/40))
|
||||
|
||||
## 2.3.1
|
||||
|
||||
_2018-08-06_
|
||||
|
||||
- Fixed ObjectPattern scope in attachScopes to recognise { ...rest } syntax ([#37](https://github.com/rollup/rollup-pluginutils/issues/37))
|
||||
|
||||
## 2.3.0
|
||||
|
||||
_2018-05-21_
|
||||
|
||||
- Add option to not generate named exports ([#32](https://github.com/rollup/rollup-pluginutils/issues/32))
|
||||
|
||||
## 2.2.1
|
||||
|
||||
_2018-05-21_
|
||||
|
||||
- Support `null` serialization ([#34](https://github.com/rollup/rollup-pluginutils/issues/34))
|
||||
|
||||
## 2.2.0
|
||||
|
||||
_2018-05-11_
|
||||
|
||||
- Improve white-space handling in `dataToEsm` and add `prepare` script ([#31](https://github.com/rollup/rollup-pluginutils/issues/31))
|
||||
|
||||
## 2.1.1
|
||||
|
||||
_2018-05-09_
|
||||
|
||||
- Update dependencies
|
||||
|
||||
## 2.1.0
|
||||
|
||||
_2018-05-08_
|
||||
|
||||
- Add `dataToEsm` helper to create named exports from objects ([#29](https://github.com/rollup/rollup-pluginutils/issues/29))
|
||||
- Support literal keys in object patterns ([#27](https://github.com/rollup/rollup-pluginutils/issues/27))
|
||||
- Support function declarations without id in `attachScopes` ([#28](https://github.com/rollup/rollup-pluginutils/issues/28))
|
||||
|
||||
## 2.0.1
|
||||
|
||||
_2017-01-03_
|
||||
|
||||
- Don't add extension to file with trailing dot ([#14](https://github.com/rollup/rollup-pluginutils/issues/14))
|
||||
|
||||
## 2.0.0
|
||||
|
||||
_2017-01-03_
|
||||
|
||||
- Use `micromatch` instead of `minimatch` ([#19](https://github.com/rollup/rollup-pluginutils/issues/19))
|
||||
- Allow `createFilter` to take regexes ([#5](https://github.com/rollup/rollup-pluginutils/issues/5))
|
||||
|
||||
## 1.5.2
|
||||
|
||||
_2016-08-29_
|
||||
|
||||
- Treat `arguments` as a reserved word ([#10](https://github.com/rollup/rollup-pluginutils/issues/10))
|
||||
|
||||
## 1.5.1
|
||||
|
||||
_2016-06-24_
|
||||
|
||||
- Add all declarators in a var declaration to scope, not just the first
|
||||
|
||||
## 1.5.0
|
||||
|
||||
_2016-06-07_
|
||||
|
||||
- Exclude IDs with null character (`\0`)
|
||||
|
||||
## 1.4.0
|
||||
|
||||
_2016-06-07_
|
||||
|
||||
- Workaround minimatch issue ([#6](https://github.com/rollup/rollup-pluginutils/pull/6))
|
||||
- Exclude non-string IDs in `createFilter`
|
||||
|
||||
## 1.3.1
|
||||
|
||||
_2015-12-16_
|
||||
|
||||
- Build with Rollup directly, rather than via Gobble
|
||||
|
||||
## 1.3.0
|
||||
|
||||
_2015-12-16_
|
||||
|
||||
- Use correct path separator on Windows
|
||||
|
||||
## 1.2.0
|
||||
|
||||
_2015-11-02_
|
||||
|
||||
- Add `attachScopes` and `makeLegalIdentifier`
|
||||
|
||||
## 1.1.0
|
||||
|
||||
2015-10-24\*
|
||||
|
||||
- Add `addExtension` function
|
||||
|
||||
## 1.0.1
|
||||
|
||||
_2015-10-24_
|
||||
|
||||
- Include dist files in package
|
||||
|
||||
## 1.0.0
|
||||
|
||||
_2015-10-24_
|
||||
|
||||
- First release
|
||||
21
node_modules/@rollup/pluginutils/LICENSE
generated
vendored
Normal file
21
node_modules/@rollup/pluginutils/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
237
node_modules/@rollup/pluginutils/README.md
generated
vendored
Executable file
237
node_modules/@rollup/pluginutils/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,237 @@
|
|||
[npm]: https://img.shields.io/npm/v/@rollup/pluginutils
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/pluginutils
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/pluginutils
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/pluginutils
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/pluginutils
|
||||
|
||||
A set of utility functions commonly used by 🍣 Rollup plugins.
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```console
|
||||
npm install @rollup/pluginutils --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import utils from '@rollup/pluginutils';
|
||||
//...
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Available utility functions are listed below:
|
||||
|
||||
_Note: Parameter names immediately followed by a `?` indicate that the parameter is optional._
|
||||
|
||||
### addExtension
|
||||
|
||||
Adds an extension to a module ID if one does not exist.
|
||||
|
||||
Parameters: `(filename: String, ext?: String)`<br>
|
||||
Returns: `String`
|
||||
|
||||
```js
|
||||
import { addExtension } from '@rollup/pluginutils';
|
||||
|
||||
export default function myPlugin(options = {}) {
|
||||
return {
|
||||
resolveId(code, id) {
|
||||
// only adds an extension if there isn't one already
|
||||
id = addExtension(id); // `foo` -> `foo.js`, `foo.js -> foo.js`
|
||||
id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js -> `foo.js`
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### attachScopes
|
||||
|
||||
Attaches `Scope` objects to the relevant nodes of an AST. Each `Scope` object has a `scope.contains(name)` method that returns `true` if a given name is defined in the current scope or a parent scope.
|
||||
|
||||
Parameters: `(ast: Node, propertyName?: String)`<br>
|
||||
Returns: `Object`
|
||||
|
||||
See [rollup-plugin-inject](https://github.com/rollup/rollup-plugin-inject) or [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs) for an example of usage.
|
||||
|
||||
```js
|
||||
import { attachScopes } from '@rollup/pluginutils';
|
||||
import { walk } from 'estree-walker';
|
||||
|
||||
export default function myPlugin(options = {}) {
|
||||
return {
|
||||
transform(code) {
|
||||
const ast = this.parse(code);
|
||||
|
||||
let scope = attachScopes(ast, 'scope');
|
||||
|
||||
walk(ast, {
|
||||
enter(node) {
|
||||
if (node.scope) scope = node.scope;
|
||||
|
||||
if (!scope.contains('foo')) {
|
||||
// `foo` is not defined, so if we encounter it,
|
||||
// we assume it's a global
|
||||
}
|
||||
},
|
||||
leave(node) {
|
||||
if (node.scope) scope = scope.parent;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### createFilter
|
||||
|
||||
Constructs a filter function which can be used to determine whether or not certain modules should be operated upon.
|
||||
|
||||
Parameters: `(include?: <minmatch>, exclude?: <minmatch>, options?: Object)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### `include` and `exclude`
|
||||
|
||||
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
||||
|
||||
A valid [`minimatch`](https://www.npmjs.com/package/minimatch) pattern, or array of patterns. If `options.include` is omitted or has zero length, filter will return `true` by default. Otherwise, an ID must match one or more of the `minimatch` patterns, and must not match any of the `options.exclude` patterns.
|
||||
|
||||
#### `options`
|
||||
|
||||
##### `resolve`
|
||||
|
||||
Type: `String | Boolean | null`
|
||||
|
||||
Optionally resolves the patterns against a directory other than `process.cwd()`. If a `String` is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `false`, then the patterns will not be resolved against any directory. This can be useful if you want to create a filter for virtual module names.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { createFilter } from '@rollup/pluginutils';
|
||||
|
||||
export default function myPlugin(options = {}) {
|
||||
// assume that the myPlugin accepts options of `options.include` and `options.exclude`
|
||||
var filter = createFilter(options.include, options.exclude, {
|
||||
resolve: '/my/base/dir'
|
||||
});
|
||||
|
||||
return {
|
||||
transform(code, id) {
|
||||
if (!filter(id)) return;
|
||||
|
||||
// proceed with the transformation...
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### dataToEsm
|
||||
|
||||
Transforms objects into tree-shakable ES Module imports.
|
||||
|
||||
Parameters: `(data: Object)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### `data`
|
||||
|
||||
Type: `Object`
|
||||
|
||||
An object to transform into an ES module.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { dataToEsm } from '@rollup/pluginutils';
|
||||
|
||||
const esModuleSource = dataToEsm(
|
||||
{
|
||||
custom: 'data',
|
||||
to: ['treeshake']
|
||||
},
|
||||
{
|
||||
compact: false,
|
||||
indent: '\t',
|
||||
preferConst: false,
|
||||
objectShorthand: false,
|
||||
namedExports: true
|
||||
}
|
||||
);
|
||||
/*
|
||||
Outputs the string ES module source:
|
||||
export const custom = 'data';
|
||||
export const to = ['treeshake'];
|
||||
export default { custom, to };
|
||||
*/
|
||||
```
|
||||
|
||||
### extractAssignedNames
|
||||
|
||||
Extracts the names of all assignment targets based upon specified patterns.
|
||||
|
||||
Parameters: `(param: Node)`<br>
|
||||
Returns: `Array[...String]`
|
||||
|
||||
#### `param`
|
||||
|
||||
Type: `Node`
|
||||
|
||||
An `acorn` AST Node.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { extractAssignedNames } from '@rollup/pluginutils';
|
||||
import { walk } from 'estree-walker';
|
||||
|
||||
export default function myPlugin(options = {}) {
|
||||
return {
|
||||
transform(code) {
|
||||
const ast = this.parse(code);
|
||||
|
||||
walk(ast, {
|
||||
enter(node) {
|
||||
if (node.type === 'VariableDeclarator') {
|
||||
const declaredNames = extractAssignedNames(node.id);
|
||||
// do something with the declared names
|
||||
// e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z']
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### makeLegalIdentifier
|
||||
|
||||
Constructs a bundle-safe identifier from a `String`.
|
||||
|
||||
Parameters: `(str: String)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { makeLegalIdentifier } from '@rollup/pluginutils';
|
||||
|
||||
makeLegalIdentifier('foo-bar'); // 'foo_bar'
|
||||
makeLegalIdentifier('typeof'); // '_typeof'
|
||||
```
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
447
node_modules/@rollup/pluginutils/dist/cjs/index.js
generated
vendored
Normal file
447
node_modules/@rollup/pluginutils/dist/cjs/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,447 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var path = require('path');
|
||||
var pm = _interopDefault(require('picomatch'));
|
||||
|
||||
const addExtension = function addExtension(filename, ext = '.js') {
|
||||
let result = `${filename}`;
|
||||
if (!path.extname(filename))
|
||||
result += ext;
|
||||
return result;
|
||||
};
|
||||
|
||||
function walk(ast, { enter, leave }) {
|
||||
return visit(ast, null, enter, leave);
|
||||
}
|
||||
|
||||
let should_skip = false;
|
||||
let should_remove = false;
|
||||
let replacement = null;
|
||||
const context = {
|
||||
skip: () => should_skip = true,
|
||||
remove: () => should_remove = true,
|
||||
replace: (node) => replacement = node
|
||||
};
|
||||
|
||||
function replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = should_skip;
|
||||
const _should_remove = should_remove;
|
||||
const _replacement = replacement;
|
||||
should_skip = false;
|
||||
should_remove = false;
|
||||
replacement = null;
|
||||
|
||||
enter.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = should_skip;
|
||||
const removed = should_remove;
|
||||
|
||||
should_skip = _should_skip;
|
||||
should_remove = _should_remove;
|
||||
replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Array.isArray(value)) {
|
||||
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
|
||||
if (value[j] !== null && typeof value[j].type === 'string') {
|
||||
if (!visit(value[j], node, enter, leave, key, k)) {
|
||||
// removed
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (value !== null && typeof value.type === 'string') {
|
||||
visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = replacement;
|
||||
const _should_remove = should_remove;
|
||||
replacement = null;
|
||||
should_remove = false;
|
||||
|
||||
leave.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = should_remove;
|
||||
|
||||
replacement = _replacement;
|
||||
should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
const extractors = {
|
||||
ArrayPattern(names, param) {
|
||||
for (const element of param.elements) {
|
||||
if (element)
|
||||
extractors[element.type](names, element);
|
||||
}
|
||||
},
|
||||
AssignmentPattern(names, param) {
|
||||
extractors[param.left.type](names, param.left);
|
||||
},
|
||||
Identifier(names, param) {
|
||||
names.push(param.name);
|
||||
},
|
||||
MemberExpression() { },
|
||||
ObjectPattern(names, param) {
|
||||
for (const prop of param.properties) {
|
||||
// @ts-ignore Typescript reports that this is not a valid type
|
||||
if (prop.type === 'RestElement') {
|
||||
extractors.RestElement(names, prop);
|
||||
}
|
||||
else {
|
||||
extractors[prop.value.type](names, prop.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
RestElement(names, param) {
|
||||
extractors[param.argument.type](names, param.argument);
|
||||
}
|
||||
};
|
||||
const extractAssignedNames = function extractAssignedNames(param) {
|
||||
const names = [];
|
||||
extractors[param.type](names, param);
|
||||
return names;
|
||||
};
|
||||
|
||||
const blockDeclarations = {
|
||||
const: true,
|
||||
let: true
|
||||
};
|
||||
class Scope {
|
||||
constructor(options = {}) {
|
||||
this.parent = options.parent;
|
||||
this.isBlockScope = !!options.block;
|
||||
this.declarations = Object.create(null);
|
||||
if (options.params) {
|
||||
options.params.forEach((param) => {
|
||||
extractAssignedNames(param).forEach((name) => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
addDeclaration(node, isBlockDeclaration, isVar) {
|
||||
if (!isBlockDeclaration && this.isBlockScope) {
|
||||
// it's a `var` or function node, and this
|
||||
// is a block scope, so we need to go up
|
||||
this.parent.addDeclaration(node, isBlockDeclaration, isVar);
|
||||
}
|
||||
else if (node.id) {
|
||||
extractAssignedNames(node.id).forEach((name) => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
contains(name) {
|
||||
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
||||
}
|
||||
}
|
||||
const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
||||
let scope = new Scope();
|
||||
walk(ast, {
|
||||
enter(n, parent) {
|
||||
const node = n;
|
||||
// function foo () {...}
|
||||
// class Foo {...}
|
||||
if (/(Function|Class)Declaration/.test(node.type)) {
|
||||
scope.addDeclaration(node, false, false);
|
||||
}
|
||||
// var foo = 1
|
||||
if (node.type === 'VariableDeclaration') {
|
||||
const { kind } = node;
|
||||
const isBlockDeclaration = blockDeclarations[kind];
|
||||
// don't add const/let declarations in the body of a for loop #113
|
||||
const parentType = parent ? parent.type : '';
|
||||
if (!(isBlockDeclaration && /ForOfStatement/.test(parentType))) {
|
||||
node.declarations.forEach((declaration) => {
|
||||
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
let newScope;
|
||||
// create new function scope
|
||||
if (/Function/.test(node.type)) {
|
||||
const func = node;
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: false,
|
||||
params: func.params
|
||||
});
|
||||
// named function expressions - the name is considered
|
||||
// part of the function's scope
|
||||
if (func.type === 'FunctionExpression' && func.id) {
|
||||
newScope.addDeclaration(func, false, false);
|
||||
}
|
||||
}
|
||||
// create new block scope
|
||||
if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: true
|
||||
});
|
||||
}
|
||||
// catch clause has its own block scope
|
||||
if (node.type === 'CatchClause') {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
params: node.param ? [node.param] : [],
|
||||
block: true
|
||||
});
|
||||
}
|
||||
if (newScope) {
|
||||
Object.defineProperty(node, propertyName, {
|
||||
value: newScope,
|
||||
configurable: true
|
||||
});
|
||||
scope = newScope;
|
||||
}
|
||||
},
|
||||
leave(n) {
|
||||
const node = n;
|
||||
if (node[propertyName])
|
||||
scope = scope.parent;
|
||||
}
|
||||
});
|
||||
return scope;
|
||||
};
|
||||
|
||||
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
||||
function isArray(arg) {
|
||||
return Array.isArray(arg);
|
||||
}
|
||||
function ensureArray(thing) {
|
||||
if (isArray(thing))
|
||||
return thing;
|
||||
if (thing == null)
|
||||
return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false) {
|
||||
return id;
|
||||
}
|
||||
// resolve('') is valid and will default to process.cwd()
|
||||
const basePath = path.resolve(resolutionBase || '')
|
||||
.split(path.sep)
|
||||
.join('/')
|
||||
// escape all possible (posix + win) path characters that might interfere with regex
|
||||
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
||||
// Note that we use posix.join because:
|
||||
// 1. the basePath has been normalized to use /
|
||||
// 2. the incoming glob (id) matcher, also uses /
|
||||
// otherwise Node will force backslash (\) on windows
|
||||
return path.posix.join(basePath, id);
|
||||
}
|
||||
const createFilter = function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp
|
||||
? id
|
||||
: {
|
||||
test: (what) => {
|
||||
// this refactor is a tad overly verbose but makes for easy debugging
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
const fn = pm(pattern, { dot: true });
|
||||
const result = fn(what);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
const includeMatchers = ensureArray(include).map(getMatcher);
|
||||
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
||||
return function result(id) {
|
||||
if (typeof id !== 'string')
|
||||
return false;
|
||||
if (/\0/.test(id))
|
||||
return false;
|
||||
const pathId = id.split(path.sep).join('/');
|
||||
for (let i = 0; i < excludeMatchers.length; ++i) {
|
||||
const matcher = excludeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < includeMatchers.length; ++i) {
|
||||
const matcher = includeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
};
|
||||
|
||||
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
||||
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
||||
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
||||
forbiddenIdentifiers.add('');
|
||||
const makeLegalIdentifier = function makeLegalIdentifier(str) {
|
||||
let identifier = str
|
||||
.replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
|
||||
.replace(/[^$_a-zA-Z0-9]/g, '_');
|
||||
if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
return identifier || '_';
|
||||
};
|
||||
|
||||
function stringify(obj) {
|
||||
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
||||
}
|
||||
function serializeArray(arr, indent, baseIndent) {
|
||||
let output = '[';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const key = arr[i];
|
||||
output += `${i > 0 ? ',' : ''}${separator}${serialize(key, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}]`;
|
||||
}
|
||||
function serializeObject(obj, indent, baseIndent) {
|
||||
let output = '{';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
const entries = Object.entries(obj);
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [key, value] = entries[i];
|
||||
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
||||
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(value, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}}`;
|
||||
}
|
||||
function serialize(obj, indent, baseIndent) {
|
||||
if (obj === Infinity)
|
||||
return 'Infinity';
|
||||
if (obj === -Infinity)
|
||||
return '-Infinity';
|
||||
if (obj === 0 && 1 / obj === -Infinity)
|
||||
return '-0';
|
||||
if (obj instanceof Date)
|
||||
return `new Date(${obj.getTime()})`;
|
||||
if (obj instanceof RegExp)
|
||||
return obj.toString();
|
||||
if (obj !== obj)
|
||||
return 'NaN'; // eslint-disable-line no-self-compare
|
||||
if (Array.isArray(obj))
|
||||
return serializeArray(obj, indent, baseIndent);
|
||||
if (obj === null)
|
||||
return 'null';
|
||||
if (typeof obj === 'object')
|
||||
return serializeObject(obj, indent, baseIndent);
|
||||
return stringify(obj);
|
||||
}
|
||||
const dataToEsm = function dataToEsm(data, options = {}) {
|
||||
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
|
||||
const _ = options.compact ? '' : ' ';
|
||||
const n = options.compact ? '' : '\n';
|
||||
const declarationType = options.preferConst ? 'const' : 'var';
|
||||
if (options.namedExports === false ||
|
||||
typeof data !== 'object' ||
|
||||
Array.isArray(data) ||
|
||||
data instanceof Date ||
|
||||
data instanceof RegExp ||
|
||||
data === null) {
|
||||
const code = serialize(data, options.compact ? null : t, '');
|
||||
const magic = _ || (/^[{[\-\/]/.test(code) ? '' : ' '); // eslint-disable-line no-useless-escape
|
||||
return `export default${magic}${code};`;
|
||||
}
|
||||
let namedExportCode = '';
|
||||
const defaultExportRows = [];
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === makeLegalIdentifier(key)) {
|
||||
if (options.objectShorthand)
|
||||
defaultExportRows.push(key);
|
||||
else
|
||||
defaultExportRows.push(`${key}:${_}${key}`);
|
||||
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`;
|
||||
}
|
||||
else {
|
||||
defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`);
|
||||
}
|
||||
}
|
||||
return `${namedExportCode}export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
||||
};
|
||||
|
||||
// TODO: remove this in next major
|
||||
var index = {
|
||||
addExtension,
|
||||
attachScopes,
|
||||
createFilter,
|
||||
dataToEsm,
|
||||
extractAssignedNames,
|
||||
makeLegalIdentifier
|
||||
};
|
||||
|
||||
exports.addExtension = addExtension;
|
||||
exports.attachScopes = attachScopes;
|
||||
exports.createFilter = createFilter;
|
||||
exports.dataToEsm = dataToEsm;
|
||||
exports.default = index;
|
||||
exports.extractAssignedNames = extractAssignedNames;
|
||||
exports.makeLegalIdentifier = makeLegalIdentifier;
|
||||
436
node_modules/@rollup/pluginutils/dist/es/index.js
generated
vendored
Normal file
436
node_modules/@rollup/pluginutils/dist/es/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,436 @@
|
|||
import { extname, sep, resolve, posix } from 'path';
|
||||
import pm from 'picomatch';
|
||||
|
||||
const addExtension = function addExtension(filename, ext = '.js') {
|
||||
let result = `${filename}`;
|
||||
if (!extname(filename))
|
||||
result += ext;
|
||||
return result;
|
||||
};
|
||||
|
||||
function walk(ast, { enter, leave }) {
|
||||
return visit(ast, null, enter, leave);
|
||||
}
|
||||
|
||||
let should_skip = false;
|
||||
let should_remove = false;
|
||||
let replacement = null;
|
||||
const context = {
|
||||
skip: () => should_skip = true,
|
||||
remove: () => should_remove = true,
|
||||
replace: (node) => replacement = node
|
||||
};
|
||||
|
||||
function replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = should_skip;
|
||||
const _should_remove = should_remove;
|
||||
const _replacement = replacement;
|
||||
should_skip = false;
|
||||
should_remove = false;
|
||||
replacement = null;
|
||||
|
||||
enter.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = should_skip;
|
||||
const removed = should_remove;
|
||||
|
||||
should_skip = _should_skip;
|
||||
should_remove = _should_remove;
|
||||
replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Array.isArray(value)) {
|
||||
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
|
||||
if (value[j] !== null && typeof value[j].type === 'string') {
|
||||
if (!visit(value[j], node, enter, leave, key, k)) {
|
||||
// removed
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (value !== null && typeof value.type === 'string') {
|
||||
visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = replacement;
|
||||
const _should_remove = should_remove;
|
||||
replacement = null;
|
||||
should_remove = false;
|
||||
|
||||
leave.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = should_remove;
|
||||
|
||||
replacement = _replacement;
|
||||
should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
const extractors = {
|
||||
ArrayPattern(names, param) {
|
||||
for (const element of param.elements) {
|
||||
if (element)
|
||||
extractors[element.type](names, element);
|
||||
}
|
||||
},
|
||||
AssignmentPattern(names, param) {
|
||||
extractors[param.left.type](names, param.left);
|
||||
},
|
||||
Identifier(names, param) {
|
||||
names.push(param.name);
|
||||
},
|
||||
MemberExpression() { },
|
||||
ObjectPattern(names, param) {
|
||||
for (const prop of param.properties) {
|
||||
// @ts-ignore Typescript reports that this is not a valid type
|
||||
if (prop.type === 'RestElement') {
|
||||
extractors.RestElement(names, prop);
|
||||
}
|
||||
else {
|
||||
extractors[prop.value.type](names, prop.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
RestElement(names, param) {
|
||||
extractors[param.argument.type](names, param.argument);
|
||||
}
|
||||
};
|
||||
const extractAssignedNames = function extractAssignedNames(param) {
|
||||
const names = [];
|
||||
extractors[param.type](names, param);
|
||||
return names;
|
||||
};
|
||||
|
||||
const blockDeclarations = {
|
||||
const: true,
|
||||
let: true
|
||||
};
|
||||
class Scope {
|
||||
constructor(options = {}) {
|
||||
this.parent = options.parent;
|
||||
this.isBlockScope = !!options.block;
|
||||
this.declarations = Object.create(null);
|
||||
if (options.params) {
|
||||
options.params.forEach((param) => {
|
||||
extractAssignedNames(param).forEach((name) => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
addDeclaration(node, isBlockDeclaration, isVar) {
|
||||
if (!isBlockDeclaration && this.isBlockScope) {
|
||||
// it's a `var` or function node, and this
|
||||
// is a block scope, so we need to go up
|
||||
this.parent.addDeclaration(node, isBlockDeclaration, isVar);
|
||||
}
|
||||
else if (node.id) {
|
||||
extractAssignedNames(node.id).forEach((name) => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
contains(name) {
|
||||
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
||||
}
|
||||
}
|
||||
const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
||||
let scope = new Scope();
|
||||
walk(ast, {
|
||||
enter(n, parent) {
|
||||
const node = n;
|
||||
// function foo () {...}
|
||||
// class Foo {...}
|
||||
if (/(Function|Class)Declaration/.test(node.type)) {
|
||||
scope.addDeclaration(node, false, false);
|
||||
}
|
||||
// var foo = 1
|
||||
if (node.type === 'VariableDeclaration') {
|
||||
const { kind } = node;
|
||||
const isBlockDeclaration = blockDeclarations[kind];
|
||||
// don't add const/let declarations in the body of a for loop #113
|
||||
const parentType = parent ? parent.type : '';
|
||||
if (!(isBlockDeclaration && /ForOfStatement/.test(parentType))) {
|
||||
node.declarations.forEach((declaration) => {
|
||||
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
let newScope;
|
||||
// create new function scope
|
||||
if (/Function/.test(node.type)) {
|
||||
const func = node;
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: false,
|
||||
params: func.params
|
||||
});
|
||||
// named function expressions - the name is considered
|
||||
// part of the function's scope
|
||||
if (func.type === 'FunctionExpression' && func.id) {
|
||||
newScope.addDeclaration(func, false, false);
|
||||
}
|
||||
}
|
||||
// create new block scope
|
||||
if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: true
|
||||
});
|
||||
}
|
||||
// catch clause has its own block scope
|
||||
if (node.type === 'CatchClause') {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
params: node.param ? [node.param] : [],
|
||||
block: true
|
||||
});
|
||||
}
|
||||
if (newScope) {
|
||||
Object.defineProperty(node, propertyName, {
|
||||
value: newScope,
|
||||
configurable: true
|
||||
});
|
||||
scope = newScope;
|
||||
}
|
||||
},
|
||||
leave(n) {
|
||||
const node = n;
|
||||
if (node[propertyName])
|
||||
scope = scope.parent;
|
||||
}
|
||||
});
|
||||
return scope;
|
||||
};
|
||||
|
||||
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
||||
function isArray(arg) {
|
||||
return Array.isArray(arg);
|
||||
}
|
||||
function ensureArray(thing) {
|
||||
if (isArray(thing))
|
||||
return thing;
|
||||
if (thing == null)
|
||||
return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false) {
|
||||
return id;
|
||||
}
|
||||
// resolve('') is valid and will default to process.cwd()
|
||||
const basePath = resolve(resolutionBase || '')
|
||||
.split(sep)
|
||||
.join('/')
|
||||
// escape all possible (posix + win) path characters that might interfere with regex
|
||||
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
||||
// Note that we use posix.join because:
|
||||
// 1. the basePath has been normalized to use /
|
||||
// 2. the incoming glob (id) matcher, also uses /
|
||||
// otherwise Node will force backslash (\) on windows
|
||||
return posix.join(basePath, id);
|
||||
}
|
||||
const createFilter = function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp
|
||||
? id
|
||||
: {
|
||||
test: (what) => {
|
||||
// this refactor is a tad overly verbose but makes for easy debugging
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
const fn = pm(pattern, { dot: true });
|
||||
const result = fn(what);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
const includeMatchers = ensureArray(include).map(getMatcher);
|
||||
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
||||
return function result(id) {
|
||||
if (typeof id !== 'string')
|
||||
return false;
|
||||
if (/\0/.test(id))
|
||||
return false;
|
||||
const pathId = id.split(sep).join('/');
|
||||
for (let i = 0; i < excludeMatchers.length; ++i) {
|
||||
const matcher = excludeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < includeMatchers.length; ++i) {
|
||||
const matcher = includeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
};
|
||||
|
||||
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
||||
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
||||
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
||||
forbiddenIdentifiers.add('');
|
||||
const makeLegalIdentifier = function makeLegalIdentifier(str) {
|
||||
let identifier = str
|
||||
.replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
|
||||
.replace(/[^$_a-zA-Z0-9]/g, '_');
|
||||
if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
return identifier || '_';
|
||||
};
|
||||
|
||||
function stringify(obj) {
|
||||
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
||||
}
|
||||
function serializeArray(arr, indent, baseIndent) {
|
||||
let output = '[';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const key = arr[i];
|
||||
output += `${i > 0 ? ',' : ''}${separator}${serialize(key, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}]`;
|
||||
}
|
||||
function serializeObject(obj, indent, baseIndent) {
|
||||
let output = '{';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
const entries = Object.entries(obj);
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [key, value] = entries[i];
|
||||
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
||||
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(value, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}}`;
|
||||
}
|
||||
function serialize(obj, indent, baseIndent) {
|
||||
if (obj === Infinity)
|
||||
return 'Infinity';
|
||||
if (obj === -Infinity)
|
||||
return '-Infinity';
|
||||
if (obj === 0 && 1 / obj === -Infinity)
|
||||
return '-0';
|
||||
if (obj instanceof Date)
|
||||
return `new Date(${obj.getTime()})`;
|
||||
if (obj instanceof RegExp)
|
||||
return obj.toString();
|
||||
if (obj !== obj)
|
||||
return 'NaN'; // eslint-disable-line no-self-compare
|
||||
if (Array.isArray(obj))
|
||||
return serializeArray(obj, indent, baseIndent);
|
||||
if (obj === null)
|
||||
return 'null';
|
||||
if (typeof obj === 'object')
|
||||
return serializeObject(obj, indent, baseIndent);
|
||||
return stringify(obj);
|
||||
}
|
||||
const dataToEsm = function dataToEsm(data, options = {}) {
|
||||
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
|
||||
const _ = options.compact ? '' : ' ';
|
||||
const n = options.compact ? '' : '\n';
|
||||
const declarationType = options.preferConst ? 'const' : 'var';
|
||||
if (options.namedExports === false ||
|
||||
typeof data !== 'object' ||
|
||||
Array.isArray(data) ||
|
||||
data instanceof Date ||
|
||||
data instanceof RegExp ||
|
||||
data === null) {
|
||||
const code = serialize(data, options.compact ? null : t, '');
|
||||
const magic = _ || (/^[{[\-\/]/.test(code) ? '' : ' '); // eslint-disable-line no-useless-escape
|
||||
return `export default${magic}${code};`;
|
||||
}
|
||||
let namedExportCode = '';
|
||||
const defaultExportRows = [];
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === makeLegalIdentifier(key)) {
|
||||
if (options.objectShorthand)
|
||||
defaultExportRows.push(key);
|
||||
else
|
||||
defaultExportRows.push(`${key}:${_}${key}`);
|
||||
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`;
|
||||
}
|
||||
else {
|
||||
defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`);
|
||||
}
|
||||
}
|
||||
return `${namedExportCode}export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
||||
};
|
||||
|
||||
// TODO: remove this in next major
|
||||
var index = {
|
||||
addExtension,
|
||||
attachScopes,
|
||||
createFilter,
|
||||
dataToEsm,
|
||||
extractAssignedNames,
|
||||
makeLegalIdentifier
|
||||
};
|
||||
|
||||
export default index;
|
||||
export { addExtension, attachScopes, createFilter, dataToEsm, extractAssignedNames, makeLegalIdentifier };
|
||||
1
node_modules/@rollup/pluginutils/dist/es/package.json
generated
vendored
Normal file
1
node_modules/@rollup/pluginutils/dist/es/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"type":"module"}
|
||||
79
node_modules/@rollup/pluginutils/node_modules/estree-walker/CHANGELOG.md
generated
vendored
Normal file
79
node_modules/@rollup/pluginutils/node_modules/estree-walker/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# changelog
|
||||
|
||||
## 1.0.1
|
||||
|
||||
* Relax node type to `BaseNode` ([#17](https://github.com/Rich-Harris/estree-walker/pull/17))
|
||||
|
||||
## 1.0.0
|
||||
|
||||
* Don't cache child keys
|
||||
|
||||
## 0.9.0
|
||||
|
||||
* Add `this.remove()` method
|
||||
|
||||
## 0.8.1
|
||||
|
||||
* Fix pkg.files
|
||||
|
||||
## 0.8.0
|
||||
|
||||
* Adopt `estree` types
|
||||
|
||||
## 0.7.0
|
||||
|
||||
* Add a `this.replace(node)` method
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9))
|
||||
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8))
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Fix walker context type
|
||||
* Update deps, remove unncessary Bublé transformation
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* Add types to package
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Prevent context corruption when `walk()` is called during a walk
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* Export `childKeys`, for manually fixing in case of malformed ASTs
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
|
||||
|
||||
## 0.3.1
|
||||
|
||||
* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2))
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* More predictable ordering
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Keep `context` shape
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Add ES6 build
|
||||
|
||||
## 0.1.3
|
||||
|
||||
* npm snafu
|
||||
|
||||
## 0.1.2
|
||||
|
||||
* Pass current prop and index to `enter`/`leave` callbacks
|
||||
|
||||
## 0.1.1
|
||||
|
||||
* First release
|
||||
48
node_modules/@rollup/pluginutils/node_modules/estree-walker/README.md
generated
vendored
Normal file
48
node_modules/@rollup/pluginutils/node_modules/estree-walker/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# estree-walker
|
||||
|
||||
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i estree-walker
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var walk = require( 'estree-walker' ).walk;
|
||||
var acorn = require( 'acorn' );
|
||||
|
||||
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
|
||||
|
||||
walk( ast, {
|
||||
enter: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
},
|
||||
leave: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
|
||||
|
||||
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
|
||||
|
||||
Call `this.remove()` in either `enter` or `leave` to remove the current node.
|
||||
|
||||
## Why not use estraverse?
|
||||
|
||||
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
|
||||
|
||||
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
|
||||
|
||||
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
135
node_modules/@rollup/pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js
generated
vendored
Normal file
135
node_modules/@rollup/pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js
generated
vendored
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.estreeWalker = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
function walk(ast, { enter, leave }) {
|
||||
return visit(ast, null, enter, leave);
|
||||
}
|
||||
|
||||
let should_skip = false;
|
||||
let should_remove = false;
|
||||
let replacement = null;
|
||||
const context = {
|
||||
skip: () => should_skip = true,
|
||||
remove: () => should_remove = true,
|
||||
replace: (node) => replacement = node
|
||||
};
|
||||
|
||||
function replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = should_skip;
|
||||
const _should_remove = should_remove;
|
||||
const _replacement = replacement;
|
||||
should_skip = false;
|
||||
should_remove = false;
|
||||
replacement = null;
|
||||
|
||||
enter.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = should_skip;
|
||||
const removed = should_remove;
|
||||
|
||||
should_skip = _should_skip;
|
||||
should_remove = _should_remove;
|
||||
replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Array.isArray(value)) {
|
||||
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
|
||||
if (value[j] !== null && typeof value[j].type === 'string') {
|
||||
if (!visit(value[j], node, enter, leave, key, k)) {
|
||||
// removed
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (value !== null && typeof value.type === 'string') {
|
||||
visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = replacement;
|
||||
const _should_remove = should_remove;
|
||||
replacement = null;
|
||||
should_remove = false;
|
||||
|
||||
leave.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = should_remove;
|
||||
|
||||
replacement = _replacement;
|
||||
should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
exports.walk = walk;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
1
node_modules/@rollup/pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js.map
generated
vendored
Normal file
1
node_modules/@rollup/pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"estree-walker.umd.js","sources":["../src/estree-walker.js"],"sourcesContent":["export function walk(ast, { enter, leave }) {\n\tvisit(ast, null, enter, leave);\n}\n\nlet shouldSkip = false;\nconst context = { skip: () => shouldSkip = true };\n\nexport const childKeys = {};\n\nconst toString = Object.prototype.toString;\n\nfunction isArray(thing) {\n\treturn toString.call(thing) === '[object Array]';\n}\n\nfunction visit(node, parent, enter, leave, prop, index) {\n\tif (!node) return;\n\n\tif (enter) {\n\t\tconst _shouldSkip = shouldSkip;\n\t\tshouldSkip = false;\n\t\tenter.call(context, node, parent, prop, index);\n\t\tconst skipped = shouldSkip;\n\t\tshouldSkip = _shouldSkip;\n\n\t\tif (skipped) return;\n\t}\n\n\tconst keys = childKeys[node.type] || (\n\t\tchildKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')\n\t);\n\n\tfor (let i = 0; i < keys.length; i += 1) {\n\t\tconst key = keys[i];\n\t\tconst value = node[key];\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let j = 0; j < value.length; j += 1) {\n\t\t\t\tvisit(value[j], node, enter, leave, key, j);\n\t\t\t}\n\t\t}\n\n\t\telse if (value && value.type) {\n\t\t\tvisit(value, node, enter, leave, key, null);\n\t\t}\n\t}\n\n\tif (leave) {\n\t\tleave(node, parent, prop, index);\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAO,SAAS,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;CAC5C,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAChC,CAAC;;CAED,IAAI,UAAU,GAAG,KAAK,CAAC;CACvB,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;;AAElD,AAAY,OAAC,SAAS,GAAG,EAAE,CAAC;;CAE5B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;;CAE3C,SAAS,OAAO,CAAC,KAAK,EAAE;CACxB,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC;CAClD,CAAC;;CAED,SAAS,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;CACxD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;;CAEnB,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,MAAM,WAAW,GAAG,UAAU,CAAC;CACjC,EAAE,UAAU,GAAG,KAAK,CAAC;CACrB,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACjD,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC;CAC7B,EAAE,UAAU,GAAG,WAAW,CAAC;;CAE3B,EAAE,IAAI,OAAO,EAAE,OAAO;CACtB,EAAE;;CAEF,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;CAClC,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;CACvF,EAAE,CAAC;;CAEH,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC1C,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtB,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;CAE1B,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;CACtB,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC7C,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;CAChD,IAAI;CACJ,GAAG;;CAEH,OAAO,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE;CAChC,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;CAC/C,GAAG;CACH,EAAE;;CAEF,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACnC,EAAE;CACF,CAAC;;;;;;;;;;;;;"}
|
||||
32
node_modules/@rollup/pluginutils/node_modules/estree-walker/package.json
generated
vendored
Normal file
32
node_modules/@rollup/pluginutils/node_modules/estree-walker/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "estree-walker",
|
||||
"description": "Traverse an ESTree-compliant AST",
|
||||
"version": "1.0.1",
|
||||
"author": "Rich Harris",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Rich-Harris/estree-walker"
|
||||
},
|
||||
"main": "dist/estree-walker.umd.js",
|
||||
"module": "src/estree-walker.js",
|
||||
"types": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build && npm test",
|
||||
"build": "tsc && rollup -c",
|
||||
"test": "mocha --opts mocha.opts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/estree": "0.0.39",
|
||||
"mocha": "^5.2.0",
|
||||
"rollup": "^0.67.3",
|
||||
"rollup-plugin-sucrase": "^2.1.0",
|
||||
"typescript": "^3.6.3"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"types",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
125
node_modules/@rollup/pluginutils/node_modules/estree-walker/src/estree-walker.js
generated
vendored
Normal file
125
node_modules/@rollup/pluginutils/node_modules/estree-walker/src/estree-walker.js
generated
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
function walk(ast, { enter, leave }) {
|
||||
return visit(ast, null, enter, leave);
|
||||
}
|
||||
|
||||
let should_skip = false;
|
||||
let should_remove = false;
|
||||
let replacement = null;
|
||||
const context = {
|
||||
skip: () => should_skip = true,
|
||||
remove: () => should_remove = true,
|
||||
replace: (node) => replacement = node
|
||||
};
|
||||
|
||||
function replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = should_skip;
|
||||
const _should_remove = should_remove;
|
||||
const _replacement = replacement;
|
||||
should_skip = false;
|
||||
should_remove = false;
|
||||
replacement = null;
|
||||
|
||||
enter.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = should_skip;
|
||||
const removed = should_remove;
|
||||
|
||||
should_skip = _should_skip;
|
||||
should_remove = _should_remove;
|
||||
replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Array.isArray(value)) {
|
||||
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
|
||||
if (value[j] !== null && typeof value[j].type === 'string') {
|
||||
if (!visit(value[j], node, enter, leave, key, k)) {
|
||||
// removed
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (value !== null && typeof value.type === 'string') {
|
||||
visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = replacement;
|
||||
const _should_remove = should_remove;
|
||||
replacement = null;
|
||||
should_remove = false;
|
||||
|
||||
leave.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = should_remove;
|
||||
|
||||
replacement = _replacement;
|
||||
should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
export { walk };
|
||||
144
node_modules/@rollup/pluginutils/node_modules/estree-walker/src/index.ts
generated
vendored
Normal file
144
node_modules/@rollup/pluginutils/node_modules/estree-walker/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
import { BaseNode } from "estree";
|
||||
|
||||
type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
};
|
||||
|
||||
type WalkerHandler = (
|
||||
this: WalkerContext,
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
key: string,
|
||||
index: number
|
||||
) => void
|
||||
|
||||
type Walker = {
|
||||
enter?: WalkerHandler;
|
||||
leave?: WalkerHandler;
|
||||
}
|
||||
|
||||
export function walk(ast: BaseNode, { enter, leave }: Walker) {
|
||||
return visit(ast, null, enter, leave);
|
||||
}
|
||||
|
||||
let should_skip = false;
|
||||
let should_remove = false;
|
||||
let replacement: BaseNode = null;
|
||||
const context: WalkerContext = {
|
||||
skip: () => should_skip = true,
|
||||
remove: () => should_remove = true,
|
||||
replace: (node: BaseNode) => replacement = node
|
||||
};
|
||||
|
||||
function replace(parent: any, prop: string, index: number, node: BaseNode) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove(parent: any, prop: string, index: number) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visit(
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
enter: WalkerHandler,
|
||||
leave: WalkerHandler,
|
||||
prop?: string,
|
||||
index?: number
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = should_skip;
|
||||
const _should_remove = should_remove;
|
||||
const _replacement = replacement;
|
||||
should_skip = false;
|
||||
should_remove = false;
|
||||
replacement = null;
|
||||
|
||||
enter.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = should_skip;
|
||||
const removed = should_remove;
|
||||
|
||||
should_skip = _should_skip;
|
||||
should_remove = _should_remove;
|
||||
replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node as any)[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Array.isArray(value)) {
|
||||
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
|
||||
if (value[j] !== null && typeof value[j].type === 'string') {
|
||||
if (!visit(value[j], node, enter, leave, key, k)) {
|
||||
// removed
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (value !== null && typeof value.type === 'string') {
|
||||
visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = replacement;
|
||||
const _should_remove = should_remove;
|
||||
replacement = null;
|
||||
should_remove = false;
|
||||
|
||||
leave.call(context, node, parent, prop, index);
|
||||
|
||||
if (replacement) {
|
||||
node = replacement;
|
||||
replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (should_remove) {
|
||||
remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = should_remove;
|
||||
|
||||
replacement = _replacement;
|
||||
should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
13
node_modules/@rollup/pluginutils/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
13
node_modules/@rollup/pluginutils/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { BaseNode } from "estree";
|
||||
declare type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
};
|
||||
declare type WalkerHandler = (this: WalkerContext, node: BaseNode, parent: BaseNode, key: string, index: number) => void;
|
||||
declare type Walker = {
|
||||
enter?: WalkerHandler;
|
||||
leave?: WalkerHandler;
|
||||
};
|
||||
export declare function walk(ast: BaseNode, { enter, leave }: Walker): BaseNode;
|
||||
export {};
|
||||
91
node_modules/@rollup/pluginutils/package.json
generated
vendored
Normal file
91
node_modules/@rollup/pluginutils/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"name": "@rollup/pluginutils",
|
||||
"version": "3.1.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "A set of utility functions commonly used by Rollup plugins",
|
||||
"license": "MIT",
|
||||
"repository": "rollup/plugins",
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/pluginutils#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rollup/plugins/issues"
|
||||
},
|
||||
"main": "./dist/cjs/index.js",
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm run build && pnpm run lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm run test -- --verbose",
|
||||
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
|
||||
"lint:docs": "prettier --single-quote --write README.md",
|
||||
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
|
||||
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "pnpm run build",
|
||||
"prepublishOnly": "pnpm run lint && pnpm run build",
|
||||
"pretest": "pnpm run build -- --sourcemap",
|
||||
"test": "ava"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"utils"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/estree": "0.0.39",
|
||||
"estree-walker": "^1.0.1",
|
||||
"picomatch": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.0.2",
|
||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||
"@rollup/plugin-typescript": "^3.0.0",
|
||||
"@types/jest": "^24.9.0",
|
||||
"@types/node": "^12.12.25",
|
||||
"@types/picomatch": "^2.2.1",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"ava": {
|
||||
"compileEnhancements": false,
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
},
|
||||
"exports": {
|
||||
"require": "./dist/cjs/index.js",
|
||||
"import": "./dist/es/index.js"
|
||||
},
|
||||
"module": "./dist/es/index.js",
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".js",
|
||||
".ts"
|
||||
]
|
||||
},
|
||||
"type": "commonjs",
|
||||
"types": "types/index.d.ts"
|
||||
}
|
||||
86
node_modules/@rollup/pluginutils/types/index.d.ts
generated
vendored
Executable file
86
node_modules/@rollup/pluginutils/types/index.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
// eslint-disable-next-line import/no-unresolved
|
||||
import { BaseNode } from 'estree';
|
||||
|
||||
export interface AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: { [key: string]: boolean };
|
||||
addDeclaration(node: BaseNode, isBlockDeclaration: boolean, isVar: boolean): void;
|
||||
contains(name: string): boolean;
|
||||
}
|
||||
|
||||
export interface DataToEsmOptions {
|
||||
compact?: boolean;
|
||||
indent?: string;
|
||||
namedExports?: boolean;
|
||||
objectShorthand?: boolean;
|
||||
preferConst?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid `minimatch` pattern, or array of patterns.
|
||||
*/
|
||||
export type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
||||
|
||||
/**
|
||||
* Adds an extension to a module ID if one does not exist.
|
||||
*/
|
||||
export function addExtension(filename: string, ext?: string): string;
|
||||
|
||||
/**
|
||||
* Attaches `Scope` objects to the relevant nodes of an AST.
|
||||
* Each `Scope` object has a `scope.contains(name)` method that returns `true`
|
||||
* if a given name is defined in the current scope or a parent scope.
|
||||
*/
|
||||
export function attachScopes(ast: BaseNode, propertyName?: string): AttachedScope;
|
||||
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `false`, then the patterns will not be resolved against any directory.
|
||||
* This can be useful if you want to create a filter for virtual module names.
|
||||
*/
|
||||
export function createFilter(
|
||||
include?: FilterPattern,
|
||||
exclude?: FilterPattern,
|
||||
options?: { resolve?: string | false | null }
|
||||
): (id: string | unknown) => boolean;
|
||||
|
||||
/**
|
||||
* Transforms objects into tree-shakable ES Module imports.
|
||||
* @param data An object to transform into an ES module.
|
||||
*/
|
||||
export function dataToEsm(data: unknown, options?: DataToEsmOptions): string;
|
||||
|
||||
/**
|
||||
* Extracts the names of all assignment targets based upon specified patterns.
|
||||
* @param param An `acorn` AST Node.
|
||||
*/
|
||||
export function extractAssignedNames(param: BaseNode): string[];
|
||||
|
||||
/**
|
||||
* Constructs a bundle-safe identifier from a `string`.
|
||||
*/
|
||||
export function makeLegalIdentifier(str: string): string;
|
||||
|
||||
export type AddExtension = typeof addExtension;
|
||||
export type AttachScopes = typeof attachScopes;
|
||||
export type CreateFilter = typeof createFilter;
|
||||
export type ExtractAssignedNames = typeof extractAssignedNames;
|
||||
export type MakeLegalIdentifier = typeof makeLegalIdentifier;
|
||||
export type DataToEsm = typeof dataToEsm;
|
||||
|
||||
declare const defaultExport: {
|
||||
addExtension: AddExtension;
|
||||
attachScopes: AttachScopes;
|
||||
createFilter: CreateFilter;
|
||||
dataToEsm: DataToEsm;
|
||||
extractAssignedNames: ExtractAssignedNames;
|
||||
makeLegalIdentifier: MakeLegalIdentifier;
|
||||
};
|
||||
export default defaultExport;
|
||||
21
node_modules/@types/codemirror/LICENSE
generated
vendored
Normal file
21
node_modules/@types/codemirror/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
16
node_modules/@types/codemirror/README.md
generated
vendored
Normal file
16
node_modules/@types/codemirror/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Installation
|
||||
> `npm install --save @types/codemirror`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for codemirror (https://github.com/marijnh/CodeMirror).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/codemirror.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Wed, 03 Feb 2021 22:47:24 GMT
|
||||
* Dependencies: [@types/tern](https://npmjs.com/package/@types/tern)
|
||||
* Global values: `CodeMirror`
|
||||
|
||||
# Credits
|
||||
These definitions were written by [mihailik](https://github.com/mihailik), [nrbernard](https://github.com/nrbernard), [Pr1st0n](https://github.com/Pr1st0n), [rileymiller](https://github.com/rileymiller), [toddself](https://github.com/toddself), [ysulyma](https://github.com/ysulyma), [azoson](https://github.com/azoson), [kylesferrazza](https://github.com/kylesferrazza), [fityocsaba96](https://github.com/fityocsaba96), [koddsson](https://github.com/koddsson), and [ficristo](https://github.com/ficristo).
|
||||
42
node_modules/@types/codemirror/addon/comment/comment.d.ts
generated
vendored
Normal file
42
node_modules/@types/codemirror/addon/comment/comment.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_comment
|
||||
|
||||
// Todo: add 'toggleComment' command, once command type definitions exist in main definitions
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface Editor {
|
||||
/** Tries to uncomment the current selection, and if that fails, line-comments it. */
|
||||
toggleComment(options?: CommentOptions): void;
|
||||
/** Set the lines in the given range to be line comments. Will fall back to `blockComment` when no line comment style is defined for the mode. */
|
||||
lineComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Wrap the code in the given range in a block comment. Will fall back to `lineComment` when no block comment style is defined for the mode. */
|
||||
blockComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Try to uncomment the given range. Returns `true` if a comment range was found and removed, `false` otherwise. */
|
||||
uncomment(from: Position, to: Position, options?: CommentOptions): boolean;
|
||||
}
|
||||
|
||||
interface CommentOptions {
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentStart?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentEnd?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentLead?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
lineComment?: string;
|
||||
/** A string that will be inserted after opening and leading markers, and before closing comment markers. Defaults to a single space. */
|
||||
padding?: string;
|
||||
/** Whether, when adding line comments, to also comment lines that contain only whitespace. */
|
||||
commentBlankLines?: boolean;
|
||||
/** When adding line comments and this is turned on, it will align the comment block to the current indentation of the first line of the block. */
|
||||
indent?: boolean;
|
||||
/** When block commenting, this controls whether the whole lines are indented, or only the precise range that is given. Defaults to `true`. */
|
||||
fullLines?: boolean;
|
||||
}
|
||||
}
|
||||
16
node_modules/@types/codemirror/addon/display/autorefresh.d.ts
generated
vendored
Normal file
16
node_modules/@types/codemirror/addon/display/autorefresh.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Type definitions for CodeMirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: mtgto <https://github.com/mtgto>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_autorefresh
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface EditorConfiguration {
|
||||
// if true, it will be refreshed the first time the editor becomes visible.
|
||||
// you can pass delay (msec) time as polling duration
|
||||
autoRefresh?: boolean | { delay: number };
|
||||
}
|
||||
}
|
||||
17
node_modules/@types/codemirror/addon/display/fullscreen.d.ts
generated
vendored
Normal file
17
node_modules/@types/codemirror/addon/display/fullscreen.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When set to true, will make the editor full-screen (as in, taking up the whole browser window).
|
||||
* Depends on fullscreen.css
|
||||
* @see {@link https://codemirror.net/doc/manual.html#addon_fullscreen}
|
||||
* @default false
|
||||
*/
|
||||
fullScreen?: boolean;
|
||||
}
|
||||
}
|
||||
45
node_modules/@types/codemirror/addon/display/panel.d.ts
generated
vendored
Normal file
45
node_modules/@types/codemirror/addon/display/panel.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_panel
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface Panel {
|
||||
/**Removes the panel from the editor */
|
||||
clear(): void;
|
||||
/**Notifies panel that height of DOM node has changed */
|
||||
changed(height?: number): void;
|
||||
}
|
||||
|
||||
interface ShowPanelOptions {
|
||||
/**Controls the position of the newly added panel. The following values are recognized:
|
||||
* `top` (default): Adds the panel at the very top.
|
||||
* `after-top`: Adds the panel at the bottom of the top panels.
|
||||
* `bottom`: Adds the panel at the very bottom.
|
||||
* `before-bottom`: Adds the panel at the top of the bottom panels.
|
||||
*/
|
||||
position?: 'top' | 'after-top' | 'bottom' | 'before-bottom';
|
||||
/**The new panel will be added before the given panel. */
|
||||
before?: Panel;
|
||||
/**The new panel will be added after the given panel. */
|
||||
after?: Panel;
|
||||
/**The new panel will replace the given panel. */
|
||||
replace?: Panel;
|
||||
/**Whether to scroll the editor to keep the text's vertical position stable, when adding a panel above it. Defaults to false. */
|
||||
stable?: boolean;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
/**
|
||||
* Places a DOM node above or below an editor and shrinks the editor to make room for the node.
|
||||
* When using the `after`, `before` or `replace` options, if the panel doesn't exists or has been removed, the value of the `position` option will be used as a fallback.
|
||||
* @param node the DOM node
|
||||
* @param options optional options object
|
||||
*/
|
||||
addPanel(node: HTMLElement, options?: ShowPanelOptions): Panel;
|
||||
}
|
||||
}
|
||||
18
node_modules/@types/codemirror/addon/display/placeholder.d.ts
generated
vendored
Normal file
18
node_modules/@types/codemirror/addon/display/placeholder.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_placeholder
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Adds a placeholder option that can be used to make content appear in the editor when it is empty and not focused.
|
||||
* It can hold either a string or a DOM node. Also gives the editor a CodeMirror-empty CSS class whenever it doesn't contain any text.
|
||||
*/
|
||||
placeholder?: string;
|
||||
}
|
||||
}
|
||||
47
node_modules/@types/codemirror/addon/edit/closebrackets.d.ts
generated
vendored
Normal file
47
node_modules/@types/codemirror/addon/edit/closebrackets.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_closebrackets
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface AutoCloseBrackets {
|
||||
/**
|
||||
* String containing pairs of matching characters.
|
||||
*/
|
||||
pairs?: string;
|
||||
|
||||
/**
|
||||
* If the next character is in the string, opening a bracket should be auto-closed.
|
||||
*/
|
||||
closeBefore?: string;
|
||||
|
||||
/**
|
||||
* String containing chars that could do a triple quote.
|
||||
*/
|
||||
triples?: string;
|
||||
|
||||
/**
|
||||
* explode should be a similar string that gives the pairs of characters that, when enter is pressed between them, should have the second character also moved to its own line.
|
||||
*/
|
||||
explode?: string;
|
||||
|
||||
/**
|
||||
* By default, if the active mode has a closeBrackets property, that overrides the configuration given in the option.
|
||||
* But you can add an override property with a truthy value to override mode-specific configuration.
|
||||
*/
|
||||
override?: boolean;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Will auto-close brackets and quotes when typed.
|
||||
* By default, it'll auto-close ()[]{}''"", but you can pass it a string similar to that (containing pairs of matching characters),
|
||||
* or an object with pairs and optionally explode properties to customize it.
|
||||
*/
|
||||
autoCloseBrackets?: AutoCloseBrackets | boolean | string;
|
||||
}
|
||||
}
|
||||
51
node_modules/@types/codemirror/addon/edit/closetag.d.ts
generated
vendored
Normal file
51
node_modules/@types/codemirror/addon/edit/closetag.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_closetag
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface CommandActions {
|
||||
closeTag(cm: CodeMirror.Editor): void;
|
||||
}
|
||||
|
||||
interface AutoCloseTags {
|
||||
/**
|
||||
* Whether to autoclose when the '/' of a closing tag is typed. (default true)
|
||||
*/
|
||||
whenClosing?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to autoclose the tag when the final '>' of an opening tag is typed. (default true)
|
||||
*/
|
||||
whenOpening?: boolean;
|
||||
|
||||
/**
|
||||
* An array of tag names that should not be autoclosed. (default is empty tags for HTML, none for XML)
|
||||
*/
|
||||
dontCloseTags?: Array<string>;
|
||||
|
||||
/**
|
||||
* An array of tag names that should, when opened, cause a
|
||||
* blank line to be added inside the tag, and the blank line and
|
||||
* closing line to be indented. (default is block tags for HTML, none for XML)
|
||||
*/
|
||||
indentTags?: Array<string>;
|
||||
|
||||
/**
|
||||
* An array of XML tag names that should be autoclosed with '/>'. (default is none)
|
||||
*/
|
||||
emptyTags: Array<string>;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Will auto-close XML tags when '>' or '/' is typed.
|
||||
* Depends on the fold/xml-fold.js addon.
|
||||
*/
|
||||
autoCloseTags?: AutoCloseTags | boolean;
|
||||
}
|
||||
}
|
||||
42
node_modules/@types/codemirror/addon/edit/matchbrackets.d.ts
generated
vendored
Normal file
42
node_modules/@types/codemirror/addon/edit/matchbrackets.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Sixin Li <https://github.com/sixinli>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_matchbrackets
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface MatchBrackets {
|
||||
/**
|
||||
* Only use the character after the start position, never the one before it.
|
||||
*/
|
||||
afterCursor?: boolean;
|
||||
|
||||
/**
|
||||
* Causes only matches where both brackets are at the same side of the start position to be considered.
|
||||
*/
|
||||
strict?: boolean;
|
||||
|
||||
/**
|
||||
* Stop after scanning this amount of lines without a successful match. Defaults to 1000.
|
||||
*/
|
||||
maxScanLines?: number;
|
||||
|
||||
/**
|
||||
* Ignore lines longer than this. Defaults to 10000.
|
||||
*/
|
||||
maxScanLineLength?: number;
|
||||
|
||||
/**
|
||||
* Don't highlight a bracket in a line longer than this. Defaults to 1000.
|
||||
*/
|
||||
maxHighlightLineLength?: number;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
// When set to true or an options object, causes matching brackets to be highlighted whenever the cursor is next to them.
|
||||
matchBrackets?: MatchBrackets | boolean;
|
||||
}
|
||||
}
|
||||
32
node_modules/@types/codemirror/addon/edit/matchtags.d.ts
generated
vendored
Normal file
32
node_modules/@types/codemirror/addon/edit/matchtags.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_matchtags
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface CommandActions {
|
||||
/**
|
||||
* You can bind a key to in order to jump to the tag matching the one under the cursor.
|
||||
*/
|
||||
toMatchingTag(cm: CodeMirror.Editor): void;
|
||||
}
|
||||
|
||||
interface MatchTags {
|
||||
/**
|
||||
* Highlight both matching tags.
|
||||
*/
|
||||
bothTags?: boolean;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When enabled will cause the tags around the cursor to be highlighted (using the CodeMirror-matchingtag class).
|
||||
* Depends on the addon/fold/xml-fold.js addon.
|
||||
*/
|
||||
matchTags?: MatchTags | boolean;
|
||||
}
|
||||
}
|
||||
68
node_modules/@types/codemirror/addon/fold/foldcode.d.ts
generated
vendored
Normal file
68
node_modules/@types/codemirror/addon/fold/foldcode.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_foldcode
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface Editor {
|
||||
/**
|
||||
* Helps with code folding. Adds a foldCode method to editor instances, which will try to do a code fold starting at the given line,
|
||||
* or unfold the fold that is already present.
|
||||
* The method takes as first argument the position that should be folded (may be a line number or a Pos), and as second optional argument either a
|
||||
* range-finder function, or an options object.
|
||||
*/
|
||||
foldCode: (
|
||||
lineOrPos: number | Position,
|
||||
rangeFindeOrFoldOptions?: ((cm: Editor, pos: Position) => FoldRange) | FoldOptions,
|
||||
) => void;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
foldOptions?: FoldOptions;
|
||||
}
|
||||
|
||||
interface FoldOptions {
|
||||
/**
|
||||
* The function that is used to find foldable ranges. If this is not directly passed, it will default to CodeMirror.fold.auto,
|
||||
* which uses getHelpers with a "fold" type to find folding functions appropriate for the local mode.
|
||||
* There are files in the addon/fold/ directory providing CodeMirror.fold.brace, which finds blocks in brace languages (JavaScript, C, Java, etc),
|
||||
* CodeMirror.fold.indent, for languages where indentation determines block structure (Python, Haskell), and CodeMirror.fold.xml, for XML-style languages,
|
||||
* and CodeMirror.fold.comment, for folding comment blocks.
|
||||
*/
|
||||
rangeFinder?: (cm: Editor, pos: Position) => FoldRange;
|
||||
|
||||
/**
|
||||
* The widget to show for folded ranges. Can be either a string, in which case it'll become a span with class CodeMirror-foldmarker, or a DOM node.
|
||||
* To dynamically generate the widget, this can be a function that returns a string or DOM node, which will then render as described.
|
||||
* The function will be invoked with parameters identifying the range to be folded.
|
||||
*/
|
||||
widget: string | Element | ((from: Position, to: Position) => string | Element);
|
||||
|
||||
/**
|
||||
* When true (default is false), the addon will try to find foldable ranges on the lines above the current one if there isn't an eligible one on the given line.
|
||||
*/
|
||||
scanUp?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum amount of lines that a fold should span to be accepted. Defaults to 0, which also allows single-line folds.
|
||||
*/
|
||||
minFoldSize?: number;
|
||||
}
|
||||
|
||||
interface FoldRange {
|
||||
from: Position;
|
||||
to: Position;
|
||||
}
|
||||
|
||||
interface CommandActions {
|
||||
toggleFold(cm: Editor): void;
|
||||
fold(cm: Editor): void;
|
||||
unfold(cm: Editor): void;
|
||||
foldAll(cm: Editor): void;
|
||||
unfoldAll(cm: Editor): void;
|
||||
}
|
||||
}
|
||||
44
node_modules/@types/codemirror/addon/fold/foldgutter.d.ts
generated
vendored
Normal file
44
node_modules/@types/codemirror/addon/fold/foldgutter.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_foldgutter
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded.
|
||||
*/
|
||||
foldGutter?: boolean | FoldGutterOptions;
|
||||
}
|
||||
|
||||
interface FoldGutterOptions {
|
||||
/**
|
||||
* The CSS class of the gutter. Defaults to "CodeMirror-foldgutter". You will have to style this yourself to give it a width (and possibly a background).
|
||||
*/
|
||||
gutter?: string;
|
||||
|
||||
/**
|
||||
* A CSS class or DOM element to be used as the marker for open, foldable blocks. Defaults to "CodeMirror-foldgutter-open".
|
||||
*/
|
||||
indicatorOpen?: string | Element;
|
||||
|
||||
/**
|
||||
* A CSS class or DOM element to be used as the marker for folded blocks. Defaults to "CodeMirror-foldgutter-folded".
|
||||
*/
|
||||
indicatorFolded?: string | Element;
|
||||
|
||||
/**
|
||||
* The range-finder function to use when determining whether something can be folded. When not given, CodeMirror.fold.auto will be used as default.
|
||||
*/
|
||||
rangeFinder?: (cm: Editor, pos: Position) => FoldGutterRange;
|
||||
}
|
||||
|
||||
interface FoldGutterRange {
|
||||
from: Position;
|
||||
to: Position;
|
||||
}
|
||||
}
|
||||
83
node_modules/@types/codemirror/addon/hint/show-hint.d.ts
generated
vendored
Normal file
83
node_modules/@types/codemirror/addon/hint/show-hint.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: jacqt <https://github.com/jacqt>
|
||||
// basarat <https://github.com/basarat>
|
||||
// mbilsing <https://github.com/mbilsing>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_show-hint
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
/** Provides a framework for showing autocompletion hints. Defines editor.showHint, which takes an optional
|
||||
options object, and pops up a widget that allows the user to select a completion. Finding hints is done with
|
||||
a hinting functions (the hint option), which is a function that take an editor instance and options object,
|
||||
and return a {list, from, to} object, where list is an array of strings or objects (the completions), and
|
||||
from and to give the start and end of the token that is being completed as {line, ch} objects. An optional
|
||||
selectedHint property (an integer) can be added to the completion object to control the initially selected hint. */
|
||||
function showHint(cm: CodeMirror.Editor, hinter?: HintFunction, options?: ShowHintOptions): void;
|
||||
|
||||
interface Hints {
|
||||
from: Position;
|
||||
to: Position;
|
||||
list: (Hint | string)[];
|
||||
}
|
||||
|
||||
/** Interface used by showHint.js Codemirror add-on
|
||||
When completions aren't simple strings, they should be objects with the following properties: */
|
||||
interface Hint {
|
||||
text: string;
|
||||
className?: string;
|
||||
displayText?: string;
|
||||
from?: Position;
|
||||
/** Called if a completion is picked. If provided *you* are responsible for applying the completion */
|
||||
hint?: (cm: CodeMirror.Editor, data: Hints, cur: Hint) => void;
|
||||
render?: (element: HTMLLIElement, data: Hints, cur: Hint) => void;
|
||||
to?: Position;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
/** An extension of the existing CodeMirror typings for the Editor.on("keyup", func) syntax */
|
||||
on(eventName: string, handler: (doc: CodeMirror.Doc, event: any) => void): void;
|
||||
off(eventName: string, handler: (doc: CodeMirror.Doc, event: any) => void): void;
|
||||
showHint: (options?: ShowHintOptions) => void;
|
||||
}
|
||||
|
||||
interface HintFunction {
|
||||
(cm: CodeMirror.Editor): Hints;
|
||||
}
|
||||
|
||||
interface AsyncHintFunction {
|
||||
(cm: CodeMirror.Editor, callback: (hints: Hints) => any): any;
|
||||
async?: boolean;
|
||||
}
|
||||
|
||||
interface ShowHintOptions {
|
||||
completeSingle?: boolean;
|
||||
hint?: HintFunction | AsyncHintFunction;
|
||||
alignWithWord?: boolean;
|
||||
closeCharacters?: RegExp;
|
||||
closeOnUnfocus?: boolean;
|
||||
completeOnSingleClick?: boolean;
|
||||
container?: HTMLElement | null;
|
||||
customKeys?: { [key: string]: ((editor: Editor, handle: Handle) => void) | string } | null;
|
||||
extraKeys?: { [key: string]: ((editor: Editor, handle: Handle) => void) | string } | null;
|
||||
}
|
||||
|
||||
/** The Handle used to interact with the autocomplete dialog box.*/
|
||||
interface Handle {
|
||||
moveFocus(n: number, avoidWrap: boolean): void;
|
||||
setFocus(n: number): void;
|
||||
menuSize(): number;
|
||||
length: number;
|
||||
close(): void;
|
||||
pick(): void;
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
showHint?: boolean;
|
||||
hintOptions?: ShowHintOptions;
|
||||
}
|
||||
}
|
||||
18
node_modules/@types/codemirror/addon/merge/merge.d.ts
generated
vendored
Normal file
18
node_modules/@types/codemirror/addon/merge/merge.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: Andrew Ritchie <https://github.com/ritchiea>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://github.com/codemirror/CodeMirror/blob/master/addon/merge/merge.js
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface CommandActions {
|
||||
/** Move cursor to the next diff */
|
||||
goNextDiff(cm: CodeMirror.Editor): void;
|
||||
|
||||
/** Move cursor to the previous diff */
|
||||
goPrevDiff(cm: CodeMirror.Editor): void;
|
||||
}
|
||||
}
|
||||
22
node_modules/@types/codemirror/addon/mode/simple.d.ts
generated
vendored
Normal file
22
node_modules/@types/codemirror/addon/mode/simple.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
// Based on https://codemirror.net/demo/simplemode.html
|
||||
interface Rule {
|
||||
regex?: string | RegExp;
|
||||
token?: string | Array<string> | null;
|
||||
sol?: boolean;
|
||||
next?: string;
|
||||
push?: string;
|
||||
pop?: boolean;
|
||||
mode?: any;
|
||||
indent?: boolean;
|
||||
dedent?: boolean;
|
||||
dedentIfLineStart?: boolean;
|
||||
}
|
||||
|
||||
function defineSimpleMode<K extends string>(
|
||||
name: string,
|
||||
mode: { [P in K]: P extends 'meta' ? Record<string, any> : Array<Rule> } & { start: Array<Rule> },
|
||||
): void;
|
||||
}
|
||||
30
node_modules/@types/codemirror/addon/runmode/runmode.d.ts
generated
vendored
Normal file
30
node_modules/@types/codemirror/addon/runmode/runmode.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Joseph Vaughan <https://github.com/Joev->
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_runmode
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
/**
|
||||
* Runs a CodeMirror mode over text without opening an editor instance.
|
||||
*
|
||||
* @param text The document to run through the highlighter.
|
||||
* @param mode The mode to use (must be loaded as normal).
|
||||
* @param output If this is a function, it will be called for each token with
|
||||
* five arguments, the token's text, the token's style class (may be null for unstyled tokens),
|
||||
* the number of row of the token, the column position of token and the state of mode.
|
||||
* If it is a DOM node, the tokens will be converted to span elements as in an editor,
|
||||
* and inserted into the node (through innerHTML).
|
||||
*/
|
||||
function runMode(
|
||||
text: string,
|
||||
mode: any,
|
||||
callback:
|
||||
| HTMLElement
|
||||
| ((text: string, style?: string | null, row?: number, column?: number, state?: any) => void),
|
||||
options?: { tabSize?: number; state?: any },
|
||||
): void;
|
||||
}
|
||||
17
node_modules/@types/codemirror/addon/scroll/scrollpastend.d.ts
generated
vendored
Normal file
17
node_modules/@types/codemirror/addon/scroll/scrollpastend.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://github.com/codemirror/CodeMirror/blob/master/addon/scroll/scrollpastend.js
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When the end of the file is reached it allows you to keep scrolling so that your last few lines of code are not stuck at the bottom of the editor.
|
||||
*/
|
||||
scrollPastEnd?: boolean;
|
||||
}
|
||||
}
|
||||
55
node_modules/@types/codemirror/addon/search/match-highlighter.d.ts
generated
vendored
Normal file
55
node_modules/@types/codemirror/addon/search/match-highlighter.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_match-highlighter
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface HighlightSelectionMatches {
|
||||
/**
|
||||
* Minimum amount of selected characters that triggers a highlight (default 2).
|
||||
*/
|
||||
minChars?: number;
|
||||
|
||||
/**
|
||||
* The style to be used to highlight the matches (default "matchhighlight", which will correspond to CSS class cm-matchhighlight).
|
||||
*/
|
||||
style?: string;
|
||||
|
||||
/**
|
||||
* Controls whether whitespace is trimmed from the selection.
|
||||
*/
|
||||
trim?: boolean;
|
||||
|
||||
/**
|
||||
* Can be set to true or to a regexp matching the characters that make up a word.
|
||||
*/
|
||||
showToken?: boolean | RegExp;
|
||||
|
||||
/**
|
||||
* Used to specify how much time to wait, in milliseconds, before highlighting the matches (default is 100).
|
||||
*/
|
||||
delay?: number,
|
||||
|
||||
/**
|
||||
* If wordsOnly is enabled, the matches will be highlighted only if the selected text is a word.
|
||||
*/
|
||||
wordsOnly?: boolean;
|
||||
|
||||
/**
|
||||
* If annotateScrollbar is enabled, the occurences will be highlighted on the scrollbar via the matchesonscrollbar addon.
|
||||
*/
|
||||
annotateScrollbar?: boolean;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* Adds a highlightSelectionMatches option that can be enabled to highlight all instances of a currently selected word.
|
||||
* When enabled, it causes the current word to be highlighted when nothing is selected (defaults to off).
|
||||
*/
|
||||
highlightSelectionMatches?: HighlightSelectionMatches | boolean;
|
||||
}
|
||||
}
|
||||
46
node_modules/@types/codemirror/addon/search/searchcursor.d.ts
generated
vendored
Normal file
46
node_modules/@types/codemirror/addon/search/searchcursor.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: jacqt <https://github.com/jacqt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface Doc {
|
||||
/** This method can be used to implement search/replace functionality.
|
||||
* `query`: This can be a regular * expression or a string (only strings will match across lines -
|
||||
* if they contain newlines).
|
||||
* `start`: This provides the starting position of the search. It can be a `{line, ch} object,
|
||||
* or can be left off to default to the start of the document
|
||||
* `caseFold`: This is only relevant when matching a string. IT will cause the search to be case-insenstive */
|
||||
getSearchCursor(query: string | RegExp, start?: Position, caseFold?: boolean): SearchCursor;
|
||||
}
|
||||
|
||||
interface SearchCursor {
|
||||
/** Searches forward or backward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups */
|
||||
find(reverse: boolean): boolean | any[];
|
||||
|
||||
/** Searches forward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups */
|
||||
findNext(): boolean | any[];
|
||||
|
||||
/** Searches backward from the current position. The return value indicates whether a match was
|
||||
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
|
||||
* you want to extract matched groups */
|
||||
findPrevious(): boolean | any[];
|
||||
|
||||
/** Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
|
||||
* objects pointing the start of the match. */
|
||||
from(): Position;
|
||||
|
||||
/** Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
|
||||
* objects pointing the end of the match. */
|
||||
to(): Position;
|
||||
|
||||
/** Replaces the currently found match with the given text and adjusts the cursor position to reflect the deplacement. */
|
||||
replace(text: string, origin?: string): void;
|
||||
}
|
||||
}
|
||||
25
node_modules/@types/codemirror/addon/selection/active-line.d.ts
generated
vendored
Normal file
25
node_modules/@types/codemirror/addon/selection/active-line.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/codemirror/CodeMirror
|
||||
// Definitions by: ficristo <https://github.com/ficristo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#active-line
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface StyleActiveLine {
|
||||
/**
|
||||
* Controls whether single-line selections, or just cursor selections, are styled. Defaults to false (only cursor selections).
|
||||
*/
|
||||
nonEmpty: boolean;
|
||||
}
|
||||
|
||||
interface EditorConfiguration {
|
||||
/**
|
||||
* When enabled gives the wrapper of the line that contains the cursor the class CodeMirror-activeline,
|
||||
* adds a background with the class CodeMirror-activeline-background, and adds the class CodeMirror-activeline-gutter to the line's gutter space is enabled.
|
||||
*/
|
||||
styleActiveLine?: StyleActiveLine | boolean;
|
||||
}
|
||||
}
|
||||
113
node_modules/@types/codemirror/addon/tern/tern.d.ts
generated
vendored
Normal file
113
node_modules/@types/codemirror/addon/tern/tern.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_tern and https://codemirror.net/addon/tern/tern.js (comments in the beginning of the file)
|
||||
// Docs for tern itself might also be helpful: http://ternjs.net/doc/manual.html
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
import * as Tern from 'tern';
|
||||
|
||||
declare module 'codemirror' {
|
||||
interface TernServer {
|
||||
readonly options: TernOptions;
|
||||
readonly docs: {
|
||||
readonly [key: string]: {
|
||||
doc: CodeMirror.Doc;
|
||||
name: string;
|
||||
changed?: {
|
||||
from: CodeMirror.Position | number;
|
||||
to: CodeMirror.Position | number;
|
||||
};
|
||||
};
|
||||
};
|
||||
readonly server: Tern.Server;
|
||||
addDoc(
|
||||
name: string,
|
||||
doc: CodeMirror.Doc,
|
||||
): { doc: CodeMirror.Doc; name: string; changed: { from: number; to: number } | null };
|
||||
delDoc(id: string | CodeMirror.Editor | CodeMirror.Doc): void;
|
||||
hideDoc(id: string | CodeMirror.Editor | CodeMirror.Doc): void;
|
||||
complete(cm: CodeMirror.Doc): void;
|
||||
showType(cm: CodeMirror.Doc, pos?: CodeMirror.Position | number, callback?: Function): void;
|
||||
showDocs(cm: CodeMirror.Doc, pos?: CodeMirror.Position | number, callback?: Function): void;
|
||||
updateArgHints(cm: CodeMirror.Doc): void;
|
||||
jumpToDef(cm: CodeMirror.Doc): void;
|
||||
jumpBack(cm: CodeMirror.Doc): void;
|
||||
rename(cm: CodeMirror.Doc): void;
|
||||
selectName(cm: CodeMirror.Doc): void;
|
||||
request<Q extends Tern.Query>(
|
||||
cm: CodeMirror.Doc,
|
||||
query: Q,
|
||||
callback: (error?: Error, data?: Tern.QueryRegistry[Q['type']]['result']) => void,
|
||||
pos?: CodeMirror.Position,
|
||||
): void;
|
||||
request<Q extends Tern.Query['type']>(
|
||||
cm: CodeMirror.Doc,
|
||||
query: Q,
|
||||
callback: (error?: Error, data?: Tern.QueryRegistry[Q]['result']) => void,
|
||||
pos?: CodeMirror.Position,
|
||||
): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
interface TernConstructor {
|
||||
new (options?: TernOptions): TernServer;
|
||||
}
|
||||
export const TernServer: TernConstructor;
|
||||
|
||||
interface TernOptions {
|
||||
/** An object mapping plugin names to configuration options. */
|
||||
plugins?: Tern.ConstructorOptions['plugins'];
|
||||
/** An array of JSON definition data structures. */
|
||||
defs?: Tern.Def[];
|
||||
/**
|
||||
* Can be used to access files in
|
||||
* the project that haven't been loaded yet. Simply do callback(null) to
|
||||
* indicate that a file is not available.
|
||||
*/
|
||||
getFile?(name: string, callback: (doc: CodeMirror.Doc | null) => any): any;
|
||||
/**
|
||||
* This function will be applied
|
||||
* to documents before passing them on to Tern.
|
||||
*/
|
||||
fileFilter?(value: string, docName: string, doc: CodeMirror.Doc): string;
|
||||
/** This function should, when providing a multi-file view, switch the view or focus to the named file. */
|
||||
switchToDoc?(name: string, doc: CodeMirror.Doc): any;
|
||||
/** Can be used to override the way errors are displayed. */
|
||||
showError?(editor: CodeMirror.Editor, message: Error): any;
|
||||
/**
|
||||
* Customize the content in tooltips for completions.
|
||||
* Is passed a single argument — the completion's data as returned by
|
||||
* Tern — and may return a string, DOM node, or null to indicate that
|
||||
* no tip should be shown. By default the docstring is shown.
|
||||
*/
|
||||
completionTip?(data: Tern.CompletionsQueryResult): string | HTMLElement | null;
|
||||
/** Like completionTip, but for the tooltips shown for type queries. */
|
||||
typeTip?(data: Tern.TypeQueryResult): string | HTMLElement | null;
|
||||
/** This function will be applied to the Tern responses before treating them */
|
||||
responseFilter?(
|
||||
doc: CodeMirror.Doc,
|
||||
query: Tern.Query,
|
||||
request: Tern.Document,
|
||||
error: Error | undefined,
|
||||
data: Tern.QueryRegistry[Tern.Query['type']]['result'] | undefined,
|
||||
): any;
|
||||
/**
|
||||
* Set to true to enable web worker mode. You'll probably
|
||||
* want to feature detect the actual value you use here, for example
|
||||
* !!window.Worker.
|
||||
*/
|
||||
useWorker?: boolean;
|
||||
/** The main script of the worker. Point this to wherever you are hosting worker.js from this directory. */
|
||||
workerScript?: string;
|
||||
/**
|
||||
* An array of paths pointing (relative to workerScript)
|
||||
* to the Acorn and Tern libraries and any Tern plugins you want to
|
||||
* load. Or, if you minified those into a single script and included
|
||||
* them in the workerScript, simply leave this undefined.
|
||||
*/
|
||||
workerDeps?: string[];
|
||||
}
|
||||
}
|
||||
1946
node_modules/@types/codemirror/index.d.ts
generated
vendored
Normal file
1946
node_modules/@types/codemirror/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
25
node_modules/@types/codemirror/mode/meta.d.ts
generated
vendored
Normal file
25
node_modules/@types/codemirror/mode/meta.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Type definitions for codemirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: koddsson <https://github.com/koddsson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.2
|
||||
|
||||
import * as CodeMirror from 'codemirror';
|
||||
|
||||
interface MimeType {
|
||||
name: string;
|
||||
mime?: string;
|
||||
mimes?: string;
|
||||
mode: string;
|
||||
file?: RegExp;
|
||||
ext?: string[];
|
||||
alias?: string[];
|
||||
}
|
||||
|
||||
declare module 'codemirror' {
|
||||
const modeInfo: MimeType[];
|
||||
function findModeByMIME(mime: string): MimeType;
|
||||
function findModeByExtension(ext: string): MimeType;
|
||||
function findModeByFileName(filename: string): MimeType;
|
||||
function findModeByName(name: string): MimeType;
|
||||
}
|
||||
76
node_modules/@types/codemirror/package.json
generated
vendored
Normal file
76
node_modules/@types/codemirror/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "@types/codemirror",
|
||||
"version": "0.0.108",
|
||||
"description": "TypeScript definitions for codemirror",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "mihailik",
|
||||
"url": "https://github.com/mihailik",
|
||||
"githubUsername": "mihailik"
|
||||
},
|
||||
{
|
||||
"name": "nrbernard",
|
||||
"url": "https://github.com/nrbernard",
|
||||
"githubUsername": "nrbernard"
|
||||
},
|
||||
{
|
||||
"name": "Pr1st0n",
|
||||
"url": "https://github.com/Pr1st0n",
|
||||
"githubUsername": "Pr1st0n"
|
||||
},
|
||||
{
|
||||
"name": "rileymiller",
|
||||
"url": "https://github.com/rileymiller",
|
||||
"githubUsername": "rileymiller"
|
||||
},
|
||||
{
|
||||
"name": "toddself",
|
||||
"url": "https://github.com/toddself",
|
||||
"githubUsername": "toddself"
|
||||
},
|
||||
{
|
||||
"name": "ysulyma",
|
||||
"url": "https://github.com/ysulyma",
|
||||
"githubUsername": "ysulyma"
|
||||
},
|
||||
{
|
||||
"name": "azoson",
|
||||
"url": "https://github.com/azoson",
|
||||
"githubUsername": "azoson"
|
||||
},
|
||||
{
|
||||
"name": "kylesferrazza",
|
||||
"url": "https://github.com/kylesferrazza",
|
||||
"githubUsername": "kylesferrazza"
|
||||
},
|
||||
{
|
||||
"name": "fityocsaba96",
|
||||
"url": "https://github.com/fityocsaba96",
|
||||
"githubUsername": "fityocsaba96"
|
||||
},
|
||||
{
|
||||
"name": "koddsson",
|
||||
"url": "https://github.com/koddsson",
|
||||
"githubUsername": "koddsson"
|
||||
},
|
||||
{
|
||||
"name": "ficristo",
|
||||
"url": "https://github.com/ficristo",
|
||||
"githubUsername": "ficristo"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/codemirror"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/tern": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "b665796938b2cbd3c4c6b56d1ed40dd73e8886cac104d7ffcadc4b08882fbd3b",
|
||||
"typeScriptVersion": "3.4"
|
||||
}
|
||||
21
node_modules/@types/estree/LICENSE
generated
vendored
Normal file
21
node_modules/@types/estree/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
16
node_modules/@types/estree/README.md
generated
vendored
Normal file
16
node_modules/@types/estree/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Installation
|
||||
> `npm install --save @types/estree`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for ESTree AST specification (https://github.com/estree/estree).
|
||||
|
||||
# Details
|
||||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree
|
||||
|
||||
Additional Details
|
||||
* Last updated: Tue, 17 Apr 2018 20:22:09 GMT
|
||||
* Dependencies: none
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by RReverser <https://github.com/RReverser>.
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue