@octane-xplat/bamboo 0.0.1 → 0.8.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 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/package.json CHANGED
@@ -1,19 +1,39 @@
1
1
  {
2
2
  "name": "@octane-xplat/bamboo",
3
- "version": "0.0.1",
3
+ "version": "0.8.0",
4
4
  "description": "Bamboo CSS integration defaults for Octane xplat apps",
5
+ "keywords": [
6
+ "bamboo",
7
+ "css",
8
+ "octane",
9
+ "xplat",
10
+ "nativescript"
11
+ ],
5
12
  "license": "MIT",
13
+ "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/bamboo",
6
14
  "repository": {
7
15
  "type": "git",
8
- "url": "https://github.com/octane-xplat/octane-xplat.git",
16
+ "url": "git+https://github.com/octane-xplat/octane-xplat.git",
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
- "README.md",
16
- "index.js",
17
- "index.d.ts"
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,117 @@
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
+ [
44
+ 'danger',
45
+ 'onprimary',
46
+ 'primary',
47
+ 'surface',
48
+ 'surface-secondary',
49
+ 'text',
50
+ 'text-secondary',
51
+ ].map((name) => [name, { value: `var(--color-${name})` }]),
52
+ )
53
+
54
+ const spacing = Object.fromEntries(
55
+ ['4'].map((name) => [name, { value: `var(--space-${name})` }]),
56
+ )
57
+
58
+ const radii = Object.fromEntries(
59
+ ['sm', 'md', 'lg', 'xl'].map((name) => [name, { value: `var(--radius-${name})` }]),
60
+ )
61
+
62
+ const portableUtilities = Object.fromEntries(
63
+ portableProperties.flatMap((property) => {
64
+ const config = presetBase.utilities[property]
65
+ if (!config) {
66
+ return []
67
+ }
68
+
69
+ // Bamboo's default margin scale includes `auto`, which NativeScript
70
+ // ignores; expose token spacing only in the shared preset.
71
+ return [[property, property.startsWith('margin') ? { ...config, values: 'spacing' } : config]]
72
+ }),
73
+ ) as UtilityConfig
74
+
75
+ const portableTheme = {
76
+ tokens: {
77
+ colors,
78
+ radii,
79
+ spacing,
80
+ },
81
+ } satisfies Theme
82
+
83
+ /**
84
+ * Utilities and tokens selected for the CSS subset shared by NativeScript and
85
+ * browsers. This intentionally omits Bamboo's full browser-oriented preset;
86
+ * apps can extend it when they have checked a property on their targets.
87
+ */
88
+ export const xplatPortablePreset: Preset = {
89
+ name: '@octane-xplat/bamboo/portable',
90
+ utilities: portableUtilities,
91
+ theme: portableTheme,
92
+ }
93
+
94
+ /**
95
+ * Bamboo defaults for apps using the shared Octane xplat stylesheet.
96
+ *
97
+ * Pass this object to `defineConfig` from `@bamboocss/dev`, then add the app's
98
+ * `include` and `outdir`. The shared UI stylesheet declares the matching layer
99
+ * order before `virtual:bamboo.css` is imported.
100
+ */
101
+ export const xplatBambooConfig = {
102
+ preflight: false,
103
+ cssVarRoot: ':root, .ns-root',
104
+ layers: {
105
+ reset: 'xplat.reset',
106
+ base: 'xplat.base',
107
+ tokens: 'xplat.tokens',
108
+ recipes: 'xplat.recipes',
109
+ utilities: 'xplat.utilities',
110
+ },
111
+ presets: [],
112
+ utilities: portableUtilities,
113
+ theme: portableTheme,
114
+ } satisfies Pick<
115
+ UserConfig,
116
+ 'preflight' | 'cssVarRoot' | 'layers' | 'presets' | 'utilities' | 'theme'
117
+ >
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/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @octane-xplat/bamboo
2
-
3
- Version 0.0.1 is a reservation stub so the automated release can publish this package name. It has no supported API. Use a later release for the implementation.
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- // Reservation stub; implementation will arrive in a later release.
2
- module.exports = {}