coss 0.0.5 → 0.2.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/LICENSE +21 -0
- package/README.md +395 -0
- package/dist/index.d.ts +2823 -0
- package/dist/index.js +1917 -0
- package/package.json +34 -23
- package/.npmignore +0 -4
- package/Cakefile +0 -46
- package/bower.json +0 -25
- package/coss.js +0 -144
- package/coss.min.js +0 -1
- package/readme.md +0 -75
package/package.json
CHANGED
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coss",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"test": "test"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "npm test",
|
|
11
|
-
"prepublish": "cake build"
|
|
12
|
-
},
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The official TypeScript SDK for COSS: email, SMS, video, scheduling and more behind one API key.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://coss.com/docs",
|
|
13
7
|
"repository": {
|
|
14
8
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "git+https://github.com/cosscom/coss.git",
|
|
10
|
+
"directory": "packages/sdk"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/cosscom/coss/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22"
|
|
16
17
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"css",
|
|
20
|
-
"compiler"
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
21
20
|
],
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./dist/index.js",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsdown",
|
|
30
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
31
|
+
"test": "bun test"
|
|
26
32
|
},
|
|
27
|
-
"homepage": "https://github.com/ysmood/coss",
|
|
28
33
|
"devDependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
34
|
+
"@arethetypeswrong/core": "0.18.5",
|
|
35
|
+
"@types/bun": "1.4.2",
|
|
36
|
+
"publint": "0.3.25",
|
|
37
|
+
"tsdown": "0.23.0",
|
|
38
|
+
"typescript": "7.0.2"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true
|
|
32
43
|
}
|
|
33
44
|
}
|
package/.npmignore
DELETED
package/Cakefile
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{kit} = require 'nobone'
|
|
2
|
-
{_} = kit
|
|
3
|
-
|
|
4
|
-
main_cs = 'coss.coffee'
|
|
5
|
-
|
|
6
|
-
task 'dev', 'Dev', ->
|
|
7
|
-
kit.monitor_app {
|
|
8
|
-
bin: 'coffee'
|
|
9
|
-
watch_list: [
|
|
10
|
-
main_cs
|
|
11
|
-
'test/basic.coffee'
|
|
12
|
-
]
|
|
13
|
-
args: ['test/basic.coffee']
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
task 'test', 'Test', ->
|
|
17
|
-
kit.spawn 'coffee', ['test/basic.coffee']
|
|
18
|
-
|
|
19
|
-
task 'build', 'Build coffee and readme', ->
|
|
20
|
-
# Coffee
|
|
21
|
-
kit.spawn 'coffee', ['-cb', main_cs]
|
|
22
|
-
.then ->
|
|
23
|
-
kit.spawn 'uglifyjs', ['coss.js', '-o', 'coss.min.js']
|
|
24
|
-
|
|
25
|
-
# Readme
|
|
26
|
-
kit.readFile main_cs
|
|
27
|
-
.then (str) ->
|
|
28
|
-
parsed = kit.parse_comment '', str
|
|
29
|
-
method_str = "## #{parsed[0].name}\n\n"
|
|
30
|
-
|
|
31
|
-
for tag in parsed[0].tags
|
|
32
|
-
tname = if tag.name then "`#{tag.name}`" else ''
|
|
33
|
-
ttype = if tag.type then "{ _#{tag.type}_ }" else ''
|
|
34
|
-
method_str += """
|
|
35
|
-
**<u>#{tag.tag_name}</u>**: #{tname} #{ttype}
|
|
36
|
-
"""
|
|
37
|
-
method_str += '\n\n'
|
|
38
|
-
if tag.description
|
|
39
|
-
method_str += tag.description
|
|
40
|
-
method_str += '\n\n'
|
|
41
|
-
|
|
42
|
-
kit.readFile 'readme.ejs.md'
|
|
43
|
-
.then (str) ->
|
|
44
|
-
_.template str, {api: method_str}
|
|
45
|
-
.then (readme) ->
|
|
46
|
-
kit.outputFile 'readme.md', readme
|
package/bower.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "coss",
|
|
3
|
-
"main": "coss.min.js",
|
|
4
|
-
"version": "0.0.5",
|
|
5
|
-
"homepage": "https://github.com/ysmood/coss",
|
|
6
|
-
"authors": [
|
|
7
|
-
"http://ysmood.org"
|
|
8
|
-
],
|
|
9
|
-
"description": "A simple compiler that compiles js to css.",
|
|
10
|
-
"keywords": [
|
|
11
|
-
"js",
|
|
12
|
-
"css",
|
|
13
|
-
"compiler"
|
|
14
|
-
],
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"ignore": [
|
|
17
|
-
"**/.*",
|
|
18
|
-
"node_modules",
|
|
19
|
-
"bower_components",
|
|
20
|
-
"test",
|
|
21
|
-
"tests",
|
|
22
|
-
"temp.js",
|
|
23
|
-
"readme.ejs.md"
|
|
24
|
-
]
|
|
25
|
-
}
|
package/coss.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 1.8.0
|
|
2
|
-
(function() {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The core compiler of coss. Supports nested css and '&' self sugar.
|
|
6
|
-
* @param {Object | Array} source The source data to compile.
|
|
7
|
-
* @param {String} indent Default is 4 spaces.
|
|
8
|
-
* @return {String} The compiled code.
|
|
9
|
-
* @example
|
|
10
|
-
* ```coffeescript
|
|
11
|
-
* level = ->
|
|
12
|
-
* level.count ?= 1
|
|
13
|
-
* '.level_' + level.count++
|
|
14
|
-
*
|
|
15
|
-
* # Compile an array css tree.
|
|
16
|
-
* # The array compiler can use variable as css selector.
|
|
17
|
-
* coss [
|
|
18
|
-
* ['#basic'
|
|
19
|
-
* ['font-size', '12px']
|
|
20
|
-
* ['opacity', 0.8]
|
|
21
|
-
* ]
|
|
22
|
-
* [level()
|
|
23
|
-
* ['background', 'red']
|
|
24
|
-
* ['border', '1px solid #fff']
|
|
25
|
-
*
|
|
26
|
-
* ['&:hover'
|
|
27
|
-
* ['background', 'blue']
|
|
28
|
-
* ]
|
|
29
|
-
*
|
|
30
|
-
* [level()
|
|
31
|
-
* ['margin', '1px']
|
|
32
|
-
*
|
|
33
|
-
* [level()
|
|
34
|
-
* ['padding', 0]
|
|
35
|
-
* ]
|
|
36
|
-
* ]
|
|
37
|
-
* ]
|
|
38
|
-
* ]
|
|
39
|
-
*
|
|
40
|
-
* # Compile an object css tree.
|
|
41
|
-
* coss {
|
|
42
|
-
* '.level_1':
|
|
43
|
-
* background: 'red'
|
|
44
|
-
* border: '1px solid #fff'
|
|
45
|
-
*
|
|
46
|
-
* '.level_2':
|
|
47
|
-
* margin: '1px'
|
|
48
|
-
*
|
|
49
|
-
* '.level_3':
|
|
50
|
-
* padding: 0
|
|
51
|
-
* '#another':
|
|
52
|
-
* 'font-size': '12px'
|
|
53
|
-
* opacity: 0.8
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
var coss;
|
|
58
|
-
coss = function(source, indent) {
|
|
59
|
-
var compile_arr, compile_obj, k, node, ret, type_error, _i, _len;
|
|
60
|
-
if (indent == null) {
|
|
61
|
-
indent = ' ';
|
|
62
|
-
}
|
|
63
|
-
compile_obj = function(node, parents) {
|
|
64
|
-
var children, leaf, props, sel;
|
|
65
|
-
props = '';
|
|
66
|
-
children = '';
|
|
67
|
-
for (sel in node) {
|
|
68
|
-
leaf = node[sel];
|
|
69
|
-
if (typeof leaf === 'object') {
|
|
70
|
-
if (sel.charAt(0) === '&') {
|
|
71
|
-
children += compile_obj(leaf, parents + sel.slice(1));
|
|
72
|
-
} else {
|
|
73
|
-
children += compile_obj(leaf, parents + ' ' + sel);
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
props += "" + indent + sel + ": " + leaf + ";\n";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return "" + parents + " {\n" + props + "}\n" + children;
|
|
80
|
-
};
|
|
81
|
-
compile_arr = function(node, parents) {
|
|
82
|
-
var children, defs, leaf, props, sel, _i, _len, _ref;
|
|
83
|
-
props = '';
|
|
84
|
-
children = '';
|
|
85
|
-
parents += node[0];
|
|
86
|
-
_ref = node.slice(1);
|
|
87
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
88
|
-
leaf = _ref[_i];
|
|
89
|
-
defs = leaf[1];
|
|
90
|
-
if (typeof defs === 'object') {
|
|
91
|
-
sel = leaf[0];
|
|
92
|
-
if (sel.charAt(0) === '&') {
|
|
93
|
-
leaf[0] = sel.slice(1);
|
|
94
|
-
children += compile_arr(leaf, parents);
|
|
95
|
-
} else {
|
|
96
|
-
children += compile_arr(leaf, parents + ' ');
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
props += "" + indent + leaf[0] + ": " + defs + ";\n";
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return "" + parents + " {\n" + props + "}\n" + children;
|
|
103
|
-
};
|
|
104
|
-
type_error = function() {
|
|
105
|
-
throw new Error('The type of source is incorrect.');
|
|
106
|
-
};
|
|
107
|
-
if (typeof source === 'object') {
|
|
108
|
-
ret = '';
|
|
109
|
-
if (typeof source.length === 'number') {
|
|
110
|
-
for (_i = 0, _len = source.length; _i < _len; _i++) {
|
|
111
|
-
node = source[_i];
|
|
112
|
-
if (typeof node === 'object') {
|
|
113
|
-
ret += compile_arr(node, '');
|
|
114
|
-
} else {
|
|
115
|
-
type_error();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
for (k in source) {
|
|
120
|
-
node = source[k];
|
|
121
|
-
if (typeof node === 'object') {
|
|
122
|
-
ret += compile_obj(node, k);
|
|
123
|
-
} else {
|
|
124
|
-
type_error();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return ret;
|
|
129
|
-
} else {
|
|
130
|
-
return type_error();
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
if (typeof module === "object" && module && typeof module.exports === "object") {
|
|
134
|
-
return module.exports = coss;
|
|
135
|
-
} else {
|
|
136
|
-
if (typeof define === "function" && define.amd) {
|
|
137
|
-
return define(function() {
|
|
138
|
-
return coss;
|
|
139
|
-
});
|
|
140
|
-
} else {
|
|
141
|
-
return window.coss = coss;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
})();
|
package/coss.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){var coss;coss=function(source,indent){var compile_arr,compile_obj,k,node,ret,type_error,_i,_len;if(indent==null){indent=" "}compile_obj=function(node,parents){var children,leaf,props,sel;props="";children="";for(sel in node){leaf=node[sel];if(typeof leaf==="object"){if(sel.charAt(0)==="&"){children+=compile_obj(leaf,parents+sel.slice(1))}else{children+=compile_obj(leaf,parents+" "+sel)}}else{props+=""+indent+sel+": "+leaf+";\n"}}return""+parents+" {\n"+props+"}\n"+children};compile_arr=function(node,parents){var children,defs,leaf,props,sel,_i,_len,_ref;props="";children="";parents+=node[0];_ref=node.slice(1);for(_i=0,_len=_ref.length;_i<_len;_i++){leaf=_ref[_i];defs=leaf[1];if(typeof defs==="object"){sel=leaf[0];if(sel.charAt(0)==="&"){leaf[0]=sel.slice(1);children+=compile_arr(leaf,parents)}else{children+=compile_arr(leaf,parents+" ")}}else{props+=""+indent+leaf[0]+": "+defs+";\n"}}return""+parents+" {\n"+props+"}\n"+children};type_error=function(){throw new Error("The type of source is incorrect.")};if(typeof source==="object"){ret="";if(typeof source.length==="number"){for(_i=0,_len=source.length;_i<_len;_i++){node=source[_i];if(typeof node==="object"){ret+=compile_arr(node,"")}else{type_error()}}}else{for(k in source){node=source[k];if(typeof node==="object"){ret+=compile_obj(node,k)}else{type_error()}}}return ret}else{return type_error()}};if(typeof module==="object"&&module&&typeof module.exports==="object"){return module.exports=coss}else{if(typeof define==="function"&&define.amd){return define(function(){return coss})}else{return window.coss=coss}}})();
|
package/readme.md
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# COSS
|
|
2
|
-
|
|
3
|
-
```
|
|
4
|
-
npm install coss
|
|
5
|
-
|
|
6
|
-
# Or use in browser. Note that only the `coss.min.js` is build for browser.
|
|
7
|
-
bower install coss
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
# API
|
|
11
|
-
|
|
12
|
-
## coss
|
|
13
|
-
|
|
14
|
-
**<u>param</u>**: `source` { _Object | Array_ }
|
|
15
|
-
|
|
16
|
-
The source data to compile.
|
|
17
|
-
|
|
18
|
-
**<u>param</u>**: `indent` { _String_ }
|
|
19
|
-
|
|
20
|
-
Default is 4 spaces.
|
|
21
|
-
|
|
22
|
-
**<u>return</u>**: { _String_ }
|
|
23
|
-
|
|
24
|
-
The compiled code.
|
|
25
|
-
|
|
26
|
-
**<u>example</u>**:
|
|
27
|
-
|
|
28
|
-
```coffeescript
|
|
29
|
-
level = ->
|
|
30
|
-
level.count ?= 1
|
|
31
|
-
'.level_' + level.count++
|
|
32
|
-
|
|
33
|
-
# Compile an array css tree.
|
|
34
|
-
# The array compiler can use variable as css selector.
|
|
35
|
-
coss [
|
|
36
|
-
['#basic'
|
|
37
|
-
['font-size', '12px']
|
|
38
|
-
['opacity', 0.8]
|
|
39
|
-
]
|
|
40
|
-
[level()
|
|
41
|
-
['background', 'red']
|
|
42
|
-
['border', '1px solid #fff']
|
|
43
|
-
|
|
44
|
-
['&:hover'
|
|
45
|
-
['background', 'blue']
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
[level()
|
|
49
|
-
['margin', '1px']
|
|
50
|
-
|
|
51
|
-
[level()
|
|
52
|
-
['padding', 0]
|
|
53
|
-
]
|
|
54
|
-
]
|
|
55
|
-
]
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
# Compile an object css tree.
|
|
59
|
-
coss {
|
|
60
|
-
'.level_1':
|
|
61
|
-
background: 'red'
|
|
62
|
-
border: '1px solid #fff'
|
|
63
|
-
|
|
64
|
-
'.level_2':
|
|
65
|
-
margin: '1px'
|
|
66
|
-
|
|
67
|
-
'.level_3':
|
|
68
|
-
padding: 0
|
|
69
|
-
'#another':
|
|
70
|
-
'font-size': '12px'
|
|
71
|
-
opacity: 0.8
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|