@vincentt-xr/sdk 2.0.0-alpha.11 → 2.0.0-alpha.13

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/GROUNDING.md CHANGED
@@ -123,12 +123,20 @@ nothing to an app bundle.
123
123
 
124
124
  - Components are keyed by export name; props by dotted path into object props
125
125
  (`screenTransform.position`, `settings.fillColor`).
126
- - `type` is one of `number`, `color`, `boolean`, `vec2`, `vec3`, `euler`, `enum`.
127
- A `vec2`/`vec3` is either a number tuple (`[x, y]`) or an object of two or three
128
- number fields (`{ x, y }`, `{ width, height }`); the editor follows the literal
129
- written in source. An `enum` lists its values in `enum`.
126
+ - `type` is one of `number`, `color`, `boolean`, `vec2`, `vec3`, `euler`, `enum`,
127
+ `text`, `asset`. A `vec2`/`vec3` is either a number tuple (`[x, y]`) or an
128
+ object of two or three number fields (`{ x, y }`, `{ width, height }`); the
129
+ editor follows the literal written in source. An `enum` lists its values in
130
+ `enum`.
130
131
  - `min`, `max`, `step` and `unit` (`px`, `m`, `deg`, `rad`, `ratio`) apply to
131
132
  `number`, `vec2`, `vec3` and `euler`; `label` to any type.
133
+ - A `text` setting is words shown on screen: `maxLength` is the most code points
134
+ the editor accepts (at most 500), and `multiline: true` allows line breaks.
135
+ - An `asset` setting is a file reference; `accept` lists the kinds of file it
136
+ takes (only `"image"` today).
137
+ - `overriddenBy` lists other props of the component that, when written, make the
138
+ setting ignored at run time. The editor hides the setting on an element that
139
+ has one of them (`ScreenImage.src` is `overriddenBy: ["source"]`).
132
140
  - `element` puts a component on the editor's **supported list** as one list kind
133
141
  (`screenText`, `screenImage`, `screenShape`), and `supported: true` marks the
134
142
  settings the editor shows for it. The editor shows only supported settings on
@@ -160,6 +168,23 @@ double-quoted. A tag on a shared props type (`TextLabelProps`,
160
168
  `ScreenTransform2DSettings`) declares the setting for every exported component
161
169
  that reaches it.
162
170
 
171
+ `text` and `asset` are always named, on a string prop. `maxLength=` (a whole
172
+ number from 1 to 500) and `multiline=true|false` apply to `text`; `accept=`
173
+ (comma-separated, `image`) is required on `asset`; `overriddenBy=` takes
174
+ comma-separated top-level prop names of the component and applies to any type.
175
+
176
+ ```ts
177
+ export type ScreenImageProps = {
178
+ source?: ScreenImageSource;
179
+ /** @tweak asset accept=image overriddenBy=source */
180
+ src?: string;
181
+ };
182
+ export type TextLabelProps = {
183
+ /** @tweak text maxLength=500 multiline=true */
184
+ text: string;
185
+ };
186
+ ```
187
+
163
188
  **SDK authors: put a component on the supported list with `@editorElement`** on
164
189
  the component's own declaration: the list kind, then the dotted paths of the
165
190
  settings the editor should show. Each path must be a `@tweak` setting that
@@ -174,33 +199,47 @@ export const ScreenShape = (props: ScreenShapeProps) => {
174
199
  };
175
200
  ```
176
201
 
177
- Listed today: `ScreenText` (`fontSize`, `color`, `screenTransform.position`,
178
- `.size`, `.rotation`), `ScreenImage` (`transform.position`, `.size`,
179
- `.rotation`) and `ScreenShape` (`transform.position`, `.size`, `.rotation`,
180
- `settings.fillColor`).
202
+ Listed today: `ScreenText` (`text`, `fontSize`, `color`,
203
+ `screenTransform.position`, `.size`, `.rotation`), `ScreenImage` (`src`,
204
+ `opacity`, `fit`, `transform.position`, `.size`, `.rotation`) and `ScreenShape`
205
+ (`transform.position`, `.size`, `.rotation`, `settings.fillColor`).
206
+
207
+ The editor offers an element only when at least one of its listed settings is
208
+ written as a plain value. A full-screen frame image placed with `anchors`
209
+ (`anchors={{ left: -1, right: 1, top: 1, bottom: -1 }}`) is selectable through
210
+ `opacity` or `fit` written as literals, but it cannot be dragged: the editor
211
+ moves and sizes only through `transform`.
181
212
 
182
213
  `pnpm settings:generate` rewrites `settings.json`; commit the result. CI runs
183
214
  `pnpm settings:check` and fails when the file does not match the tags or the
184
215
  `package.json` version, so a version bump regenerates it too. The generator
185
216
  also fails on a malformed tag, an unknown key or unit, a type that does not fit
186
- the prop, and a `@tweak` that no exported component reaches. It also fails on
217
+ the prop, a `text`/`asset` key on another type, an `asset` without `accept`, an
218
+ `overriddenBy` that does not name another prop of the component, and a
219
+ `@tweak` that no exported component reaches. It also fails on
187
220
  an `@editorElement` with an unknown kind, no settings, a path that is not a
188
221
  `@tweak` setting of that component, a second tag on one component, or a tag
189
222
  that is not on an exported component.
190
223
 
191
224
  ### Live preview of unsaved editor changes
192
225
 
193
- In the console's visual editor, an unsaved change to `color` on `<ScreenText>`
194
- or `<TextLabel>` shows in the running app at once. Its other changes show after
195
- Save, which rebuilds the app. The editor's build defines a small override store
196
- on the page, and those two components read it for `color`. Published and
226
+ In the console's visual editor, an unsaved change to one of these settings
227
+ shows in the running app at once: `<ScreenText>` text, colour, font size and
228
+ screen placement; `<ScreenImage>` image (`src`, only when no `source` prop is
229
+ written), opacity, fit and screen placement; `<ScreenShape>` screen placement
230
+ and fill colour; `<TextLabel>` colour. Other changes show after Save, which
231
+ rebuilds the app. The editor's build defines a small override store on the
232
+ page, and those components read it for those settings. Published and
197
233
  preview builds have no store, so they render the props exactly as written.
198
234
  App code does nothing for this and must not define or read
199
235
  `__VCT_EDIT_OVERRIDES__`.
200
236
 
201
- SDK authors: to make another prop live, add its name to the component's
202
- `LIVE_EDITABLE` list (`lib/components/ScreenText/index.tsx`,
203
- `lib/components/TextLabel/TextLabel.tsx`). The hook is
237
+ SDK authors: to make another prop live, add its key to the component's live
238
+ list (`liveEditable.ts` beside `ScreenText` and `ScreenImage`, `LIVE_EDITABLE`
239
+ in `ScreenShape` and `TextLabel`). A key is the prop name or a dotted path into an object prop
240
+ (`settings.fillColor`, `transform.position`), the same key as in
241
+ `settings.json`. A dotted key replaces only that leaf, copying the objects
242
+ around it, and is skipped when the parent object is not written. The hook is
204
243
  `useEditOverrides(props, keys)` in `lib/utils/useEditOverrides.ts`. Call it with
205
244
  the component's own props object, before destructuring.
206
245
 
@@ -287,6 +326,15 @@ authoring prefer `position`, `size`, and `rotation`. `anchors` still exist as
287
326
  the lower-level layout escape hatch. If no source is provided, it renders the
288
327
  SDK-owned square default image.
289
328
 
329
+ **Placeholder images: always use `src`.** An image that is a placeholder or is
330
+ "to be replaced" is written as
331
+ `<ScreenImage src="/images/placeholder.png" ... />` (the template ships that
332
+ file), never `source={{ kind: "default" }}` and never `source={{ kind: "image",
333
+ src }}`. Only a `src` image can be swapped in the visual editor: `source` wins
334
+ over `src` whenever both are set, so the editor does not offer an image swap on a
335
+ `ScreenImage` that has a `source` prop. Keep `source` for GIFs, textures and
336
+ media a program produces.
337
+
290
338
  ### `<ScreenShape>` — editable vector primitives
291
339
 
292
340
  Use `ScreenShape` for circles, ellipses, rectangles, rounded rectangles, regular
@@ -384,7 +432,7 @@ import { ScreenImage, ScreenSpaceUI } from "@vincentt-xr/sdk";
384
432
  <ScreenSpaceUI>
385
433
  <ScreenImage
386
434
  name="logo"
387
- source={{ kind: "image", src: "https://cdn.../logo.png" }}
435
+ src="https://cdn.../logo.png"
388
436
  coordinateSpace="canvas"
389
437
  canvasSize={{ width: 720, height: 1280 }}
390
438
  position={[-180, 464]}
@@ -398,7 +446,8 @@ import { ScreenImage, ScreenSpaceUI } from "@vincentt-xr/sdk";
398
446
  Props:
399
447
 
400
448
  - `source`: `{ kind: "default" }`, `{ kind: "image", src }`, `{ kind: "gif", src }`, or `{ kind: "texture", texture }`.
401
- - `src`: shorthand for `{ kind: "image", src }`.
449
+ - `src`: shorthand for `{ kind: "image", src }`, ignored while `source` is set.
450
+ The form to use for a still image, because the visual editor can swap it.
402
451
  - `fit`: `"stretch" | "contain" | "cover"`; default `"contain"`.
403
452
  - `coordinateSpace`: `"normalized" | "canvas"`; default `"normalized"`.
404
453
  - `canvasSize`: design canvas size for `coordinateSpace="canvas"`; default
@@ -7660,6 +7709,12 @@ import { ScreenSpaceUI, ScreenText } from "@vincentt-xr/sdk";
7660
7709
  rectangle. The text renderer then aligns, shrinks, clips, or backgrounds the
7661
7710
  text inside that rectangle.
7662
7711
 
7712
+ **Visual editor:** write `text` as a literal string (`text="Tap to start"` or
7713
+ `text={"Tap to start"}`), with no `lines` prop, when it should be editable in the
7714
+ visual editor (`lines` wins over `text` when both are set). Text
7715
+ built from an expression, a variable, a translation lookup or a template literal
7716
+ with `${...}` shows there as made by code and can only be changed in source.
7717
+
7663
7718
  Use `ScreenText` when:
7664
7719
 
7665
7720
  - you want top / center / bottom screen placement