-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scala3doc: Add build step for FE resources #10187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scala3doc: Add build step for FE resources #10187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
480053f
to
6428258
Compare
@@ -0,0 +1,2 @@ | |||
(()=>{"use strict";var t,e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},n=function(){function t(t){void 0===t&&(t={}),this.props=t,this.state={}}return t.prototype.render=function(t){},t.prototype.setState=function(t){this.state=e(e({},this.state),t(this.state)),this.render(this.props)},t}(),r=function(t,e){var n;return void 0===e&&(e=document),null!==(n=e.querySelector(t))&&void 0!==n?n:void 0},i=function(t,e){return void 0===e&&(e=document),e?Array.from(e.querySelectorAll(t)):[]},o=function(t){return t.startsWith("f")},s=function(t){return"f"+t.charAt(0).toUpperCase()+t.slice(1)},l=function(t,e,n){return t.map((function(t){return function(t,e,n){return t&&t.addEventListener(e,n),function(){return t&&t.removeEventListener(e,n)}}(t,e,n)}))},u=function(t){return t?t.textContent:""},a=function(t){return r(".documentableBrief",t)},c=function(t){return r(".documentableName",t)},f=function(){return(f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},p=function(){function t(t,e,n,r){void 0===r&&(r=!1),this.value=t,this.elementsRefs=n,this.init=r,this.splitByComma=function(t){return t.split(",")},this.getDatasetWithKeywordData=function(t){return Object.entries(t).filter((function(t){var e=t[0];return o(e)}))},this.filters=this.init?this.withNewFilters():e}return Object.defineProperty(t,"defaultFilters",{get:function(){return scala3DocData.filterDefaults},enumerable:!1,configurable:!0}),t.prototype.onFilterToggle=function(e,n){return new t(this.value,this.withToggledFilter(e,n),this.elementsRefs)},t.prototype.onGroupSelectionChange=function(e,n){return new t(this.value,this.withNewSelectionOfGroup(e,n),this.elementsRefs)},t.prototype.onInputValueChange=function(e){return new t(e,this.generateFiltersOnTyping(e),this.elementsRefs)},t.prototype.generateFiltersOnTyping=function(t){var e=this,n=this.elementsRefs.filter((function(e){var n=u(c(e)),r=u(a(e));return(null==n?void 0:n.includes(t))||(null==r?void 0:r.includes(t))})).map((function(t){return e.getDatasetWithKeywordData(t.dataset)})).reduce((function(t,n){return n.forEach((function(n){var r=n[0],i=n[1],o=r;e.splitByComma(i).forEach((function(e){var n;t[o]=f(f({},t[o]),((n={})[e]=f(f({},t[o][e]),{visible:!0}),n))}))})),t}),this.allFiltersAreHidden());return this.attachDefaultFilters(n)},t.prototype.allFiltersAreHidden=function(){return Object.entries(this.filters).reduce((function(t,e){var n=e[0],r=e[1];return t[n]=Object.keys(r).reduce((function(t,e){return t[e]=f(f({},r[e]),{visible:!1}),t}),{}),t}),{})},t.prototype.withNewSelectionOfGroup=function(t,e){var n,r=this;return f(f({},this.filters),((n={})[t]=Object.keys(this.filters[t]).reduce((function(n,i){return n[i]=f(f({},r.filters[t][i]),r.filters[t][i].visible&&{selected:e}),n}),{}),n))},t.prototype.withNewFilters=function(){var t=this,e=this.elementsRefs.reduce((function(e,n){return t.getDatasetWithKeywordData(n.dataset).forEach((function(n){var r=n[0],i=n[1];return t.splitByComma(i).forEach((function(t){var n,i,o,s=r;e[s]=e[s]?f(f({},e[s]),((n={})[t]=null!==(o=e[s][t])&&void 0!==o?o:new h,n)):((i={})[t]=new h,i)}))})),e}),{});return this.attachDefaultFilters(e)},t.prototype.attachDefaultFilters=function(e){var n=this;return Object.entries(t.defaultFilters).reduce((function(t,e){var r,i,o=e[0],l=e[1],u=s(o);return n.elementsRefs.some((function(t){return!!t.dataset[u]}))?f(f({},t),((r={})[u]=f(f({},t[u]),((i={})[l]=new h,i)),r)):t}),e)},t.prototype.withToggledFilter=function(t,e){var n,r;return f(f({},this.filters),((n={})[t]=f(f({},this.filters[t]),((r={})[e]=f(f({},this.filters[t][e]),{selected:!this.filters[t][e].selected}),r)),n))},t}(),h=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.selected=t,this.visible=e},d=(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)},function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),g=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,l=o.length;s<l;s++,i++)r[i]=o[s];return r},y=function(t){function e(e){var n=t.call(this,e)||this;return n.refs={tabs:i(".section-tab[data-togglable]",r(".tabbedcontent")),sections:i("div[data-togglable]",r(".tabbedcontent"))},n.state={list:new v(n.refs.tabs,n.refs.sections)},n.render(e),n}return d(e,t),e.prototype.toggleElementDatasetVisibility=function(t,e){e.dataset.visibility=null==t?void 0:t.toLocaleString()},e.prototype.toggleDisplayStyles=function(t,e,n){e&&(e.style.display=t?n:"none")},e.prototype.render=function(t){var e=this,n=t.filter;this.state.list.sectionsRefs.map((function(t){var r=e.state.list.getTabRefFromSectionRef(t),i=!!e.state.list.getSectionListRefs(t).filter((function(t){var r=!!e.state.list.getSectionListElementsRefs(t).map((function(t){return e.state.list.toListElement(t)})).filter((function(t){var r=e.state.list.isElementVisible(t,n);return e.toggleDisplayStyles(r,t.ref,"table"),e.toggleElementDatasetVisibility(r,t.ref),r})).length;return e.toggleDisplayStyles(r,t,"block"),r})).length;e.toggleDisplayStyles(i,r,"inline-block")}))},e}(n),v=function(){function t(t,e){this.tabsRef=t,this.sectionRefs=e,this.getTogglable=function(t){return t.dataset.togglable}}return Object.defineProperty(t.prototype,"tabsRefs",{get:function(){var t=this;return this.tabsRef.filter((function(e){return t.filterTab(t.getTogglable(e))}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sectionsRefs",{get:function(){var t=this;return this.sectionRefs.filter((function(e){return t.filterTab(t.getTogglable(e))}))},enumerable:!1,configurable:!0}),t.prototype.filterTab=function(t){return"Linear supertypes"!==t&&"Known subtypes"!==t&&"Type hierarchy"!==t},t.prototype.getTabRefFromSectionRef=function(t){var e=this;return this.tabsRefs.find((function(n){return e.getTogglable(n)===e.getTogglable(t)}))},t.prototype.getSectionListRefs=function(t){return i(".documentableList",t)},t.prototype.getSectionListElementsRefs=function(t){return i(".documentableElement",t)},t.prototype.toListElement=function(t){return{ref:t,name:u(c(t)),description:u(a(t))}},t.prototype.isElementVisible=function(t,e){return i=Object.entries(t.ref.dataset),u=(l=Object.entries(p.defaultFilters).filter((function(t){var n=t[0];return!!e.filters[s(n)]}))).reduce((function(t,e){var n=e[0],r=e[1],o=s(n);return i.some((function(t){return t[0]===o}))?t:g(t,[[o,r]])}),[]),a=i.filter((function(t){var e=t[0];return o(e)})).map((function(t){var e=t[0],n=t[1],r=l.find((function(t){return t[0]===e}));return r?[e,n+","+r[1]]:[e,n]})),!!g(u,a).every((function(t){var n=t[0],r=t[1],i=e.filters[n];return r.split(",").some((function(t){return i&&i[t].selected}))}))&&((null===(n=t.name)||void 0===n?void 0:n.includes(e.value))||(null===(r=t.description)||void 0===r?void 0:r.includes(e.value)));var n,r,i,l,u,a},t}(),b=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(t){function e(e){var n=t.call(this,e)||this;return n.onFilterClick=function(t){var e=t.currentTarget.dataset,r=e.key,i=e.value;n.props.onFilterToggle(r,i)},n.onSelectAllClick=function(t){var e=t.currentTarget;n.props.onGroupSelectChange(e.dataset.key,!0)},n.onDeselectAllClick=function(t){var e=t.currentTarget;n.props.onGroupSelectChange(e.dataset.key,!1)},n.filterToggleRef=r(".filterToggleButton"),n.filterLowerContainerRef=r(".filterLowerContainer"),n.filterToggleRef.addEventListener("click",(function(t){return n.props.onFilterVisibilityChange(t)})),n.render(n.props),n}return b(e,t),e.prototype.attachFiltersClicks=function(){var t=i("button.filterButtonItem",this.filterLowerContainerRef);l(t,"click",this.onFilterClick)},e.prototype.attachSelectingButtonsClicks=function(){var t=i("button.selectAll",this.filterLowerContainerRef),e=i("button.deselectAll",this.filterLowerContainerRef);l(t,"click",this.onSelectAllClick),l(e,"click",this.onDeselectAllClick)},e.prototype.isActive=function(t){return t?"active":""},e.prototype.isVisible=function(t){return t?"visible":""},e.prototype.getSortedValues=function(t,e){var n=""+t.charAt(1).toLowerCase()+t.slice(2),r=p.defaultFilters[n];return Object.entries(e).sort((function(t,e){var n=t[0],i=e[0];return n===r?-1:i===r?1:n.localeCompare(i)}))},e.prototype.getFilterGroup=function(t,e){var n=this;return'\n <div class="filterGroup" data-test-id="filterGroup">\n <div class="groupTitle">\n <span data-test-id="filterGroupTitle">'+t.substring(1)+'</span>\n <div class="groupButtonsContainer" data-test-id="filterGroupBatchToggle">\n <button class="selectAll" data-key="'+t+'">Select All</button>\n <button class="deselectAll" data-key="'+t+'">Deselect All</button>\n </div>\n </div>\n <div class="filterList" data-test-id="filterGroupList">\n '+this.getSortedValues(t,e).map((function(e){var r=e[0],i=e[1];return'<button class="filterButtonItem '+n.isActive(i.selected)+" "+n.isVisible(i.visible)+'" data-key="'+t+'" data-selected="'+i.selected+'" data-value="'+r+'" data-test-id="filterGroupButton">'+r+"</button>"})).join(" ")+"\n </div>\n </div>\n "},e.prototype.render=function(t){var e,n,r=this,i=t.filter;e=this.filterLowerContainerRef,n=Object.entries(i.filters).filter((function(t){t[0];var e=t[1];return Object.values(e).some((function(t){return t.visible}))})).map((function(t){var e=t[0],n=t[1];return r.getFilterGroup(e,n)})),e&&(e.innerHTML=function(t){return Array.isArray(t)?t.join(""):t}(n)),this.attachFiltersClicks(),this.attachSelectingButtonsClicks()},e}(n),C=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e){var n=t.call(this,e)||this;return n.onInputChange=function(t){var e=t.currentTarget;n.props.onInputChange(e.value)},r(".filterableInput").addEventListener("input",(function(t){return n.onInputChange(t)})),n}return C(e,t),e}(n),O=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),F=function(t){function e(e){var n=t.call(this,e)||this;return n.onInputChange=function(t){n.setState((function(e){return{filter:e.filter.onInputValueChange(t)}}))},n.onGroupSelectChange=function(t,e){n.setState((function(n){return{filter:n.filter.onGroupSelectionChange(t,e)}}))},n.onFilterVisibilityChange=function(){n.setState((function(t){return{isVisible:!t.isVisible}}))},n.onFilterToggle=function(t,e){n.setState((function(n){return{filter:n.filter.onFilterToggle(t,e)}}))},n.refs={elements:i(".documentableElement"),filterBar:r(".documentableFilter")},n.state={filter:new p("",{},n.refs.elements,!0),isVisible:!1},n.input=new w({onInputChange:n.onInputChange}),n.list=new y({filter:n.state.filter}),n.filterGroup=new m({filter:n.state.filter,onFilterToggle:n.onFilterToggle,onGroupSelectChange:n.onGroupSelectChange,onFilterVisibilityChange:n.onFilterVisibilityChange}),n.render(),n}return O(e,t),e.tryAttaching=function(){r(".documentableFilter")&&new e},e.prototype.render=function(){this.refs.filterBar&&(this.state.isVisible?this.refs.filterBar.classList.add("active"):this.refs.filterBar.classList.remove("active")),this.list.render({filter:this.state.filter}),this.filterGroup.render({filter:this.state.filter,onFilterToggle:this.onFilterToggle,onGroupSelectChange:this.onGroupSelectChange,onFilterVisibilityChange:this.onFilterVisibilityChange})},e}(n);window.addEventListener("DOMContentLoaded",(function(){F.tryAttaching()}))})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid committing generated files in the repo? It's fine if the build process involves calling npm, it just means the sbt project needs to call npm itself when needed, this is what we do in the vscode-dotty project: https://github.com/lampepfl/dotty/blob/93f24a09ef22e8c150a14531dbb49e7599a70d2f/project/Build.scala#L1231-L1233
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
4e3fdf0
to
519ab53
Compare
a5848f1
to
25a443e
Compare
@romanowski you might be interested as well
|
25a443e
to
d56f1b5
Compare
Although the fix for the e2e tests and the pipeline might be still useful, the rest is pretty outdated at this point. |
Requires #10155 and a rebaseMain change
scala3doc
FE resources with a TS and Sass support - this will make the codebase more maintainable in the long run and is a base for subsequent refactors.Extras
.scss
without any refactor, for now(but it doesn't seem to be picked by PR CI job...)tested here: https://github.com/grzegorz-bielski/dotty/pull/1/checks?check_run_id=1426973874