Skip to content

Commit

Permalink
fix: fix source maps (#181)
Browse files Browse the repository at this point in the history
Template files with DOS line endings are breaking the source map.
Convert DOS line endings to Unix line endings when generating renderers.
This way, .hbs files with DOS line endings (no eslint) will not break the source
maps as the generated renderer will have the correct line ending.
The change is also correcting the line endings of existing .hbs templates.
  • Loading branch information
pskelin authored Mar 14, 2019
1 parent f4028b3 commit 7084c96
Show file tree
Hide file tree
Showing 15 changed files with 371 additions and 368 deletions.
5 changes: 4 additions & 1 deletion packages/main/lib/hbs2ui5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const writeRenderers = (outputDir, controlName, fileContent) => {
try {
const compiledFilePath = `${outputDir}${path.sep}${controlName}Renderer.lit.js`;

fs.writeFileSync(compiledFilePath, fileContent);
// strip DOS line endings because the break the source maps
let fileContentUnix = fileContent.replace(/\r\n/g, "\n");
fileContentUnix = fileContentUnix.replace(/\r/g, "\n");
fs.writeFileSync(compiledFilePath, fileContentUnix);

} catch (e) {
console.log(e);
Expand Down
52 changes: 26 additions & 26 deletions packages/main/src/Button.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<button {{> controlData}}
type="button"
class="{{classes.main}}"
style="{{styles.main}}"
disabled="{{ctr.disabled}}"
aria-disabled="{{ariaDisabled}}"
title="{{ctr.tooltip}}"
tabindex="{{tabindex}}"
data-sap-focus-ref
{{> ariaPressed}}
>
{{#if ctr._iconSettings}}
<ui5-icon
class="{{classes.icon}}"
src="{{ctr._iconSettings.src}}"
></ui5-icon>
{{/if}}

{{#if ctr._nodeText}}
<span id="{{ctr._id}}-content" dir="{{dir}}" class="{{classes.text}}">
<bdi>{{ctr._nodeText}}</bdi>
</span>
{{/if}}
</button>

{{#*inline "ariaPressed"}}{{/inline}}
<button {{> controlData}}
type="button"
class="{{classes.main}}"
style="{{styles.main}}"
disabled="{{ctr.disabled}}"
aria-disabled="{{ariaDisabled}}"
title="{{ctr.tooltip}}"
tabindex="{{tabindex}}"
data-sap-focus-ref
{{> ariaPressed}}
>
{{#if ctr._iconSettings}}
<ui5-icon
class="{{classes.icon}}"
src="{{ctr._iconSettings.src}}"
></ui5-icon>
{{/if}}

{{#if ctr._nodeText}}
<span id="{{ctr._id}}-content" dir="{{dir}}" class="{{classes.text}}">
<bdi>{{ctr._nodeText}}</bdi>
</span>
{{/if}}
</button>

{{#*inline "ariaPressed"}}{{/inline}}
90 changes: 45 additions & 45 deletions packages/main/src/Calendar.hbs
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<div {{> controlData}} class="{{classes.main}}" style="{{styles.main}}">

<ui5-calendar-header
id="{{ctr._id}}-head"
month-text="{{ctr._header.monthText}}"
year-text="{{ctr._header.yearText}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
@pressPrevious="{{ctr._header.onPressPrevious}}"
@pressNext="{{ctr._header.onPressNext}}"
@btn1Press="{{ctr._header.onBtn1Press}}"
@btn2Press="{{ctr._header.onBtn2Press}}"
></ui5-calendar-header>

<div id="{{ctr._id}}-content" class="sapUiCalContent">
<ui5-daypicker
id="{{ctr._id}}-daypicker"
class="{{classes.dayPicker}}"
format-pattern="{{ctr._oMonth.formatPattern}}"
.selectedDates="{{ctr._oMonth.selectedDates}}"
._hidden="{{ctr._oMonth._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._oMonth.timestamp}}"
@selectionChange="{{ctr._oMonth.onSelectedDatesChange}}"
@navigate="{{ctr._oMonth.onNavigate}}"
></ui5-daypicker>

<ui5-month-picker
id="{{ctr._id}}-MP"
class="{{classes.monthPicker}}"
._hidden="{{ctr._monthPicker._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._monthPicker.timestamp}}"
@selectedMonthChange="{{ctr._monthPicker.onSelectedMonthChange}}"
></ui5-month-picker>

<ui5-yearpicker
id="{{ctr._id}}-YP"
class="{{classes.yearPicker}}"
._hidden="{{ctr._yearPicker._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._yearPicker.timestamp}}"
._selectedYear="{{ctr._yearPicker._selectedYear}}"
@selectedYearChange="{{ctr._yearPicker.onSelectedYearChange}}"
></ui5-yearpicker>
</div>
<div {{> controlData}} class="{{classes.main}}" style="{{styles.main}}">

<ui5-calendar-header
id="{{ctr._id}}-head"
month-text="{{ctr._header.monthText}}"
year-text="{{ctr._header.yearText}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
@pressPrevious="{{ctr._header.onPressPrevious}}"
@pressNext="{{ctr._header.onPressNext}}"
@btn1Press="{{ctr._header.onBtn1Press}}"
@btn2Press="{{ctr._header.onBtn2Press}}"
></ui5-calendar-header>

<div id="{{ctr._id}}-content" class="sapUiCalContent">
<ui5-daypicker
id="{{ctr._id}}-daypicker"
class="{{classes.dayPicker}}"
format-pattern="{{ctr._oMonth.formatPattern}}"
.selectedDates="{{ctr._oMonth.selectedDates}}"
._hidden="{{ctr._oMonth._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._oMonth.timestamp}}"
@selectionChange="{{ctr._oMonth.onSelectedDatesChange}}"
@navigate="{{ctr._oMonth.onNavigate}}"
></ui5-daypicker>

<ui5-month-picker
id="{{ctr._id}}-MP"
class="{{classes.monthPicker}}"
._hidden="{{ctr._monthPicker._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._monthPicker.timestamp}}"
@selectedMonthChange="{{ctr._monthPicker.onSelectedMonthChange}}"
></ui5-month-picker>

<ui5-yearpicker
id="{{ctr._id}}-YP"
class="{{classes.yearPicker}}"
._hidden="{{ctr._yearPicker._hidden}}"
.primaryCalendarType="{{ctr._oMonth.primaryCalendarType}}"
timestamp="{{ctr._yearPicker.timestamp}}"
._selectedYear="{{ctr._yearPicker._selectedYear}}"
@selectedYearChange="{{ctr._yearPicker.onSelectedYearChange}}"
></ui5-yearpicker>
</div>
</div>
76 changes: 38 additions & 38 deletions packages/main/src/CalendarHeader.hbs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<div {{> controlData}}
class="{{classes.main}}">

<ui5-icon id="{{ctr._id}}-btnPrev"
class="{{classes.buttons}}"
src="{{ctr._btnPrev.icon}}"
data-sap-cal-head-button="Prev">
</ui5-icon>

<div class="sapWCCalHeadMidButtonContainer">
<div
id="{{ctr._id}}-btn1"
class="{{classes.middleButtons}}"
type="{{ctr._btn1.type}}"
tabindex="0"
data-sap-show-picker="Month"
>
{{ctr._btn1.text}}
</div>

<div
id="{{ctr._id}}-btn2"
class="{{classes.middleButtons}}"
type="{{ctr._btn2.type}}"
tabindex="0"
data-sap-show-picker="Year"
>
{{ctr._btn2.text}}
</div>
</div>

<ui5-icon
id="{{ctr._id}}-btnNext"
class="{{classes.buttons}}"
src="{{ctr._btnNext.icon}}"
data-sap-cal-head-button="Next">
</ui5-icon>

<div {{> controlData}}
class="{{classes.main}}">

<ui5-icon id="{{ctr._id}}-btnPrev"
class="{{classes.buttons}}"
src="{{ctr._btnPrev.icon}}"
data-sap-cal-head-button="Prev">
</ui5-icon>

<div class="sapWCCalHeadMidButtonContainer">
<div
id="{{ctr._id}}-btn1"
class="{{classes.middleButtons}}"
type="{{ctr._btn1.type}}"
tabindex="0"
data-sap-show-picker="Month"
>
{{ctr._btn1.text}}
</div>

<div
id="{{ctr._id}}-btn2"
class="{{classes.middleButtons}}"
type="{{ctr._btn2.type}}"
tabindex="0"
data-sap-show-picker="Year"
>
{{ctr._btn2.text}}
</div>
</div>

<ui5-icon
id="{{ctr._id}}-btnNext"
class="{{classes.buttons}}"
src="{{ctr._btnNext.icon}}"
data-sap-cal-head-button="Next">
</ui5-icon>

</div>
34 changes: 17 additions & 17 deletions packages/main/src/CheckBox.hbs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
role="checkbox"
aria-checked="{{ctr.checked}}"
aria-readonly="{{ariaReadonly}}"
tabindex="{{tabIndex}}">
<div id="{{ctr._id}}-CbBg" class="{{classes.inner}}">
<input id="{{ctr._id}}-CB" type='checkbox' ?checked="{{ctr.checked}}" ?readonly="{{ctr.readOnly}}" data-sap-no-tab-ref/>
</div>

{{#if ctr._label.text}}
<ui5-label
class="sapWCLabelInCheckBox"
?wrap="{{ctr._label.wrap}}"
>{{ctr._label.text}}</ui5-label>
{{/if}}
<div {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
role="checkbox"
aria-checked="{{ctr.checked}}"
aria-readonly="{{ariaReadonly}}"
tabindex="{{tabIndex}}">
<div id="{{ctr._id}}-CbBg" class="{{classes.inner}}">
<input id="{{ctr._id}}-CB" type='checkbox' ?checked="{{ctr.checked}}" ?readonly="{{ctr.readOnly}}" data-sap-no-tab-ref/>
</div>

{{#if ctr._label.text}}
<ui5-label
class="sapWCLabelInCheckBox"
?wrap="{{ctr._label.wrap}}"
>{{ctr._label.text}}</ui5-label>
{{/if}}
</div>
100 changes: 50 additions & 50 deletions packages/main/src/DatePicker.hbs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
<div {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
>
<!-- INPUT -->
<ui5-input
id="{{ctr._id}}-inner"
placeholder="{{ctr._input.placeholder}}"
type="{{ctr._input.type}}"
value="{{ctr.value}}"
?disabled="{{ctr.disabled}}"
?readonly="{{ctr.readonly}}"
value-state="{{ctr.valueState}}"
@change="{{ctr._input.onChange}}"
@input="{{ctr._input.onLiveChange}}"
data-sap-focus-ref
>
{{#if showIcon}}
<ui5-icon
data-ui5-slot="icon"
src="{{ctr._input.icon.src}}"
class="{{classes.icon}}"
tabindex="-1"
></ui5-icon>
{{/if}}
</ui5-input>

<!-- POPOVER -->
<ui5-popover
id="{{ctr._id}}-popover"
allow-target-overlap="{{ctr._popover.allowTargetOverlap}}"
placement-type="{{ctr._popover.placementType}}"
hide-header="{{ctr._popover.hideHeader}}"
hide-arrow="{{ctr._popover.hideArrow}}"
horizontal-align="{{ctr._popover.horizontalAlign}}"
stay-open-on-scroll="{{ctr._popover.stayOpenOnScroll}}"
.customClasses="{{ctr._popover._customClasses}}"
@afterClose="{{ctr._popover.afterClose}}"
@afterOpen="{{ctr._popover.afterOpen}}"
>
<ui5-calendar
id="{{ctr._id}}-calendar"
data-ui5-slot="content"
primary-calendar-type="{{ctr._calendar.primaryCalendarType}}"
format-pattern="{{ctr._calendar.formatPattern}}"
timestamp="{{ctr._calendar.timestamp}}"
.selectedDates="{{ctr._calendar.selectedDates}}"
@selectedDatesChange="{{ctr._calendar.onSelectedDatesChange}}"
></ui5-calendar>
</ui5-popover>
<div {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
>
<!-- INPUT -->
<ui5-input
id="{{ctr._id}}-inner"
placeholder="{{ctr._input.placeholder}}"
type="{{ctr._input.type}}"
value="{{ctr.value}}"
?disabled="{{ctr.disabled}}"
?readonly="{{ctr.readonly}}"
value-state="{{ctr.valueState}}"
@change="{{ctr._input.onChange}}"
@input="{{ctr._input.onLiveChange}}"
data-sap-focus-ref
>
{{#if showIcon}}
<ui5-icon
data-ui5-slot="icon"
src="{{ctr._input.icon.src}}"
class="{{classes.icon}}"
tabindex="-1"
></ui5-icon>
{{/if}}
</ui5-input>

<!-- POPOVER -->
<ui5-popover
id="{{ctr._id}}-popover"
allow-target-overlap="{{ctr._popover.allowTargetOverlap}}"
placement-type="{{ctr._popover.placementType}}"
hide-header="{{ctr._popover.hideHeader}}"
hide-arrow="{{ctr._popover.hideArrow}}"
horizontal-align="{{ctr._popover.horizontalAlign}}"
stay-open-on-scroll="{{ctr._popover.stayOpenOnScroll}}"
.customClasses="{{ctr._popover._customClasses}}"
@afterClose="{{ctr._popover.afterClose}}"
@afterOpen="{{ctr._popover.afterOpen}}"
>
<ui5-calendar
id="{{ctr._id}}-calendar"
data-ui5-slot="content"
primary-calendar-type="{{ctr._calendar.primaryCalendarType}}"
format-pattern="{{ctr._calendar.formatPattern}}"
timestamp="{{ctr._calendar.timestamp}}"
.selectedDates="{{ctr._calendar.selectedDates}}"
@selectedDatesChange="{{ctr._calendar.onSelectedDatesChange}}"
></ui5-calendar>
</ui5-popover>
</div>
16 changes: 8 additions & 8 deletions packages/main/src/Icon.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<span {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
tabindex="-1"
data-sap-ui-icon-content="{{iconContent}}"
aria-expanded="{{ariaExpanded}}"
aria-labelledby="{{ariaLabelledBy}}"
dir="{{dir}}"
<span {{> controlData}}
class="{{classes.main}}"
style="{{styles.main}}"
tabindex="-1"
data-sap-ui-icon-content="{{iconContent}}"
aria-expanded="{{ariaExpanded}}"
aria-labelledby="{{ariaLabelledBy}}"
dir="{{dir}}"
></span>
Loading

0 comments on commit 7084c96

Please sign in to comment.