Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03k
1'use strict'2 3// Escapes sequences that could break out of an HTML <style> context.4// Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed5// correctly by all compliant CSS consumers.6const STYLE_TAG = /(<)(\/?style\b)/gi7const COMMENT_OPEN = /(<)(!--)/g8 9// Characters that end an at-rule name, mirroring RE_AT_END in the tokenizer.10// Params starting with anything else need a space to stay separate tokens.11const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/12 13function escapeHTMLInCSS(str) {14 if (typeof str !== 'string') return str15 if (!str.includes('<')) return str16 return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')17}18 19const DEFAULT_RAW = {20 after: '\n',21 beforeClose: '\n',22 beforeComment: '\n',23 beforeDecl: '\n',24 beforeOpen: ' ',25 beforeRule: '\n',26 colon: ': ',27 commentLeft: ' ',28 commentRight: ' ',29 emptyBody: '',30 indent: ' ',31 semicolon: false32}33 34function capitalize(str) {35 return str[0].toUpperCase() + str.slice(1)36}37 38function atruleStart(str, node) {39 let name = '@' + node.name40 let params = node.params ? str.rawValue(node, 'params') : ''41 let afterName = node.raws.afterName42 43 if (typeof afterName === 'undefined') {44 afterName = params ? ' ' : ''45 } else if (afterName === '' && params && !AT_NAME_END.test(params[0])) {46 afterName = ' '47 }48 49 return name + afterName + params50}51 52function pushBody(str, stack, node) {53 let nodes = node.nodes54 let last = nodes.length - 155 while (last > 0) {56 if (nodes[last].type !== 'comment') break57 last -= 158 }59 60 let semicolon = str.raw(node, 'semicolon')61 let isDocument = node.type === 'document'62 for (let i = nodes.length - 1; i >= 0; i--) {63 let child = nodes[i]64 let childSemicolon = last !== i || semicolon65 // A childless at-rule or a custom property declaration that still has66 // following siblings must be terminated. Without the semicolon those67 // trailing comments are folded into the at-rule's prelude or the custom68 // property's value and disappear when the output is re-parsed.69 if (70 !childSemicolon &&71 i < nodes.length - 1 &&72 ((child.type === 'atrule' && !child.nodes) ||73 (child.type === 'decl' && child.prop.startsWith('--')))74 ) {75 childSemicolon = true76 }77 stack.push({78 document: isDocument,79 node: child,80 semicolon: childSemicolon81 })82 }83}84 85function pushBlock(str, stack, node, start) {86 let between = str.raw(node, 'between', 'beforeOpen')87 str.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')88 89 let hasNodes = node.nodes && node.nodes.length90 let close = () => {91 let after = hasNodes92 ? str.raw(node, 'after')93 : str.raw(node, 'after', 'emptyBody')94 if (after) str.builder(escapeHTMLInCSS(after))95 str.builder('}', node, 'end')96 if (node.type === 'rule' && node.raws.ownSemicolon) {97 str.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')98 }99 }100 101 if (hasNodes) {102 stack.push(close)103 pushBody(str, stack, node)104 } else {105 close()106 }107}108 109class Stringifier {110 constructor(builder) {111 this.builder = builder112 }113 114 atrule(node, semicolon) {115 let start = atruleStart(this, node)116 if (node.nodes) {117 this.block(node, start)118 } else {119 let end = (node.raws.between || '') + (semicolon ? ';' : '')120 this.builder(escapeHTMLInCSS(start + end), node)121 }122 }123 124 beforeAfter(node, detect) {125 let value126 if (node.type === 'decl') {127 value = this.raw(node, null, 'beforeDecl')128 } else if (node.type === 'comment') {129 value = this.raw(node, null, 'beforeComment')130 } else if (detect === 'before') {131 value = this.raw(node, null, 'beforeRule')132 } else {133 value = this.raw(node, null, 'beforeClose')134 }135 136 let buf = node.parent137 let depth = 0138 while (buf && buf.type !== 'root') {139 depth += 1140 buf = buf.parent141 }142 143 if (value.includes('\n')) {144 let indent = this.raw(node, null, 'indent')145 if (indent.length) {146 for (let step = 0; step < depth; step++) value += indent147 }148 }149 150 return value151 }152 153 block(node, start) {154 let between = this.raw(node, 'between', 'beforeOpen')155 this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')156 157 let after158 if (node.nodes && node.nodes.length) {159 this.body(node)160 after = this.raw(node, 'after')161 } else {162 after = this.raw(node, 'after', 'emptyBody')163 }164 165 if (after) this.builder(escapeHTMLInCSS(after))166 this.builder('}', node, 'end')167 }168 169 body(node) {170 // Rules and at-rules are expanded into an explicit stack instead of171 // recursive `stringify()` calls to survive deeply nested trees.172 // If a subclass changes the traversal methods, its children go173 // through `stringify()` to keep the override in charge.174 let proto = Stringifier.prototype175 let expandable = ['atrule', 'block', 'body', 'rule', 'stringify'].every(176 method => this[method] === proto[method]177 )178 179 let stack = []180 pushBody(this, stack, node)181 182 while (stack.length > 0) {183 let entry = stack.pop()184 if (typeof entry === 'function') {185 entry()186 continue187 }188 189 let child = entry.node190 let before = this.raw(child, 'before')191 if (before) {192 this.builder(entry.document ? before : escapeHTMLInCSS(before))193 }194 195 if (expandable && child.type === 'rule') {196 pushBlock(this, stack, child, this.rawValue(child, 'selector'))197 } else if (expandable && child.type === 'atrule' && child.nodes) {198 pushBlock(this, stack, child, atruleStart(this, child))199 } else {200 this.stringify(child, entry.semicolon)201 }202 }203 }204 205 comment(node) {206 let left = this.raw(node, 'left', 'commentLeft')207 let right = this.raw(node, 'right', 'commentRight')208 this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)209 }210 211 decl(node, semicolon) {212 let raws = node.raws213 let between = this.raw(node, 'between', 'colon')214 215 let string = node.prop + between + this.rawValue(node, 'value')216 217 if (node.important) {218 string += raws.important || ' !important'219 }220 221 if (semicolon) string += ';'222 this.builder(escapeHTMLInCSS(string), node)223 }224 225 document(node) {226 this.body(node)227 }228 229 raw(node, own, detect) {230 let value231 if (!detect) detect = own232 233 // Already had234 if (own) {235 value = node.raws[own]236 if (typeof value !== 'undefined') return value237 }238 239 let parent = node.parent240 241 if (detect === 'before') {242 // Hack for first rule in CSS243 if (!parent || (parent.type === 'root' && parent.first === node)) {244 return ''245 }246 247 // `root` nodes in `document` should use only their own raws248 if (parent && parent.type === 'document') {249 return ''250 }251 }252 253 // Floating child without parent254 if (!parent) return DEFAULT_RAW[detect]255 256 // Detect style by other nodes257 let root = node.root()258 let cache = root.rawCache || (root.rawCache = {})259 if (typeof cache[detect] !== 'undefined') {260 return cache[detect]261 }262 263 if (detect === 'before' || detect === 'after') {264 return this.beforeAfter(node, detect)265 } else {266 let method = 'raw' + capitalize(detect)267 if (this[method]) {268 value = this[method](root, node)269 } else {270 root.walk(i => {271 value = i.raws[own]272 if (typeof value !== 'undefined') return false273 })274 }275 }276 277 if (typeof value === 'undefined') value = DEFAULT_RAW[detect]278 279 cache[detect] = value280 return value281 }282 283 rawBeforeClose(root) {284 let value285 root.walk(i => {286 if (i.nodes && i.nodes.length > 0) {287 if (typeof i.raws.after !== 'undefined') {288 value = i.raws.after289 if (value.includes('\n')) {290 value = value.replace(/[^\n]+$/, '')291 }292 return false293 }294 }295 })296 if (value) value = value.replace(/\S/g, '')297 return value298 }299 300 rawBeforeComment(root, node) {301 let value302 root.walkComments(i => {303 if (typeof i.raws.before !== 'undefined') {304 value = i.raws.before305 if (value.includes('\n')) {306 value = value.replace(/[^\n]+$/, '')307 }308 return false309 }310 })311 if (typeof value === 'undefined') {312 value = this.raw(node, null, 'beforeDecl')313 } else if (value) {314 value = value.replace(/\S/g, '')315 }316 return value317 }318 319 rawBeforeDecl(root, node) {320 let value321 root.walkDecls(i => {322 if (typeof i.raws.before !== 'undefined') {323 value = i.raws.before324 if (value.includes('\n')) {325 value = value.replace(/[^\n]+$/, '')326 }327 return false328 }329 })330 if (typeof value === 'undefined') {331 value = this.raw(node, null, 'beforeRule')332 } else if (value) {333 value = value.replace(/\S/g, '')334 }335 return value336 }337 338 rawBeforeOpen(root) {339 let value340 root.walk(i => {341 if (i.type !== 'decl') {342 value = i.raws.between343 if (typeof value !== 'undefined') return false344 }345 })346 return value347 }348 349 rawBeforeRule(root) {350 let value351 root.walk(i => {352 if (i.nodes && (i.parent !== root || root.first !== i)) {353 if (typeof i.raws.before !== 'undefined') {354 value = i.raws.before355 if (value.includes('\n')) {356 value = value.replace(/[^\n]+$/, '')357 }358 return false359 }360 }361 })362 if (value) value = value.replace(/\S/g, '')363 return value364 }365 366 rawColon(root) {367 let value368 root.walkDecls(i => {369 if (typeof i.raws.between !== 'undefined') {370 value = i.raws.between.replace(/[^\s:]/g, '')371 return false372 }373 })374 return value375 }376 377 rawEmptyBody(root) {378 let value379 root.walk(i => {380 if (i.nodes && i.nodes.length === 0) {381 value = i.raws.after382 if (typeof value !== 'undefined') return false383 }384 })385 return value386 }387 388 rawIndent(root) {389 if (root.raws.indent) return root.raws.indent390 let value391 root.walk(i => {392 let p = i.parent393 if (p && p !== root && p.parent && p.parent === root) {394 if (typeof i.raws.before !== 'undefined') {395 let parts = i.raws.before.split('\n')396 value = parts[parts.length - 1]397 value = value.replace(/\S/g, '')398 return false399 }400 }401 })402 return value403 }404 405 rawSemicolon(root) {406 let value407 root.walk(i => {408 if (i.nodes && i.nodes.length && i.last.type === 'decl') {409 value = i.raws.semicolon410 if (typeof value !== 'undefined') return false411 }412 })413 return value414 }415 416 rawValue(node, prop) {417 let value = node[prop]418 let raw = node.raws[prop]419 if (raw && raw.value === value) {420 return raw.raw421 }422 423 return value424 }425 426 root(node) {427 if (node.source && node.source.input.hasBOM) {428 this.builder('\uFEFF', node, 'start')429 }430 this.body(node)431 if (node.raws.after) {432 let after = node.raws.after433 let isDocument = node.parent && node.parent.type === 'document'434 this.builder(isDocument ? after : escapeHTMLInCSS(after))435 }436 }437 438 rule(node) {439 this.block(node, this.rawValue(node, 'selector'))440 if (node.raws.ownSemicolon) {441 this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')442 }443 }444 445 stringify(node, semicolon) {446 /* c8 ignore start */447 if (!this[node.type]) {448 throw new Error(449 'Unknown AST node type ' +450 node.type +451 '. ' +452 'Maybe you need to change PostCSS stringifier.'453 )454 }455 /* c8 ignore stop */456 this[node.type](node, semicolon)457 }458}459 460module.exports = Stringifier461Stringifier.default = Stringifier462 