| | @@ -700,19 +700,52 @@ |
| 700 | 700 | builtin_emit_script_fossil_bootstrap(1); |
| 701 | 701 | } |
| 702 | 702 | zName = mprintf("fossil.%s.js", zApi); |
| 703 | 703 | builtin_request_js(zName); |
| 704 | 704 | fossil_free(zName); |
| 705 | + va_start(vargs,zApi); |
| 706 | + while( (zArg = va_arg (vargs, const char *))!=0 ){ |
| 707 | + zName = mprintf("fossil.%s.js", zArg); |
| 708 | + builtin_request_js(zName); |
| 709 | + fossil_free(zName); |
| 710 | + } |
| 711 | + va_end(vargs); |
| 712 | +} |
| 713 | + |
| 714 | +/* |
| 715 | +** This is a variant of builtin_emit_fossil_js_apis() which is |
| 716 | +** equivalent to: |
| 717 | +** |
| 718 | +** if(!builtin_bundle_all_fossil_js_apis()){ |
| 719 | +** builtin_emit_fossil_js_apis(zApi, ...args); |
| 720 | +** } |
| 721 | +** |
| 722 | +*/ |
| 723 | +void builtin_fossil_js_bundle_or( const char * zApi, ... ) { |
| 724 | + const char *zArg; |
| 725 | + char * zName; |
| 726 | + va_list vargs; |
| 727 | + static int once = 0; |
| 705 | 728 | |
| 729 | + if(builtin_bundle_all_fossil_js_apis()){ |
| 730 | + return; |
| 731 | + } |
| 732 | + if(0==once++){ |
| 733 | + builtin_emit_script_fossil_bootstrap(1); |
| 734 | + } |
| 735 | + zName = mprintf("fossil.%s.js", zApi); |
| 736 | + builtin_request_js(zName); |
| 737 | + fossil_free(zName); |
| 706 | 738 | va_start(vargs,zApi); |
| 707 | 739 | while( (zArg = va_arg (vargs, const char *))!=0 ){ |
| 708 | 740 | zName = mprintf("fossil.%s.js", zArg); |
| 709 | 741 | builtin_request_js(zName); |
| 710 | 742 | fossil_free(zName); |
| 711 | 743 | } |
| 712 | 744 | va_end(vargs); |
| 713 | 745 | } |
| 746 | + |
| 714 | 747 | |
| 715 | 748 | /* |
| 716 | 749 | ** If builtin_get_js_delivery_mode() returns JS_BUNDLED then this |
| 717 | 750 | ** function emits, via builtin_request_js(), all JS fossil.XYZ APIs |
| 718 | 751 | ** which are not strictly specific to a single page, and then calls |
| | @@ -724,11 +757,11 @@ |
| 724 | 757 | ** |
| 725 | 758 | ** If the current JS delivery mode is *not* JS_BUNDLED then this |
| 726 | 759 | ** function is a no-op and returns false. The reason is simply because |
| 727 | 760 | ** bundled mode is the only mode in which this API improves aggregate |
| 728 | 761 | ** over-the-wire and HTTP request costs. For other modes, reducing the |
| 729 | | -** inclusion of fossil.XYZ APIs to their bare minimum, provides the |
| 762 | +** inclusion of fossil.XYZ APIs to their bare minimum provides the |
| 730 | 763 | ** lowest aggregate costs. For debate and details, see the discussion |
| 731 | 764 | ** at: |
| 732 | 765 | ** |
| 733 | 766 | ** https://fossil-scm.org/forum/forumpost/3fa2633f3e |
| 734 | 767 | ** |
| | @@ -759,12 +792,13 @@ |
| 759 | 792 | if(!bundled){ |
| 760 | 793 | bundled = 1; |
| 761 | 794 | builtin_emit_fossil_js_apis( |
| 762 | 795 | /* The order of the following arguments is important: any |
| 763 | 796 | which have dependencies must be listed after their |
| 764 | | - dependencies. ALL of them depend on the core |
| 765 | | - window.fossil bootstrapping bits. */ |
| 797 | + dependencies. ALL of them depend on the core window.fossil |
| 798 | + bootstrapping bits, and those are initialize by this |
| 799 | + call. */ |
| 766 | 800 | "dom", "fetch", "storage", "tabs", |
| 767 | 801 | "confirmer", "popupwidget", |
| 768 | 802 | "copybutton", "numbered-lines", |
| 769 | 803 | "pikchr", |
| 770 | 804 | 0); |
| 771 | 805 | |