okai 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +6 -1
 - package/dist/icons.js +2 -2
 - package/dist/index.js +15 -9
 - package/dist/utils.js +5 -0
 - package/package.json +1 -1
 
    
        package/dist/client.js
    CHANGED
    
    
    
        package/dist/icons.js
    CHANGED
    
    | 
         @@ -7,7 +7,7 @@ function withAliases(icons, aliases) { 
     | 
|
| 
       7 
7 
     | 
    
         
             
                });
         
     | 
| 
       8 
8 
     | 
    
         
             
                return result;
         
     | 
| 
       9 
9 
     | 
    
         
             
            }
         
     | 
| 
       10 
     | 
    
         
            -
            const P = `<svg xmlns='http://www.w3.org/2000/svg' width= 
     | 
| 
      
 10 
     | 
    
         
            +
            const P = `<svg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' `;
         
     | 
| 
       11 
11 
     | 
    
         
             
            function S(viewbox, body) {
         
     | 
| 
       12 
12 
     | 
    
         
             
                return P + `viewBox='${viewbox}'>${body}</svg>`;
         
     | 
| 
       13 
13 
     | 
    
         
             
            }
         
     | 
| 
         @@ -21,7 +21,7 @@ export const Icons = withAliases({ 
     | 
|
| 
       21 
21 
     | 
    
         
             
                Company: S(`0 0 24 24`, `<path fill='currentColor' d='M18 15h-2v2h2m0-6h-2v2h2m2 6h-8v-2h2v-2h-2v-2h2v-2h-2V9h8M10 7H8V5h2m0 6H8V9h2m0 6H8v-2h2m0 6H8v-2h2M6 7H4V5h2m0 6H4V9h2m0 6H4v-2h2m0 6H4v-2h2m6-10V3H2v18h20V7z'/>`),
         
     | 
| 
       22 
22 
     | 
    
         
             
                Location: S(`0 0 24 24`, `<path fill='currentColor' d='M12 6.5A2.5 2.5 0 0 1 14.5 9a2.5 2.5 0 0 1-2.5 2.5A2.5 2.5 0 0 1 9.5 9A2.5 2.5 0 0 1 12 6.5M12 2a7 7 0 0 1 7 7c0 5.25-7 13-7 13S5 14.25 5 9a7 7 0 0 1 7-7m0 2a5 5 0 0 0-5 5c0 1 0 3 5 9.71C17 12 17 10 17 9a5 5 0 0 0-5-5'/>`),
         
     | 
| 
       23 
23 
     | 
    
         
             
                /** Admin */
         
     | 
| 
       24 
     | 
    
         
            -
                Dashboard: P +  
     | 
| 
      
 24 
     | 
    
         
            +
                Dashboard: P + `viewBox='0 0 24 24' fill='none' stroke-width='1.5' stroke='currentColor'><path stroke-linecap='round' stroke-linejoin='round' d='M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25' /></svg>`,
         
     | 
| 
       25 
25 
     | 
    
         
             
                Stats: S(`0 0 24 24`, `<path fill='currentColor' d='M8.143 15.857H5.57V9.43h2.572v6.428zm5.143 0h-2.572V3h2.572v12.857zm5.142 0h-2.571v-9h2.571v9z'/><path fill='currentColor' fill-rule='evenodd' d='M21 20.714H3v-2h18v2z' clip-rule='evenodd'/>`),
         
     | 
| 
       26 
26 
     | 
    
         
             
                Logs: S(`0 0 24 24`, `<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 12h8m-8 6h8M13 6h8M3 12h1m-1 6h1M3 6h1m4 6h1m-1 6h1M8 6h1'/>`),
         
     | 
| 
       27 
27 
     | 
    
         
             
                Task: S(`0 0 32 32`, `<path fill='currentColor' d='M10.293 5.293L7 8.586L5.707 7.293L4.293 8.707L7 11.414l4.707-4.707zM14 7v2h14V7zm0 8v2h14v-2zm0 8v2h14v-2z'/>`),
         
     | 
    
        package/dist/index.js
    CHANGED
    
    | 
         @@ -8,6 +8,7 @@ import { toMetadataTypes } from "./cs-ast.js"; 
     | 
|
| 
       8 
8 
     | 
    
         
             
            import { CSharpApiGenerator } from "./cs-apis.js";
         
     | 
| 
       9 
9 
     | 
    
         
             
            import { CSharpMigrationGenerator } from "./cs-migrations.js";
         
     | 
| 
       10 
10 
     | 
    
         
             
            import { TsdDataModelGenerator } from "./tsd-gen.js";
         
     | 
| 
      
 11 
     | 
    
         
            +
            import { getFileContent } from "./client.js";
         
     | 
| 
       11 
12 
     | 
    
         
             
            function normalizeSwitches(cmd) { return cmd.replace(/^-+/, '/'); }
         
     | 
| 
       12 
13 
     | 
    
         
             
            function parseArgs(...args) {
         
     | 
| 
       13 
14 
     | 
    
         
             
                const ret = {
         
     | 
| 
         @@ -491,7 +492,7 @@ async function createGistPreview(title, gist) { 
     | 
|
| 
       491 
492 
     | 
    
         
             
                    border: {
         
     | 
| 
       492 
493 
     | 
    
         
             
                        type: 'line'
         
     | 
| 
       493 
494 
     | 
    
         
             
                    },
         
     | 
| 
       494 
     | 
    
         
            -
                    content: gist.files[firstFilename] 
     | 
| 
      
 495 
     | 
    
         
            +
                    content: getFileContent(gist.files[firstFilename]),
         
     | 
| 
       495 
496 
     | 
    
         
             
                    scrollable: true,
         
     | 
| 
       496 
497 
     | 
    
         
             
                    alwaysScroll: true,
         
     | 
| 
       497 
498 
     | 
    
         
             
                    keys: true,
         
     | 
| 
         @@ -524,7 +525,8 @@ async function createGistPreview(title, gist) { 
     | 
|
| 
       524 
525 
     | 
    
         
             
                    result.selectedFile = filename;
         
     | 
| 
       525 
526 
     | 
    
         
             
                    const file = gist.files[filename];
         
     | 
| 
       526 
527 
     | 
    
         
             
                    if (file) {
         
     | 
| 
       527 
     | 
    
         
            -
                         
     | 
| 
      
 528 
     | 
    
         
            +
                        const content = getFileContent(file);
         
     | 
| 
      
 529 
     | 
    
         
            +
                        preview.setContent(content);
         
     | 
| 
       528 
530 
     | 
    
         
             
                        screen.render();
         
     | 
| 
       529 
531 
     | 
    
         
             
                    }
         
     | 
| 
       530 
532 
     | 
    
         
             
                });
         
     | 
| 
         @@ -539,15 +541,17 @@ async function createGistPreview(title, gist) { 
     | 
|
| 
       539 
541 
     | 
    
         
             
                        // Calculate new scroll position, ensuring it doesn't go below 0
         
     | 
| 
       540 
542 
     | 
    
         
             
                        const newScrollPosition = Math.max(0, currentScroll - scrollAmount);
         
     | 
| 
       541 
543 
     | 
    
         
             
                        preview.setScroll(newScrollPosition);
         
     | 
| 
      
 544 
     | 
    
         
            +
                        // titleBar.setContent(`UP ${newScrollPosition} = ${currentScroll} - ${scrollAmount}`)
         
     | 
| 
       542 
545 
     | 
    
         
             
                        screen.render();
         
     | 
| 
       543 
546 
     | 
    
         
             
                    }
         
     | 
| 
       544 
547 
     | 
    
         
             
                    // Page Down handler
         
     | 
| 
       545 
548 
     | 
    
         
             
                    if (key.name === 'pagedown') {
         
     | 
| 
       546 
549 
     | 
    
         
             
                        // Calculate max scroll position to prevent scrolling beyond content
         
     | 
| 
       547 
     | 
    
         
            -
                        const maxScroll = Math.max(0, contentHeight - boxHeight);
         
     | 
| 
      
 550 
     | 
    
         
            +
                        const maxScroll = Math.max(0, contentHeight - boxHeight + 1);
         
     | 
| 
       548 
551 
     | 
    
         
             
                        // Calculate new scroll position, ensuring it doesn't exceed max
         
     | 
| 
       549 
552 
     | 
    
         
             
                        const newScrollPosition = Math.min(maxScroll, currentScroll + scrollAmount);
         
     | 
| 
       550 
553 
     | 
    
         
             
                        preview.setScroll(newScrollPosition);
         
     | 
| 
      
 554 
     | 
    
         
            +
                        // titleBar.setContent(`DOWN ${maxScroll} = ${contentHeight} - ${boxHeight}; min(${maxScroll}, ${currentScroll} + ${scrollAmount}) => ${newScrollPosition}`)
         
     | 
| 
       551 
555 
     | 
    
         
             
                        screen.render();
         
     | 
| 
       552 
556 
     | 
    
         
             
                    }
         
     | 
| 
       553 
557 
     | 
    
         
             
                });
         
     | 
| 
         @@ -573,8 +577,10 @@ function chooseFile(ctx, info, gist, comamnd) { 
     | 
|
| 
       573 
577 
     | 
    
         
             
                        console.log(`POST ${acceptUrl}`);
         
     | 
| 
       574 
578 
     | 
    
         
             
                    acceptTask = fetch(acceptUrl, { method: 'POST' });
         
     | 
| 
       575 
579 
     | 
    
         
             
                }
         
     | 
| 
       576 
     | 
    
         
            -
                const  
     | 
| 
       577 
     | 
    
         
            -
                const tsdAst = toAst( 
     | 
| 
      
 580 
     | 
    
         
            +
                const origTsd = file.content;
         
     | 
| 
      
 581 
     | 
    
         
            +
                const tsdAst = toAst(origTsd);
         
     | 
| 
      
 582 
     | 
    
         
            +
                const generator = new TsdDataModelGenerator();
         
     | 
| 
      
 583 
     | 
    
         
            +
                const tsd = generator.generate(tsdAst);
         
     | 
| 
       578 
584 
     | 
    
         
             
                const csAst = toMetadataTypes(tsdAst);
         
     | 
| 
       579 
585 
     | 
    
         
             
                const groupName = getGroupName(csAst);
         
     | 
| 
       580 
586 
     | 
    
         
             
                const genApis = new CSharpApiGenerator();
         
     | 
| 
         @@ -620,16 +626,16 @@ function chooseFile(ctx, info, gist, comamnd) { 
     | 
|
| 
       620 
626 
     | 
    
         
             
                console.log(`\nTo regenerate classes, update '${tsdFileName}' then run:`);
         
     | 
| 
       621 
627 
     | 
    
         
             
                console.log(`$ ${script} ${tsdFileName}`);
         
     | 
| 
       622 
628 
     | 
    
         
             
                if (acceptTask) {
         
     | 
| 
       623 
     | 
    
         
            -
                    acceptTask.then(r => r.text())
         
     | 
| 
      
 629 
     | 
    
         
            +
                    acceptTask.then((r) => r.text())
         
     | 
| 
       624 
630 
     | 
    
         
             
                        .then((txt) => {
         
     | 
| 
       625 
631 
     | 
    
         
             
                        if (comamnd.verbose)
         
     | 
| 
       626 
632 
     | 
    
         
             
                            console.log(`${txt}`);
         
     | 
| 
       627 
633 
     | 
    
         
             
                        process.exit(0);
         
     | 
| 
       628 
634 
     | 
    
         
             
                    })
         
     | 
| 
       629 
     | 
    
         
            -
                        .catch(err => {
         
     | 
| 
      
 635 
     | 
    
         
            +
                        .catch((err) => {
         
     | 
| 
       630 
636 
     | 
    
         
             
                        if (comamnd.verbose)
         
     | 
| 
       631 
     | 
    
         
            -
                            console. 
     | 
| 
       632 
     | 
    
         
            -
                        process.exit( 
     | 
| 
      
 637 
     | 
    
         
            +
                            console.log(`ERROR: ${err.message ?? err}`);
         
     | 
| 
      
 638 
     | 
    
         
            +
                        process.exit(0);
         
     | 
| 
       633 
639 
     | 
    
         
             
                    });
         
     | 
| 
       634 
640 
     | 
    
         
             
                }
         
     | 
| 
       635 
641 
     | 
    
         
             
                else {
         
     | 
    
        package/dist/utils.js
    CHANGED
    
    | 
         @@ -125,6 +125,11 @@ export function getGroupName(ast) { 
     | 
|
| 
       125 
125 
     | 
    
         
             
            export function tsdWithPrompt(tsd, prompt) {
         
     | 
| 
       126 
126 
     | 
    
         
             
                return `/*prompt:  ${prompt}\n*/\n\n${tsd}`;
         
     | 
| 
       127 
127 
     | 
    
         
             
            }
         
     | 
| 
      
 128 
     | 
    
         
            +
            export function tsdWithoutPrompt(tsd) {
         
     | 
| 
      
 129 
     | 
    
         
            +
                return tsd.trim().startsWith('/*prompt:')
         
     | 
| 
      
 130 
     | 
    
         
            +
                    ? tsd.substring(tsd.indexOf('*/') + 2).trim()
         
     | 
| 
      
 131 
     | 
    
         
            +
                    : tsd;
         
     | 
| 
      
 132 
     | 
    
         
            +
            }
         
     | 
| 
       128 
133 
     | 
    
         
             
            export function parseTsdHeader(tsd) {
         
     | 
| 
       129 
134 
     | 
    
         
             
                const header = tsd.includes('/*prompt:')
         
     | 
| 
       130 
135 
     | 
    
         
             
                    ? leftPart(tsd, '*/').replace('/*prompt:', '').trim()
         
     |