revojs 0.0.41 → 0.0.43
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/app/index.d.ts +3 -1
- package/dist/html/index.d.ts +2 -6
- package/dist/index.js +5 -12
- package/dist/jsx/index.js +0 -48
- package/package.json +1 -1
package/dist/app/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Middleware } from "../http";
|
|
|
3
3
|
export type NestedPartial<T> = T extends any[] ? T : T extends Record<string, any> ? {
|
|
4
4
|
[P in keyof T]?: NestedPartial<T[P]>;
|
|
5
5
|
} : T;
|
|
6
|
-
export type Environment =
|
|
6
|
+
export type Environment = typeof CLIENT | typeof SERVER;
|
|
7
7
|
export type ServerEntry = "revojs/presets/node" | "revojs/presets/deno" | "revojs/presets/bun" | "revojs/presets/cloudflare" | (string & {});
|
|
8
8
|
export type ClientConfig = {
|
|
9
9
|
entry: string;
|
|
@@ -27,3 +27,5 @@ export type App<T> = {
|
|
|
27
27
|
export declare const getRoutes: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
28
28
|
export declare const getAssets: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
29
29
|
export declare const createApp: <T>(config?: NestedPartial<Config<T>>) => App<T>;
|
|
30
|
+
export declare const SERVER = "ssr";
|
|
31
|
+
export declare const CLIENT = "client";
|
package/dist/html/index.d.ts
CHANGED
|
@@ -39,16 +39,13 @@ export type AttributeOptions<T = unknown> = {
|
|
|
39
39
|
type: T;
|
|
40
40
|
default?: Infer<T>;
|
|
41
41
|
};
|
|
42
|
-
export type ShadowRootOptions = ShadowRootInit & {
|
|
43
|
-
globalStyles?: boolean;
|
|
44
|
-
};
|
|
45
42
|
export type Events = Record<string, EventOptions>;
|
|
46
43
|
export type Attributes = Record<string, AttributeOptions>;
|
|
47
44
|
export interface ComponentOptions<TEvents extends Events, TAttributes extends Attributes> {
|
|
48
45
|
name: string;
|
|
49
46
|
events?: TEvents;
|
|
50
47
|
attributes?: TAttributes;
|
|
51
|
-
shadowRoot?:
|
|
48
|
+
shadowRoot?: ShadowRootInit;
|
|
52
49
|
styles?: Array<string>;
|
|
53
50
|
setup: (component: Component<TEvents, TAttributes>) => Slot | Promise<Slot>;
|
|
54
51
|
}
|
|
@@ -56,7 +53,7 @@ export interface Component<TEvents extends Events, TAttributes extends Attribute
|
|
|
56
53
|
readonly scope: Scope;
|
|
57
54
|
readonly events: EventOutput<TEvents>;
|
|
58
55
|
readonly attributes: State<AttributeOutput<TAttributes>>;
|
|
59
|
-
readonly shadowRoot?:
|
|
56
|
+
readonly shadowRoot?: ShadowRootInit;
|
|
60
57
|
setup: () => Slot | Promise<Slot>;
|
|
61
58
|
}
|
|
62
59
|
export interface ComponentConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
@@ -97,7 +94,6 @@ export declare const preventDefault: (event: Event) => void;
|
|
|
97
94
|
export declare const stopPropagation: (event: Event) => void;
|
|
98
95
|
export declare const stopImmediatePropagation: (event: Event) => void;
|
|
99
96
|
export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
|
|
100
|
-
export declare const globalStyles: CSSStyleSheet[];
|
|
101
97
|
export declare const HOST_CONTEXT: import("..").Descriptor<HostContext>;
|
|
102
98
|
declare global {
|
|
103
99
|
interface HTMLElementEventMap {
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,8 @@ const createApp = (config) => {
|
|
|
19
19
|
virtuals: {}
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
const SERVER = "ssr";
|
|
23
|
+
const CLIENT = "client";
|
|
22
24
|
|
|
23
25
|
//#endregion
|
|
24
26
|
//#region src/jsx/index.ts
|
|
@@ -381,7 +383,7 @@ const defineComponent = (options) => {
|
|
|
381
383
|
Reflect.set(attributes.value, name, fromValue(input?.[name]) ?? attribute.default, attributes.value);
|
|
382
384
|
return attributes;
|
|
383
385
|
}, createState({}));
|
|
384
|
-
|
|
386
|
+
this.shadowRoot = options.shadowRoot;
|
|
385
387
|
}
|
|
386
388
|
setup = () => options.setup(this);
|
|
387
389
|
}
|
|
@@ -403,10 +405,7 @@ const toCustomElement = (Component) => {
|
|
|
403
405
|
};
|
|
404
406
|
const parentNode = findParent(this.parentNode);
|
|
405
407
|
if (parentNode) this.component.scope.parentScope = parentNode.component.scope;
|
|
406
|
-
if (this.component.shadowRoot)
|
|
407
|
-
rootNode = this.shadowRoot ?? this.attachShadow(this.component.shadowRoot);
|
|
408
|
-
if (this.component.shadowRoot.globalStyles) rootNode.adoptedStyleSheets = globalStyles;
|
|
409
|
-
}
|
|
408
|
+
if (this.component.shadowRoot) rootNode = this.shadowRoot ?? this.attachShadow(this.component.shadowRoot);
|
|
410
409
|
for (const [name, event] of Object.entries(Component.$events)) Reflect.set(this.component.events, name, (value) => {
|
|
411
410
|
if (value instanceof Event) return;
|
|
412
411
|
this.dispatchEvent(new CustomEvent(name.substring(2).toLowerCase(), {
|
|
@@ -481,12 +480,6 @@ const preventDefault = (event) => event.preventDefault();
|
|
|
481
480
|
const stopPropagation = (event) => event.stopPropagation();
|
|
482
481
|
const stopImmediatePropagation = (event) => event.stopImmediatePropagation();
|
|
483
482
|
const components = new Map();
|
|
484
|
-
const globalStyles = Array.from(isClient() ? document.styleSheets : []).map((style) => {
|
|
485
|
-
const sheet = new CSSStyleSheet();
|
|
486
|
-
const css = Array.from(style.cssRules).map((rule) => rule.cssText).join(" ");
|
|
487
|
-
sheet.replaceSync(css);
|
|
488
|
-
return sheet;
|
|
489
|
-
});
|
|
490
483
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
491
484
|
|
|
492
485
|
//#endregion
|
|
@@ -907,4 +900,4 @@ const markdownToSlot = (input, options) => {
|
|
|
907
900
|
};
|
|
908
901
|
|
|
909
902
|
//#endregion
|
|
910
|
-
export { $fetch, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createEvent, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue, getAssets, getCookies, getCustomElement, getMimeType, getRequestUrl, getRoutes, getSetCookies, getVariables,
|
|
903
|
+
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createEvent, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue, getAssets, getCookies, getCustomElement, getMimeType, getRequestUrl, getRoutes, getSetCookies, getVariables, hydrate, isClient, isServer, isTemplate, markdownToSlot, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useEvent, useHost, useLocale, useRouter, useRuntime };
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,45 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
//#region ../../node_modules/defu/dist/defu.mjs
|
|
3
|
-
function isPlainObject(value) {
|
|
4
|
-
if (value === null || typeof value !== "object") return false;
|
|
5
|
-
const prototype = Object.getPrototypeOf(value);
|
|
6
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
7
|
-
if (Symbol.iterator in value) return false;
|
|
8
|
-
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
function _defu(baseObject, defaults, namespace$1 = ".", merger) {
|
|
12
|
-
if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace$1, merger);
|
|
13
|
-
const object = Object.assign({}, defaults);
|
|
14
|
-
for (const key in baseObject) {
|
|
15
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
16
|
-
const value = baseObject[key];
|
|
17
|
-
if (value === null || value === void 0) continue;
|
|
18
|
-
if (merger && merger(object, key, value, namespace$1)) continue;
|
|
19
|
-
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
20
|
-
else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace$1 ? `${namespace$1}.` : "") + key.toString(), merger);
|
|
21
|
-
else object[key] = value;
|
|
22
|
-
}
|
|
23
|
-
return object;
|
|
24
|
-
}
|
|
25
|
-
function createDefu(merger) {
|
|
26
|
-
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
27
|
-
}
|
|
28
|
-
const defu = createDefu();
|
|
29
|
-
const defuFn = createDefu((object, key, currentValue) => {
|
|
30
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
31
|
-
object[key] = currentValue(object[key]);
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const defuArrayFn = createDefu((object, key, currentValue) => {
|
|
36
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
37
|
-
object[key] = currentValue(object[key]);
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
2
|
//#region src/signals/index.ts
|
|
44
3
|
function defineContext(key) {
|
|
45
4
|
return key;
|
|
@@ -59,13 +18,6 @@ const createElement = (input, attributes, ...children) => {
|
|
|
59
18
|
}
|
|
60
19
|
return template;
|
|
61
20
|
};
|
|
62
|
-
const isClient = () => typeof window !== "undefined";
|
|
63
|
-
const globalStyles = Array.from(isClient() ? document.styleSheets : []).map((style) => {
|
|
64
|
-
const sheet = new CSSStyleSheet();
|
|
65
|
-
const css = Array.from(style.cssRules).map((rule) => rule.cssText).join(" ");
|
|
66
|
-
sheet.replaceSync(css);
|
|
67
|
-
return sheet;
|
|
68
|
-
});
|
|
69
21
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
70
22
|
|
|
71
23
|
//#endregion
|