p-elements-core 1.2.32-rc2 → 1.2.32-rc4

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.
Files changed (78) hide show
  1. package/.editorconfig +17 -17
  2. package/.gitlab-ci.yml +18 -18
  3. package/CHANGELOG.md +201 -0
  4. package/demo/sample.js +1 -1
  5. package/demo/screen.css +16 -16
  6. package/dist/p-elements-core-modern.js +1 -1
  7. package/dist/p-elements-core.js +1 -1
  8. package/docs/package-lock.json +6897 -6897
  9. package/docs/package.json +27 -27
  10. package/docs/src/404.md +8 -8
  11. package/docs/src/_data/demos/hello-world/hello-world.tsx +35 -35
  12. package/docs/src/_data/demos/hello-world/index.html +10 -10
  13. package/docs/src/_data/demos/hello-world/project.json +7 -7
  14. package/docs/src/_data/demos/timer/demo-timer.tsx +120 -120
  15. package/docs/src/_data/demos/timer/icons.tsx +62 -62
  16. package/docs/src/_data/demos/timer/index.html +12 -12
  17. package/docs/src/_data/demos/timer/project.json +8 -8
  18. package/docs/src/_data/global.js +13 -13
  19. package/docs/src/_data/helpers.js +19 -19
  20. package/docs/src/_includes/layouts/base.njk +30 -30
  21. package/docs/src/_includes/layouts/playground.njk +40 -40
  22. package/docs/src/_includes/partials/app-header.njk +8 -8
  23. package/docs/src/_includes/partials/head.njk +14 -14
  24. package/docs/src/_includes/partials/nav.njk +19 -19
  25. package/docs/src/_includes/partials/top-nav.njk +51 -51
  26. package/docs/src/documentation/custom-element.md +221 -221
  27. package/docs/src/documentation/decorators/bind.md +71 -71
  28. package/docs/src/documentation/decorators/custom-element-config.md +63 -63
  29. package/docs/src/documentation/decorators/property.md +83 -83
  30. package/docs/src/documentation/decorators/query.md +66 -66
  31. package/docs/src/documentation/decorators/render-property-on-set.md +60 -60
  32. package/docs/src/documentation/decorators.md +9 -9
  33. package/docs/src/documentation/reactive-properties.md +53 -53
  34. package/docs/src/index.d.ts +25 -25
  35. package/docs/src/index.md +3 -3
  36. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.css +78 -78
  37. package/docs/src/scripts/components/app-mode-switch/app-mode-switch.tsx +166 -166
  38. package/docs/src/scripts/components/app-playground/app-playground.tsx +189 -189
  39. package/docs/tsconfig.json +22 -22
  40. package/package.json +9 -2
  41. package/readme.md +206 -206
  42. package/src/custom-element-controller.test.ts +226 -0
  43. package/src/custom-element-controller.ts +31 -31
  44. package/src/custom-element.test.ts +906 -0
  45. package/src/custom-element.ts +17 -1
  46. package/src/custom-style-element.ts +4 -1
  47. package/src/decorators/bind.test.ts +163 -0
  48. package/src/decorators/bind.ts +46 -46
  49. package/src/decorators/custom-element-config.ts +17 -17
  50. package/src/decorators/property.test.ts +279 -0
  51. package/src/decorators/property.ts +789 -684
  52. package/src/decorators/query.test.ts +146 -0
  53. package/src/decorators/query.ts +12 -12
  54. package/src/decorators/render-property-on-set.ts +3 -3
  55. package/src/helpers/css.test.ts +150 -0
  56. package/src/helpers/css.ts +71 -71
  57. package/src/maquette/cache.test.ts +150 -0
  58. package/src/maquette/cache.ts +35 -35
  59. package/src/maquette/dom.test.ts +263 -0
  60. package/src/maquette/dom.ts +115 -115
  61. package/src/maquette/h.test.ts +165 -0
  62. package/src/maquette/h.ts +100 -100
  63. package/src/maquette/index.ts +12 -12
  64. package/src/maquette/interfaces.ts +536 -536
  65. package/src/maquette/jsx.ts +61 -61
  66. package/src/maquette/mapping.test.ts +294 -0
  67. package/src/maquette/mapping.ts +56 -56
  68. package/src/maquette/maquette.test.ts +493 -0
  69. package/src/maquette/projection.test.ts +366 -0
  70. package/src/maquette/projection.ts +666 -666
  71. package/src/maquette/projector.test.ts +351 -0
  72. package/src/maquette/projector.ts +200 -200
  73. package/src/sample/mixin/highlight.tsx +33 -33
  74. package/src/test-setup.ts +85 -0
  75. package/src/test-utils.ts +223 -0
  76. package/tsconfig.json +1 -0
  77. package/vitest.config.ts +41 -0
  78. package/webpack.config.js +1 -1
@@ -1,190 +1,190 @@
1
- @CustomElementConfig({
2
- tagName: "app-playground",
3
- })
4
- export class AppPlaygroundElement extends CustomElement {
5
-
6
- static style = `
7
- :host{
8
- display: block;
9
- height: 100%;
10
- }
11
- .app-playground{
12
- height: 100%;
13
- }
14
- .app-playground-split-panel{
15
- height: 100%;
16
- }
17
- playground-preview{
18
- height: 100%;
19
- position: unset;
20
- }
21
- .app-playground-editor-container{
22
- height: 100%;
23
- display: flex;
24
- flex-direction: column;
25
- }
26
- .app-playground-editor{
27
- height: 100%;
28
- flex: 1;
29
- }
30
- `;
31
-
32
- constructor() {
33
- super();
34
- if (!this.id) {
35
- this.id = "app-playground-" + Math.floor(Math.random() * 1000);
36
- }
37
- }
38
-
39
- #initDone = false;
40
-
41
- static readonly projectorMode = "replace";
42
-
43
- #_playgroundLoaded = false;
44
-
45
- get #playgroundLoaded() {
46
- return this.#_playgroundLoaded;
47
- }
48
-
49
- set #playgroundLoaded(value: boolean) {
50
- this.#_playgroundLoaded = value;
51
- this.scheduleRender();
52
- }
53
-
54
- @Property({ type: "string", attribute: "playground-src", reflect: true })
55
- playgroundSrc: string = null;
56
-
57
- @Property({ type: "string", attribute: "project-src", reflect: true })
58
- projectSrc: string = null;
59
-
60
- @Property({ type: "object" })
61
- files: any = null;
62
-
63
- @Property({ type: "string", attribute: "cdn-base-url", reflect: true })
64
- cdnBaseUrl: string = null;
65
-
66
- updated(propertyName: string, oldValue: any, newValue: any): void {
67
- if (propertyName === "projectSrc" && newValue) {
68
- this.#loadProject(newValue);
69
- }
70
- }
71
-
72
- async #loadProject(projectSrc: string) {
73
- const response = await fetch(projectSrc).catch((e) => e);
74
- if (response instanceof Error || !response.ok) {
75
- console.error("Failed to load project:", response);
76
- return;
77
- }
78
- const data = await response.json();
79
- if (!data) {
80
- console.error("Failed to load project: no data");
81
- return;
82
- }
83
- const configuredFiles: string[] = [];
84
- for (const key in data.files) {
85
- configuredFiles.push(key);
86
- }
87
- const url = new URL(projectSrc, window.location.href);
88
- const projectPath = url.pathname.substring(
89
- 0,
90
- url.pathname.lastIndexOf("/") + 1
91
- );
92
- const fileResponses = await Promise.all(
93
- configuredFiles.map((file: string) => {
94
- const filePath = projectPath + file;
95
- return fetch(filePath)
96
- .then((response) =>
97
- response.ok
98
- ? response.text()
99
- : Promise.reject(Error(response.statusText))
100
- )
101
- .catch((e) => e);
102
- })
103
- );
104
- const files: any = [];
105
- fileResponses.forEach((fileResponse: string | Error, index) => {
106
- if (!(fileResponse instanceof Error)) {
107
- const file = configuredFiles[index];
108
- files.push({
109
- name: file,
110
- content: fileResponse,
111
- });
112
- }
113
- });
114
- this.files = files;
115
- }
116
-
117
- #afterCreate = (e: HTMLDivElement) => {
118
- const esm = this.playgroundSrc;
119
- if (!esm) return;
120
- import(esm)
121
- .then(() => {
122
- this.#playgroundLoaded = true;
123
- })
124
- .catch((error) => {
125
- console.error("Failed to load module:", error);
126
- });
127
- };
128
-
129
- #getType = (file: string) => {
130
- if (file.endsWith(".html")) {
131
- return "sample/html";
132
- } else if (file.endsWith(".tsx") || file.endsWith(".ts")) {
133
- return "sample/ts";
134
- }
135
- return "sample/unknown";
136
- };
137
-
138
- render = () => {
139
- return (
140
- <div afterCreate={this.#afterCreate} class="app-playground">
141
-
142
- <app-split-panel class="app-playground-split-panel">
143
- {this.#playgroundLoaded && (
144
- [
145
- <playground-project
146
- class="app-playground-project"
147
- cdn-base-url={
148
- this.cdnBaseUrl ? this.cdnBaseUrl : "https://cdn.jsdelivr.net/npm"
149
- }
150
- id={"project" + this.id}
151
- >
152
- {this.files?.map((file: any) => {
153
- return (
154
- <script
155
- key={file.name}
156
- type={this.#getType(file.name)}
157
- filename={file.name}
158
- innerHTML={file.content}
159
- ></script>
160
- );
161
- })}
162
- </playground-project>,<playground-preview
163
- slot="primary"
164
- class="app-playground-preview"
165
- project={"project" + this.id}
166
- ></playground-preview>]
167
- )}
168
- <div slot="secondary" class="app-playground-editor-container">
169
- {this.#playgroundLoaded && (
170
- <playground-tab-bar
171
- class="app-playground-tab-bar"
172
- id={"tab-bar" + this.id}
173
- project={"project" + this.id}
174
- editor={"editor" + this.id}
175
- ></playground-tab-bar>
176
- )}
177
- {this.#playgroundLoaded && (
178
- <playground-file-editor
179
- class="app-playground-editor"
180
- id={"editor" + this.id}
181
- project={"project" + this.id}
182
- ></playground-file-editor>
183
- )}
184
- </div>
185
-
186
- </app-split-panel>
187
- </div>
188
- );
189
- };
1
+ @CustomElementConfig({
2
+ tagName: "app-playground",
3
+ })
4
+ export class AppPlaygroundElement extends CustomElement {
5
+
6
+ static style = `
7
+ :host{
8
+ display: block;
9
+ height: 100%;
10
+ }
11
+ .app-playground{
12
+ height: 100%;
13
+ }
14
+ .app-playground-split-panel{
15
+ height: 100%;
16
+ }
17
+ playground-preview{
18
+ height: 100%;
19
+ position: unset;
20
+ }
21
+ .app-playground-editor-container{
22
+ height: 100%;
23
+ display: flex;
24
+ flex-direction: column;
25
+ }
26
+ .app-playground-editor{
27
+ height: 100%;
28
+ flex: 1;
29
+ }
30
+ `;
31
+
32
+ constructor() {
33
+ super();
34
+ if (!this.id) {
35
+ this.id = "app-playground-" + Math.floor(Math.random() * 1000);
36
+ }
37
+ }
38
+
39
+ #initDone = false;
40
+
41
+ static readonly projectorMode = "replace";
42
+
43
+ #_playgroundLoaded = false;
44
+
45
+ get #playgroundLoaded() {
46
+ return this.#_playgroundLoaded;
47
+ }
48
+
49
+ set #playgroundLoaded(value: boolean) {
50
+ this.#_playgroundLoaded = value;
51
+ this.scheduleRender();
52
+ }
53
+
54
+ @Property({ type: "string", attribute: "playground-src", reflect: true })
55
+ playgroundSrc: string = null;
56
+
57
+ @Property({ type: "string", attribute: "project-src", reflect: true })
58
+ projectSrc: string = null;
59
+
60
+ @Property({ type: "object" })
61
+ files: any = null;
62
+
63
+ @Property({ type: "string", attribute: "cdn-base-url", reflect: true })
64
+ cdnBaseUrl: string = null;
65
+
66
+ updated(propertyName: string, oldValue: any, newValue: any): void {
67
+ if (propertyName === "projectSrc" && newValue) {
68
+ this.#loadProject(newValue);
69
+ }
70
+ }
71
+
72
+ async #loadProject(projectSrc: string) {
73
+ const response = await fetch(projectSrc).catch((e) => e);
74
+ if (response instanceof Error || !response.ok) {
75
+ console.error("Failed to load project:", response);
76
+ return;
77
+ }
78
+ const data = await response.json();
79
+ if (!data) {
80
+ console.error("Failed to load project: no data");
81
+ return;
82
+ }
83
+ const configuredFiles: string[] = [];
84
+ for (const key in data.files) {
85
+ configuredFiles.push(key);
86
+ }
87
+ const url = new URL(projectSrc, window.location.href);
88
+ const projectPath = url.pathname.substring(
89
+ 0,
90
+ url.pathname.lastIndexOf("/") + 1
91
+ );
92
+ const fileResponses = await Promise.all(
93
+ configuredFiles.map((file: string) => {
94
+ const filePath = projectPath + file;
95
+ return fetch(filePath)
96
+ .then((response) =>
97
+ response.ok
98
+ ? response.text()
99
+ : Promise.reject(Error(response.statusText))
100
+ )
101
+ .catch((e) => e);
102
+ })
103
+ );
104
+ const files: any = [];
105
+ fileResponses.forEach((fileResponse: string | Error, index) => {
106
+ if (!(fileResponse instanceof Error)) {
107
+ const file = configuredFiles[index];
108
+ files.push({
109
+ name: file,
110
+ content: fileResponse,
111
+ });
112
+ }
113
+ });
114
+ this.files = files;
115
+ }
116
+
117
+ #afterCreate = (e: HTMLDivElement) => {
118
+ const esm = this.playgroundSrc;
119
+ if (!esm) return;
120
+ import(esm)
121
+ .then(() => {
122
+ this.#playgroundLoaded = true;
123
+ })
124
+ .catch((error) => {
125
+ console.error("Failed to load module:", error);
126
+ });
127
+ };
128
+
129
+ #getType = (file: string) => {
130
+ if (file.endsWith(".html")) {
131
+ return "sample/html";
132
+ } else if (file.endsWith(".tsx") || file.endsWith(".ts")) {
133
+ return "sample/ts";
134
+ }
135
+ return "sample/unknown";
136
+ };
137
+
138
+ render = () => {
139
+ return (
140
+ <div afterCreate={this.#afterCreate} class="app-playground">
141
+
142
+ <app-split-panel class="app-playground-split-panel">
143
+ {this.#playgroundLoaded && (
144
+ [
145
+ <playground-project
146
+ class="app-playground-project"
147
+ cdn-base-url={
148
+ this.cdnBaseUrl ? this.cdnBaseUrl : "https://cdn.jsdelivr.net/npm"
149
+ }
150
+ id={"project" + this.id}
151
+ >
152
+ {this.files?.map((file: any) => {
153
+ return (
154
+ <script
155
+ key={file.name}
156
+ type={this.#getType(file.name)}
157
+ filename={file.name}
158
+ innerHTML={file.content}
159
+ ></script>
160
+ );
161
+ })}
162
+ </playground-project>,<playground-preview
163
+ slot="primary"
164
+ class="app-playground-preview"
165
+ project={"project" + this.id}
166
+ ></playground-preview>]
167
+ )}
168
+ <div slot="secondary" class="app-playground-editor-container">
169
+ {this.#playgroundLoaded && (
170
+ <playground-tab-bar
171
+ class="app-playground-tab-bar"
172
+ id={"tab-bar" + this.id}
173
+ project={"project" + this.id}
174
+ editor={"editor" + this.id}
175
+ ></playground-tab-bar>
176
+ )}
177
+ {this.#playgroundLoaded && (
178
+ <playground-file-editor
179
+ class="app-playground-editor"
180
+ id={"editor" + this.id}
181
+ project={"project" + this.id}
182
+ ></playground-file-editor>
183
+ )}
184
+ </div>
185
+
186
+ </app-split-panel>
187
+ </div>
188
+ );
189
+ };
190
190
  }
@@ -1,22 +1,22 @@
1
- {
2
- "compilerOptions": {
3
- "experimentalDecorators": true,
4
- "target": "ES6",
5
- "useDefineForClassFields": false,
6
- "module": "ES2020",
7
- "lib": ["ES2020", "DOM", "dom.iterable"],
8
- "jsx": "react",
9
- "jsxFactory": "Maquette.h",
10
- "moduleResolution": "Node",
11
- "strict": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "esModuleInterop": true,
15
- "noUnusedLocals": false,
16
- "noUnusedParameters": false,
17
- "noImplicitReturns": true,
18
- "skipLibCheck": true,
19
- "strictNullChecks": false
20
- },
21
- "include": ["src"]
22
- }
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "target": "ES6",
5
+ "useDefineForClassFields": false,
6
+ "module": "ES2020",
7
+ "lib": ["ES2020", "DOM", "dom.iterable"],
8
+ "jsx": "react",
9
+ "jsxFactory": "Maquette.h",
10
+ "moduleResolution": "Node",
11
+ "strict": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "esModuleInterop": true,
15
+ "noUnusedLocals": false,
16
+ "noUnusedParameters": false,
17
+ "noImplicitReturns": true,
18
+ "skipLibCheck": true,
19
+ "strictNullChecks": false
20
+ },
21
+ "include": ["src"]
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "p-elements-core",
3
- "version": "1.2.32-rc2",
3
+ "version": "1.2.32-rc4",
4
4
  "description": "P Elements Core V1",
5
5
  "main": "dist/p-elements-core.js",
6
6
  "types": "p-elements-core.d.ts",
@@ -9,7 +9,10 @@
9
9
  "url": "gitlab.com:p-elements/p-element-core.git"
10
10
  },
11
11
  "scripts": {
12
- "test": "echo \"Error: no test specified\" && exit 1",
12
+ "test": "vitest --run",
13
+ "test:watch": "vitest --ui",
14
+ "test:ui": "vitest --ui",
15
+ "test:coverage": "vitest --coverage --run",
13
16
  "dev-docs": "rimraf ./docs/public && cd docs && npm run dev",
14
17
  "clean": "rimraf ./dist",
15
18
  "build-old": "webpack --config older-browsers-webpack.config.js --mode=production",
@@ -24,6 +27,9 @@
24
27
  "@babel/preset-react": "=7.24.7",
25
28
  "@types/animejs": "^3.1.12",
26
29
  "@types/underscore": "^1.11.15",
30
+ "@vitest/browser-playwright": "^4.0.0",
31
+ "@vitest/coverage-v8": "^4.0.0",
32
+ "@vitest/ui": "^4.0.0",
27
33
  "@webreflection/custom-elements-builtin": "^0.4.1",
28
34
  "animejs": "=2.2.0",
29
35
  "babel-loader": "^8.2.3",
@@ -35,6 +41,7 @@
35
41
  "ts-loader": "^9.2.6",
36
42
  "typescript": "^5.4.3",
37
43
  "underscore": "=1.13.1",
44
+ "vitest": "^4.0.0",
38
45
  "webpack": "^5.105.0",
39
46
  "webpack-cli": "=4.9.1"
40
47
  }