Skip to content

Commit

Permalink
fix: misc dx improvements (QwikDev#2697)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Jan 24, 2023
1 parent 4a4f60d commit 125f191
Show file tree
Hide file tree
Showing 21 changed files with 445 additions and 377 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ jobs:
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -129,8 +127,6 @@ jobs:

- uses: pnpm/action-setup@v2.2.4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 7

- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
Expand Down Expand Up @@ -225,8 +221,6 @@ jobs:

- uses: pnpm/action-setup@v2.2.4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 7

- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
Expand Down Expand Up @@ -315,8 +309,6 @@ jobs:

- uses: pnpm/action-setup@v2.2.4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 7

- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
Expand Down Expand Up @@ -408,8 +400,6 @@ jobs:
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -483,8 +473,6 @@ jobs:

- uses: pnpm/action-setup@v2.2.4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 7

- name: Setup Node ${{ matrix.settings.node }}
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
Expand Down Expand Up @@ -542,8 +530,6 @@ jobs:
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -634,8 +620,6 @@ jobs:
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release-qwik-city.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build.cli.prod": "tsm scripts/index.ts --cli",
"build.watch": "tsm scripts/index.ts --build --qwikcity --watch --dev --platform-binding",
"commit": "git-cz",
"link.dist": "cd packages/qwik/dist && npm link && cd ../../qwik-city/lib && npm link && cd ../../eslint-plugin-qwik/dist && npm link && cd ../../qwik-react && npm link",
"link.dist": "cd packages/qwik/dist && pnpm link --global && cd ../../qwik-city/lib && pnpm link --global && cd ../../eslint-plugin-qwik/dist && pnpm link --global && cd ../../qwik-react && pnpm link --global",
"cli": "pnpm build.cli && node packages/create-qwik/dist/create-qwik.cjs && tsm scripts/validate-cli.ts --copy-local-qwik-dist",
"cli.validate": "tsm scripts/validate-cli.ts",
"api.update": "tsm scripts/index.ts --tsc --api --dev",
Expand Down Expand Up @@ -53,8 +53,8 @@
"prepare": "husky install"
},
"devDependencies": {
"@builder.io/partytown": "0.7.4",
"@microsoft/api-extractor": "7.33.7",
"@builder.io/partytown": "0.7.5",
"@microsoft/api-extractor": "7.33.8",
"@napi-rs/cli": "2.12.1",
"@napi-rs/triples": "1.1.0",
"@node-rs/helper": "1.3.3",
Expand All @@ -72,28 +72,28 @@
"@types/prompts": "2.4.2",
"@types/semver": "7.3.13",
"@types/which-pm-runs": "1.0.0",
"@typescript-eslint/eslint-plugin": "5.48.0",
"@typescript-eslint/parser": "5.48.0",
"@typescript-eslint/utils": "5.48.0",
"@typescript-eslint/eslint-plugin": "5.48.2",
"@typescript-eslint/parser": "5.48.2",
"@typescript-eslint/utils": "5.48.2",
"all-contributors-cli": "6.24.0",
"brotli": "1.3.3",
"commitizen": "4.2.6",
"commitizen": "4.3.0",
"concurrently": "7.6.0",
"create-qwik": "workspace:*",
"cross-spawn": "7.0.3",
"cz-conventional-changelog": "3.3.0",
"esbuild": "0.16.16",
"eslint": "8.31.0",
"eslint": "8.32.0",
"eslint-plugin-no-only-tests": "3.1.0",
"execa": "6.1.0",
"express": "4.18.2",
"husky": "^8.0.0",
"husky": "^8.0.3",
"monaco-editor": "^0.34.1",
"mri": "1.2.0",
"node-fetch": "3.3.0",
"ora": "6.1.2",
"path-browserify": "1.0.1",
"prettier": "2.8.2",
"prettier": "2.8.3",
"pretty-quick": "^3.1.3",
"prompts": "2.4.2",
"rollup": "3.9.1",
Expand All @@ -102,10 +102,10 @@
"terser": "5.16.1",
"tsm": "2.2.2",
"typescript": "4.9.4",
"undici": "5.14.0",
"undici": "5.16.0",
"uvu": "0.5.6",
"vite": "4.0.4",
"vite-tsconfig-paths": "4.0.3",
"vite-tsconfig-paths": "4.0.5",
"watchlist": "0.3.1",
"which-pm-runs": "1.1.0"
},
Expand All @@ -126,12 +126,12 @@
"url": "https://twitter.com/manucorporat"
}
],
"packageManager": "pnpm@7.15.0",
"packageManager": "pnpm@7.25.1",
"engines": {
"node": ">=16",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">=7"
"pnpm": ">=7.18.0"
},
"config": {
"commitizen": {
Expand Down
8 changes: 4 additions & 4 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@algolia/autocomplete-core": "1.7.3",
"@algolia/autocomplete-shared": "1.7.3",
"@algolia/client-search": "4.14.2",
"@builder.io/partytown": "0.7.4",
"@builder.io/partytown": "0.7.5",
"@builder.io/qwik": "0.16.2",
"@builder.io/qwik-city": "0.1.0-beta8",
"@builder.io/sdk-qwik": "0.0.37",
Expand All @@ -37,14 +37,14 @@
"postcss": "8.4.21",
"prism-themes": "1.9.0",
"prismjs": "1.29.0",
"puppeteer": "^19.5.0",
"puppeteer": "^19.5.2",
"tailwindcss": "3.2.4",
"tsm": "2.3.0",
"typescript": "4.9.4",
"undici": "5.14.0",
"undici": "5.16.0",
"uvu": "0.5.6",
"vite": "4.0.4",
"wrangler": "^2.6.2"
"wrangler": "^2.8.0"
},
"author": "Builder.io Team",
"bugs": {
Expand Down
13 changes: 3 additions & 10 deletions packages/qwik-city/middleware/request-handler/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@ import type { RequestEvent as RequestEvent_2 } from '@builder.io/qwik-city';
import { Signal } from '@builder.io/qwik';
import { ValueOrPromise } from '@builder.io/qwik';

// Warning: (ae-forgotten-export) The symbol "CacheControlOptions" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export interface CacheControl {
immutable?: boolean;
maxAge?: number;
noCache?: boolean;
noStore?: boolean;
private?: boolean;
public?: boolean;
sMaxAge?: number;
staleWhileRevalidate?: number;
}
export type CacheControl = CacheControlOptions | number | 'day' | 'week' | 'month' | 'year' | 'no-cache' | 'immutable' | 'private';

// @alpha (undocumented)
export interface Cookie {
Expand Down
34 changes: 33 additions & 1 deletion packages/qwik-city/middleware/request-handler/cache-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@ import type { CacheControl } from './types';

export function createCacheControl(cacheControl: CacheControl) {
const controls: string[] = [];
if (cacheControl === 'day') {
cacheControl = 60 * 60 * 24;
} else if (cacheControl === 'week') {
cacheControl = 60 * 60 * 24 * 7;
} else if (cacheControl === 'month') {
cacheControl = 60 * 60 * 24 * 30;
} else if (cacheControl === 'year') {
cacheControl = 60 * 60 * 24 * 365;
} else if (cacheControl === 'private') {
cacheControl = {
private: true,
noCache: true,
};
} else if (cacheControl === 'immutable') {
cacheControl = {
public: true,
immutable: true,
maxAge: 60 * 60 * 24 * 365,
staleWhileRevalidate: 60 * 60 * 24 * 365,
};
} else if (cacheControl === 'no-cache') {
cacheControl = {
noCache: true,
};
}

if (typeof cacheControl === 'number') {
cacheControl = {
maxAge: cacheControl,
sMaxAge: cacheControl,
staleWhileRevalidate: cacheControl,
};
}

if (cacheControl.immutable) {
controls.push('immutable');
Expand All @@ -27,6 +60,5 @@ export function createCacheControl(cacheControl: CacheControl) {
if (cacheControl.staleWhileRevalidate) {
controls.push(`stale-while-revalidate=${cacheControl.staleWhileRevalidate}`);
}

return controls.join(', ');
}
16 changes: 15 additions & 1 deletion packages/qwik-city/middleware/request-handler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,21 @@ export interface RequestEventCommon<PLATFORM = unknown> {
/**
* @alpha
*/
export interface CacheControl {
export type CacheControl =
| CacheControlOptions
| number
| 'day'
| 'week'
| 'month'
| 'year'
| 'no-cache'
| 'immutable'
| 'private';

/**
* @alpha
*/
export interface CacheControlOptions {
/**
* The max-age=N response directive indicates that the response remains fresh until N seconds after the response is generated.
* Note that max-age is not the elapsed time since the response was received; it is the elapsed time since the response was generated on the origin server. So if the other cache(s) — on the network route taken by the response — store the response for 100 seconds (indicated using the Age response header field), the browser cache would deduct 100 seconds from its freshness lifetime.
Expand Down
4 changes: 2 additions & 2 deletions packages/qwik-city/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"devDependencies": {
"@azure/functions": "^3.5.0",
"@builder.io/qwik": "workspace:*",
"@microsoft/api-extractor": "7.33.7",
"@microsoft/api-extractor": "7.33.8",
"@netlify/edge-functions": "^2.0.0",
"@types/marked": "4.0.8",
"@types/mdast": "^3.0.10",
Expand All @@ -96,7 +96,7 @@
"github-slugger": "2.0.0",
"hast-util-heading-rank": "2.1.0",
"hast-util-to-string": "2.0.0",
"marked": "4.2.5",
"marked": "4.2.12",
"mdast-util-mdx": "^2.0.0",
"refractor": "4.8.0",
"rehype-autolink-headings": "6.1.1",
Expand Down
9 changes: 5 additions & 4 deletions packages/qwik-city/runtime/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CookieOptions } from '@builder.io/qwik-city/middleware/request-handler'
import { CookieValue } from '@builder.io/qwik-city/middleware/request-handler';
import type { GetSyncData } from '@builder.io/qwik-city/middleware/request-handler';
import { JSXNode } from '@builder.io/qwik';
import { PropFunction } from '@builder.io/qwik';
import { QRL } from '@builder.io/qwik';
import { QwikIntrinsicElements } from '@builder.io/qwik';
import { QwikJSX } from '@builder.io/qwik';
Expand Down Expand Up @@ -153,13 +152,15 @@ export type EndpointHandler<BODY = unknown> = RequestHandler<BODY>;
export const Form: <T>({ action, spaReset, reloadDocument, onSubmit$, ...rest }: FormProps<T>) => JSXNode<"form">;

// @alpha (undocumented)
export interface FormProps<T> extends Omit<QwikJSX.IntrinsicElements['form'], 'action'> {
export interface FormProps<T> extends Omit<QwikJSX.IntrinsicElements['form'], 'action' | 'method'> {
// (undocumented)
action: ServerActionUse<T>;
// (undocumented)
method?: 'post';
onSubmit$?: (event: Event, form: HTMLFormElement) => ValueOrPromise<void>;
// Warning: (ae-forgotten-export) The symbol "FormSubmitCompletedDetail" needs to be exported by the entry point index.d.ts
//
// (undocumented)
onSubmit$?: PropFunction<(event: Event) => void>;
onSubmitCompleted$?: (event: CustomEvent<FormSubmitCompletedDetail<T>>, form: HTMLFormElement) => ValueOrPromise<void>;
// (undocumented)
reloadDocument?: boolean;
// (undocumented)
Expand Down
19 changes: 15 additions & 4 deletions packages/qwik-city/runtime/src/form-component.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import type { ServerActionUse } from './server-functions';
import { jsx, _wrapSignal, QwikJSX, PropFunction } from '@builder.io/qwik';
import { jsx, _wrapSignal, QwikJSX, ValueOrPromise } from '@builder.io/qwik';

/**
* @alpha
*/
export interface FormProps<T> extends Omit<QwikJSX.IntrinsicElements['form'], 'action'> {
export interface FormSubmitCompletedDetail<T> {
status: number;
value: T;
}

/**
* @alpha
*/
export interface FormProps<T> extends Omit<QwikJSX.IntrinsicElements['form'], 'action' | 'method'> {
action: ServerActionUse<T>;
method?: 'post';
onSubmit$?: PropFunction<(event: Event) => void>;
reloadDocument?: boolean;
spaReset?: boolean;
onSubmit$?: (event: Event, form: HTMLFormElement) => ValueOrPromise<void>;
onSubmitCompleted$?: (
event: CustomEvent<FormSubmitCompletedDetail<T>>,
form: HTMLFormElement
) => ValueOrPromise<void>;
}

/**
Expand Down
Loading

0 comments on commit 125f191

Please sign in to comment.