@octane-xplat/bamboo 0.17.1 → 0.18.0
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 +43 -0
- package/dist/build-environments.js +52 -0
- package/dist/config.js +37 -2
- package/dist/vite.js +5 -1
- package/package.json +3 -3
- package/src/build-environments.ts +64 -0
- package/src/config.ts +37 -4
- package/src/vite.ts +14 -2
- package/types/generated/build-environments.d.ts +3 -0
- package/types/generated/vite.d.ts +6 -2
package/README.md
CHANGED
|
@@ -24,6 +24,16 @@ export default defineConfig({
|
|
|
24
24
|
})
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Token names mirror the UI theme variables: every `--color-*`, `--radius-*`,
|
|
28
|
+
and `--space-*` the default theme in `@octane-xplat/ui/theme/chrome.css`
|
|
29
|
+
declares is a valid token, compiled to its variable (`warning` →
|
|
30
|
+
`var(--color-warning)`). A token only resolves when that stylesheet is
|
|
31
|
+
imported or the app defines the variable itself.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
css({ color: 'warning' }) // -> var(--color-warning)
|
|
35
|
+
```
|
|
36
|
+
|
|
27
37
|
Preflight is off by default and tokens land on `:root, .ns-root`. The
|
|
28
38
|
xplat NativeScript CSS transform unwraps the emitted `@layer` blocks for
|
|
29
39
|
native builds (the NS parser drops unknown at-rules); browsers keep the
|
|
@@ -37,6 +47,10 @@ const webPlugins = xplatBamboo()
|
|
|
37
47
|
const nativePlugins = xplatBamboo({ native: true })
|
|
38
48
|
```
|
|
39
49
|
|
|
50
|
+
`native: true` covers NativeScript (iOS/Android), the AppKit renderer, and
|
|
51
|
+
the GTK renderer — both desktop presets consume the same finalized
|
|
52
|
+
`virtual:bamboo.css` asset through `xplatInlineStylesheets`.
|
|
53
|
+
|
|
40
54
|
Platform conditions use the same build-time compiler as ordinary CSS. Add
|
|
41
55
|
`xplatCss('web')` from `@octane-xplat/cli/vite` to web plugins; native presets
|
|
42
56
|
include it. Keep the portable utility subset unless you explicitly extend it.
|
|
@@ -53,3 +67,32 @@ const card = css({
|
|
|
53
67
|
```
|
|
54
68
|
|
|
55
69
|
Guide: [Styling screens](../../docs/app/styling.md).
|
|
70
|
+
|
|
71
|
+
## Custom builders with unused environments
|
|
72
|
+
|
|
73
|
+
A Vite environment is a named build target. Some Cloudflare setups configure
|
|
74
|
+
`ssr` but only build a Worker and a browser client. With Bamboo 1.56.2, pass
|
|
75
|
+
`buildEnvironments` containing every target your builder actually runs to avoid
|
|
76
|
+
an incorrect incomplete-run warning. Use your Worker's environment name:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { xplatBamboo } from '@octane-xplat/bamboo/vite'
|
|
80
|
+
|
|
81
|
+
const plugins = xplatBamboo({
|
|
82
|
+
buildEnvironments: ['api', 'client'],
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Keep real server-rendering targets in the list, even when they emit no CSS
|
|
87
|
+
asset: their reachable styles must remain in the browser stylesheet. An
|
|
88
|
+
excluded target that starts building causes an error; a listed target that
|
|
89
|
+
never completes still triggers Bamboo's warning. Omit the option for builders
|
|
90
|
+
that build all configured environments. Pruning stays enabled.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
const plugins = xplatBamboo({ buildEnvironments: ['client', 'ssr'] })
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This option declares participation; it does not schedule builds. It adapts
|
|
97
|
+
Bamboo 1.56.2's environment accounting and requires Vite's environment builder.
|
|
98
|
+
Platform conditions with real SSR remain unsupported, as described above.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Adapt Bamboo 1.56.2's configured-environment accounting to an explicit build plan. */
|
|
2
|
+
export function buildEnvironments(plugins, names) {
|
|
3
|
+
const participating = new Set(names);
|
|
4
|
+
if (!participating.size || names.some((name) => !name)) {
|
|
5
|
+
throw new Error('@octane-xplat/bamboo: buildEnvironments must contain environment names');
|
|
6
|
+
}
|
|
7
|
+
const css = plugins.find((plugin) => plugin.name === 'bamboocss:css');
|
|
8
|
+
const resolvedHook = css?.configResolved;
|
|
9
|
+
const appHook = css?.buildApp;
|
|
10
|
+
const resolved = typeof resolvedHook === 'function' ? resolvedHook : resolvedHook?.handler;
|
|
11
|
+
const app = typeof appHook === 'function' ? appHook : appHook?.handler;
|
|
12
|
+
if (!css || !resolved || !app) {
|
|
13
|
+
throw new Error('@octane-xplat/bamboo: buildEnvironments requires Bamboo CSS configResolved and buildApp hooks');
|
|
14
|
+
}
|
|
15
|
+
function select(environments) {
|
|
16
|
+
for (const name of participating) {
|
|
17
|
+
if (!Object.hasOwn(environments, name)) {
|
|
18
|
+
throw new Error(`@octane-xplat/bamboo: unknown buildEnvironments entry "${name}"`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return Object.fromEntries([...participating].map((name) => [name, environments[name]]));
|
|
22
|
+
}
|
|
23
|
+
// Only Bamboo receives this view. Vite and other plugins retain the full registry.
|
|
24
|
+
css.configResolved = {
|
|
25
|
+
...(typeof resolvedHook === 'object' ? resolvedHook : {}),
|
|
26
|
+
handler(config) {
|
|
27
|
+
return resolved.call(this, config.command === 'build'
|
|
28
|
+
? { ...config, environments: select(config.environments) }
|
|
29
|
+
: config);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
css.buildApp = {
|
|
33
|
+
...(typeof appHook === 'object' ? appHook : {}),
|
|
34
|
+
handler(builder) {
|
|
35
|
+
return app.call(this, { ...builder, environments: select(builder.environments) });
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
plugins.unshift({
|
|
39
|
+
name: 'xplat-bamboo:build-environments',
|
|
40
|
+
apply: 'build',
|
|
41
|
+
buildStart: {
|
|
42
|
+
order: 'pre',
|
|
43
|
+
sequential: true,
|
|
44
|
+
handler() {
|
|
45
|
+
const name = this.environment?.name;
|
|
46
|
+
if (!name || !participating.has(name)) {
|
|
47
|
+
this.error(`@octane-xplat/bamboo: building environment "${name ?? 'unknown'}" is missing from buildEnvironments; include every environment the builder runs`);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -37,9 +37,44 @@ const portableProperties = [
|
|
|
37
37
|
'textAlign',
|
|
38
38
|
'width',
|
|
39
39
|
];
|
|
40
|
-
|
|
40
|
+
// Token names mirror every --color-* / --radius-* / --space-* variable the
|
|
41
|
+
// @octane-xplat/ui default theme (theme/chrome.css `:root, .ns-root` block)
|
|
42
|
+
// declares. tests/theme-tokens.test.mjs fails when the lists drift apart.
|
|
43
|
+
const colors = Object.fromEntries([
|
|
44
|
+
'primary',
|
|
45
|
+
'onprimary',
|
|
46
|
+
'surface',
|
|
47
|
+
'surface-secondary',
|
|
48
|
+
'text',
|
|
49
|
+
'text-secondary',
|
|
50
|
+
'text-disabled',
|
|
51
|
+
'border',
|
|
52
|
+
'border-strong',
|
|
53
|
+
'danger',
|
|
54
|
+
'warning',
|
|
55
|
+
'success',
|
|
56
|
+
'overlay-hover',
|
|
57
|
+
'overlay-pressed',
|
|
58
|
+
'danger-text',
|
|
59
|
+
'warning-text',
|
|
60
|
+
'success-text',
|
|
61
|
+
'syntax-keyword',
|
|
62
|
+
'syntax-string',
|
|
63
|
+
'syntax-comment',
|
|
64
|
+
'syntax-number',
|
|
65
|
+
'syntax-function',
|
|
66
|
+
'syntax-type',
|
|
67
|
+
'syntax-variable',
|
|
68
|
+
'syntax-operator',
|
|
69
|
+
'syntax-constant',
|
|
70
|
+
'syntax-tag',
|
|
71
|
+
'syntax-attribute',
|
|
72
|
+
'syntax-property',
|
|
73
|
+
'syntax-punctuation',
|
|
74
|
+
'syntax-background',
|
|
75
|
+
].map((name) => [name, { value: `var(--color-${name})` }]));
|
|
41
76
|
const spacing = Object.fromEntries(['4'].map((name) => [name, { value: `var(--space-${name})` }]));
|
|
42
|
-
const radii = Object.fromEntries(['sm', 'md', 'lg', 'xl'].map((name) => [name, { value: `var(--radius-${name})` }]));
|
|
77
|
+
const radii = Object.fromEntries(['sm', 'md', 'lg', 'xl', 'container'].map((name) => [name, { value: `var(--radius-${name})` }]));
|
|
43
78
|
const portableUtilities = Object.fromEntries(portableProperties.map((property) => {
|
|
44
79
|
const config = presetBase.utilities[property];
|
|
45
80
|
if (!config) {
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bamboocss } from '@bamboocss/vite';
|
|
2
|
+
import { buildEnvironments as adaptBuildEnvironments } from "./build-environments.js";
|
|
2
3
|
import { platformOutput } from "./platform-output.js";
|
|
3
4
|
function runBeforeNativeCss(plugin, anchor) {
|
|
4
5
|
const hook = plugin?.generateBundle;
|
|
@@ -18,8 +19,11 @@ function runBeforeNativeCss(plugin, anchor) {
|
|
|
18
19
|
* Pass `cwd` and `configPath` when Bamboo's source/config root differs from
|
|
19
20
|
* Vite's app root, as it does in the shared harness.
|
|
20
21
|
*/
|
|
21
|
-
export function xplatBamboo({ native = false, ...options } = {}) {
|
|
22
|
+
export function xplatBamboo({ native = false, buildEnvironments, ...options } = {}) {
|
|
22
23
|
const plugins = bamboocss(options);
|
|
24
|
+
if (buildEnvironments) {
|
|
25
|
+
adaptBuildEnvironments(plugins, buildEnvironments);
|
|
26
|
+
}
|
|
23
27
|
if (native) {
|
|
24
28
|
// Let Bamboo prune and validate the emitted asset before NativeScript's
|
|
25
29
|
// main-entry hook serializes it into the native bootstrap and removes it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/bamboo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Bamboo CSS integration defaults for Octane xplat apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bamboo",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@bamboocss/dev": "1.56.2",
|
|
53
|
-
"@octane-xplat/cli": "0.
|
|
53
|
+
"@octane-xplat/cli": "0.18.0",
|
|
54
54
|
"typescript": "5.9.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test:packed": "node tests/packed-consumer.mjs",
|
|
61
61
|
"typegen": "tsc -p tsconfig.build.json",
|
|
62
|
-
"test": "node --test tests
|
|
62
|
+
"test": "node --test tests/*.test.mjs"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
/** Adapt Bamboo 1.56.2's configured-environment accounting to an explicit build plan. */
|
|
4
|
+
export function buildEnvironments(plugins: Plugin[], names: readonly string[]) {
|
|
5
|
+
const participating = new Set(names)
|
|
6
|
+
if (!participating.size || names.some((name) => !name)) {
|
|
7
|
+
throw new Error('@octane-xplat/bamboo: buildEnvironments must contain environment names')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const css = plugins.find((plugin) => plugin.name === 'bamboocss:css')
|
|
11
|
+
const resolvedHook = css?.configResolved
|
|
12
|
+
const appHook = css?.buildApp
|
|
13
|
+
const resolved = typeof resolvedHook === 'function' ? resolvedHook : resolvedHook?.handler
|
|
14
|
+
const app = typeof appHook === 'function' ? appHook : appHook?.handler
|
|
15
|
+
if (!css || !resolved || !app) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
'@octane-xplat/bamboo: buildEnvironments requires Bamboo CSS configResolved and buildApp hooks',
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function select<T>(environments: Record<string, T>): Record<string, T> {
|
|
22
|
+
for (const name of participating) {
|
|
23
|
+
if (!Object.hasOwn(environments, name)) {
|
|
24
|
+
throw new Error(`@octane-xplat/bamboo: unknown buildEnvironments entry "${name}"`)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return Object.fromEntries([...participating].map((name) => [name, environments[name]]))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Only Bamboo receives this view. Vite and other plugins retain the full registry.
|
|
31
|
+
css.configResolved = {
|
|
32
|
+
...(typeof resolvedHook === 'object' ? resolvedHook : {}),
|
|
33
|
+
handler(config) {
|
|
34
|
+
return resolved.call(
|
|
35
|
+
this,
|
|
36
|
+
config.command === 'build'
|
|
37
|
+
? { ...config, environments: select(config.environments) }
|
|
38
|
+
: config,
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
css.buildApp = {
|
|
43
|
+
...(typeof appHook === 'object' ? appHook : {}),
|
|
44
|
+
handler(builder) {
|
|
45
|
+
return app.call(this, { ...builder, environments: select(builder.environments) })
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
plugins.unshift({
|
|
49
|
+
name: 'xplat-bamboo:build-environments',
|
|
50
|
+
apply: 'build',
|
|
51
|
+
buildStart: {
|
|
52
|
+
order: 'pre',
|
|
53
|
+
sequential: true,
|
|
54
|
+
handler() {
|
|
55
|
+
const name = this.environment?.name
|
|
56
|
+
if (!name || !participating.has(name)) {
|
|
57
|
+
this.error(
|
|
58
|
+
`@octane-xplat/bamboo: building environment "${name ?? 'unknown'}" is missing from buildEnvironments; include every environment the builder runs`,
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -40,16 +40,49 @@ const portableProperties = [
|
|
|
40
40
|
'width',
|
|
41
41
|
] as const
|
|
42
42
|
|
|
43
|
+
// Token names mirror every --color-* / --radius-* / --space-* variable the
|
|
44
|
+
// @octane-xplat/ui default theme (theme/chrome.css `:root, .ns-root` block)
|
|
45
|
+
// declares. tests/theme-tokens.test.mjs fails when the lists drift apart.
|
|
43
46
|
const colors = Object.fromEntries(
|
|
44
|
-
[
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
[
|
|
48
|
+
'primary',
|
|
49
|
+
'onprimary',
|
|
50
|
+
'surface',
|
|
51
|
+
'surface-secondary',
|
|
52
|
+
'text',
|
|
53
|
+
'text-secondary',
|
|
54
|
+
'text-disabled',
|
|
55
|
+
'border',
|
|
56
|
+
'border-strong',
|
|
57
|
+
'danger',
|
|
58
|
+
'warning',
|
|
59
|
+
'success',
|
|
60
|
+
'overlay-hover',
|
|
61
|
+
'overlay-pressed',
|
|
62
|
+
'danger-text',
|
|
63
|
+
'warning-text',
|
|
64
|
+
'success-text',
|
|
65
|
+
'syntax-keyword',
|
|
66
|
+
'syntax-string',
|
|
67
|
+
'syntax-comment',
|
|
68
|
+
'syntax-number',
|
|
69
|
+
'syntax-function',
|
|
70
|
+
'syntax-type',
|
|
71
|
+
'syntax-variable',
|
|
72
|
+
'syntax-operator',
|
|
73
|
+
'syntax-constant',
|
|
74
|
+
'syntax-tag',
|
|
75
|
+
'syntax-attribute',
|
|
76
|
+
'syntax-property',
|
|
77
|
+
'syntax-punctuation',
|
|
78
|
+
'syntax-background',
|
|
79
|
+
].map((name) => [name, { value: `var(--color-${name})` }]),
|
|
47
80
|
)
|
|
48
81
|
|
|
49
82
|
const spacing = Object.fromEntries(['4'].map((name) => [name, { value: `var(--space-${name})` }]))
|
|
50
83
|
|
|
51
84
|
const radii = Object.fromEntries(
|
|
52
|
-
['sm', 'md', 'lg', 'xl'].map((name) => [name, { value: `var(--radius-${name})` }]),
|
|
85
|
+
['sm', 'md', 'lg', 'xl', 'container'].map((name) => [name, { value: `var(--radius-${name})` }]),
|
|
53
86
|
)
|
|
54
87
|
|
|
55
88
|
const portableUtilities = Object.fromEntries(
|
package/src/vite.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bamboocss, type BambooVitePluginOptions } from '@bamboocss/vite'
|
|
2
2
|
import type { Plugin } from 'vite'
|
|
3
|
+
import { buildEnvironments as adaptBuildEnvironments } from './build-environments.ts'
|
|
3
4
|
import { platformOutput } from './platform-output.ts'
|
|
4
5
|
|
|
5
6
|
function runBeforeNativeCss(plugin: Plugin | undefined, anchor: string) {
|
|
@@ -16,8 +17,12 @@ function runBeforeNativeCss(plugin: Plugin | undefined, anchor: string) {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export interface XplatBambooOptions extends BambooVitePluginOptions {
|
|
19
|
-
/**
|
|
20
|
+
/** Native CSS delivery — NativeScript's generateBundle serializer and the
|
|
21
|
+
* desktop `xplatInlineStylesheets` plugin both consume the finalized assets
|
|
22
|
+
* after this 'pre' finalizer. */
|
|
20
23
|
native?: boolean
|
|
24
|
+
/** All environments the custom Vite builder will run, including real SSR targets. */
|
|
25
|
+
buildEnvironments?: readonly string[]
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -26,8 +31,15 @@ export interface XplatBambooOptions extends BambooVitePluginOptions {
|
|
|
26
31
|
* Pass `cwd` and `configPath` when Bamboo's source/config root differs from
|
|
27
32
|
* Vite's app root, as it does in the shared harness.
|
|
28
33
|
*/
|
|
29
|
-
export function xplatBamboo({
|
|
34
|
+
export function xplatBamboo({
|
|
35
|
+
native = false,
|
|
36
|
+
buildEnvironments,
|
|
37
|
+
...options
|
|
38
|
+
}: XplatBambooOptions = {}) {
|
|
30
39
|
const plugins = bamboocss(options)
|
|
40
|
+
if (buildEnvironments) {
|
|
41
|
+
adaptBuildEnvironments(plugins, buildEnvironments)
|
|
42
|
+
}
|
|
31
43
|
|
|
32
44
|
if (native) {
|
|
33
45
|
// Let Bamboo prune and validate the emitted asset before NativeScript's
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { type BambooVitePluginOptions } from '@bamboocss/vite';
|
|
2
2
|
import type { Plugin } from 'vite';
|
|
3
3
|
export interface XplatBambooOptions extends BambooVitePluginOptions {
|
|
4
|
-
/**
|
|
4
|
+
/** Native CSS delivery — NativeScript's generateBundle serializer and the
|
|
5
|
+
* desktop `xplatInlineStylesheets` plugin both consume the finalized assets
|
|
6
|
+
* after this 'pre' finalizer. */
|
|
5
7
|
native?: boolean;
|
|
8
|
+
/** All environments the custom Vite builder will run, including real SSR targets. */
|
|
9
|
+
buildEnvironments?: readonly string[];
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
12
|
* Create Bamboo's Vite plugins for an Octane xplat app.
|
|
@@ -10,4 +14,4 @@ export interface XplatBambooOptions extends BambooVitePluginOptions {
|
|
|
10
14
|
* Pass `cwd` and `configPath` when Bamboo's source/config root differs from
|
|
11
15
|
* Vite's app root, as it does in the shared harness.
|
|
12
16
|
*/
|
|
13
|
-
export declare function xplatBamboo({ native, ...options }?: XplatBambooOptions): Plugin<any>[];
|
|
17
|
+
export declare function xplatBamboo({ native, buildEnvironments, ...options }?: XplatBambooOptions): Plugin<any>[];
|