acrylblends 0.6.3 → 0.6.4
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/README.md +3 -2
- package/docs/framework/README.md +2 -2
- package/docs/framework/UPSTREAM.md +1 -1
- package/docs/framework/guides/jsx.md +24 -0
- package/docs/framework/helpers/ssg.md +3 -6
- package/docs/framework/middleware/builtin/jsx-renderer.md +0 -3
- package/docs/framework/upstream.json +2 -2
- package/lib/accepts.d.ts +1 -1
- package/lib/acryl-base.d.ts +1 -1
- package/lib/adapter.d.ts +1 -1
- package/lib/{app-wFwpg-bt.d.ts → app-D8riatvv.d.ts} +1 -1
- package/lib/basic-auth.d.ts +1 -1
- package/lib/bearer-auth.d.ts +1 -1
- package/lib/body-limit.d.ts +1 -1
- package/lib/cache.d.ts +1 -1
- package/lib/cache.js +4 -4
- package/lib/{client-BHTr318g.js → client-DDLXwhBo.js} +2 -125
- package/lib/client.d.ts +2 -2
- package/lib/client.js +2 -1
- package/lib/combine.d.ts +1 -1
- package/lib/{components-Ce5FRyHU.js → components-0o0CBYNv.js} +2 -2
- package/lib/{components-DYZdxJIJ.js → components-DdI7-ns7.js} +1 -1
- package/lib/compress.d.ts +1 -1
- package/lib/conninfo.d.ts +2 -2
- package/lib/{context-DVQBjuns.d.ts → context-DS3fYyG-.d.ts} +1 -1
- package/lib/context-storage.d.ts +1 -1
- package/lib/cookie.d.ts +1 -1
- package/lib/cors.d.ts +1 -1
- package/lib/csrf.d.ts +1 -1
- package/lib/dev.d.ts +2 -2
- package/lib/etag.d.ts +1 -1
- package/lib/factory.d.ts +2 -2
- package/lib/{hooks-Bq5q9IMl.js → hooks-BMw6BAyP.js} +5 -5
- package/lib/{index-CUTfU69R.d.ts → index-Bb7YJKCq.d.ts} +2 -2
- package/lib/{index-CsvB-F9j.d.ts → index-BvFh1Gfx.d.ts} +1 -1
- package/lib/{index-Cqcdluyn.d.ts → index-CTy4N7ng.d.ts} +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/ip-restriction.d.ts +2 -2
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +1 -1
- package/lib/jsx/dom/server.js +1 -1
- package/lib/jsx/dom.js +3 -3
- package/lib/jsx/streaming.js +1 -1
- package/lib/{jsx-dev-runtime-kAhR_4C7.js → jsx-dev-runtime-D18Y35TI.js} +1 -1
- package/lib/jsx-renderer.d.ts +75 -0
- package/lib/jsx-renderer.js +99 -0
- package/lib/jsx.js +3 -3
- package/lib/jwk.d.ts +1 -1
- package/lib/jwt.d.ts +1 -1
- package/lib/language.d.ts +1 -1
- package/lib/logger.d.ts +1 -1
- package/lib/loopback-only.d.ts +1 -1
- package/lib/method-not-allowed.d.ts +2 -2
- package/lib/method-override.d.ts +2 -2
- package/lib/mount.d.ts +1 -1
- package/lib/node-server/conninfo.d.ts +1 -1
- package/lib/node-server/serve-static.d.ts +1 -1
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +1 -1
- package/lib/node-server.js +1 -1
- package/lib/powered-by.d.ts +1 -1
- package/lib/pretty-json.d.ts +1 -1
- package/lib/quick.d.ts +1 -1
- package/lib/request-id.d.ts +1 -1
- package/lib/request.d.ts +1 -1
- package/lib/route.d.ts +1 -1
- package/lib/schema-validator.d.ts +1 -1
- package/lib/secure-headers.d.ts +1 -1
- package/lib/{serve-static-Cw23shXv.js → serve-static-B14MF1Va.js} +1 -0
- package/lib/serve-static.d.ts +1 -1
- package/lib/ssg-BwjcA-Ge.js +389 -0
- package/lib/ssg.d.ts +156 -0
- package/lib/ssg.js +2 -0
- package/lib/streaming.d.ts +1 -1
- package/lib/testing.d.ts +3 -3
- package/lib/testing.js +1 -1
- package/lib/timeout.d.ts +1 -1
- package/lib/timing.d.ts +1 -1
- package/lib/tiny.d.ts +1 -1
- package/lib/trailing-slash.d.ts +1 -1
- package/lib/{types-nEL8VPDC.d.ts → types-Dv_nV2cv.d.ts} +1 -1
- package/lib/{types-CQiGmsWW.d.ts → types-zNxyEpG2.d.ts} +2 -2
- package/lib/types.d.ts +1 -1
- package/lib/utils/body.d.ts +1 -1
- package/lib/utils/ipaddr.d.ts +1 -1
- package/lib/utils-Cx61GFMC.js +125 -0
- package/lib/validator.d.ts +1 -1
- package/lib/ws.d.ts +1 -1
- package/package.json +9 -1
- package/plugins/acryl-inspect/upstream.json +1 -1
- package/plugins/acryl-node-server/upstream.json +1 -1
- package/plugins/acryl-router/src/core/helper/ssg/index.ts +14 -0
- package/plugins/acryl-router/src/core/helper/ssg/middleware.ts +83 -0
- package/plugins/acryl-router/src/core/helper/ssg/plugins.ts +72 -0
- package/plugins/acryl-router/src/core/helper/ssg/ssg.ts +471 -0
- package/plugins/acryl-router/src/core/helper/ssg/utils.ts +118 -0
- package/plugins/acryl-router/src/core/jsx/dom/render.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/cache/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/jsx-renderer/index.ts +162 -0
- package/plugins/acryl-router/src/helpers/index.ts +1 -0
- package/plugins/acryl-router/src/middleware/index.ts +1 -0
- package/plugins/acryl-router/upstream.json +2 -2
- package/plugins/acryl-router-http/upstream.json +1 -1
- package/plugins/acryl-state/upstream.json +1 -1
- package/plugins/desktop/upstream.json +1 -1
- package/plugins/desktop-web/upstream.json +1 -1
- package/plugins/extensions/resolve.ts +4 -0
- package/shared/AGENTS.core.md +4 -0
- package/templates/agent/tsconfig.json +7 -1
- package/templates/todo/upstream.json +1 -1
- package/plugins/acryl-inspect/tests/report.spec.ts +0 -69
- package/plugins/acryl-inspect/tests/service.spec.ts +0 -121
- package/plugins/acryl-node-server/tests/adapter/app.ts +0 -76
- package/plugins/acryl-node-server/tests/adapter/assets/.static/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/favicon.ico +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/secret.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/admin/secret.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/data.json +0 -5
- package/plugins/acryl-node-server/tests/adapter/assets/static/extensionless +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/foo..bar.txt +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-context-path/plain.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin.br +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.br +0 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst +0 -1
- package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +0 -34
- package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +0 -248
- package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +0 -457
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-cert.pem +0 -23
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-key.pem +0 -27
- package/plugins/acryl-node-server/tests/adapter/headers.test.ts +0 -252
- package/plugins/acryl-node-server/tests/adapter/helpers/request.ts +0 -190
- package/plugins/acryl-node-server/tests/adapter/listener.test.ts +0 -727
- package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +0 -189
- package/plugins/acryl-node-server/tests/adapter/request.test.ts +0 -1230
- package/plugins/acryl-node-server/tests/adapter/response.test.ts +0 -285
- package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +0 -849
- package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +0 -790
- package/plugins/acryl-node-server/tests/adapter/server.test.ts +0 -1312
- package/plugins/acryl-node-server/tests/adapter/setup.ts +0 -16
- package/plugins/acryl-node-server/tests/adapter/url.test.ts +0 -76
- package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +0 -23
- package/plugins/acryl-node-server/tests/adapter/utils/stream.test.ts +0 -75
- package/plugins/acryl-node-server/tests/adapter/utils.test.ts +0 -235
- package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +0 -260
- package/plugins/acryl-node-server/tests/server.spec.ts +0 -141
- package/plugins/acryl-router/src/core/app.test.ts +0 -3833
- package/plugins/acryl-router/src/core/client/client.test.ts +0 -2313
- package/plugins/acryl-router/src/core/client/types.test.ts +0 -149
- package/plugins/acryl-router/src/core/client/utils.test.ts +0 -405
- package/plugins/acryl-router/src/core/compose.test.ts +0 -751
- package/plugins/acryl-router/src/core/context.test.ts +0 -629
- package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +0 -344
- package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +0 -55
- package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +0 -510
- package/plugins/acryl-router/src/core/helper/css/common.case.test.tsx +0 -506
- package/plugins/acryl-router/src/core/helper/css/index.test.tsx +0 -678
- package/plugins/acryl-router/src/core/helper/dev/index.test.ts +0 -181
- package/plugins/acryl-router/src/core/helper/factory/index.test.ts +0 -434
- package/plugins/acryl-router/src/core/helper/html/index.test.ts +0 -78
- package/plugins/acryl-router/src/core/helper/proxy/index.test.ts +0 -356
- package/plugins/acryl-router/src/core/helper/route/index.test.ts +0 -259
- package/plugins/acryl-router/src/core/helper/streaming/sse.test.tsx +0 -557
- package/plugins/acryl-router/src/core/helper/streaming/stream.test.ts +0 -128
- package/plugins/acryl-router/src/core/helper/streaming/text.test.ts +0 -34
- package/plugins/acryl-router/src/core/helper/testing/index.test.ts +0 -42
- package/plugins/acryl-router/src/core/helper/websocket/index.test.ts +0 -124
- package/plugins/acryl-router/src/core/http-exception.test.ts +0 -45
- package/plugins/acryl-router/src/core/jsx/base.test.tsx +0 -97
- package/plugins/acryl-router/src/core/jsx/children.test.ts +0 -52
- package/plugins/acryl-router/src/core/jsx/components.test.tsx +0 -936
- package/plugins/acryl-router/src/core/jsx/context-isolation.test.ts +0 -655
- package/plugins/acryl-router/src/core/jsx/dom/client.test.tsx +0 -128
- package/plugins/acryl-router/src/core/jsx/dom/components.test.tsx +0 -330
- package/plugins/acryl-router/src/core/jsx/dom/context.test.tsx +0 -184
- package/plugins/acryl-router/src/core/jsx/dom/css.test.tsx +0 -149
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.test.tsx +0 -172
- package/plugins/acryl-router/src/core/jsx/dom/index.test.tsx +0 -3681
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.test.tsx +0 -1344
- package/plugins/acryl-router/src/core/jsx/dom/server.test.tsx +0 -199
- package/plugins/acryl-router/src/core/jsx/hooks/dom.test.tsx +0 -859
- package/plugins/acryl-router/src/core/jsx/hooks/string.test.tsx +0 -40
- package/plugins/acryl-router/src/core/jsx/index.test.tsx +0 -1744
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.test.tsx +0 -666
- package/plugins/acryl-router/src/core/jsx/jsx-runtime.test.tsx +0 -85
- package/plugins/acryl-router/src/core/jsx/streaming.test.tsx +0 -1281
- package/plugins/acryl-router/src/core/jsx/utils.test.ts +0 -366
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +0 -434
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +0 -1018
- package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +0 -273
- package/plugins/acryl-router/src/core/middleware/cache/index.test.ts +0 -1211
- package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +0 -355
- package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +0 -535
- package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +0 -43
- package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +0 -532
- package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +0 -534
- package/plugins/acryl-router/src/core/middleware/etag/digest.test.ts +0 -21
- package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +0 -503
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +0 -217
- package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +0 -1135
- package/plugins/acryl-router/src/core/middleware/jwk/keys.test.json +0 -48
- package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +0 -802
- package/plugins/acryl-router/src/core/middleware/language/index.test.ts +0 -552
- package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +0 -204
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +0 -292
- package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +0 -221
- package/plugins/acryl-router/src/core/middleware/mount/index.test.ts +0 -334
- package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +0 -37
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +0 -218
- package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +0 -168
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +0 -671
- package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +0 -450
- package/plugins/acryl-router/src/core/middleware/serve-static/path.test.ts +0 -50
- package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +0 -70
- package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +0 -310
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +0 -381
- package/plugins/acryl-router/src/core/preset/quick.test.ts +0 -42
- package/plugins/acryl-router/src/core/preset/tiny.test.ts +0 -42
- package/plugins/acryl-router/src/core/request.test.ts +0 -751
- package/plugins/acryl-router/src/core/router/common.case.test.ts +0 -1132
- package/plugins/acryl-router/src/core/router/linear-router/router.test.ts +0 -80
- package/plugins/acryl-router/src/core/router/pattern-router/router.test.ts +0 -46
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.test.ts +0 -154
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.test.ts +0 -265
- package/plugins/acryl-router/src/core/router/smart-router/router.test.ts +0 -13
- package/plugins/acryl-router/src/core/router/trie-router/node.test.ts +0 -896
- package/plugins/acryl-router/src/core/router/trie-router/router.test.ts +0 -8
- package/plugins/acryl-router/src/core/types.test.ts +0 -4134
- package/plugins/acryl-router/src/core/utils/accept.test.ts +0 -299
- package/plugins/acryl-router/src/core/utils/basic-auth.test.ts +0 -56
- package/plugins/acryl-router/src/core/utils/body.test.ts +0 -496
- package/plugins/acryl-router/src/core/utils/buffer.test.ts +0 -147
- package/plugins/acryl-router/src/core/utils/color.test.ts +0 -23
- package/plugins/acryl-router/src/core/utils/concurrent.test.ts +0 -69
- package/plugins/acryl-router/src/core/utils/cookie.test.ts +0 -460
- package/plugins/acryl-router/src/core/utils/crypto.test.ts +0 -43
- package/plugins/acryl-router/src/core/utils/encode.test.ts +0 -61
- package/plugins/acryl-router/src/core/utils/filepath.test.ts +0 -78
- package/plugins/acryl-router/src/core/utils/html.test.ts +0 -16
- package/plugins/acryl-router/src/core/utils/ipaddr.test.ts +0 -149
- package/plugins/acryl-router/src/core/utils/jwt/jwa.test.ts +0 -86
- package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +0 -1788
- package/plugins/acryl-router/src/core/utils/mime.test.ts +0 -64
- package/plugins/acryl-router/src/core/utils/stream.test.ts +0 -212
- package/plugins/acryl-router/src/core/utils/types.test.ts +0 -295
- package/plugins/acryl-router/src/core/utils/url.test.ts +0 -384
- package/plugins/acryl-router/src/core/validator/utils.test.ts +0 -82
- package/plugins/acryl-router/src/core/validator/validator.test.ts +0 -1488
- package/plugins/acryl-router/tests/docs-examples.spec.ts +0 -152
- package/plugins/acryl-router/tests/jsx.spec.tsx +0 -63
- package/plugins/acryl-router/tests/live-install.spec.ts +0 -64
- package/plugins/acryl-router/tests/loader.spec.ts +0 -72
- package/plugins/acryl-router/tests/loopback-only.spec.ts +0 -80
- package/plugins/acryl-router/tests/no-dom/consumer.ts +0 -11
- package/plugins/acryl-router/tests/no-dom/tsconfig.json +0 -13
- package/plugins/acryl-router/tests/service.spec.ts +0 -426
- package/plugins/acryl-router/tests/shadow-state.spec.ts +0 -79
- package/plugins/acryl-router-http/tests/adapter.spec.ts +0 -174
- package/plugins/acryl-router-http/tests/stream.spec.ts +0 -133
- package/plugins/acryl-router-http/tests/surfaces.spec.ts +0 -101
- package/plugins/acryl-state/src/react.ts +0 -11
- package/plugins/acryl-state/tests/cell.spec.ts +0 -71
- package/plugins/acryl-state/tests/react.spec.ts +0 -39
- package/plugins/acryl-state/tests/service.spec.ts +0 -132
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource ../../jsx */
|
|
2
|
-
import type {
|
|
3
|
-
Style as StyleComponent,
|
|
4
|
-
css as cssHelper,
|
|
5
|
-
keyframes as keyframesHelper,
|
|
6
|
-
rawCssString as rawCssStringHelper,
|
|
7
|
-
viewTransition as viewTransitionHelper,
|
|
8
|
-
} from './index.ts'
|
|
9
|
-
|
|
10
|
-
interface Support {
|
|
11
|
-
nest: boolean
|
|
12
|
-
}
|
|
13
|
-
export const renderTest = (
|
|
14
|
-
getEnv: () => {
|
|
15
|
-
css: typeof cssHelper
|
|
16
|
-
keyframes: typeof keyframesHelper
|
|
17
|
-
viewTransition: typeof viewTransitionHelper
|
|
18
|
-
rawCssString: typeof rawCssStringHelper
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
toString: (template: any) => Promise<string>
|
|
21
|
-
Style: typeof StyleComponent
|
|
22
|
-
support: Support
|
|
23
|
-
}
|
|
24
|
-
) => {
|
|
25
|
-
const { support } = getEnv()
|
|
26
|
-
|
|
27
|
-
let css: typeof cssHelper
|
|
28
|
-
let keyframes: typeof keyframesHelper
|
|
29
|
-
let viewTransition: typeof viewTransitionHelper
|
|
30
|
-
let rawCssString: typeof rawCssStringHelper
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
let toString: (template: any) => Promise<string>
|
|
33
|
-
let Style: typeof StyleComponent
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
;({ css, keyframes, viewTransition, rawCssString, toString, Style } = getEnv())
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
describe('render css', () => {
|
|
39
|
-
it('Should render CSS styles with JSX', async () => {
|
|
40
|
-
const headerClass = css`
|
|
41
|
-
background-color: blue;
|
|
42
|
-
`
|
|
43
|
-
const template = (
|
|
44
|
-
<>
|
|
45
|
-
<Style />
|
|
46
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
47
|
-
</>
|
|
48
|
-
)
|
|
49
|
-
expect(await toString(template)).toBe(
|
|
50
|
-
'<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
|
|
51
|
-
)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('Should render CSS with keyframes', async () => {
|
|
55
|
-
const animation = keyframes`
|
|
56
|
-
from {
|
|
57
|
-
opacity: 0;
|
|
58
|
-
}
|
|
59
|
-
to {
|
|
60
|
-
opacity: 1;
|
|
61
|
-
}
|
|
62
|
-
`
|
|
63
|
-
const headerClass = css`
|
|
64
|
-
background-color: blue;
|
|
65
|
-
animation: ${animation} 1s ease-in-out;
|
|
66
|
-
`
|
|
67
|
-
const template = (
|
|
68
|
-
<>
|
|
69
|
-
<Style />
|
|
70
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
71
|
-
</>
|
|
72
|
-
)
|
|
73
|
-
expect(await toString(template)).toBe(
|
|
74
|
-
'<style id="acryl-css">.css-1580801783{background-color:blue;animation:css-9294673 1s ease-in-out}@keyframes css-9294673{from{opacity:0}to{opacity:1}}</style><h1 class="css-1580801783">Hello!</h1>'
|
|
75
|
-
)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('Should not output the same class name multiple times.', async () => {
|
|
79
|
-
const headerClass = css`
|
|
80
|
-
background-color: blue;
|
|
81
|
-
`
|
|
82
|
-
const headerClass2 = css`
|
|
83
|
-
background-color: blue;
|
|
84
|
-
`
|
|
85
|
-
const template = (
|
|
86
|
-
<>
|
|
87
|
-
<Style />
|
|
88
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
89
|
-
<h1 class={headerClass2}>Hello2!</h1>
|
|
90
|
-
</>
|
|
91
|
-
)
|
|
92
|
-
expect(await toString(template)).toBe(
|
|
93
|
-
'<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1><h1 class="css-2458908649">Hello2!</h1>'
|
|
94
|
-
)
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('Should render CSS with variable', async () => {
|
|
98
|
-
const headerClass = css`
|
|
99
|
-
background-color: blue;
|
|
100
|
-
content: '${"I'm a variable!"}';
|
|
101
|
-
`
|
|
102
|
-
const template = (
|
|
103
|
-
<>
|
|
104
|
-
<Style />
|
|
105
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
106
|
-
</>
|
|
107
|
-
)
|
|
108
|
-
expect(await toString(template)).toBe(
|
|
109
|
-
'<style id="acryl-css">.css-4027435072{background-color:blue;content:\'I\\\'m a variable!\'}</style><h1 class="css-4027435072">Hello!</h1>'
|
|
110
|
-
)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('Should escape </style>', async () => {
|
|
114
|
-
const headerClass = css`
|
|
115
|
-
background-color: blue;
|
|
116
|
-
content: '${'</style>'}';
|
|
117
|
-
`
|
|
118
|
-
const template = (
|
|
119
|
-
<>
|
|
120
|
-
<Style />
|
|
121
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
122
|
-
</>
|
|
123
|
-
)
|
|
124
|
-
expect(await toString(template)).toBe(
|
|
125
|
-
'<style id="acryl-css">.css-372954897{background-color:blue;content:\'<\\/style>\'}</style><h1 class="css-372954897">Hello!</h1>'
|
|
126
|
-
)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it('Should not escape URL', async () => {
|
|
130
|
-
const headerClass = css`
|
|
131
|
-
background-color: blue;
|
|
132
|
-
background: url('${'http://www.example.com/path/to/file.jpg'}');
|
|
133
|
-
`
|
|
134
|
-
const template = (
|
|
135
|
-
<>
|
|
136
|
-
<Style />
|
|
137
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
138
|
-
</>
|
|
139
|
-
)
|
|
140
|
-
expect(await toString(template)).toBe(
|
|
141
|
-
'<style id="acryl-css">.css-1321888780{background-color:blue;background:url(\'http://www.example.com/path/to/file.jpg\')}</style><h1 class="css-1321888780">Hello!</h1>'
|
|
142
|
-
)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('Should render CSS with escaped variable', async () => {
|
|
146
|
-
const headerClass = css`
|
|
147
|
-
background-color: blue;
|
|
148
|
-
content: '${rawCssString('say "Hello!"')}';
|
|
149
|
-
`
|
|
150
|
-
const template = (
|
|
151
|
-
<>
|
|
152
|
-
<Style />
|
|
153
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
154
|
-
</>
|
|
155
|
-
)
|
|
156
|
-
expect(await toString(template)).toBe(
|
|
157
|
-
'<style id="acryl-css">.css-2238574885{background-color:blue;content:\'say "Hello!"\'}</style><h1 class="css-2238574885">Hello!</h1>'
|
|
158
|
-
)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
it('Should render CSS with number', async () => {
|
|
162
|
-
const headerClass = css`
|
|
163
|
-
background-color: blue;
|
|
164
|
-
font-size: ${1}rem;
|
|
165
|
-
`
|
|
166
|
-
const template = (
|
|
167
|
-
<>
|
|
168
|
-
<Style />
|
|
169
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
170
|
-
</>
|
|
171
|
-
)
|
|
172
|
-
expect(await toString(template)).toBe(
|
|
173
|
-
'<style id="acryl-css">.css-1847536026{background-color:blue;font-size:1rem}</style><h1 class="css-1847536026">Hello!</h1>'
|
|
174
|
-
)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('Should render CSS with array', async () => {
|
|
178
|
-
const animation = keyframes`
|
|
179
|
-
from {
|
|
180
|
-
opacity: 0;
|
|
181
|
-
}
|
|
182
|
-
to {
|
|
183
|
-
opacity: 1;
|
|
184
|
-
}
|
|
185
|
-
`
|
|
186
|
-
const headerClass = css`
|
|
187
|
-
background-color: blue;
|
|
188
|
-
animation: ${animation} 1s ease-in-out;
|
|
189
|
-
`
|
|
190
|
-
const extendedHeaderClass = css`
|
|
191
|
-
${headerClass}
|
|
192
|
-
color: red;
|
|
193
|
-
`
|
|
194
|
-
const template = (
|
|
195
|
-
<>
|
|
196
|
-
<Style />
|
|
197
|
-
<h1 class={extendedHeaderClass}>Hello!</h1>
|
|
198
|
-
</>
|
|
199
|
-
)
|
|
200
|
-
expect(await toString(template)).toBe(
|
|
201
|
-
'<style id="acryl-css">.css-2558359670{background-color:blue;animation:css-9294673 1s ease-in-out;color:red}@keyframes css-9294673{from{opacity:0}to{opacity:1}}</style><h1 class="css-2558359670">Hello!</h1>'
|
|
202
|
-
)
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
it.runIf(support.nest)(
|
|
206
|
-
'Should be used as a class name for syntax `${className} {`',
|
|
207
|
-
async () => {
|
|
208
|
-
const headerClass = css`
|
|
209
|
-
font-weight: bold;
|
|
210
|
-
`
|
|
211
|
-
const containerClass = css`
|
|
212
|
-
${headerClass} {
|
|
213
|
-
h1 {
|
|
214
|
-
color: red;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
`
|
|
218
|
-
const template = (
|
|
219
|
-
<>
|
|
220
|
-
<Style />
|
|
221
|
-
<div class={containerClass}>
|
|
222
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
223
|
-
</div>
|
|
224
|
-
</>
|
|
225
|
-
)
|
|
226
|
-
expect(await toString(template)).toBe(
|
|
227
|
-
'<style id="acryl-css">.css-4220297002{.css-1032195302{h1{color:red}}}.css-1032195302{font-weight:bold}</style><div class="css-4220297002"><h1 class="css-1032195302">Hello!</h1></div>'
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
it('Should be inserted to global if style string starts with :-acryl-root', async () => {
|
|
233
|
-
const globalClass = css`
|
|
234
|
-
:-acryl-global {
|
|
235
|
-
html {
|
|
236
|
-
color: red;
|
|
237
|
-
}
|
|
238
|
-
body {
|
|
239
|
-
display: flex;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
`
|
|
243
|
-
const template = (
|
|
244
|
-
<>
|
|
245
|
-
<Style />
|
|
246
|
-
<div class={globalClass}>
|
|
247
|
-
<h1>Hello!</h1>
|
|
248
|
-
</div>
|
|
249
|
-
</>
|
|
250
|
-
)
|
|
251
|
-
expect(await toString(template)).toBe(
|
|
252
|
-
'<style id="acryl-css">html{color:red}body{display:flex}</style><div class=""><h1>Hello!</h1></div>'
|
|
253
|
-
)
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
it.runIf(support.nest)(
|
|
257
|
-
'Should be inserted to global if style string starts with :-acryl-root and extends class name',
|
|
258
|
-
async () => {
|
|
259
|
-
const headerClass = css`
|
|
260
|
-
display: flex;
|
|
261
|
-
`
|
|
262
|
-
const specialHeaderClass = css`
|
|
263
|
-
:-acryl-global {
|
|
264
|
-
${headerClass} {
|
|
265
|
-
h1 {
|
|
266
|
-
color: red;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
`
|
|
271
|
-
const template = (
|
|
272
|
-
<>
|
|
273
|
-
<Style />
|
|
274
|
-
<div class={specialHeaderClass}>
|
|
275
|
-
<h1>Hello!</h1>
|
|
276
|
-
</div>
|
|
277
|
-
</>
|
|
278
|
-
)
|
|
279
|
-
expect(await toString(template)).toBe(
|
|
280
|
-
'<style id="acryl-css">.css-3980466870{h1{color:red}}.css-3980466870{display:flex}</style><div class="css-3980466870"><h1>Hello!</h1></div>'
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
it('Should be inserted as global css if passed css`` to Style component', async () => {
|
|
286
|
-
const headerClass = css`
|
|
287
|
-
font-size: 1rem;
|
|
288
|
-
`
|
|
289
|
-
const template = (
|
|
290
|
-
<>
|
|
291
|
-
<Style>{css`
|
|
292
|
-
html {
|
|
293
|
-
color: red;
|
|
294
|
-
}
|
|
295
|
-
body {
|
|
296
|
-
display: flex;
|
|
297
|
-
}
|
|
298
|
-
`}</Style>
|
|
299
|
-
<div>
|
|
300
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
301
|
-
</div>
|
|
302
|
-
</>
|
|
303
|
-
)
|
|
304
|
-
expect(await toString(template)).toBe(
|
|
305
|
-
'<style id="acryl-css">html{color:red}body{display:flex}.css-1740067317{font-size:1rem}</style><div><h1 class="css-1740067317">Hello!</h1></div>'
|
|
306
|
-
)
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
it('Should be ignored :-acryl-root inside Style component', async () => {
|
|
310
|
-
const headerClass = css`
|
|
311
|
-
font-size: 1rem;
|
|
312
|
-
`
|
|
313
|
-
const template = (
|
|
314
|
-
<>
|
|
315
|
-
<Style>{css`
|
|
316
|
-
:-acryl-global {
|
|
317
|
-
html {
|
|
318
|
-
color: red;
|
|
319
|
-
}
|
|
320
|
-
body {
|
|
321
|
-
display: flex;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
`}</Style>
|
|
325
|
-
<div>
|
|
326
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
327
|
-
</div>
|
|
328
|
-
</>
|
|
329
|
-
)
|
|
330
|
-
expect(await toString(template)).toBe(
|
|
331
|
-
'<style id="acryl-css">html{color:red}body{display:flex}.css-1740067317{font-size:1rem}</style><div><h1 class="css-1740067317">Hello!</h1></div>'
|
|
332
|
-
)
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
describe('viewTransition', () => {
|
|
336
|
-
it('Should render CSS with unique view-transition-name', async () => {
|
|
337
|
-
const transition = viewTransition()
|
|
338
|
-
const template = (
|
|
339
|
-
<>
|
|
340
|
-
<Style />
|
|
341
|
-
<h1 class={transition}>Hello!</h1>
|
|
342
|
-
</>
|
|
343
|
-
)
|
|
344
|
-
expect(await toString(template)).toBe(
|
|
345
|
-
'<style id="acryl-css">.css-1644952339{view-transition-name:css-1644952339}</style><h1 class="css-1644952339">Hello!</h1>'
|
|
346
|
-
)
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
it('Should render CSS with css and keyframes', async () => {
|
|
350
|
-
const kf = keyframes`
|
|
351
|
-
from {
|
|
352
|
-
opacity: 0;
|
|
353
|
-
}
|
|
354
|
-
to {
|
|
355
|
-
opacity: 1;
|
|
356
|
-
}
|
|
357
|
-
`
|
|
358
|
-
const transition = viewTransition(css`
|
|
359
|
-
::view-transition-old() {
|
|
360
|
-
animation-name: ${kf};
|
|
361
|
-
}
|
|
362
|
-
::view-transition-new() {
|
|
363
|
-
animation-name: ${kf};
|
|
364
|
-
}
|
|
365
|
-
`)
|
|
366
|
-
const headerClass = css`
|
|
367
|
-
${transition}
|
|
368
|
-
background-color: blue;
|
|
369
|
-
`
|
|
370
|
-
const template = (
|
|
371
|
-
<>
|
|
372
|
-
<Style />
|
|
373
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
374
|
-
</>
|
|
375
|
-
)
|
|
376
|
-
expect(await toString(template)).toBe(
|
|
377
|
-
'<style id="acryl-css">.css-1245070278{view-transition-name:css-399742870;background-color:blue}@keyframes css-9294673{from{opacity:0}to{opacity:1}}::view-transition-old(css-399742870){animation-name:css-9294673}::view-transition-new(css-399742870){animation-name:css-9294673}</style><h1 class="css-1245070278">Hello!</h1>'
|
|
378
|
-
)
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
it('Should works as a template tag function', async () => {
|
|
382
|
-
const kf = keyframes`
|
|
383
|
-
from {
|
|
384
|
-
opacity: 0;
|
|
385
|
-
}
|
|
386
|
-
to {
|
|
387
|
-
opacity: 1;
|
|
388
|
-
}
|
|
389
|
-
`
|
|
390
|
-
const transition = viewTransition`
|
|
391
|
-
::view-transition-old() {
|
|
392
|
-
animation-name: ${kf};
|
|
393
|
-
}
|
|
394
|
-
::view-transition-new() {
|
|
395
|
-
animation-name: ${kf};
|
|
396
|
-
}
|
|
397
|
-
`
|
|
398
|
-
const headerClass = css`
|
|
399
|
-
${transition}
|
|
400
|
-
background-color: blue;
|
|
401
|
-
`
|
|
402
|
-
const template = (
|
|
403
|
-
<>
|
|
404
|
-
<Style />
|
|
405
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
406
|
-
</>
|
|
407
|
-
)
|
|
408
|
-
expect(await toString(template)).toBe(
|
|
409
|
-
'<style id="acryl-css">.css-1245070278{view-transition-name:css-399742870;background-color:blue}@keyframes css-9294673{from{opacity:0}to{opacity:1}}::view-transition-old(css-399742870){animation-name:css-9294673}::view-transition-new(css-399742870){animation-name:css-9294673}</style><h1 class="css-1245070278">Hello!</h1>'
|
|
410
|
-
)
|
|
411
|
-
})
|
|
412
|
-
})
|
|
413
|
-
|
|
414
|
-
it.runIf(support.nest)('Should render sub CSS with keyframe', async () => {
|
|
415
|
-
const headerClass = css`
|
|
416
|
-
background-color: blue;
|
|
417
|
-
${[1, 2].map(
|
|
418
|
-
(i) => css`
|
|
419
|
-
:nth-child(${i}) {
|
|
420
|
-
color: red;
|
|
421
|
-
}
|
|
422
|
-
`
|
|
423
|
-
)}
|
|
424
|
-
`
|
|
425
|
-
const template = (
|
|
426
|
-
<>
|
|
427
|
-
<Style />
|
|
428
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
429
|
-
</>
|
|
430
|
-
)
|
|
431
|
-
expect(await toString(template)).toBe(
|
|
432
|
-
'<style id="acryl-css">.css-1539881271{background-color:blue;:nth-child(1){color:red}:nth-child(2){color:red}}</style><h1 class="css-1539881271">Hello!</h1>'
|
|
433
|
-
)
|
|
434
|
-
})
|
|
435
|
-
|
|
436
|
-
it('Should be generated deferent class name for deferent first line comment even if the content is the same', async () => {
|
|
437
|
-
const headerClassA = css`
|
|
438
|
-
/* class A */
|
|
439
|
-
display: flex;
|
|
440
|
-
`
|
|
441
|
-
const headerClassB = css`
|
|
442
|
-
/* class B */
|
|
443
|
-
display: flex;
|
|
444
|
-
`
|
|
445
|
-
const template = (
|
|
446
|
-
<>
|
|
447
|
-
<Style />
|
|
448
|
-
<h1 class={headerClassA}>Hello!</h1>
|
|
449
|
-
<h1 class={headerClassB}>Hello!</h1>
|
|
450
|
-
</>
|
|
451
|
-
)
|
|
452
|
-
expect(await toString(template)).toBe(
|
|
453
|
-
'<style id="acryl-css">.css-3170754153{display:flex}.css-896513246{display:flex}</style><h1 class="css-3170754153">Hello!</h1><h1 class="css-896513246">Hello!</h1>'
|
|
454
|
-
)
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
describe('Booleans, Null, and Undefined Are Ignored', () => {
|
|
458
|
-
it.each([true, false, undefined, null])('%s', async (value) => {
|
|
459
|
-
const headerClass = css`
|
|
460
|
-
${value}
|
|
461
|
-
background-color: blue;
|
|
462
|
-
`
|
|
463
|
-
const template = (
|
|
464
|
-
<>
|
|
465
|
-
<Style />
|
|
466
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
467
|
-
</>
|
|
468
|
-
)
|
|
469
|
-
expect(await toString(template)).toBe(
|
|
470
|
-
'<style id="acryl-css">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
|
|
471
|
-
)
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
it('falsy value', async () => {
|
|
475
|
-
const value = 0
|
|
476
|
-
const headerClass = css`
|
|
477
|
-
padding: ${value};
|
|
478
|
-
`
|
|
479
|
-
const template = (
|
|
480
|
-
<>
|
|
481
|
-
<Style />
|
|
482
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
483
|
-
</>
|
|
484
|
-
)
|
|
485
|
-
expect(await toString(template)).toBe(
|
|
486
|
-
'<style id="acryl-css">.css-478287868{padding:0}</style><h1 class="css-478287868">Hello!</h1>'
|
|
487
|
-
)
|
|
488
|
-
})
|
|
489
|
-
|
|
490
|
-
it('Should render CSS styles with CSP nonce', async () => {
|
|
491
|
-
const headerClass = css`
|
|
492
|
-
background-color: blue;
|
|
493
|
-
`
|
|
494
|
-
const template = (
|
|
495
|
-
<>
|
|
496
|
-
<Style nonce='1234' />
|
|
497
|
-
<h1 class={headerClass}>Hello!</h1>
|
|
498
|
-
</>
|
|
499
|
-
)
|
|
500
|
-
expect(await toString(template)).toBe(
|
|
501
|
-
'<style id="acryl-css" nonce="1234">.css-2458908649{background-color:blue}</style><h1 class="css-2458908649">Hello!</h1>'
|
|
502
|
-
)
|
|
503
|
-
})
|
|
504
|
-
})
|
|
505
|
-
})
|
|
506
|
-
}
|