boxwood 0.79.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +43 -3
- package/package.json +6 -13
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { join } = require("path")
|
|
2
2
|
const { readFileSync } = require("fs")
|
|
3
3
|
const csstree = require("css-tree")
|
|
4
|
-
const toHash = require("string-hash")
|
|
5
4
|
|
|
6
5
|
function compile(path) {
|
|
7
6
|
const fn = require(path)
|
|
@@ -268,6 +267,39 @@ const tag = (a, b, c) => {
|
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
|
|
270
|
+
let number = 1
|
|
271
|
+
function sequence() {
|
|
272
|
+
return number++
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function decamelize(string) {
|
|
276
|
+
return string.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function stylesheet(input) {
|
|
280
|
+
const object = { ...input }
|
|
281
|
+
return {
|
|
282
|
+
add(item) {
|
|
283
|
+
for (const key in item) {
|
|
284
|
+
object[key] = item[key]
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
set(key, value) {
|
|
288
|
+
object[key] = value
|
|
289
|
+
},
|
|
290
|
+
toString() {
|
|
291
|
+
let result = []
|
|
292
|
+
for (const key in object) {
|
|
293
|
+
const value = object[key]
|
|
294
|
+
if (value) {
|
|
295
|
+
result.push(`${decamelize(key)}:${value}`)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return result.join(";")
|
|
299
|
+
},
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
271
303
|
function css(inputs) {
|
|
272
304
|
let result = ""
|
|
273
305
|
for (let i = 0, ilen = inputs.length; i < ilen; i += 1) {
|
|
@@ -279,13 +311,13 @@ function css(inputs) {
|
|
|
279
311
|
result += input
|
|
280
312
|
}
|
|
281
313
|
}
|
|
282
|
-
const hash =
|
|
314
|
+
const hash = sequence()
|
|
283
315
|
const tree = csstree.parse(result)
|
|
284
316
|
const classes = {}
|
|
285
317
|
|
|
286
318
|
csstree.walk(tree, (node) => {
|
|
287
319
|
if (node.type === "ClassSelector") {
|
|
288
|
-
const name =
|
|
320
|
+
const name = `${node.name}_${hash}`
|
|
289
321
|
classes[node.name] = name
|
|
290
322
|
node.name = name
|
|
291
323
|
}
|
|
@@ -306,6 +338,14 @@ css.load = function () {
|
|
|
306
338
|
`
|
|
307
339
|
}
|
|
308
340
|
|
|
341
|
+
css.create = function (object) {
|
|
342
|
+
return stylesheet(object)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
css.inline = function (object) {
|
|
346
|
+
return stylesheet(object).toString()
|
|
347
|
+
}
|
|
348
|
+
|
|
309
349
|
function js(inputs) {
|
|
310
350
|
let result = ""
|
|
311
351
|
for (let i = 0, ilen = inputs.length; i < ilen; i += 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,12 +11,6 @@
|
|
|
11
11
|
"watch": "npm test -- --watch",
|
|
12
12
|
"prepush": "npm test"
|
|
13
13
|
},
|
|
14
|
-
"ava": {
|
|
15
|
-
"files": [
|
|
16
|
-
"test/spec/**/*.js",
|
|
17
|
-
"**/*.spec.js"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
14
|
"engines": {
|
|
21
15
|
"node": ">= 20.11.1"
|
|
22
16
|
},
|
|
@@ -47,12 +41,12 @@
|
|
|
47
41
|
"homepage": "https://github.com/buxlabs/boxwood#readme",
|
|
48
42
|
"devDependencies": {
|
|
49
43
|
"benchmark": "2.1.4",
|
|
50
|
-
"c8": "^
|
|
51
|
-
"express": "^
|
|
44
|
+
"c8": "^10.1.3",
|
|
45
|
+
"express": "^5.1.0",
|
|
52
46
|
"handlebars": "^4.7.8",
|
|
53
|
-
"jsdom": "^
|
|
47
|
+
"jsdom": "^26.1.0",
|
|
54
48
|
"mustache": "^4.2.0",
|
|
55
|
-
"underscore": "^1.13.
|
|
49
|
+
"underscore": "^1.13.7"
|
|
56
50
|
},
|
|
57
51
|
"standard": {
|
|
58
52
|
"ignore": [
|
|
@@ -62,8 +56,7 @@
|
|
|
62
56
|
]
|
|
63
57
|
},
|
|
64
58
|
"dependencies": {
|
|
65
|
-
"css-tree": "^
|
|
66
|
-
"string-hash": "^1.1.3"
|
|
59
|
+
"css-tree": "^3.1.0"
|
|
67
60
|
},
|
|
68
61
|
"prettier": {
|
|
69
62
|
"semi": false
|