@excom/super-img 0.1.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/.rush/temp/chunked-rush-logs/super-img.apply-exports.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/super-img.build_docs.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/super-img.build_package-metas.chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/all.log +1 -0
- package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/state.json +3 -0
- package/.rush/temp/operation/build_docs/all.log +1 -0
- package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_docs/state.json +3 -0
- package/.rush/temp/operation/build_package-metas/all.log +1 -0
- package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_package-metas/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +3 -0
- package/config/rig.json +5 -0
- package/index.css +5 -0
- package/index.ts +17 -0
- package/package.json +44 -0
- package/rush-logs/super-img.apply-exports.cache.log +1 -0
- package/rush-logs/super-img.apply-exports.log +1 -0
- package/rush-logs/super-img.build_docs.cache.log +1 -0
- package/rush-logs/super-img.build_docs.log +1 -0
- package/rush-logs/super-img.build_package-metas.cache.log +1 -0
- package/rush-logs/super-img.build_package-metas.log +1 -0
- package/src/super-img.css +8 -0
- package/super-img.ts +149 -0
- package/support/custom-elements.json +47 -0
- package/support/dist-docs/super-img.md +33 -0
- package/support/tests/super-img.test.ts +26 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: cd \"$RUSH_PROJECT_FOLDER\" && node ../heft-rig/scripts/apply-exports.mjs \n"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs \n"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs \n"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: cd "$RUSH_PROJECT_FOLDER" && node ../heft-rig/scripts/apply-exports.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: cd \"$RUSH_PROJECT_FOLDER\" && node ../heft-rig/scripts/apply-exports.mjs \n"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs \n"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs \n"}
|
package/config/rig.json
ADDED
package/index.css
ADDED
package/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SuperImg } from "./super-img";
|
|
2
|
+
|
|
3
|
+
SuperImg.define();
|
|
4
|
+
|
|
5
|
+
export { SuperImg };
|
|
6
|
+
|
|
7
|
+
type T_HTMLSuperImgElement = typeof SuperImg.CustomElement;
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLSuperImgElement extends T_HTMLSuperImgElement {}
|
|
10
|
+
interface Window {
|
|
11
|
+
HTMLSuperImgElement: HTMLSuperImgElement;
|
|
12
|
+
}
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
"super-img": HTMLSuperImgElement;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export type { HTMLSuperImgElement };
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@excom/super-img",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "<super-img> custom element",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24.13.0"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@excom/neutron": "^0.1.0"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@excom/heft-rig": "^0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"url": "excom-dev/nucleus",
|
|
19
|
+
"directory": "packages/super-img"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/excom-dev/nucleus/tree/main/packages/super-img/support/docs/README.md",
|
|
22
|
+
"bugs": "https://github.com/excom-dev/nucleus/issues",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"super-img",
|
|
25
|
+
"neutron",
|
|
26
|
+
"custom-elements"
|
|
27
|
+
],
|
|
28
|
+
"excom": {
|
|
29
|
+
"coverageThreshold": false,
|
|
30
|
+
"documented": false,
|
|
31
|
+
"packageType": "kit-element"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node node_modules/@excom/heft-rig/scripts/vite-build.mjs",
|
|
35
|
+
"build:watch": "node node_modules/@excom/heft-rig/scripts/vite-build-watch.mjs",
|
|
36
|
+
"format": "node node_modules/@excom/heft-rig/scripts/format.mjs",
|
|
37
|
+
"test": "node node_modules/@excom/heft-rig/scripts/vitest.mjs",
|
|
38
|
+
"coverage": "node node_modules/@excom/heft-rig/scripts/coverage.mjs",
|
|
39
|
+
"dev": "node node_modules/@excom/heft-rig/scripts/vite-dev.mjs",
|
|
40
|
+
"preview": "node node_modules/@excom/heft-rig/scripts/vite-preview.mjs",
|
|
41
|
+
"build:package-metas": "node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs",
|
|
42
|
+
"build:docs": "node node_modules/@excom/heft-rig/scripts/build-docs.mjs"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Caching has been disabled for this project's "apply-exports" command.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: cd "$RUSH_PROJECT_FOLDER" && node ../heft-rig/scripts/apply-exports.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This project does not define the caching behavior of the "build:docs" command, so caching has been disabled.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This project does not define the caching behavior of the "build:package-metas" command, so caching has been disabled.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs
|
package/super-img.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Neutron } from "@excom/neutron";
|
|
2
|
+
|
|
3
|
+
export const SuperImg = Neutron({
|
|
4
|
+
tag: "super-img",
|
|
5
|
+
props: {
|
|
6
|
+
// options
|
|
7
|
+
imgSrc: String,
|
|
8
|
+
fallbackSrc: String,
|
|
9
|
+
// state
|
|
10
|
+
isSuccess: Boolean,
|
|
11
|
+
isError: String,
|
|
12
|
+
isLoading: Boolean,
|
|
13
|
+
imgElement: HTMLImageElement,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
SuperImg.onConnected((element) => [
|
|
17
|
+
{ imgElement: element.querySelector("img") },
|
|
18
|
+
{
|
|
19
|
+
imgElement: {
|
|
20
|
+
addListeners: [
|
|
21
|
+
[
|
|
22
|
+
"error",
|
|
23
|
+
({ currentTarget, message }) => {
|
|
24
|
+
return {
|
|
25
|
+
imgElement: {
|
|
26
|
+
src:
|
|
27
|
+
element.fallbackSrc &&
|
|
28
|
+
currentTarget?.src !== element.fallbackSrc
|
|
29
|
+
? element.fallbackSrc
|
|
30
|
+
: currentTarget?.src,
|
|
31
|
+
},
|
|
32
|
+
isLoading: false,
|
|
33
|
+
isError: message,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
"load",
|
|
39
|
+
() => ({
|
|
40
|
+
isLoading: false,
|
|
41
|
+
isSuccess: true,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
]).onPropChanged("imgSrc", ({ imgSrc }) => ({
|
|
48
|
+
isSuccess: false,
|
|
49
|
+
isError: null,
|
|
50
|
+
isLoading: true,
|
|
51
|
+
imgElement: { src: imgSrc || undefined },
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
// TYPE TESTING
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* // type Y = HTMLImageElement extends HTMLElement ? "test" : never;
|
|
58
|
+
* // type ESig = ["my-event", () => void];
|
|
59
|
+
* // type B = (string | (() => void))[]
|
|
60
|
+
* // const foo: B = ["my-event", () => {}];
|
|
61
|
+
* // const bar = foo satisfies ESig;
|
|
62
|
+
* type Y = Array<any> extends Record<symbol, any> ? "yes" : never;
|
|
63
|
+
* const res = (
|
|
64
|
+
* element
|
|
65
|
+
* ) => [
|
|
66
|
+
* {
|
|
67
|
+
* appendChild: ["x"],
|
|
68
|
+
* xuyz: "foo",
|
|
69
|
+
* },
|
|
70
|
+
* ];
|
|
71
|
+
* type TEST = ReturnType<typeof res>;
|
|
72
|
+
* const bar = [
|
|
73
|
+
* {
|
|
74
|
+
* appendChild: ["x"],
|
|
75
|
+
* xuyz: "foo",
|
|
76
|
+
* },
|
|
77
|
+
* ]
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
// type Obj = Record<symbol, any>;
|
|
81
|
+
// type baz = typeof bar extends Array<Obj> ? "yes" : "no";
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* const b = SuperImg.onConnected((element) => [
|
|
85
|
+
* {
|
|
86
|
+
* imgElement: element.querySelector("img"),
|
|
87
|
+
* appendChild: ["x"],
|
|
88
|
+
* xuyz: "foo",
|
|
89
|
+
* },
|
|
90
|
+
* ]);
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* SuperImg.onConnected((element) => ({
|
|
95
|
+
* imgElement: {
|
|
96
|
+
* src: element.imgSrc,
|
|
97
|
+
* hidden: true,
|
|
98
|
+
* },
|
|
99
|
+
* appendChild: ["x"],
|
|
100
|
+
* xuyz: "foo",
|
|
101
|
+
* }))
|
|
102
|
+
* .onPropSet("imgSrc", ({ imgSrc }) => ({
|
|
103
|
+
* isSuccess: false,
|
|
104
|
+
* isError: null,
|
|
105
|
+
* isLoading: true,
|
|
106
|
+
* imgElement: { src: imgSrc },
|
|
107
|
+
* x: 1,
|
|
108
|
+
* }))
|
|
109
|
+
* .onPropChanged("imgSrc", ({ imgSrc }) => ({
|
|
110
|
+
* isSuccess: false,
|
|
111
|
+
* isError: null,
|
|
112
|
+
* isLoading: true,
|
|
113
|
+
* imgElement: { src: imgSrc },
|
|
114
|
+
* }))
|
|
115
|
+
* .onPropSet(["imgSrc", "isLoading"], ({ imgSrc }) => ({
|
|
116
|
+
* isSuccess: false,
|
|
117
|
+
* isError: null,
|
|
118
|
+
* isLoading: true,
|
|
119
|
+
* imgElement: { src: imgSrc },
|
|
120
|
+
* addEventListener: "foo",
|
|
121
|
+
* removeEventListener: ["bar", () => {}],
|
|
122
|
+
* appendChild: ["x"],
|
|
123
|
+
* }))
|
|
124
|
+
* .onPropSet(["imgSrc", "isLoading"], ({ imgSrc, fallbackSrc }) => ({
|
|
125
|
+
* isSuccess: false,
|
|
126
|
+
* isError: null,
|
|
127
|
+
* isLoading: true,
|
|
128
|
+
* imgElement: { src: fallbackSrc },
|
|
129
|
+
* addEventListener: "foo",
|
|
130
|
+
* removeEventListener: ["bar", () => {}],
|
|
131
|
+
* appendChild: ["x"],
|
|
132
|
+
* }))
|
|
133
|
+
* .onPropUnset("imgSrc", ({ imgSrc, fallbackSrc }) => ({
|
|
134
|
+
* isSuccess: false,
|
|
135
|
+
* isError: null,
|
|
136
|
+
* isLoading: true,
|
|
137
|
+
* imgElement: {
|
|
138
|
+
* src: "h",
|
|
139
|
+
* inert: true,
|
|
140
|
+
* hidden: "",
|
|
141
|
+
* fakeProp: fallbackSrc,
|
|
142
|
+
* removeEventListener: ["bar", () => {}],
|
|
143
|
+
* toggleListeners: [["foo", () => {}, false]],
|
|
144
|
+
* },
|
|
145
|
+
* addEventListener: "foo",
|
|
146
|
+
* removeEventListener: ["bar", () => {}],
|
|
147
|
+
* appendChild: ["x"],
|
|
148
|
+
* }));
|
|
149
|
+
*/
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"modules": [
|
|
4
|
+
{
|
|
5
|
+
"kind": "javascript-module",
|
|
6
|
+
"path": "super-img.ts",
|
|
7
|
+
"declarations": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "class",
|
|
10
|
+
"name": "SuperImg",
|
|
11
|
+
"customElement": true,
|
|
12
|
+
"tagName": "super-img",
|
|
13
|
+
"_neutron": {
|
|
14
|
+
"cssAliases": [
|
|
15
|
+
{
|
|
16
|
+
"name": ":--super-img",
|
|
17
|
+
"selectors": [
|
|
18
|
+
"super-img",
|
|
19
|
+
".tag-super-img"
|
|
20
|
+
],
|
|
21
|
+
"kind": "element"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"exports": [
|
|
28
|
+
{
|
|
29
|
+
"kind": "js",
|
|
30
|
+
"name": "SuperImg",
|
|
31
|
+
"declaration": {
|
|
32
|
+
"name": "SuperImg",
|
|
33
|
+
"module": "super-img.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"kind": "custom-element-definition",
|
|
38
|
+
"name": "super-img",
|
|
39
|
+
"declaration": {
|
|
40
|
+
"name": "SuperImg",
|
|
41
|
+
"module": "super-img.ts"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `<super-img>`
|
|
2
|
+
|
|
3
|
+
**Tag:** `<super-img>`
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`@excom/super-img` v0.1.0
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @excom/super-img
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @excom/super-img
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add @excom/super-img
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Import
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import "@excom/super-img";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
### CSS Aliases
|
|
30
|
+
|
|
31
|
+
| Alias | Kind | Matches | Description |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `:--super-img` | element | `super-img`, `.tag-super-img` | |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterEach,
|
|
3
|
+
describe,
|
|
4
|
+
expect,
|
|
5
|
+
fixture,
|
|
6
|
+
it,
|
|
7
|
+
vi,
|
|
8
|
+
wait,
|
|
9
|
+
} from "@excom/heft-rig/profiles/default/config/test-utils";
|
|
10
|
+
import "../../index";
|
|
11
|
+
|
|
12
|
+
describe("super-img", () => {
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
document.body.innerHTML = "";
|
|
15
|
+
vi.restoreAllMocks();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("captures the inner image element on connect", async () => {
|
|
19
|
+
const el = fixture<HTMLSuperImgElement>(
|
|
20
|
+
`<super-img><img /></super-img>`,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
await wait(0);
|
|
24
|
+
expect(el.imgElement).toBe(el.querySelector("img"));
|
|
25
|
+
});
|
|
26
|
+
});
|