coss 0.0.4 → 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/package.json CHANGED
@@ -1,34 +1,44 @@
1
1
  {
2
2
  "name": "coss",
3
- "version": "0.0.4",
4
- "description": "A simple compiler that compiles js to css.",
5
- "main": "coss.js",
6
- "directories": {
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/ysmood/coss.git"
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
- "keywords": [
18
- "js",
19
- "css",
20
- "compiler"
18
+ "files": [
19
+ "dist"
21
20
  ],
22
- "author": "http://ysmood.org",
23
- "license": "MIT",
24
- "bugs": {
25
- "url": "https://github.com/ysmood/coss/issues"
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
- "browserify": "^6.1.0",
30
- "coffee-script": "^1.8.0",
31
- "nobone": "^0.8.2",
32
- "uglify-js": "^2.4.15"
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
33
43
  }
34
44
  }
package/.npmignore DELETED
@@ -1,4 +0,0 @@
1
- temp.js
2
- *.coffee
3
- test/*
4
- readme.ejs.md
package/Cakefile DELETED
@@ -1,50 +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.remove 'temp.js'
24
- .then ->
25
- kit.spawn 'browserify', ['coss.js', '-o', 'temp.js']
26
- .then ->
27
- kit.spawn 'uglifyjs', ['temp.js', '-o', 'coss.min.js']
28
-
29
- # Readme
30
- kit.readFile main_cs
31
- .then (str) ->
32
- parsed = kit.parse_comment '', str
33
- method_str = "## #{parsed[0].name}\n\n"
34
-
35
- for tag in parsed[0].tags
36
- tname = if tag.name then "`#{tag.name}`" else ''
37
- ttype = if tag.type then "{ _#{tag.type}_ }" else ''
38
- method_str += """
39
- **<u>#{tag.tag_name}</u>**: #{tname} #{ttype}
40
- """
41
- method_str += '\n\n'
42
- if tag.description
43
- method_str += tag.description
44
- method_str += '\n\n'
45
-
46
- kit.readFile 'readme.ejs.md'
47
- .then (str) ->
48
- _.template str, {api: method_str}
49
- .then (readme) ->
50
- 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.4",
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,134 +0,0 @@
1
- // Generated by CoffeeScript 1.8.0
2
-
3
- /**
4
- * The core compiler of coss. Supports nested css and '&' self sugar.
5
- * @param {Object | Array} source The source data to compile.
6
- * @param {String} indent Default is 4 spaces.
7
- * @return {String} The compiled code.
8
- * @example
9
- * ```coffeescript
10
- * level = ->
11
- * level.count ?= 1
12
- * '.level_' + level.count++
13
- *
14
- * # Compile an array css tree.
15
- * # The array compiler can use variable as css selector.
16
- * coss [
17
- * ['#basic'
18
- * ['font-size', '12px']
19
- * ['opacity', 0.8]
20
- * ]
21
- * [level()
22
- * ['background', 'red']
23
- * ['border', '1px solid #fff']
24
- *
25
- * ['&:hover'
26
- * ['background', 'blue']
27
- * ]
28
- *
29
- * [level()
30
- * ['margin', '1px']
31
- *
32
- * [level()
33
- * ['padding', 0]
34
- * ]
35
- * ]
36
- * ]
37
- * ]
38
- *
39
- * # Compile an object css tree.
40
- * coss {
41
- * '.level_1':
42
- * background: 'red'
43
- * border: '1px solid #fff'
44
- *
45
- * '.level_2':
46
- * margin: '1px'
47
- *
48
- * '.level_3':
49
- * padding: 0
50
- * '#another':
51
- * 'font-size': '12px'
52
- * opacity: 0.8
53
- * }
54
- * ```
55
- */
56
- var coss;
57
-
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
-
134
- module.exports = coss;
package/coss.min.js DELETED
@@ -1 +0,0 @@
1
- (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){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()}};module.exports=coss},{}]},{},[1]);
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
-