Skip to content

Commit

Permalink
Update web bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat committed Jul 31, 2023
1 parent 8b1e963 commit 975213e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/editor/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,17 @@ function toYAML(input, followImports = true, document = false) {
} else if (val.includes('=>')) {
const type = val.replace('=>', '').trim()
lines[i] = pad(thisLevel, `"%map,${key},${type}":`)

if (document) { // we need index numbers for the docs
let autoIncrementPos = 0
for (let j = i + 1; j < lines.length; j++) {
if (lines[j].startsWith('- '.padStart(nextLevel + 2))) {
lines[j] = lines[j].replace('- ', autoIncrementPos++ + ': ')
} else if (!lines[j].trim().startsWith('#')) {
break
}
}
}
} else if (val.includes('?')) {
val = val.replace('?', '').trim()
lines[i] = pad(thisLevel, `"%switch,${key},${val}":`)
Expand All @@ -385,6 +396,9 @@ function toYAML(input, followImports = true, document = false) {
// keys to ensure proper ordering with '%n,NUMBER'
const num = key.replace(/'/g, '')
lines[i] = pad(thisLevel, `'%n,${parseInt(num)}': ${val}`)
} else if (val.includes('=>')) {
const [sizeType,valueType] = val.split('=>')
lines[i] = pad(thisLevel, `"%map,${key},${sizeType.trim()},${valueType.trim()}":`)
}
}
}
Expand Down Expand Up @@ -472,12 +486,14 @@ function transform(json) {
const args = key.split(',')
if (key.startsWith('%map')) {
const mappings = {}
const [, name, mappingType, valueType] = args
if (!mappingType) continue
val = val || json['%map,' + valueType + ',']
for (const i in val) {
if (i.startsWith('!')) continue
const _i = i.startsWith('%') ? i.split(',')[1] : i
mappings[_i] = val[i] // Ignore comments + encapsulated numbers
}
const [, name, mappingType] = args
ctx.push({
name,
type: [
Expand Down

0 comments on commit 975213e

Please sign in to comment.