@furystack/shades 8.0.0 → 8.0.1

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.
Files changed (39) hide show
  1. package/esm/components/index.js +4 -0
  2. package/esm/components/index.js.map +1 -0
  3. package/esm/components/lazy-load.js +42 -0
  4. package/esm/components/lazy-load.js.map +1 -0
  5. package/esm/components/route-link.js +25 -0
  6. package/esm/components/route-link.js.map +1 -0
  7. package/esm/components/router.js +56 -0
  8. package/esm/components/router.js.map +1 -0
  9. package/esm/index.js +8 -0
  10. package/esm/index.js.map +1 -0
  11. package/esm/initialize.js +5 -0
  12. package/esm/initialize.js.map +1 -0
  13. package/esm/jsx.js +2 -0
  14. package/esm/jsx.js.map +1 -0
  15. package/esm/models/children-list.js +2 -0
  16. package/esm/models/children-list.js.map +1 -0
  17. package/esm/models/index.js +6 -0
  18. package/esm/models/index.js.map +1 -0
  19. package/esm/models/partial-element.js +2 -0
  20. package/esm/models/partial-element.js.map +1 -0
  21. package/esm/models/render-options.js +2 -0
  22. package/esm/models/render-options.js.map +1 -0
  23. package/esm/models/selection-state.js +2 -0
  24. package/esm/models/selection-state.js.map +1 -0
  25. package/esm/models/shade-component.js +9 -0
  26. package/esm/models/shade-component.js.map +1 -0
  27. package/esm/services/index.js +3 -0
  28. package/esm/services/index.js.map +1 -0
  29. package/esm/services/location-service.js +90 -0
  30. package/esm/services/location-service.js.map +1 -0
  31. package/esm/services/resource-manager.js +44 -0
  32. package/esm/services/resource-manager.js.map +1 -0
  33. package/esm/services/screen-service.js +69 -0
  34. package/esm/services/screen-service.js.map +1 -0
  35. package/esm/shade-component.js +88 -0
  36. package/esm/shade-component.js.map +1 -0
  37. package/esm/shade.js +180 -0
  38. package/esm/shade.js.map +1 -0
  39. package/package.json +5 -5
@@ -0,0 +1,4 @@
1
+ export * from './lazy-load';
2
+ export * from './router';
3
+ export * from './route-link';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { Shade } from '../shade';
2
+ export const LazyLoad = Shade({
3
+ shadowDomName: 'lazy-load',
4
+ constructed: async ({ props, useState, element }) => {
5
+ const [_component, setComponent] = useState('component', undefined);
6
+ const [_errorState, setErrorState] = useState('error', undefined);
7
+ try {
8
+ const loaded = await props.component();
9
+ element.isConnected && setComponent(loaded);
10
+ }
11
+ catch (error) {
12
+ if (props.error) {
13
+ element.isConnected && setErrorState(error);
14
+ }
15
+ else {
16
+ throw error;
17
+ }
18
+ }
19
+ },
20
+ render: ({ props, useState }) => {
21
+ const [error, setError] = useState('error', undefined);
22
+ const [component, setComponent] = useState('component', undefined);
23
+ if (error && props.error) {
24
+ return props.error(error, async () => {
25
+ try {
26
+ setError(undefined);
27
+ setComponent(undefined);
28
+ const loaded = await props.component();
29
+ setComponent(loaded);
30
+ }
31
+ catch (e) {
32
+ setError(e);
33
+ }
34
+ });
35
+ }
36
+ if (component) {
37
+ return component;
38
+ }
39
+ return props.loader;
40
+ },
41
+ });
42
+ //# sourceMappingURL=lazy-load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-load.js","sourceRoot":"","sources":["../../src/components/lazy-load.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAahC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAgB;IAC3C,aAAa,EAAE,WAAW;IAC1B,WAAW,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAClD,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA0B,WAAW,EAAE,SAAS,CAAC,CAAA;QAC5F,MAAM,CAAC,WAAW,EAAE,aAAa,C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from '..';
4
+ export const RouteLink = Shade({
5
+ shadowDomName: 'route-link',
6
+ elementBase: HTMLAnchorElement,
7
+ elementBaseName: 'a',
8
+ render: ({ children, props, injector, element }) => {
9
+ attachProps(element, {
10
+ ...props,
11
+ style: {
12
+ color: 'inherit',
13
+ textDecoration: 'inherit',
14
+ ...props.style,
15
+ },
16
+ onclick: (ev) => {
17
+ ev.preventDefault();
18
+ history.pushState('', props.title || '', props.href);
19
+ injector.getInstance(LocationService).updateState();
20
+ },
21
+ });
22
+ return createComponent(createComponent, null, children);
23
+ },
24
+ });
25
+ //# sourceMappingURL=route-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-link.js","sourceRoot":"","sources":["../../src/components/route-link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAIjD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAiB;IAC7C,aAAa,EAAE,YAAY;IAC3B,WAAW,EAAE,iBAAiB;IAC9B,eAAe,EAAE,GAAG;IACpB,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACjD,WAAW,CAAC,OAAO,EAAE;YACnB,GAAG,KAAK;YACR,KAAK,EAAE;gBACL,KAAK,EAAE,SAAS;gBAChB,cAAc,EAAE,SAAS;gBACzB,GAAG,KAAK,CAAC,KAAK;aACf;YACD,OAAO,EAAE,CAAC,EAAc,EAAE,EAAE;gBAC1B,EAAE,CAAC,cAAc,EAAE,CAAA;gBACnB,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;gBACpD,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAA;YACrD,CAAC;SACF,CAAC,CAAA;QACF,OAAO,uCAAG,QAAQ,CAAI,CAAA;IACxB,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { Shade } from '../shade';
2
+ import { createComponent } from '../shade-component';
3
+ import { LocationService } from '../services';
4
+ import { match } from 'path-to-regexp';
5
+ import { Lock } from 'semaphore-async-await';
6
+ import { ObservableAlreadyDisposedError } from '@furystack/utils';
7
+ export const Router = Shade({
8
+ shadowDomName: 'shade-router',
9
+ render: (options) => {
10
+ const { useState, useObservable, injector } = options;
11
+ const [lock] = useState('lock', new Lock());
12
+ const [state, setState] = useState('routerState', {
13
+ jsx: createComponent("div", null),
14
+ });
15
+ const updateUrl = async (currentUrl) => {
16
+ const [lastState] = useState('routerState', state);
17
+ const { activeRoute: lastRoute, activeRouteParams: lastRouteParams, jsx: lastJsx } = lastState;
18
+ try {
19
+ await lock.acquire();
20
+ for (const route of options.props.routes) {
21
+ const matchFn = match(route.url, route.routingOptions);
22
+ const matchResult = matchFn(currentUrl);
23
+ if (matchResult) {
24
+ if (route !== lastRoute || JSON.stringify(lastRouteParams) !== JSON.stringify(matchResult.params)) {
25
+ await lastRoute?.onLeave?.({ ...options, element: lastState.jsx });
26
+ const newJsx = route.component({ currentUrl, match: matchResult });
27
+ setState({ jsx: newJsx, activeRoute: route, activeRouteParams: matchResult.params });
28
+ await route.onVisit?.({ ...options, element: newJsx });
29
+ }
30
+ return;
31
+ }
32
+ }
33
+ if (lastRoute?.onLeave) {
34
+ await lastRoute.onLeave({ ...options, element: lastJsx });
35
+ }
36
+ setState({
37
+ jsx: options.props.notFound || createComponent("div", null),
38
+ activeRoute: null,
39
+ activeRouteParams: null,
40
+ });
41
+ }
42
+ catch (e) {
43
+ // path updates can be async, this can be ignored
44
+ if (!(e instanceof ObservableAlreadyDisposedError)) {
45
+ throw e;
46
+ }
47
+ }
48
+ finally {
49
+ lock?.release();
50
+ }
51
+ };
52
+ useObservable('locationPathChanged', injector.getInstance(LocationService).onLocationPathChanged, updateUrl, true);
53
+ return state.jsx;
54
+ },
55
+ });
56
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/components/router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAqBjE,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAc;IACvC,aAAa,EAAE,cAAc;IAC7B,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;QACrD,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAc,aAAa,EAAE;YAC7D,GAAG,EAAE,4BAAO;SACb,CAAC,CAAA;QAEF,MAAM,SAAS,GAAG,KAAK,EAAE,UAAkB,EAAE,EAAE;YAC7C,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAc,aAAa,EAAE,KAAK,CAAC,CAAA;YAC/D,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;YAC9F,IAAI;gBACF,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;gBACpB,KAAK,MAAM,KAAK,IAA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CAAC,CAAA;iBACR;aACF;oBAAS;gBACR,IAAI,EAAE,OAAO,EAAE,CAAA;aAChB;QACH,CAAC,CAAA;QAED,aAAa,CAAC,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QAClH,OAAO,KAAK,CAAC,GAAG,CAAA;IAClB,CAAC;CACF,CAAC,CAAA"}
package/esm/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './services';
2
+ import './jsx';
3
+ export * from './shade-component';
4
+ export * from './shade';
5
+ export * from './models';
6
+ export * from './components';
7
+ export * from './initialize';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,OAAO,CAAA;AACd,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const initializeShadeRoot = (options) => {
2
+ options.jsxElement.injector = options.injector;
3
+ options.rootElement.appendChild(options.jsxElement);
4
+ };
5
+ //# sourceMappingURL=initialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAA0B,EAAE,EAAE;IAChE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;IAC9C,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACrD,CAAC,CAAA"}
package/esm/jsx.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsx.js.map
package/esm/jsx.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx.js","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=children-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"children-list.js","sourceRoot":"","sources":["../../src/models/children-list.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from './children-list';
2
+ export * from './partial-element';
3
+ export * from './render-options';
4
+ export * from './selection-state';
5
+ export * from './shade-component';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=partial-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial-element.js","sourceRoot":"","sources":["../../src/models/partial-element.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../src/models/render-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=selection-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection-state.js","sourceRoot":"","sources":["../../src/models/selection-state.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type guard that checks if an object is a stateless component
3
+ * @param obj The object to check
4
+ * @returns a value that indicates if the object is a Shade component
5
+ */
6
+ export const isShadeComponent = (obj) => {
7
+ return typeof obj === 'function';
8
+ };
9
+ //# sourceMappingURL=shade-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shade-component.js","sourceRoot":"","sources":["../../src/models/shade-component.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAA8B,EAAE;IACvE,OAAO,OAAO,GAAG,KAAK,UAAU,CAAA;AAClC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './location-service';
2
+ export * from './screen-service';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,90 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ObservableValue, Trace } from '@furystack/utils';
11
+ import { Injectable } from '@furystack/inject';
12
+ import { deserializeQueryString, serializeToQueryString } from '@furystack/rest';
13
+ let LocationService = class LocationService {
14
+ dispose() {
15
+ window.removeEventListener('popstate', this.updateState);
16
+ window.removeEventListener('hashchange', this.updateState);
17
+ this.pushStateTracer.dispose();
18
+ this.replaceStateTracer.dispose();
19
+ this.onLocationPathChanged.dispose();
20
+ this.onLocationSearchChanged.dispose();
21
+ this.onDeserializedLocationSearchChanged.dispose();
22
+ this.locationDeserializerObserver.dispose();
23
+ }
24
+ updateState() {
25
+ this.onLocationPathChanged.setValue(location.pathname);
26
+ this.onLocationHashChanged.setValue(location.hash);
27
+ this.onLocationSearchChanged.setValue(location.search);
28
+ }
29
+ /**
30
+ *
31
+ * @param key The search param key (e.g. ?search=1 -> search)
32
+ * @param defaultValue The default value if not provided
33
+ * @returns An observable with the current value (or default value) of the search param
34
+ */
35
+ useSearchParam(key, defaultValue) {
36
+ const actualValue = this.onDeserializedLocationSearchChanged.getValue()[key] ?? defaultValue;
37
+ if (!this.searchParamObservables.has(key)) {
38
+ const newObservable = new ObservableValue(actualValue);
39
+ this.searchParamObservables.set(key, newObservable);
40
+ newObservable.subscribe((value) => {
41
+ const params = serializeToQueryString({ ...deserializeQueryString(location.search), [key]: value });
42
+ history.pushState({}, '', `${location.pathname}?${params}`);
43
+ });
44
+ this.onDeserializedLocationSearchChanged.subscribe((search) => {
45
+ const value = search[key] ?? defaultValue;
46
+ this.searchParamObservables.get(key)?.setValue(value);
47
+ });
48
+ }
49
+ return this.searchParamObservables.get(key);
50
+ }
51
+ constructor() {
52
+ /**
53
+ * Observable value that will be updated when the location pathname (e.g. /page/1) changes
54
+ */
55
+ this.onLocationPathChanged = new ObservableValue(new URL(location.href).pathname);
56
+ /**
57
+ * Observable value that will be updated when the location hash (e.g. #hash) changes
58
+ */
59
+ this.onLocationHashChanged = new ObservableValue(location.hash);
60
+ /**
61
+ * Observable value that will be updated when the location search (e.g. ?search=1) changes
62
+ */
63
+ this.onLocationSearchChanged = new ObservableValue(location.search);
64
+ this.onDeserializedLocationSearchChanged = new ObservableValue(deserializeQueryString(this.onLocationSearchChanged.getValue()));
65
+ this.locationDeserializerObserver = this.onLocationSearchChanged.subscribe((search) => {
66
+ this.onDeserializedLocationSearchChanged.setValue(deserializeQueryString(search));
67
+ });
68
+ this.searchParamObservables = new Map();
69
+ window.addEventListener('popstate', () => this.updateState());
70
+ window.addEventListener('hashchange', () => this.updateState());
71
+ this.pushStateTracer = Trace.method({
72
+ object: history,
73
+ method: history.pushState,
74
+ isAsync: false,
75
+ onFinished: () => this.updateState(),
76
+ });
77
+ this.replaceStateTracer = Trace.method({
78
+ object: history,
79
+ method: history.replaceState,
80
+ isAsync: false,
81
+ onFinished: () => this.updateState(),
82
+ });
83
+ }
84
+ };
85
+ LocationService = __decorate([
86
+ Injectable({ lifetime: 'singleton' }),
87
+ __metadata("design:paramtypes", [])
88
+ ], LocationService);
89
+ export { LocationService };
90
+ //# sourceMappingURL=location-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location-service.js","sourceRoot":"","sources":["../../src/services/location-service.tsx"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAChF,IACa,eAAe,GAD5B,MACa,eAAe;IACnB,OAAO;QACZ,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACxD,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAC1D,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;QAC9B,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAA;QACjC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAA;QACpC,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAA;QACtC,IAAI,CAAC,mCAAmC,CAAC,OAAO,EAAE,CAAA;QAClD,IAAI,CAAC,4BAA4B,CAAC,OAAO,EAAE,CAAA;IAC7C,CAAC;IAyBM,WAAW;QAChB,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QACtD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,C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U,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;;GACzB,eAAe,CAyF3B;SAzFY,eAAe"}
@@ -0,0 +1,44 @@
1
+ import { ObservableValue } from '@furystack/utils';
2
+ /**
3
+ * Class for managing observables and disposables for components, based on key-value maps
4
+ */
5
+ export class ResourceManager {
6
+ constructor() {
7
+ this.disposables = new Map();
8
+ this.observers = new Map();
9
+ this.useObservable = (key, observable, callback, getLast) => {
10
+ const alreadyUsed = this.observers.get(key);
11
+ if (alreadyUsed) {
12
+ return [alreadyUsed.observable.getValue(), alreadyUsed.observable.setValue.bind(alreadyUsed.observable)];
13
+ }
14
+ const observer = observable.subscribe(callback, getLast);
15
+ this.observers.set(key, observer);
16
+ return [observable.getValue(), observable.setValue.bind(observable)];
17
+ };
18
+ this.stateObservers = new Map();
19
+ this.useState = (key, initialValue, callback) => {
20
+ if (!this.stateObservers.has(key)) {
21
+ const newObservable = new ObservableValue(initialValue);
22
+ this.stateObservers.set(key, newObservable);
23
+ newObservable.subscribe(callback);
24
+ }
25
+ const observable = this.stateObservers.get(key);
26
+ return [observable.getValue(), observable.setValue.bind(observable)];
27
+ };
28
+ }
29
+ useDisposable(key, factory) {
30
+ if (!this.disposables.has(key)) {
31
+ this.disposables.set(key, factory());
32
+ }
33
+ return this.disposables.get(key);
34
+ }
35
+ dispose() {
36
+ this.disposables.forEach((r) => r.dispose());
37
+ this.disposables.clear();
38
+ this.observers.forEach((r) => r.dispose());
39
+ this.observers.clear();
40
+ this.stateObservers.forEach((r) => r.dispose());
41
+ this.stateObservers.clear();
42
+ }
43
+ }
44
+ //# sourceMappingURL=resource-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-manager.js","sourceRoot":"","sources":["../../src/services/resource-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAIlD;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QACmB,gBAAW,GAAG,IAAI,GAAG,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CAAC,CAAC,CAAA;QACtE,CAAC,CAAA;IAWH,CAAC;IAjDQ,aAAa,CAAuB,GAAW,EAAE,OAAgB;QACtE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC9B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;SACrC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAM,CAAA;IACvC,CAAC;IAmCM,OAAO;QACZ,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC5C,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC1C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QAEtB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/C,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Injectable } from '@furystack/inject';
11
+ import { ObservableValue } from '@furystack/utils';
12
+ export const ScreenSizes = ['xs', 'sm', 'md', 'lg', 'xl'];
13
+ /**
14
+ * Service for handling screen size changes
15
+ */
16
+ let ScreenService = class ScreenService {
17
+ dispose() {
18
+ window.removeEventListener('resize', this.onResizeListener);
19
+ }
20
+ screenSizeAtLeast(size) {
21
+ return window.innerWidth >= this.breakpoints[size].minSize;
22
+ }
23
+ refreshValues() {
24
+ this.orientation.setValue(this.getOrientation());
25
+ ScreenSizes.forEach((size) => {
26
+ this.screenSize.atLeast[size].setValue(this.screenSizeAtLeast(size));
27
+ });
28
+ }
29
+ constructor() {
30
+ this.getOrientation = () => (window.matchMedia?.('(orientation:landscape').matches ? 'landscape' : 'portrait');
31
+ /**
32
+ * The definitions of the breakpoints
33
+ */
34
+ this.breakpoints = {
35
+ xl: { minSize: 1920 },
36
+ lg: { minSize: 1280 },
37
+ md: { minSize: 960 },
38
+ sm: { minSize: 600 },
39
+ xs: { minSize: 0 },
40
+ };
41
+ /**
42
+ * Observers for the current screen size. Will refresh on resize
43
+ */
44
+ this.screenSize = {
45
+ atLeast: {
46
+ xs: new ObservableValue(this.screenSizeAtLeast('xs')),
47
+ sm: new ObservableValue(this.screenSizeAtLeast('sm')),
48
+ md: new ObservableValue(this.screenSizeAtLeast('md')),
49
+ lg: new ObservableValue(this.screenSizeAtLeast('lg')),
50
+ xl: new ObservableValue(this.screenSizeAtLeast('xl')),
51
+ },
52
+ };
53
+ /**
54
+ * Observable value for tracking the screen orientation
55
+ */
56
+ this.orientation = new ObservableValue(this.getOrientation());
57
+ this.onResizeListener = () => {
58
+ this.refreshValues();
59
+ };
60
+ window.addEventListener('resize', this.onResizeListener);
61
+ this.refreshValues();
62
+ }
63
+ };
64
+ ScreenService = __decorate([
65
+ Injectable({ lifetime: 'singleton' }),
66
+ __metadata("design:paramtypes", [])
67
+ ], ScreenService);
68
+ export { ScreenService };
69
+ //# sourceMappingURL=screen-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-service.js","sourceRoot":"","sources":["../../src/services/screen-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AAMlE;;GAEG;AACH,IACa,aAAa,GAD1B,MACa,aAAa;IAcjB,OAAO;QACZ,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAC7D,CAAC;IAiBO,iBAAiB,CAAC,IAAgB;QACxC,OAAO,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAA;IAC5D,CAAC;IAWO,aAAa;QACnB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAA;QAChD,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;QApDQ,mBAAc,GAAG,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;QAEjH;;WAEG;QACa,gBAAW,GAA+C;YACxE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YACrB,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YACrB,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;YACpB,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;YACpB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;SACnB,CAAA;QAMD;;WAEG;QACa,eAAU,GAEtB;YACF,OAAO,EAAE;gBACP,EAAE,EAAE,IAAI,eAAe,CAAU,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC9D,EAAE,EAAE,IAAI,eAAe,CAAU,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC9D,EAAE,EAAE,IAAI,eAAe,CAAU,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC9D,EAAE,EAAE,IAAI,eAAe,CAAU,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC9D,EAAE,EAAE,IAAI,eAAe,CAAU,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC/D;SACF,CAAA;QAMD;;WAEG;QACI,gBAAW,GAAG,IAAI,eAAe,CAA2B,IAAI,CAAC,cAAc,EAAE,CAAC,CAAA;QAEjF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,aAAa,EAAE,CAAA;QACtB,CAAC,CAAA;QAUC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACxD,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;CACF,CAAA;AAzDY,aAAa;IADzB,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;;GACzB,aAAa,CAyDzB;SAzDY,aAAa"}
@@ -0,0 +1,88 @@
1
+ import { isShadeComponent } from './models';
2
+ /**
3
+ * Appends a list of items to a HTML element
4
+ * @param el the root element
5
+ * @param children array of items to append
6
+ */
7
+ export const appendChild = (el, children) => {
8
+ for (const child of children) {
9
+ if (typeof child === 'string' || typeof child === 'number') {
10
+ el.appendChild(document.createTextNode(child));
11
+ }
12
+ else {
13
+ if (child instanceof HTMLElement || child instanceof DocumentFragment) {
14
+ el.appendChild(child);
15
+ }
16
+ else if (child instanceof Array) {
17
+ appendChild(el, child);
18
+ }
19
+ }
20
+ }
21
+ };
22
+ export const hasStyle = (props) => {
23
+ return props?.style !== undefined;
24
+ };
25
+ /**
26
+ * @param el The Target HTML Element
27
+ * @param props The Properties to fetch The Styles Object
28
+ */
29
+ export const attachStyles = (el, props) => {
30
+ if (hasStyle(props))
31
+ for (const key in props.style) {
32
+ if (Object.prototype.hasOwnProperty.call(props.style, key)) {
33
+ ;
34
+ el.style[key] = props.style[key];
35
+ }
36
+ }
37
+ };
38
+ export const attachDataAttributes = (el, props) => {
39
+ props &&
40
+ Object.entries(props)
41
+ .filter(([key]) => key.startsWith('data-'))
42
+ .forEach(([key, value]) => el.setAttribute(key, value || ''));
43
+ };
44
+ /**
45
+ *
46
+ * @param el The Target HTML Element
47
+ * @param props The Props to attach
48
+ */
49
+ export const attachProps = (el, props) => {
50
+ Object.assign(el, props);
51
+ if (props && props.style) {
52
+ attachStyles(el, props);
53
+ }
54
+ attachDataAttributes(el, props);
55
+ };
56
+ // eslint-disable-next-line jsdoc/require-param
57
+ /**
58
+ * Factory method that creates a component. This should be configured as a default JSX Factory in tsconfig.
59
+ * @returns the created JSX element
60
+ */
61
+ export const createComponentInner = (...[elementType, props, ...children]) => {
62
+ if (typeof elementType === 'string') {
63
+ const el = document.createElement(elementType);
64
+ attachProps(el, props);
65
+ if (children) {
66
+ appendChild(el, children);
67
+ }
68
+ return el;
69
+ }
70
+ else if (isShadeComponent(elementType)) {
71
+ const el = elementType(props, children);
72
+ attachStyles(el, props);
73
+ return el;
74
+ }
75
+ return undefined;
76
+ };
77
+ export const createFragmentInner = (...[_props, ...children]) => {
78
+ const fragment = document.createDocumentFragment();
79
+ appendChild(fragment, children);
80
+ return fragment;
81
+ };
82
+ export const createComponent = (...args) => {
83
+ if (args[0] === null) {
84
+ return createFragmentInner(...args);
85
+ }
86
+ return createComponentInner(...args);
87
+ };
88
+ //# sourceMappingURL=shade-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shade-component.js","sourceRoot":"","sources":["../src/shade-component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAkC,EAAE,QAAsB,EAAE,EAAE;IACxF,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;QAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC1D,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;SAC/C;aAAM;YACL,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,YAAY,gBAAgB,EAAE;gBACrE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;aACtB;iBAAM,IAAI,KAAK,YAAY,KAAK,EAAE;gBACjC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;aACvB;SACF;KACF;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAoD,EAAE;IACvF,OAAO,KAAK,EAAE,KAAK,KAAK,SAAS,CAAA;AACnC,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAe,EAAE,KAAU,EAAE,EAAE;IAC1D,IAAI,QAAQ,CAAC,KAAK,CAAC;QACjB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE;YAC7B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;gBAC1D,CAAC;gBAAC,EAAE,CAAC,KAAa,CAAC,GAA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C,WAAW,CAAC,EAAE;QACxC,MAAM,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACvC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QACvB,OAAO,EAAE,CAAA;KACV;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAID,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAqB,EAAE,EAAE;IAClF,MAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAA;IAClD,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC/B,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAS,GAAG,IAAsD,EAAE,EAAE;IACnG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAA;KACpC;IACD,OAAO,oBAAoB,CAAC,GAAG,IAAI,CAAC,CAAA;AACtC,CAAC,CAAA"}
package/esm/shade.js ADDED
@@ -0,0 +1,180 @@
1
+ import { ObservableValue } from '@furystack/utils';
2
+ import { Injector } from '@furystack/inject';
3
+ import { ResourceManager } from './services/resource-manager';
4
+ import { LocationService } from './services';
5
+ /**
6
+ * Factory method for creating Shade components
7
+ * @param o for component creation
8
+ * @returns the JSX element
9
+ */
10
+ export const Shade = (o) => {
11
+ // register shadow-dom element
12
+ const customElementName = o.shadowDomName;
13
+ const existing = customElements.get(customElementName);
14
+ if (!existing) {
15
+ const ElementBase = o.elementBase || HTMLElement;
16
+ customElements.define(customElementName, class extends ElementBase {
17
+ constructor() {
18
+ super(...arguments);
19
+ this._renderCount = 0;
20
+ this.resourceManager = new ResourceManager();
21
+ /**
22
+ * @param options Options for rendering the component
23
+ * @returns the JSX element
24
+ */
25
+ this.render = (options) => {
26
+ this._renderCount++;
27
+ return o.render(options);
28
+ };
29
+ /**
30
+ * @returns values for the current render options
31
+ */
32
+ this.getRenderOptions = () => {
33
+ const renderOptions = {
34
+ props: this.props,
35
+ injector: this.injector,
36
+ children: this.shadeChildren,
37
+ element: this,
38
+ useObservable: (key, obesrvable, callback, getLast) => this.resourceManager.useObservable(key, obesrvable, callback || (() => this.updateComponent()), getLast),
39
+ useState: (key, initialValue) => this.resourceManager.useState(key, initialValue, this.updateComponent.bind(this)),
40
+ useSearchState: (key, initialValue) => this.resourceManager.useObservable(`useSearchState-${key}`, this.injector.getInstance(LocationService).useSearchParam(key, initialValue), () => this.updateComponent()),
41
+ useStoredState: (key, initialValue, storageArea = localStorage) => {
42
+ const getFromStorage = () => {
43
+ const value = storageArea?.getItem(key);
44
+ return value ? JSON.parse(value) : initialValue;
45
+ };
46
+ const setToStorage = (value) => {
47
+ if (JSON.stringify(value) !== storageArea?.getItem(key)) {
48
+ const newValue = JSON.stringify(value);
49
+ storageArea?.setItem(key, newValue);
50
+ }
51
+ if (JSON.stringify(observable.getValue()) !== JSON.stringify(value)) {
52
+ observable.setValue(value);
53
+ }
54
+ };
55
+ const observable = this.resourceManager.useDisposable(`useStoredState-${key}`, () => new ObservableValue(getFromStorage()));
56
+ const updateFromStorageEvent = (e) => {
57
+ e.key === key &&
58
+ e.storageArea === storageArea &&
59
+ setToStorage((e.newValue && JSON.parse(e.newValue)) || initialValue);
60
+ };
61
+ this.resourceManager.useDisposable(`useStoredState-${key}-storage-event`, () => {
62
+ window.addEventListener('storage', updateFromStorageEvent);
63
+ const channelName = `useStoredState-broadcast-channel`;
64
+ const messageChannel = new BroadcastChannel(channelName);
65
+ messageChannel.onmessage = (e) => {
66
+ if (e.data.key === key) {
67
+ setToStorage(e.data.value);
68
+ }
69
+ };
70
+ const subscription = observable.subscribe((value) => {
71
+ messageChannel.postMessage({ key, value });
72
+ });
73
+ return {
74
+ dispose: () => {
75
+ window.removeEventListener('storage', updateFromStorageEvent);
76
+ subscription.dispose();
77
+ messageChannel.close();
78
+ },
79
+ };
80
+ });
81
+ observable.subscribe(setToStorage);
82
+ return this.resourceManager.useObservable(`useStoredState-${key}`, observable, () => this.updateComponent());
83
+ },
84
+ useDisposable: this.resourceManager.useDisposable.bind(this.resourceManager),
85
+ };
86
+ return renderOptions;
87
+ };
88
+ this.cleanup = undefined;
89
+ }
90
+ /**
91
+ * @returns the current render count
92
+ */
93
+ getRenderCount() {
94
+ return this._renderCount;
95
+ }
96
+ connectedCallback() {
97
+ o.onAttach?.(this.getRenderOptions());
98
+ this.callConstructed();
99
+ }
100
+ disconnectedCallback() {
101
+ o.onDetach?.(this.getRenderOptions());
102
+ this.resourceManager.dispose();
103
+ this.cleanup?.();
104
+ }
105
+ /**
106
+ * Updates the component in the DOM.
107
+ */
108
+ updateComponent() {
109
+ const renderResult = this.render(this.getRenderOptions());
110
+ if (renderResult === null || renderResult === undefined) {
111
+ this.innerHTML = '';
112
+ }
113
+ if (typeof renderResult === 'string' || typeof renderResult === 'number') {
114
+ this.innerHTML = renderResult;
115
+ }
116
+ if (renderResult instanceof HTMLElement) {
117
+ this.replaceChildren(renderResult);
118
+ }
119
+ if (renderResult instanceof DocumentFragment) {
120
+ this.replaceChildren(renderResult);
121
+ }
122
+ }
123
+ /**
124
+ * Finialize the component initialization after it gets the Props. Called by the framework internally
125
+ */
126
+ callConstructed() {
127
+ this.updateComponent();
128
+ const cleanupResult = o.constructed && o.constructed(this.getRenderOptions());
129
+ if (cleanupResult instanceof Promise) {
130
+ cleanupResult.then((cleanup) => (this.cleanup = cleanup));
131
+ }
132
+ else {
133
+ // construct is not async
134
+ this.cleanup = cleanupResult;
135
+ }
136
+ }
137
+ getInjectorFromParent() {
138
+ let parent = this.parentElement;
139
+ while (parent) {
140
+ if (parent.injector) {
141
+ return parent.injector;
142
+ }
143
+ parent = parent.parentElement;
144
+ }
145
+ }
146
+ get injector() {
147
+ if (this._injector) {
148
+ return this._injector;
149
+ }
150
+ const fromProps = this.props?.injector;
151
+ if (fromProps && fromProps instanceof Injector) {
152
+ return fromProps;
153
+ }
154
+ const fromParent = this.getInjectorFromParent();
155
+ if (fromParent) {
156
+ this._injector = fromParent;
157
+ return fromParent;
158
+ }
159
+ // Injector not set explicitly and not found on parents!
160
+ return new Injector();
161
+ }
162
+ set injector(i) {
163
+ this._injector = i;
164
+ }
165
+ }, o.elementBaseName ? { extends: o.elementBaseName } : undefined);
166
+ }
167
+ else {
168
+ throw Error(`A custom shade with shadow DOM name '${o.shadowDomName}' has already been registered!`);
169
+ }
170
+ return (props, children) => {
171
+ const ElementType = customElements.get(customElementName);
172
+ const el = new ElementType({
173
+ ...props,
174
+ });
175
+ el.props = props || {};
176
+ el.shadeChildren = children;
177
+ return el;
178
+ };
179
+ };
180
+ //# sourceMappingURL=shade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shade.js","sourceRoot":"","sources":["../src/shade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA8C5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAS,CAAuB,EAAE,EAAE;IACvD,8BAA8B;IAC9B,MAAM,iBAAiB,GAAG,CAAC,CAAC,aAAa,CAAA;IAEzC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IACtD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,WAAW,CAAA;QAEhD,cAAc,CAAC,MAAM,CACnB,iBAAiB,EACjB,KAAM,SAAQ,WAAW;YAAzB;;gBACU,iBAAY,GAAG,CAAC,CAAA;gBASjB,oBAAe,GAAG,IAAI,eAAe,EAAE,CAAA;gBAuB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,CAAC,KAAK,GAAG,KAAK,IAAK,EAAa,CAAA;QAClC,EAAE,CAAC,aAAa,GAAG,QAAQ,CAAA;QAC3B,OAAO,EAAiB,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furystack/shades",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Google Authentication Provider for FuryStack",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "files": [
24
- "dist",
24
+ "esm",
25
25
  "types",
26
26
  "src"
27
27
  ],
@@ -53,9 +53,9 @@
53
53
  "vitest": "^0.30.1"
54
54
  },
55
55
  "dependencies": {
56
- "@furystack/inject": "^8.0.0",
57
- "@furystack/rest": "^5.0.0",
58
- "@furystack/utils": "^4.0.0",
56
+ "@furystack/inject": "^8.0.1",
57
+ "@furystack/rest": "^5.0.1",
58
+ "@furystack/utils": "^4.0.1",
59
59
  "path-to-regexp": "^6.2.1",
60
60
  "semaphore-async-await": "^1.5.1"
61
61
  },