Skip to content

Commit fdd9487

Browse files
refactor: run formatter
1 parent 8eb1d26 commit fdd9487

File tree

13 files changed

+7686
-2653
lines changed

13 files changed

+7686
-2653
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
export { qwikify$, qwikifyQrl } from './lib/qwikify';
22

3-
export type { QwikifyProps, QwikifiedComponentProps, WithRequiredProps } from './lib/types';
3+
export type {
4+
QwikifyProps,
5+
QwikifiedComponentProps,
6+
WithRequiredProps,
7+
} from './lib/types';

packages/qwik-angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './index.qwik';
1+
export * from './index.qwik';

packages/qwik-angular/src/lib/client.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ export class ClientRenderer {
3333

3434
private initialized = false;
3535

36-
constructor(private component: Type<unknown>, private initialProps: Record<string, unknown>) {}
37-
38-
async render(hostElement: Element, slot: Element | undefined, props = this.initialProps) {
36+
constructor(
37+
private component: Type<unknown>,
38+
private initialProps: Record<string, unknown>
39+
) {}
40+
41+
async render(
42+
hostElement: Element,
43+
slot: Element | undefined,
44+
props = this.initialProps
45+
) {
3946
await this.loadZoneJs();
4047
try {
4148
this.appRef = await createApplication({
@@ -51,7 +58,10 @@ export class ClientRenderer {
5158
this.mirror = reflectComponentType(this.component);
5259

5360
const projectableNodes =
54-
slot && extractProjectableNodes(slot, [...(this.mirror?.ngContentSelectors ?? [])]);
61+
slot &&
62+
extractProjectableNodes(slot, [
63+
...(this.mirror?.ngContentSelectors ?? []),
64+
]);
5565

5666
this.componentRef = createComponent(this.component, {
5767
environmentInjector: this.appRef!.injector,
@@ -109,10 +119,16 @@ export class ClientRenderer {
109119
return;
110120
}
111121

112-
const eventEmitters = this.mirror.outputs.map(({ propName, templateName }) => {
113-
const emitter = (this.componentRef.instance as any)[propName] as EventEmitter<any>;
114-
return emitter.pipe(map((value: any) => ({ name: templateName, value })));
115-
});
122+
const eventEmitters = this.mirror.outputs.map(
123+
({ propName, templateName }) => {
124+
const emitter = (this.componentRef.instance as any)[
125+
propName
126+
] as EventEmitter<any>;
127+
return emitter.pipe(
128+
map((value: any) => ({ name: templateName, value }))
129+
);
130+
}
131+
);
116132
const outputEvents = merge(...eventEmitters);
117133
// listen for events from the merged stream and dispatch them as custom events
118134
outputEvents.pipe(takeUntil(this.onDestroy$)).subscribe((e) => {

packages/qwik-angular/src/lib/extract-projectable-nodes.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// source: https://github.com/angular/angular/blob/d1ea1f4c7f3358b730b0d94e65b00bc28cae279c/packages/elements/src/extract-projectable-nodes.ts
22
// this util is not exposed from the Angular package, thus copying it here
33

4-
export function extractProjectableNodes(host: Element, ngContentSelectors: string[]): Node[][] {
4+
export function extractProjectableNodes(
5+
host: Element,
6+
ngContentSelectors: string[]
7+
): Node[][] {
58
const nodes = host.childNodes;
69
const projectableNodes: Node[][] = ngContentSelectors.map(() => []);
710
let wildcardIndex = -1;
@@ -16,7 +19,11 @@ export function extractProjectableNodes(host: Element, ngContentSelectors: strin
1619

1720
for (let i = 0, ii = nodes.length; i < ii; ++i) {
1821
const node = nodes[i];
19-
const ngContentIndex = findMatchingIndex(node, ngContentSelectors, wildcardIndex);
22+
const ngContentIndex = findMatchingIndex(
23+
node,
24+
ngContentSelectors,
25+
wildcardIndex
26+
);
2027

2128
if (ngContentIndex !== -1) {
2229
projectableNodes[ngContentIndex].push(node);
@@ -26,7 +33,11 @@ export function extractProjectableNodes(host: Element, ngContentSelectors: strin
2633
return projectableNodes;
2734
}
2835

29-
function findMatchingIndex(node: Node, selectors: string[], defaultIndex: number): number {
36+
function findMatchingIndex(
37+
node: Node,
38+
selectors: string[],
39+
defaultIndex: number
40+
): number {
3041
let matchingIndex = defaultIndex;
3142

3243
if (isElement(node)) {
@@ -62,7 +73,9 @@ function matchesSelector(el: any, selector: string): boolean {
6273
elProto.oMatchesSelector ||
6374
elProto.webkitMatchesSelector;
6475
}
65-
return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;
76+
return el.nodeType === Node.ELEMENT_NODE
77+
? _matches.call(el, selector)
78+
: false;
6679
}
6780

6881
/**

packages/qwik-angular/src/lib/qwikify.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ export function qwikifyQrl<PROPS extends {}>(
8383
hostRef.value = el;
8484
if (isBrowser && internalState.value) {
8585
internalState.value.renderer &&
86-
(await internalState.value.renderer.render(el, slotRef.value, props));
86+
(await internalState.value.renderer.render(
87+
el,
88+
slotRef.value,
89+
props
90+
));
8791
}
8892
});
8993
}}

packages/qwik-angular/src/lib/server.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ const create = ɵRender3ComponentFactory.prototype.create;
3434
environmentInjector?: any
3535
) {
3636
if (projectableNodesMap.has(this.componentType)) {
37-
const document_local: typeof document = this['ngModule'].injector.get(DOCUMENT);
37+
const document_local: typeof document =
38+
this['ngModule'].injector.get(DOCUMENT);
3839
const slotComment = document_local.createComment(SLOT_MARK);
3940
projectableNodes = [[slotComment]]; // TODO: support multiple ng-content
4041
}
41-
return create.call(this, injector, projectableNodes, rootSelectorOrNode, environmentInjector);
42+
return create.call(
43+
this,
44+
injector,
45+
projectableNodes,
46+
rootSelectorOrNode,
47+
environmentInjector
48+
);
4249
};
4350

4451
const QWIK_ANGULAR_STATIC_PROPS = new InjectionToken<{
@@ -73,7 +80,8 @@ const STATIC_PROPS_HOOK_PROVIDER: Provider = {
7380
// because there might be additional props
7481
// that aren't actually Input defined on the Component
7582
mirror.inputs.some(
76-
({ templateName, propName }) => templateName === key || propName === key
83+
({ templateName, propName }) =>
84+
templateName === key || propName === key
7785
)
7886
) {
7987
compRef.setInput(key, value);

packages/qwik-angular/src/lib/slot.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const getHostProps = (props: Record<string, any>): Record<string, any> => {
1+
export const getHostProps = (
2+
props: Record<string, any>
3+
): Record<string, any> => {
24
const obj: Record<string, any> = {};
35
Object.keys(props).forEach((key) => {
46
if (key.startsWith(HOST_PREFIX)) {
@@ -8,7 +10,9 @@ export const getHostProps = (props: Record<string, any>): Record<string, any> =>
810
return obj;
911
};
1012

11-
export const getAngularProps = (props: Record<string, any>): Record<string, any> => {
13+
export const getAngularProps = (
14+
props: Record<string, any>
15+
): Record<string, any> => {
1216
const obj: Record<string, any> = {};
1317
Object.keys(props).forEach((key) => {
1418
if (!key.startsWith('client:') && !key.startsWith(HOST_PREFIX)) {

packages/qwik-angular/src/lib/types.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export interface QwikifyBase {
7777
'host:onMouseOver$'?: PropFunction<(ev: Event) => void>;
7878
}
7979

80-
export type QwikifyProps<PROPS extends Record<string, any>> = PROPS & QwikifyBase;
80+
export type QwikifyProps<PROPS extends Record<string, any>> = PROPS &
81+
QwikifyBase;
8182

8283
export interface QwikifyOptions {
8384
tagName?: string;
@@ -89,9 +90,10 @@ export interface QwikifyOptions {
8990
type TransformKey<K> = K extends string ? `${K}$` : K;
9091

9192
type QwikifiedOutputs<ComponentType, Props extends keyof ComponentType> = {
92-
[K in keyof Pick<ComponentType, Props> as TransformKey<K>]: ComponentType[K] extends EventEmitter<
93-
infer V
94-
>
93+
[K in keyof Pick<
94+
ComponentType,
95+
Props
96+
> as TransformKey<K>]: ComponentType[K] extends EventEmitter<infer V>
9597
? (value: V) => void
9698
: never;
9799
};
@@ -145,7 +147,9 @@ export type QwikifiedComponentProps<
145147
ComponentType,
146148
Inputs extends keyof ComponentType = never,
147149
Outputs extends keyof ComponentType = never
148-
> = Partial<Pick<ComponentType, Inputs> & QwikifiedOutputs<ComponentType, Outputs>>;
150+
> = Partial<
151+
Pick<ComponentType, Inputs> & QwikifiedOutputs<ComponentType, Outputs>
152+
>;
149153

150154
/**
151155
* Marks provided keys `K` of type `T` as required
@@ -167,4 +171,5 @@ export type QwikifiedComponentProps<
167171
* }
168172
* ```
169173
*/
170-
export type WithRequiredProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
174+
export type WithRequiredProps<T, K extends keyof T> = Omit<T, K> &
175+
Required<Pick<T, K>>;

packages/qwik-angular/src/lib/vite-plugin/vite.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,31 @@ function analogQwikPlugin(options: PluginOptions) {
4949
return {
5050
optimizeDeps: {
5151
include: [
52-
"@angular/core",
53-
"@angular/platform-browser",
54-
"@angular/platform-browser/animations",
55-
"@angular/compiler",
56-
"@angular/common",
57-
"@angular/animations",
58-
"@angular/animations/browser",
52+
'@angular/core',
53+
'@angular/platform-browser',
54+
'@angular/platform-browser/animations',
55+
'@angular/compiler',
56+
'@angular/common',
57+
'@angular/animations',
58+
'@angular/animations/browser',
5959
],
6060
exclude: ['@angular/platform-server'],
6161
},
6262
};
6363
},
6464

6565
load: function (id) {
66-
if (viteCommand === 'serve' && bundleSassFilePaths?.some((p) => id.includes(p))) {
66+
if (
67+
viteCommand === 'serve' &&
68+
bundleSassFilePaths?.some((p) => id.includes(p))
69+
) {
6770
// TODO: normalize path
6871
id = id.replace(/\?(.*)/, '');
6972
try {
70-
const compiledAsset = compile(id, options.bundleSassFilesInDevMode?.compileOptions).css;
73+
const compiledAsset = compile(
74+
id,
75+
options.bundleSassFilesInDevMode?.compileOptions
76+
).css;
7177
return compiledAsset;
7278
} catch (e) {
7379
// if failed to compile, do nothing

packages/qwik-angular/src/lib/wake-up-signal.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { $, useOn, useOnDocument, useSignal } from '@builder.io/qwik';
22
import { isServer } from '@builder.io/qwik/build';
33
import type { QwikifyOptions, QwikifyProps } from './types';
44

5-
export const useWakeupSignal = (props: QwikifyProps<{}>, opts: QwikifyOptions = {}) => {
5+
export const useWakeupSignal = (
6+
props: QwikifyProps<{}>,
7+
opts: QwikifyOptions = {}
8+
) => {
69
const signal = useSignal(false);
710
const activate = $(() => (signal.value = true));
811
const clientOnly = !!(props['client:only'] || opts?.clientOnly);

0 commit comments

Comments
 (0)