@octane-xplat/bamboo 0.0.1 → 0.9.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/LICENSE +21 -0
- package/README.md +30 -2
- package/package.json +30 -10
- package/src/config.ts +109 -0
- package/src/vite.ts +62 -0
- package/index.d.ts +0 -1
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alec Larson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@octane-xplat/bamboo`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bamboo CSS integration defaults for Octane xplat apps — the glue between
|
|
4
|
+
[`@bamboocss`](https://github.com/aleclarson/bamboo) portable utilities
|
|
5
|
+
and the framework stylesheet. It exports a preset scoped to the CSS subset
|
|
6
|
+
both NativeScript and browsers support (`xplatPortablePreset`, the `vx-*`
|
|
7
|
+
utility classes on framework token vars), plus layer ordering that keeps
|
|
8
|
+
utilities under the app's own CSS.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add -D @octane-xplat/bamboo
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Two entry points:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// bamboo.config.ts — ./ or ./config
|
|
18
|
+
import { xplatBambooConfig, xplatPortablePreset } from '@octane-xplat/bamboo'
|
|
19
|
+
|
|
20
|
+
// vite.config.ts — ./vite
|
|
21
|
+
import { xplatBamboo } from '@octane-xplat/bamboo/vite'
|
|
22
|
+
|
|
23
|
+
plugins: [xplatBamboo()] // { native: true } for the native build
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Preflight is off by default and tokens land on `:root, .ns-root`. The
|
|
27
|
+
xplat NativeScript CSS transform unwraps the emitted `@layer` blocks for
|
|
28
|
+
native builds (the NS parser drops unknown at-rules); browsers keep the
|
|
29
|
+
layers, which is what lets app CSS stay unlayered on top.
|
|
30
|
+
|
|
31
|
+
Guide: [Styling screens](../../docs/styling.md).
|
package/package.json
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/bamboo",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Bamboo CSS integration defaults for Octane xplat apps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bamboo",
|
|
7
|
+
"css",
|
|
8
|
+
"nativescript",
|
|
9
|
+
"octane",
|
|
10
|
+
"xplat"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/bamboo",
|
|
5
13
|
"license": "MIT",
|
|
6
14
|
"repository": {
|
|
7
15
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/octane-xplat/octane-xplat
|
|
16
|
+
"url": "https://github.com/octane-xplat/octane-xplat",
|
|
9
17
|
"directory": "packages/bamboo"
|
|
10
18
|
},
|
|
11
|
-
"homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/bamboo",
|
|
12
|
-
"main": "./index.js",
|
|
13
|
-
"types": "./index.d.ts",
|
|
14
19
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./src/config.ts",
|
|
25
|
+
"./config": "./src/config.ts",
|
|
26
|
+
"./vite": "./src/vite.ts"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@bamboocss/preset-base": "1.56.2",
|
|
33
|
+
"@bamboocss/types": "1.56.2",
|
|
34
|
+
"@bamboocss/vite": "1.56.2"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"vite": ">=5"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { preset as presetBase } from '@bamboocss/preset-base'
|
|
2
|
+
import type { Preset, Theme, UserConfig, UtilityConfig } from '@bamboocss/types'
|
|
3
|
+
|
|
4
|
+
const portableProperties = [
|
|
5
|
+
'alignItems',
|
|
6
|
+
'alignSelf',
|
|
7
|
+
'backgroundColor',
|
|
8
|
+
'borderColor',
|
|
9
|
+
'borderRadius',
|
|
10
|
+
'borderWidth',
|
|
11
|
+
'color',
|
|
12
|
+
'display',
|
|
13
|
+
'flexDirection',
|
|
14
|
+
'flexGrow',
|
|
15
|
+
'flexShrink',
|
|
16
|
+
'flexWrap',
|
|
17
|
+
'fontFamily',
|
|
18
|
+
'fontSize',
|
|
19
|
+
'fontWeight',
|
|
20
|
+
'gap',
|
|
21
|
+
'height',
|
|
22
|
+
'justifyContent',
|
|
23
|
+
'lineHeight',
|
|
24
|
+
'margin',
|
|
25
|
+
'marginBottom',
|
|
26
|
+
'marginLeft',
|
|
27
|
+
'marginRight',
|
|
28
|
+
'marginTop',
|
|
29
|
+
'maxHeight',
|
|
30
|
+
'maxWidth',
|
|
31
|
+
'minHeight',
|
|
32
|
+
'minWidth',
|
|
33
|
+
'padding',
|
|
34
|
+
'paddingBottom',
|
|
35
|
+
'paddingLeft',
|
|
36
|
+
'paddingRight',
|
|
37
|
+
'paddingTop',
|
|
38
|
+
'textAlign',
|
|
39
|
+
'width',
|
|
40
|
+
] as const
|
|
41
|
+
|
|
42
|
+
const colors = Object.fromEntries(
|
|
43
|
+
['danger', 'onprimary', 'primary', 'surface', 'surface-secondary', 'text', 'text-secondary'].map(
|
|
44
|
+
(name) => [name, { value: `var(--color-${name})` }],
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const spacing = Object.fromEntries(['4'].map((name) => [name, { value: `var(--space-${name})` }]))
|
|
49
|
+
|
|
50
|
+
const radii = Object.fromEntries(
|
|
51
|
+
['sm', 'md', 'lg', 'xl'].map((name) => [name, { value: `var(--radius-${name})` }]),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const portableUtilities = Object.fromEntries(
|
|
55
|
+
portableProperties.flatMap((property) => {
|
|
56
|
+
const config = presetBase.utilities[property]
|
|
57
|
+
if (!config) {
|
|
58
|
+
return []
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Bamboo's default margin scale includes `auto`, which NativeScript
|
|
62
|
+
// ignores; expose token spacing only in the shared preset.
|
|
63
|
+
return [[property, property.startsWith('margin') ? { ...config, values: 'spacing' } : config]]
|
|
64
|
+
}),
|
|
65
|
+
) as UtilityConfig
|
|
66
|
+
|
|
67
|
+
const portableTheme = {
|
|
68
|
+
tokens: {
|
|
69
|
+
colors,
|
|
70
|
+
radii,
|
|
71
|
+
spacing,
|
|
72
|
+
},
|
|
73
|
+
} satisfies Theme
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Utilities and tokens selected for the CSS subset shared by NativeScript and
|
|
77
|
+
* browsers. This intentionally omits Bamboo's full browser-oriented preset;
|
|
78
|
+
* apps can extend it when they have checked a property on their targets.
|
|
79
|
+
*/
|
|
80
|
+
export const xplatPortablePreset: Preset = {
|
|
81
|
+
name: '@octane-xplat/bamboo/portable',
|
|
82
|
+
utilities: portableUtilities,
|
|
83
|
+
theme: portableTheme,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Bamboo defaults for apps using the shared Octane xplat stylesheet.
|
|
88
|
+
*
|
|
89
|
+
* Pass this object to `defineConfig` from `@bamboocss/dev`, then add the app's
|
|
90
|
+
* `include` and `outdir`. The shared UI stylesheet declares the matching layer
|
|
91
|
+
* order before `virtual:bamboo.css` is imported.
|
|
92
|
+
*/
|
|
93
|
+
export const xplatBambooConfig = {
|
|
94
|
+
preflight: false,
|
|
95
|
+
cssVarRoot: ':root, .ns-root',
|
|
96
|
+
layers: {
|
|
97
|
+
reset: 'xplat.reset',
|
|
98
|
+
base: 'xplat.base',
|
|
99
|
+
tokens: 'xplat.tokens',
|
|
100
|
+
recipes: 'xplat.recipes',
|
|
101
|
+
utilities: 'xplat.utilities',
|
|
102
|
+
},
|
|
103
|
+
presets: [],
|
|
104
|
+
utilities: portableUtilities,
|
|
105
|
+
theme: portableTheme,
|
|
106
|
+
} satisfies Pick<
|
|
107
|
+
UserConfig,
|
|
108
|
+
'preflight' | 'cssVarRoot' | 'layers' | 'presets' | 'utilities' | 'theme'
|
|
109
|
+
>
|
package/src/vite.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { bamboocss, type BambooVitePluginOptions } from '@bamboocss/vite'
|
|
2
|
+
|
|
3
|
+
export interface XplatBambooOptions extends BambooVitePluginOptions {
|
|
4
|
+
/** NativeScript consumes CSS assets in its own generateBundle hook. */
|
|
5
|
+
native?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create Bamboo's Vite plugins for an Octane xplat app.
|
|
10
|
+
*
|
|
11
|
+
* Pass `cwd` and `configPath` when Bamboo's source/config root differs from
|
|
12
|
+
* Vite's app root, as it does in the shared harness.
|
|
13
|
+
*/
|
|
14
|
+
export function xplatBamboo({ native = false, ...options }: XplatBambooOptions = {}) {
|
|
15
|
+
const plugins = bamboocss(options)
|
|
16
|
+
|
|
17
|
+
if (native) {
|
|
18
|
+
// Let Bamboo prune and validate the emitted asset before NativeScript's
|
|
19
|
+
// main-entry hook serializes it into the native bootstrap and removes it.
|
|
20
|
+
const cssPlugin = plugins.find((plugin) => plugin.name === 'bamboocss:css')
|
|
21
|
+
if (cssPlugin && typeof cssPlugin.generateBundle === 'object') {
|
|
22
|
+
cssPlugin.generateBundle.order = 'pre'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
plugins.push({
|
|
26
|
+
name: 'xplat-bamboo:nativescript-output',
|
|
27
|
+
enforce: 'post',
|
|
28
|
+
options: {
|
|
29
|
+
order: 'post',
|
|
30
|
+
handler(inputOptions) {
|
|
31
|
+
type OutputHook = {
|
|
32
|
+
name?: string
|
|
33
|
+
generateBundle?: { order?: string } | ((...args: never[]) => unknown)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const options = inputOptions as unknown as {
|
|
37
|
+
output?: { plugins?: OutputHook[] } | Array<{ plugins?: OutputHook[] }>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const outputs = Array.isArray(options.output)
|
|
41
|
+
? options.output
|
|
42
|
+
: options.output
|
|
43
|
+
? [options.output]
|
|
44
|
+
: []
|
|
45
|
+
|
|
46
|
+
for (const output of outputs) {
|
|
47
|
+
for (const plugin of output.plugins ?? []) {
|
|
48
|
+
if (
|
|
49
|
+
plugin.name?.startsWith('bamboocss:output-finalizer:') &&
|
|
50
|
+
typeof plugin.generateBundle === 'object'
|
|
51
|
+
) {
|
|
52
|
+
plugin.generateBundle.order = 'pre'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return plugins
|
|
62
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
package/index.js
DELETED