wc-compiler 0.19.0 → 0.20.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.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022 Project Evergreen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://merry-caramel-524e61.netlify.app/assets/wcc-logo.png" width="30%"/>
1
+ <img src="https://wcc.dev/assets/wcc-logo.svg" width="30%"/>
2
2
 
3
3
  # Web Components Compiler (WCC)
4
4
 
@@ -8,7 +8,7 @@
8
8
  [![NodeJS compatibility](https://img.shields.io/node/v/wc-compiler.svg)](https://nodejs.org/en/about/previous-releases")
9
9
  [![Discord Chat](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://www.greenwoodjs.dev/discord/)
10
10
 
11
- > _Experimental Web Components compiler. It's Web Components all the way down!_ 🐢
11
+ > _Native Web Components compiler. It's Web Components all the way down!_ 🐢
12
12
 
13
13
  ## How It Works
14
14
 
@@ -81,7 +81,7 @@ $ npm install wc-compiler --save-dev
81
81
 
82
82
  ## Documentation
83
83
 
84
- See our [website](https://merry-caramel-524e61.netlify.app/) for API docs and examples.
84
+ See our [website](https://www.wcc.dev) for API docs and examples.
85
85
 
86
86
  ## Motivation
87
87
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wc-compiler",
3
- "version": "0.19.0",
4
- "description": "Experimental native Web Components compiler.",
3
+ "version": "0.20.0",
4
+ "description": "WCC supports server-rendering of standard Web Components, generating HTML directly from your custom element definitions.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ProjectEvergreen/wcc.git"
@@ -15,7 +15,8 @@
15
15
  "import": "./src/wcc.js"
16
16
  },
17
17
  "./register": "./src/register.js",
18
- "./src/jsx-loader.js": "./src/jsx-loader.js",
18
+ "./dom-shim": "./src/dom-shim.js",
19
+ "./jsx-loader": "./src/jsx-loader.js",
19
20
  "./jsx-runtime": "./src/jsx-runtime.ts"
20
21
  },
21
22
  "author": "Owen Buckley <owen@thegreenhouse.io>",
@@ -36,22 +37,22 @@
36
37
  "access": "public"
37
38
  },
38
39
  "scripts": {
39
- "clean": "rimraf ./dist",
40
- "lint": "npm run lint:js && npm run lint:ls",
40
+ "dev": "greenwood develop",
41
+ "build": "NODE_OPTIONS='--import @greenwood/cli/register' greenwood build",
42
+ "serve": "greenwood serve",
43
+ "lint": "npm run lint:js && npm run lint:ls && npm run lint:css",
41
44
  "lint:js": "eslint",
42
45
  "lint:ls": "ls-lint",
43
- "lint:types": "tsc",
46
+ "lint:css": "stylelint \"./docs/**/*.css\"",
47
+ "check:types": "tsc",
44
48
  "format": "prettier . --write",
45
49
  "format:check": "prettier . --check",
46
- "docs:dev": "concurrently \"nodemon --watch src --watch docs -e js,md,css,html,jsx,ts,tsx ./build.js\" \"http-server ./dist --open\"",
47
- "docs:build": "node ./build.js",
48
- "docs:serve": "npm run clean && npm run docs:build && http-server ./dist --open",
49
- "sandbox": "npm run clean && concurrently \"nodemon --experimental-strip-types --loader ./test-loader.js --watch src --watch sandbox -e js,md,css,html,jsx,ts ./sandbox.js\" \"http-server ./dist --open\" \"livereload ./dist\"",
50
- "start": "npm run docs:serve",
51
50
  "test": "mocha --exclude \"./test/cases/jsx*/**\" --exclude \"./test/cases/ts*/**\" --exclude \"./test/cases/custom-extension/**\" \"./test/**/**/*.spec.js\"",
52
51
  "test:jsx": "c8 node --import ./test-register.js --experimental-strip-types ./node_modules/mocha/bin/mocha \"./test/**/**/*.spec.js\"",
53
52
  "test:tdd": "npm run test -- --watch",
54
53
  "test:tdd:jsx": "npm run test:jsx -- --watch",
54
+ "test:docs": "vitest run --coverage",
55
+ "test:docs:tdd": "vitest",
55
56
  "prepare": "husky"
56
57
  },
57
58
  "dependencies": {
@@ -63,38 +64,45 @@
63
64
  "sucrase": "^3.35.0"
64
65
  },
65
66
  "devDependencies": {
67
+ "@double-great/stylelint-a11y": "^3.0.2",
66
68
  "@eslint/js": "^9.39.1",
69
+ "@greenwood/cli": "^0.34.0-alpha.4",
70
+ "@greenwood/plugin-css-modules": "^0.34.0-alpha.4",
71
+ "@greenwood/plugin-import-jsx": "^0.34.0-alpha.4",
72
+ "@greenwood/plugin-import-raw": "^0.34.0-alpha.4",
73
+ "@greenwood/plugin-markdown": "^0.34.0-alpha.4",
67
74
  "@ls-lint/ls-lint": "^2.3.1",
68
75
  "@mapbox/rehype-prism": "^0.8.0",
69
76
  "@types/mocha": "^10.0.10",
70
77
  "@types/node": "^22.13.4",
78
+ "@vitest/browser-playwright": "^4.0.18",
79
+ "@vitest/coverage-v8": "^4.0.18",
71
80
  "c8": "^7.11.2",
72
81
  "chai": "^4.3.6",
73
- "concurrently": "^7.1.0",
74
82
  "eslint": "^9.39.1",
75
83
  "eslint-config-prettier": "^10.1.8",
76
84
  "eslint-plugin-no-only-tests": "^3.3.0",
85
+ "geist": "^1.2.0",
77
86
  "globals": "^15.10.0",
78
- "http-server": "^14.1.0",
79
87
  "husky": "^9.1.7",
80
88
  "jsdom": "^19.0.0",
81
89
  "lint-staged": "^16.2.6",
82
- "livereload": "^0.9.3",
83
90
  "mocha": "^9.2.2",
84
- "nodemon": "^2.0.15",
91
+ "open-props": "^1.7.4",
92
+ "playwright": "^1.58.2",
85
93
  "prettier": "^3.6.2",
94
+ "prism-themes": "^1.9.0",
86
95
  "prismjs": "^1.28.0",
87
- "rehype-autolink-headings": "^6.1.1",
88
- "rehype-raw": "^6.1.1",
89
- "rehype-slug": "^5.0.1",
90
- "rehype-stringify": "^9.0.3",
91
- "remark-parse": "^10.0.1",
92
- "remark-rehype": "^10.1.0",
93
- "remark-toc": "^8.0.1",
94
- "rimraf": "^3.0.2",
95
- "simple.css": "^0.1.3",
96
- "typescript": "^5.8.2",
96
+ "rehype-autolink-headings": "^4.0.0",
97
+ "rehype-external-links": "^3.0.0",
98
+ "rehype-slug": "^3.0.0",
99
+ "remark-gfm": "^4.0.0",
100
+ "remark-github": "^10.0.1",
101
+ "stylelint": "^16.10.0",
102
+ "stylelint-config-recommended": "^14.0.1",
103
+ "typescript": "^5.9.3",
97
104
  "typescript-eslint": "^8.46.2",
98
- "unified": "^10.1.2"
105
+ "vite": "^7.3.1",
106
+ "vitest": "^4.0.18"
99
107
  }
100
108
  }
package/src/jsx.d.ts CHANGED
@@ -1,20 +1,31 @@
1
1
  // to support `style` attributes, we override `CSSStyleDeclaration` with `string`
2
2
  type IsCSSStyleDeclaration<T> = T extends CSSStyleDeclaration ? string : T;
3
3
 
4
- // create a utility type to extract the attributes from any given element's DOM interface.
4
+ // creates a utility type to extract the attributes from any given element's DOM interface from `HTMLElementTagNameMap`
5
5
  type ElementAttributes<E extends HTMLElement> = {
6
- // Extract all properties from the element, including inherited ones.
6
+ // Extract all properties from the element, including inherited ones
7
7
  [A in keyof E]?: E[A] extends (...args: any) => any ? any : IsCSSStyleDeclaration<E[A]>;
8
8
  } & {
9
9
  class?: string;
10
10
  };
11
11
 
12
- // map each HTML tag to a union of its attributes and the global attributes.
12
+ type PopoverTargetAction = 'show' | 'hide' | 'toggle';
13
+ type PopoverTargetAttributes = {
14
+ // have to manage this manually, can't seem to get this from TypeScript itself (not sure if just skill issue? :D)
15
+ // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1790
16
+ // it should be there per https://github.com/mdn/browser-compat-data/pull/21875
17
+ // https://github.com/ProjectEvergreen/wcc/issues/236
18
+ // per the spec, this should only apply to <button> and <input> elements.
19
+ popovertarget?: string;
20
+ popovertargetaction?: PopoverTargetAction;
21
+ };
22
+
23
+ // map each HTML tag to its attributes
13
24
  type IntrinsicElementsFromDom = {
14
- [E in keyof HTMLElementTagNameMap]: ElementAttributes<HTMLElementTagNameMap[E]>;
25
+ [E in keyof HTMLElementTagNameMap]: ElementAttributes<HTMLElementTagNameMap[E]> &
26
+ (E extends 'button' | 'input' ? PopoverTargetAttributes : {});
15
27
  };
16
28
 
17
- // declare the global JSX namespace with your generated intrinsic elements.
18
29
  declare namespace JSX {
19
30
  interface IntrinsicElements extends IntrinsicElementsFromDom {}
20
31
  }