revojs 0.0.41 → 0.0.42

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.
@@ -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?: Partial<ShadowRootOptions>;
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?: ShadowRootOptions;
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
@@ -381,7 +381,7 @@ const defineComponent = (options) => {
381
381
  Reflect.set(attributes.value, name, fromValue(input?.[name]) ?? attribute.default, attributes.value);
382
382
  return attributes;
383
383
  }, createState({}));
384
- if (options.shadowRoot) this.shadowRoot = defu(options.shadowRoot, { mode: "open" });
384
+ this.shadowRoot = options.shadowRoot;
385
385
  }
386
386
  setup = () => options.setup(this);
387
387
  }
@@ -403,10 +403,7 @@ const toCustomElement = (Component) => {
403
403
  };
404
404
  const parentNode = findParent(this.parentNode);
405
405
  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
- }
406
+ if (this.component.shadowRoot) rootNode = this.shadowRoot ?? this.attachShadow(this.component.shadowRoot);
410
407
  for (const [name, event] of Object.entries(Component.$events)) Reflect.set(this.component.events, name, (value) => {
411
408
  if (value instanceof Event) return;
412
409
  this.dispatchEvent(new CustomEvent(name.substring(2).toLowerCase(), {
@@ -481,12 +478,6 @@ const preventDefault = (event) => event.preventDefault();
481
478
  const stopPropagation = (event) => event.stopPropagation();
482
479
  const stopImmediatePropagation = (event) => event.stopImmediatePropagation();
483
480
  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
481
  const HOST_CONTEXT = defineContext("HOST_CONTEXT");
491
482
 
492
483
  //#endregion
@@ -907,4 +898,4 @@ const markdownToSlot = (input, options) => {
907
898
  };
908
899
 
909
900
  //#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, globalStyles, 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 };
901
+ 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, 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",