chemicaljs 2.2.0 → 2.4.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/dist/index.cjs +428 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +57 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +407 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -10
- package/client/chemical.components.js +0 -214
- package/client/chemical.demo.html +0 -43
- package/client/chemical.js +0 -478
- package/client/chemical.sw.js +0 -46
- package/config/meteor/meteor.config.js +0 -13
- package/config/scramjet/scramjet.config.js +0 -9
- package/config/uv/uv.config.js +0 -10
- package/index.js +0 -597
- package/rammerhead.tgz +0 -0
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
class ChemicalInput extends HTMLInputElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super();
|
|
4
|
-
}
|
|
5
|
-
connectedCallback() {
|
|
6
|
-
this.addEventListener("keydown", async function (e) {
|
|
7
|
-
if (e.key === "Enter" && window.chemical.loaded && e.target.value) {
|
|
8
|
-
let service =
|
|
9
|
-
this.dataset.serviceStore !== undefined
|
|
10
|
-
? localStorage.getItem("@chemical/service") ||
|
|
11
|
-
this.dataset.service ||
|
|
12
|
-
"uv"
|
|
13
|
-
: this.dataset.service || "uv";
|
|
14
|
-
let autoHttps =
|
|
15
|
-
this.dataset.autoHttpsStore !== undefined
|
|
16
|
-
? localStorage.getItem("@chemical/autoHttps") === "true"
|
|
17
|
-
: this.dataset.autoHttps !== undefined
|
|
18
|
-
? true
|
|
19
|
-
: false;
|
|
20
|
-
let searchEngine =
|
|
21
|
-
this.dataset.searchEngineStore !== undefined
|
|
22
|
-
? localStorage.getItem("@chemical/searchEngine")
|
|
23
|
-
: this.dataset.searchEngine;
|
|
24
|
-
let action = this.dataset.action;
|
|
25
|
-
let target = this.dataset.target;
|
|
26
|
-
let frame = this.dataset.frame;
|
|
27
|
-
let encodedURL = await chemical.encode(e.target.value, {
|
|
28
|
-
service,
|
|
29
|
-
autoHttps,
|
|
30
|
-
searchEngine,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (frame) {
|
|
34
|
-
let forFrame = document.getElementById(frame);
|
|
35
|
-
forFrame.src = encodedURL;
|
|
36
|
-
forFrame.setAttribute("data-open", "true");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (action) {
|
|
40
|
-
window[action](encodedURL);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (target) {
|
|
44
|
-
if (target === "_self") {
|
|
45
|
-
window.location = encodedURL;
|
|
46
|
-
} else if (target === "_blank") {
|
|
47
|
-
window.open(encodedURL);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class ChemicalButton extends HTMLButtonElement {
|
|
56
|
-
constructor() {
|
|
57
|
-
super();
|
|
58
|
-
}
|
|
59
|
-
connectedCallback() {
|
|
60
|
-
this.addEventListener("click", function (e) {
|
|
61
|
-
let forInput = document.getElementById(this.dataset.for);
|
|
62
|
-
|
|
63
|
-
if (forInput) {
|
|
64
|
-
forInput.dispatchEvent(
|
|
65
|
-
new KeyboardEvent("keydown", {
|
|
66
|
-
key: "Enter",
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
class ChemicalIFrame extends HTMLIFrameElement {
|
|
75
|
-
static observedAttributes = ["data-open"];
|
|
76
|
-
constructor() {
|
|
77
|
-
super();
|
|
78
|
-
}
|
|
79
|
-
connectedCallback() {
|
|
80
|
-
let open = this.dataset.open;
|
|
81
|
-
this.style.display = open === "true" ? "" : "none";
|
|
82
|
-
}
|
|
83
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
84
|
-
if (name === "data-open") {
|
|
85
|
-
let open = this.dataset.open;
|
|
86
|
-
this.style.display = open === "true" ? "" : "none";
|
|
87
|
-
|
|
88
|
-
let controls = document.getElementById(this.dataset.controls);
|
|
89
|
-
|
|
90
|
-
if (controls) {
|
|
91
|
-
controls.dataset.open = open;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
class ChemicalControls extends HTMLElement {
|
|
98
|
-
static observedAttributes = ["data-open"];
|
|
99
|
-
constructor() {
|
|
100
|
-
super();
|
|
101
|
-
}
|
|
102
|
-
connectedCallback() {
|
|
103
|
-
let open = this.dataset.open;
|
|
104
|
-
this.style.display = open === "true" ? "" : "none";
|
|
105
|
-
}
|
|
106
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
107
|
-
if (name === "data-open") {
|
|
108
|
-
let open = this.dataset.open;
|
|
109
|
-
this.style.display = open === "true" ? "" : "none";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
class ChemicalLink extends HTMLAnchorElement {
|
|
115
|
-
constructor() {
|
|
116
|
-
super();
|
|
117
|
-
}
|
|
118
|
-
async connectedCallback() {
|
|
119
|
-
let href = this.dataset.href;
|
|
120
|
-
let service = this.dataset.service || "uv";
|
|
121
|
-
let autoHttps = this.dataset.autoHttps !== undefined ? true : false;
|
|
122
|
-
let searchEngine = this.dataset.searchEngine;
|
|
123
|
-
this.dataset.chemicalLoading = "true";
|
|
124
|
-
|
|
125
|
-
if (window.chemical.loaded) {
|
|
126
|
-
this.setAttribute(
|
|
127
|
-
"href",
|
|
128
|
-
await chemical.encode(href, {
|
|
129
|
-
service,
|
|
130
|
-
autoHttps,
|
|
131
|
-
searchEngine,
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
this.dataset.chemicalLoading = "false";
|
|
135
|
-
} else {
|
|
136
|
-
window.addEventListener("chemicalLoaded", async () => {
|
|
137
|
-
this.setAttribute(
|
|
138
|
-
"href",
|
|
139
|
-
await chemical.encode(href, {
|
|
140
|
-
service,
|
|
141
|
-
autoHttps,
|
|
142
|
-
searchEngine,
|
|
143
|
-
})
|
|
144
|
-
);
|
|
145
|
-
this.dataset.chemicalLoading = "false";
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
class ChemicalSelect extends HTMLSelectElement {
|
|
152
|
-
constructor() {
|
|
153
|
-
super();
|
|
154
|
-
}
|
|
155
|
-
connectedCallback() {
|
|
156
|
-
const store = this.dataset.defaultStore;
|
|
157
|
-
|
|
158
|
-
this.addEventListener("change", function () {
|
|
159
|
-
window.chemical.setStore(store, this.value);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
if (store) {
|
|
163
|
-
const value = window.chemical.getStore(store);
|
|
164
|
-
|
|
165
|
-
const observerOptions = {
|
|
166
|
-
childList: true,
|
|
167
|
-
subtree: false,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const observer = new MutationObserver((records, observer) => {
|
|
171
|
-
for (const record of records) {
|
|
172
|
-
for (const addedNode of record.addedNodes) {
|
|
173
|
-
if (addedNode.tagName === "OPTION") {
|
|
174
|
-
if (addedNode.getAttribute("value") === value) {
|
|
175
|
-
addedNode.setAttribute("selected", "");
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
observer.observe(this, observerOptions);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
customElements.define("chemical-input", ChemicalInput, { extends: "input" });
|
|
187
|
-
customElements.define("chemical-button", ChemicalButton, { extends: "button" });
|
|
188
|
-
customElements.define("chemical-iframe", ChemicalIFrame, { extends: "iframe" });
|
|
189
|
-
customElements.define("chemical-controls", ChemicalControls, {
|
|
190
|
-
extends: "section",
|
|
191
|
-
});
|
|
192
|
-
customElements.define("chemical-link", ChemicalLink, { extends: "a" });
|
|
193
|
-
customElements.define("chemical-select", ChemicalSelect, { extends: "select" });
|
|
194
|
-
|
|
195
|
-
window.chemical.componentAction = function (action, frameID) {
|
|
196
|
-
let frame = document.getElementById(frameID);
|
|
197
|
-
|
|
198
|
-
if (frame) {
|
|
199
|
-
switch (action) {
|
|
200
|
-
case "back":
|
|
201
|
-
frame.contentWindow.history.back();
|
|
202
|
-
break;
|
|
203
|
-
case "forward":
|
|
204
|
-
frame.contentWindow.history.forward();
|
|
205
|
-
break;
|
|
206
|
-
case "reload":
|
|
207
|
-
frame.contentWindow.location.reload();
|
|
208
|
-
break;
|
|
209
|
-
case "close":
|
|
210
|
-
frame.dataset.open = "false";
|
|
211
|
-
frame.src = "";
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Demo Site</title>
|
|
7
|
-
<style>
|
|
8
|
-
*,
|
|
9
|
-
*::before,
|
|
10
|
-
*::after {
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
margin: 0;
|
|
16
|
-
min-height: 100vh;
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
align-items: center;
|
|
21
|
-
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
|
|
22
|
-
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
23
|
-
background: #e5e5e5;
|
|
24
|
-
color: black;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media (prefers-color-scheme: dark) {
|
|
28
|
-
body {
|
|
29
|
-
background: #0a0a0a;
|
|
30
|
-
color: #fafafa;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
h1 {
|
|
35
|
-
margin: 0;
|
|
36
|
-
}
|
|
37
|
-
</style>
|
|
38
|
-
</head>
|
|
39
|
-
<body>
|
|
40
|
-
<h1>Demo Site</h1>
|
|
41
|
-
<p>This is a demo site without proxy functionality.</p>
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|