@weft-js/plugin-surface-keel 0.0.0-stage → 0.1.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,16 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ravonus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
1
+ # @weft-js/plugin-surface-keel
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **Early release (0.1.0).** APIs will change between minor versions.
4
+
5
+ The `keel-pixel` surface kind (surface.renderer@1): KEEL's WebGL2 pixel renderer and theme recipes..
6
+
7
+ ```bash
8
+ npm install @weft-js/plugin-surface-keel
9
+ ```
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@weft-js/plugin-surface-keel",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "@weft-js/plugin-surface-keel: the `keel-pixel` surface kind (surface.renderer@1): KEEL's WebGL2 pixel renderer and theme recipes.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "default": "./src/index.mjs"
11
+ },
12
+ "./runtime": "./src/runtime.mjs",
13
+ "./theme": {
14
+ "types": "./src/index.d.ts",
15
+ "default": "./src/theme.mjs"
16
+ },
17
+ "./styles.css": "./vendor/keel-styles.css"
18
+ },
19
+ "peerDependencies": {
20
+ "@weft-js/core": "^0.1.0"
21
+ },
22
+ "engines": {
23
+ "node": ">=26"
24
+ },
25
+ "keywords": [
26
+ "weft"
27
+ ],
28
+ "files": [
29
+ "src",
30
+ "vendor",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { PluginEntry } from '@weft-js/core/config'
2
+ import type { Palette, PixelRenderer } from './vendor-types'
3
+
4
+ /** The plugin for `weft.config.ts`: adds the `keel-pixel` surface kind and KEEL's theme. */
5
+ export declare const keel: () => PluginEntry
6
+
7
+ /** `{ seed, culture, pins }` → KEEL's theme: palette ramps, frame, type, spacing and motion. */
8
+ export declare function recipeTheme(recipe?: { seed?: string; culture?: string; pins?: Record<string, unknown> }): { key: string; palette: Palette; [k: string]: unknown }
9
+ /** A theme as `--keel-*` CSS variables at an integer scale. */
10
+ export declare function themeTokens(theme: unknown, scale?: number): Record<string, string>
11
+
12
+ declare module '@weft-js/core/surface' {
13
+ interface SurfaceKinds {
14
+ /** `s.px`: KEEL's PixelRenderer. */
15
+ 'keel-pixel': { px: PixelRenderer }
16
+ }
17
+ }
package/src/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ // keel() for weft.config.ts (PLAN §5, research 33 §5): the `keel-pixel` surface kind. KEEL's renderer is ~27 KB br, so it
2
+ // stays behind the slot's `import()` and only pages that mount a `keel-pixel` surface load it.
3
+ import { definePlugin, defineSlot, provide } from '@weft-js/core/plugin'
4
+
5
+ const renderer = defineSlot({ id: 'surface.renderer', version: 1, cardinality: 'keyed', sides: ['client'] })
6
+
7
+ export const keel = definePlugin({
8
+ name: '@weft-js/plugin-surface-keel',
9
+ version: '0.1.0',
10
+ weft: '*',
11
+ namespace: 'surface-keel/',
12
+ contribute: () => ({
13
+ provides: [provide(renderer, { key: 'keel-pixel', sides: { client: { module: '@weft-js/plugin-surface-keel/runtime', export: 'renderer' } } })],
14
+ agents: {
15
+ title: 'KEEL surfaces (@weft-js/plugin-surface-keel)',
16
+ text: "- `kind: 'keel-pixel'` needs `pixel: { width, height }`. `s.px` is KEEL's `PixelRenderer`: `setPalette`, `setMaterials`, `setWorld`, `render`. Palettes come from `recipeTheme()` in `@weft-js/plugin-surface-keel/theme`.",
17
+ },
18
+ catalog: [{ name: 'keel', import: '@weft-js/plugin-surface-keel', summary: 'surface.renderer: keel-pixel' }],
19
+ }),
20
+ })
@@ -0,0 +1,11 @@
1
+ // surface.renderer@1 for `keel-pixel`. The renderer owns the GL context, so a surface adds only the fixed target.
2
+ import { createPixelRenderer } from '../vendor/keel-render.mjs'
3
+
4
+ /** The surface.renderer@1 provider: `context` makes the surface's `s.px` and undoes it when the surface goes. */
5
+ export const renderer = {
6
+ context(canvas, def) {
7
+ if (!def.pixel) throw new Error(`surface \`${def.name}\`: \`keel-pixel\` needs \`pixel: { width, height }\``)
8
+ const px = createPixelRenderer(canvas, def.pixel)
9
+ return { fields: { px }, dispose: () => canvas.getContext('webgl2')?.getExtension('WEBGL_lose_context')?.loseContext() }
10
+ },
11
+ }
package/src/theme.mjs ADDED
@@ -0,0 +1 @@
1
+ export { recipeTheme, themeTokens } from '../vendor/keel-theme.mjs'
@@ -0,0 +1,24 @@
1
+ /** A KEEL theme's colours: ramps of packed RGB, as the vendored engine computes them. */
2
+ export interface Palette {
3
+ tone: string
4
+ surface: number[]
5
+ ink: number[]
6
+ accent: number[]
7
+ good: number[]
8
+ warn: number[]
9
+ bad: number[]
10
+ team: unknown[]
11
+ outline: number
12
+ onAccent: number
13
+ hues: { surface: number; accent: number }
14
+ }
15
+
16
+ /** KEEL's renderer, typed as far as a surface drives one. The rest of the vendored API is reachable, untyped. */
17
+ export interface PixelRenderer {
18
+ setPalette(colours: number[][], ramps: Record<string, number[]>): void
19
+ setMaterials(materials: { ramp: string }[]): void
20
+ setWorld(world: object): void
21
+ setStyle(style: object): void
22
+ render(view: object): void
23
+ [other: string]: unknown
24
+ }
package/vendor/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ravonus
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # vendor
2
+
3
+ Built by `scripts/vendor.mjs` from keel-engine 4bcccc7 (MIT, Copyright (c) 2026 ravonus; see LICENSE).
4
+ Don't edit these files: fix KEEL and run the script again.
5
+
6
+ - `keel-render.mjs`: `createPixelRenderer` from `packages/render`, with what it needs of `packages/core`.
7
+ - `keel-theme.mjs`: `recipeTheme` and `themeTokens` from `packages/react/src/design.ts`.
8
+ - `keel-styles.css`: `packages/react/src/styles.css`.