elegance-js 2.0.16 → 2.0.18
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/client/client.mjs +1 -1
- package/package.json +1 -1
- package/dist/docs/components/Header.d.ts +0 -1
- package/dist/docs/components/Header.mjs +0 -249
- package/dist/docs/components/RootLayout.d.ts +0 -1
- package/dist/docs/components/RootLayout.mjs +0 -10
- package/dist/docs/docs/basics/page.d.ts +0 -2
- package/dist/docs/docs/basics/page.mjs +0 -1057
- package/dist/docs/docs/compilations/page.d.ts +0 -2
- package/dist/docs/docs/compilations/page.mjs +0 -15
- package/dist/docs/docs/components/CodeBlock.d.ts +0 -2
- package/dist/docs/docs/components/CodeBlock.mjs +0 -324
- package/dist/docs/docs/components/DocsLayout.d.ts +0 -1
- package/dist/docs/docs/components/DocsLayout.mjs +0 -527
- package/dist/docs/docs/components/Header.d.ts +0 -1
- package/dist/docs/docs/components/Header.mjs +0 -160
- package/dist/docs/docs/components/Mono.d.ts +0 -1
- package/dist/docs/docs/components/Mono.mjs +0 -7
- package/dist/docs/docs/components/PageHeading.d.ts +0 -1
- package/dist/docs/docs/components/PageHeading.mjs +0 -9
- package/dist/docs/docs/components/Paragraph.d.ts +0 -1
- package/dist/docs/docs/components/Paragraph.mjs +0 -10
- package/dist/docs/docs/components/Separator.d.ts +0 -1
- package/dist/docs/docs/components/Separator.mjs +0 -7
- package/dist/docs/docs/components/SubHeading.d.ts +0 -1
- package/dist/docs/docs/components/SubHeading.mjs +0 -8
- package/dist/docs/docs/components/SubSeparator.d.ts +0 -1
- package/dist/docs/docs/components/SubSeparator.mjs +0 -7
- package/dist/docs/docs/components/Subtext.d.ts +0 -1
- package/dist/docs/docs/components/Subtext.mjs +0 -8
- package/dist/docs/docs/concepts/page.d.ts +0 -2
- package/dist/docs/docs/concepts/page.mjs +0 -954
- package/dist/docs/docs/page-files/page.d.ts +0 -2
- package/dist/docs/docs/page-files/page.mjs +0 -1206
- package/dist/docs/docs/route.d.ts +0 -2
- package/dist/docs/docs/route.mjs +0 -8
- package/dist/docs/docs/running/page.d.ts +0 -2
- package/dist/docs/docs/running/page.mjs +0 -7
- package/dist/docs/nullpage/page.d.ts +0 -2
- package/dist/docs/nullpage/page.mjs +0 -58
- package/dist/docs/page.d.ts +0 -2
- package/dist/docs/page.mjs +0 -437
- package/dist/docs/utils/MEGALEXER.d.ts +0 -1
- package/dist/docs/utils/MEGALEXER.mjs +0 -171
- package/dist/types/Metadata.d.ts +0 -19
- package/dist/types/Metadata.mjs +0 -15
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/docs/components/RootLayout.ts
|
|
2
|
-
var RootLayout = (...children) => body(
|
|
3
|
-
{
|
|
4
|
-
class: "bg-background-900 text-text-50 font-inter select-none text-text-50"
|
|
5
|
-
},
|
|
6
|
-
...children
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
// src/docs/docs/compilations/page.ts
|
|
10
|
-
var page = RootLayout();
|
|
11
|
-
var metadata = () => head();
|
|
12
|
-
export {
|
|
13
|
-
metadata,
|
|
14
|
-
page
|
|
15
|
-
};
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
// src/internal/deprecate.ts
|
|
2
|
-
var ShowDeprecationWarning = (msg) => {
|
|
3
|
-
console.warn("\x1B[31m", msg, "\x1B[0m");
|
|
4
|
-
console.trace("Stack Trace:");
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/server/createState.ts
|
|
8
|
-
if (!globalThis.__SERVER_CURRENT_STATE_ID__) {
|
|
9
|
-
globalThis.__SERVER_CURRENT_STATE_ID__ = 1;
|
|
10
|
-
}
|
|
11
|
-
var createState = (value, options) => {
|
|
12
|
-
ShowDeprecationWarning("WARNING: The createState() and function is deprecated. Please use state() instead, from elegance-js/state.");
|
|
13
|
-
const serverStateEntry = {
|
|
14
|
-
id: __SERVER_CURRENT_STATE_ID__ += 1,
|
|
15
|
-
value,
|
|
16
|
-
type: 1 /* STATE */,
|
|
17
|
-
bind: options?.bind
|
|
18
|
-
};
|
|
19
|
-
globalThis.__SERVER_CURRENT_STATE__.push(serverStateEntry);
|
|
20
|
-
return serverStateEntry;
|
|
21
|
-
};
|
|
22
|
-
var createEventListener = ({
|
|
23
|
-
eventListener,
|
|
24
|
-
dependencies = [],
|
|
25
|
-
params
|
|
26
|
-
}) => {
|
|
27
|
-
ShowDeprecationWarning("WARNING: The createEventListener() and function is deprecated. Please use eventListener() instead, from elegance-js/state.");
|
|
28
|
-
const deps = dependencies.map((dep) => ({ id: dep.id, bind: dep.bind }));
|
|
29
|
-
let dependencyString = "[";
|
|
30
|
-
for (const dep of deps) {
|
|
31
|
-
dependencyString += `{id:${dep.id}`;
|
|
32
|
-
if (dep.bind) dependencyString += `,bind:${dep.bind}`;
|
|
33
|
-
dependencyString += `},`;
|
|
34
|
-
}
|
|
35
|
-
dependencyString += "]";
|
|
36
|
-
const value = {
|
|
37
|
-
id: __SERVER_CURRENT_STATE_ID__ += 1,
|
|
38
|
-
type: 1 /* STATE */,
|
|
39
|
-
value: new Function(
|
|
40
|
-
"state",
|
|
41
|
-
"event",
|
|
42
|
-
`(${eventListener.toString()})({ event, ...${JSON.stringify(params || {})} }, ...state.getAll(${dependencyString}))`
|
|
43
|
-
)
|
|
44
|
-
};
|
|
45
|
-
globalThis.__SERVER_CURRENT_STATE__.push(value);
|
|
46
|
-
return value;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/server/loadHook.ts
|
|
50
|
-
var createLoadHook = (options) => {
|
|
51
|
-
ShowDeprecationWarning("WARNING: createLoadHook() is a deprecated function. Use loadHook() from elegance-js/loadHook instead.");
|
|
52
|
-
const stringFn = options.fn.toString();
|
|
53
|
-
const deps = (options.deps || []).map((dep) => ({
|
|
54
|
-
id: dep.id,
|
|
55
|
-
bind: dep.bind
|
|
56
|
-
}));
|
|
57
|
-
let dependencyString = "[";
|
|
58
|
-
for (const dep of deps) {
|
|
59
|
-
dependencyString += `{id:${dep.id}`;
|
|
60
|
-
if (dep.bind) dependencyString += `,bind:${dep.bind}`;
|
|
61
|
-
dependencyString += `},`;
|
|
62
|
-
}
|
|
63
|
-
dependencyString += "]";
|
|
64
|
-
const isAsync = options.fn.constructor.name === "AsyncFunction";
|
|
65
|
-
const wrapperFn = isAsync ? `async (state) => await (${stringFn})(state, ...state.getAll(${dependencyString}))` : `(state) => (${stringFn})(state, ...state.getAll(${dependencyString}))`;
|
|
66
|
-
globalThis.__SERVER_CURRENT_LOADHOOKS__.push({
|
|
67
|
-
fn: wrapperFn,
|
|
68
|
-
bind: options.bind || ""
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/server/observe.ts
|
|
73
|
-
var observe = (refs, update) => {
|
|
74
|
-
const returnValue = {
|
|
75
|
-
type: 2 /* OBSERVER */,
|
|
76
|
-
initialValues: refs.map((ref) => ref.value),
|
|
77
|
-
update,
|
|
78
|
-
refs: refs.map((ref) => ({
|
|
79
|
-
id: ref.id,
|
|
80
|
-
bind: ref.bind
|
|
81
|
-
}))
|
|
82
|
-
};
|
|
83
|
-
return returnValue;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/docs/utils/MEGALEXER.ts
|
|
87
|
-
var tokenize = (input) => {
|
|
88
|
-
const tokens = [];
|
|
89
|
-
const length = input.length;
|
|
90
|
-
let index = 0;
|
|
91
|
-
const keywords = /* @__PURE__ */ new Set([
|
|
92
|
-
"if",
|
|
93
|
-
"else",
|
|
94
|
-
"for",
|
|
95
|
-
"while",
|
|
96
|
-
"function",
|
|
97
|
-
"return",
|
|
98
|
-
"class",
|
|
99
|
-
"const",
|
|
100
|
-
"let",
|
|
101
|
-
"var",
|
|
102
|
-
"interface",
|
|
103
|
-
"extends",
|
|
104
|
-
"implements",
|
|
105
|
-
"export",
|
|
106
|
-
"import",
|
|
107
|
-
"from"
|
|
108
|
-
]);
|
|
109
|
-
const operatorChars = /* @__PURE__ */ new Set([
|
|
110
|
-
"+",
|
|
111
|
-
"-",
|
|
112
|
-
"*",
|
|
113
|
-
"/",
|
|
114
|
-
"%",
|
|
115
|
-
"=",
|
|
116
|
-
">",
|
|
117
|
-
"<",
|
|
118
|
-
"!",
|
|
119
|
-
"&",
|
|
120
|
-
"|",
|
|
121
|
-
"^",
|
|
122
|
-
"~",
|
|
123
|
-
"?",
|
|
124
|
-
":"
|
|
125
|
-
]);
|
|
126
|
-
const punctuationChars = /* @__PURE__ */ new Set([
|
|
127
|
-
";",
|
|
128
|
-
",",
|
|
129
|
-
".",
|
|
130
|
-
"(",
|
|
131
|
-
")",
|
|
132
|
-
"{",
|
|
133
|
-
"}",
|
|
134
|
-
"[",
|
|
135
|
-
"]"
|
|
136
|
-
]);
|
|
137
|
-
const peek = (offset = 1) => index + offset < length ? input[index + offset] : "";
|
|
138
|
-
const readWhile = (predicate) => {
|
|
139
|
-
const start = index;
|
|
140
|
-
while (index < length && predicate(input[index])) {
|
|
141
|
-
index++;
|
|
142
|
-
}
|
|
143
|
-
return input.slice(start, index);
|
|
144
|
-
};
|
|
145
|
-
const readString = (quoteType) => {
|
|
146
|
-
let value = input[index++];
|
|
147
|
-
while (index < length && input[index] !== quoteType) {
|
|
148
|
-
if (input[index] === "\\") {
|
|
149
|
-
value += input[index++];
|
|
150
|
-
if (index < length) {
|
|
151
|
-
value += input[index++];
|
|
152
|
-
}
|
|
153
|
-
} else {
|
|
154
|
-
value += input[index++];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (index < length) {
|
|
158
|
-
value += input[index++];
|
|
159
|
-
}
|
|
160
|
-
return value;
|
|
161
|
-
};
|
|
162
|
-
const readLineComment = () => {
|
|
163
|
-
const start = index;
|
|
164
|
-
index += 2;
|
|
165
|
-
while (index < length && input[index] !== "\n") {
|
|
166
|
-
index++;
|
|
167
|
-
}
|
|
168
|
-
return input.slice(start, index);
|
|
169
|
-
};
|
|
170
|
-
const readBlockComment = () => {
|
|
171
|
-
const start = index;
|
|
172
|
-
index += 2;
|
|
173
|
-
while (index < length && !(input[index] === "*" && peek() === "/")) {
|
|
174
|
-
index++;
|
|
175
|
-
}
|
|
176
|
-
if (index < length) {
|
|
177
|
-
index += 2;
|
|
178
|
-
}
|
|
179
|
-
return input.slice(start, index);
|
|
180
|
-
};
|
|
181
|
-
while (index < length) {
|
|
182
|
-
const char = input[index];
|
|
183
|
-
const startPos = index;
|
|
184
|
-
if (/\s/.test(char)) {
|
|
185
|
-
const value = readWhile((c) => /\s/.test(c));
|
|
186
|
-
tokens.push({ type: "" /* Whitespace */, value, position: startPos });
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (char === "/") {
|
|
190
|
-
if (peek() === "/") {
|
|
191
|
-
const value = readLineComment();
|
|
192
|
-
tokens.push({ type: "text-gray-400" /* Comment */, value, position: startPos });
|
|
193
|
-
continue;
|
|
194
|
-
} else if (peek() === "*") {
|
|
195
|
-
const value = readBlockComment();
|
|
196
|
-
tokens.push({ type: "text-gray-400" /* Comment */, value, position: startPos });
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (char === '"' || char === "'") {
|
|
201
|
-
const value = readString(char);
|
|
202
|
-
tokens.push({ type: "text-green-200" /* String */, value, position: startPos });
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (/\d/.test(char)) {
|
|
206
|
-
const value = readWhile((c) => /[\d\.]/.test(c));
|
|
207
|
-
tokens.push({ type: "text-blue-400" /* Number */, value, position: startPos });
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (/[a-zA-Z_$]/.test(char)) {
|
|
211
|
-
const value = readWhile((c) => /[a-zA-Z0-9_$]/.test(c));
|
|
212
|
-
let type = "text-orange-300" /* Identifier */;
|
|
213
|
-
if (keywords.has(value)) {
|
|
214
|
-
type = "text-amber-100 font-semibold" /* Keyword */;
|
|
215
|
-
} else if (value === "true" || value === "false") {
|
|
216
|
-
type = "text-blue-200" /* Boolean */;
|
|
217
|
-
}
|
|
218
|
-
let tempIndex = index;
|
|
219
|
-
while (tempIndex < length && /\s/.test(input[tempIndex])) {
|
|
220
|
-
tempIndex++;
|
|
221
|
-
}
|
|
222
|
-
if (tempIndex < length && input[tempIndex] === "(") {
|
|
223
|
-
type = "text-red-300" /* FunctionCall */;
|
|
224
|
-
}
|
|
225
|
-
tokens.push({ type, value, position: startPos });
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (operatorChars.has(char)) {
|
|
229
|
-
let value = char;
|
|
230
|
-
index++;
|
|
231
|
-
if (index < length && operatorChars.has(input[index])) {
|
|
232
|
-
value += input[index++];
|
|
233
|
-
}
|
|
234
|
-
tokens.push({ type: "" /* Operator */, value, position: startPos });
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
if (punctuationChars.has(char)) {
|
|
238
|
-
tokens.push({ type: "text-gray-400" /* Punctuation */, value: char, position: startPos });
|
|
239
|
-
index++;
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
tokens.push({ type: "" /* Unknown */, value: char, position: startPos });
|
|
243
|
-
index++;
|
|
244
|
-
}
|
|
245
|
-
return tokens;
|
|
246
|
-
};
|
|
247
|
-
var escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
248
|
-
var highlightCode = (code) => {
|
|
249
|
-
const tokens = tokenize(code);
|
|
250
|
-
return tokens.map(
|
|
251
|
-
(token) => token.type === "" /* Whitespace */ ? token.value : `<span class="${token.type}">${escapeHtml(token.value)}</span>`
|
|
252
|
-
).join("");
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// src/docs/docs/components/CodeBlock.ts
|
|
256
|
-
var isToastShowing = createState(false);
|
|
257
|
-
var toastTimeoutId = createState(0);
|
|
258
|
-
var copyCode = createEventListener({
|
|
259
|
-
dependencies: [
|
|
260
|
-
isToastShowing,
|
|
261
|
-
toastTimeoutId
|
|
262
|
-
],
|
|
263
|
-
eventListener: async (params, isToastShowing2, toastTimeoutId2) => {
|
|
264
|
-
const children = params.event.currentTarget.children;
|
|
265
|
-
const pre2 = children.item(0);
|
|
266
|
-
const content = pre2.innerText;
|
|
267
|
-
await navigator.clipboard.writeText(content);
|
|
268
|
-
if (toastTimeoutId2.value !== 0) clearTimeout(toastTimeoutId2.value);
|
|
269
|
-
isToastShowing2.value = true;
|
|
270
|
-
isToastShowing2.signal();
|
|
271
|
-
const timeoutId = window.setTimeout(() => {
|
|
272
|
-
isToastShowing2.value = false;
|
|
273
|
-
isToastShowing2.signal();
|
|
274
|
-
}, 3e3);
|
|
275
|
-
toastTimeoutId2.value = timeoutId;
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
var Toast = (bind) => {
|
|
279
|
-
createLoadHook({
|
|
280
|
-
bind,
|
|
281
|
-
deps: [
|
|
282
|
-
toastTimeoutId,
|
|
283
|
-
isToastShowing
|
|
284
|
-
],
|
|
285
|
-
fn: (state, toastTimeoutId2, isToastShowing2) => {
|
|
286
|
-
return () => {
|
|
287
|
-
clearTimeout(toastTimeoutId2.value);
|
|
288
|
-
isToastShowing2.value = false;
|
|
289
|
-
isToastShowing2.signal();
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
return div(
|
|
294
|
-
{
|
|
295
|
-
class: observe(
|
|
296
|
-
[isToastShowing],
|
|
297
|
-
(isShowing) => {
|
|
298
|
-
const modularClass = isShowing ? "right-8" : "right-0 translate-x-full";
|
|
299
|
-
return `fixed z-50 shadow-lg rounded-sm duration-200 bottom-4 px-4 py-2 w-max bg-background-950 ` + modularClass;
|
|
300
|
-
}
|
|
301
|
-
)
|
|
302
|
-
},
|
|
303
|
-
h1({
|
|
304
|
-
class: "font-mono uppercase"
|
|
305
|
-
}, "copied to clipboard")
|
|
306
|
-
);
|
|
307
|
-
};
|
|
308
|
-
var escapeHtml2 = (str) => {
|
|
309
|
-
const replaced = str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
310
|
-
return replaced;
|
|
311
|
-
};
|
|
312
|
-
var CodeBlock = (value, parse = true) => div(
|
|
313
|
-
{
|
|
314
|
-
class: `bg-background-950 hover:cursor-pointer p-2 rounded-sm
|
|
315
|
-
border-[1px] border-background-800 w-max my-3 max-w-full
|
|
316
|
-
overflow-scroll`,
|
|
317
|
-
onClick: copyCode
|
|
318
|
-
},
|
|
319
|
-
pre({}, parse ? highlightCode(value) : escapeHtml2(value))
|
|
320
|
-
);
|
|
321
|
-
export {
|
|
322
|
-
CodeBlock,
|
|
323
|
-
Toast
|
|
324
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DocsLayout: (...children: Child[]) => BuiltElement<"div">;
|