@uniweb/build 1.7.1 → 1.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/build",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,15 +56,15 @@
56
56
  "js-yaml": "^4.1.0",
57
57
  "sharp": "^0.35.3",
58
58
  "yaml": "^2.5.0",
59
- "@uniweb/content-reader": "~1.5.4",
60
59
  "@uniweb/semantic-parser": "~1.12.2",
60
+ "@uniweb/schemas": "~1.6.1",
61
61
  "@uniweb/theming": "~1.2.1",
62
- "@uniweb/projections": "~1.1.6",
63
- "@uniweb/schemas": "~1.6.0",
64
- "@uniweb/content-writer": "~1.3.0"
62
+ "@uniweb/content-reader": "~1.5.4",
63
+ "@uniweb/content-writer": "~1.3.0",
64
+ "@uniweb/projections": "~1.1.6"
65
65
  },
66
66
  "optionalDependencies": {
67
- "@uniweb/runtime": "~1.1.14"
67
+ "@uniweb/runtime": "~1.1.15"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -74,7 +74,7 @@
74
74
  "@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
75
75
  "vite-plugin-svgr": "^4.0.0",
76
76
  "@uniweb/core": "~1.4.0",
77
- "@uniweb/runtime": "~1.1.14"
77
+ "@uniweb/runtime": "~1.1.15"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "vite": {
@@ -37,35 +37,7 @@
37
37
 
38
38
  import { lowerData } from '@uniweb/schemas/content'
39
39
  import { schemaDeclarationOf } from '@uniweb/schemas/foundation'
40
-
41
- /**
42
- * A section type's `sticky`, checked: `true` or `false`, or `{ default, top }`. `top` is how far
43
- * below the top the section stays — one CSS value, `4rem` or `var(--header-height)` — and is
44
- * written into the style of the box that sticks, so a declaration (`;`, a brace) is refused.
45
- *
46
- * @param {*} declared - `meta.js`'s `sticky`
47
- * @returns {{ default: boolean, top?: string }}
48
- * @throws {Error} for any other shape
49
- */
50
- export function stickyDeclaration(declared) {
51
- if (typeof declared === 'boolean') return { default: declared }
52
- if (!declared || typeof declared !== 'object' || Array.isArray(declared)) {
53
- throw new Error(`[uniweb] Invalid 'sticky': write true, false or { default, top } — got ${JSON.stringify(declared)}`)
54
- }
55
- const unknown = Object.keys(declared).filter((key) => key !== 'default' && key !== 'top')
56
- if (unknown.length) throw new Error(`[uniweb] Invalid 'sticky': ${unknown.join(', ')} — it takes default and top`)
57
- if (declared.default !== undefined && typeof declared.default !== 'boolean') {
58
- throw new Error(`[uniweb] Invalid 'sticky.default': write true or false`)
59
- }
60
- const out = { default: declared.default === true }
61
- if (declared.top !== undefined) {
62
- if (typeof declared.top !== 'string' || !declared.top.trim() || /[;{}]/.test(declared.top)) {
63
- throw new Error(`[uniweb] Invalid 'sticky.top': one CSS length, such as '4rem' or 'var(--header-height)'`)
64
- }
65
- out.top = declared.top.trim()
66
- }
67
- return out
68
- }
40
+ import { stickyDeclaration } from '@uniweb/schemas/section'
69
41
 
70
42
  /**
71
43
  * A `data:` entry as the runtime reads it: its schema ref, with the flags set on it — or null for an
@@ -164,8 +136,13 @@ export function extractRuntimeSchema(fullMeta) {
164
136
 
165
137
  // Whether the section stays in view by default: core reads it, and the author's
166
138
  // `sticky:` wins (`Block#initComponent`). The runtime makes sticky the box that can.
139
+ // `{ default }`, with `top` when the type has one — the shape a registered entry holds too.
167
140
  if (fullMeta.sticky !== undefined) {
168
- runtime.sticky = stickyDeclaration(fullMeta.sticky)
141
+ try {
142
+ runtime.sticky = stickyDeclaration(fullMeta.sticky)
143
+ } catch (err) {
144
+ throw new Error(`[uniweb] ${err.message}`)
145
+ }
169
146
  }
170
147
 
171
148
  // Data. `data:` is the single declaration surface for a section's structured
package/src/schema.js CHANGED
@@ -21,8 +21,7 @@ import { describeChildren, describeVisuals, lowerChildren } from '@uniweb/schema
21
21
  import { describeContent, lowerData } from '@uniweb/schemas/content'
22
22
  import { normalizeData, schemaDeclarationOf } from '@uniweb/schemas/foundation'
23
23
  import { rootListSection } from '@uniweb/schemas/conform'
24
- import { SECTION_PARAMS, SECTION_KEYS } from '@uniweb/schemas/section'
25
- import { stickyDeclaration } from './runtime-schema.js'
24
+ import { SECTION_PARAMS, SECTION_KEYS, stickyDeclaration } from '@uniweb/schemas/section'
26
25
  import { collectSchemaRefs, buildDataSchemaMap, ownSchemaRefs } from './resolve-data-schema.js'
27
26
  import {
28
27
  composeSupports,
@@ -661,8 +660,9 @@ function buildComponentEntry(name, relativePath, meta) {
661
660
  }
662
661
 
663
662
  /**
664
- * Refuse a `sticky` that is not `true`, `false` or `{ default, top }` (`stickyDeclaration`), naming
665
- * the component — the lean runtime schema checks it too, without the name.
663
+ * Refuse a `sticky` that is not `true`, `false` or `{ default, top }` (`stickyDeclaration`,
664
+ * `@uniweb/schemas/section`), naming the component — the lean runtime schema checks it too,
665
+ * without the name. The entry keeps it as written; `register` writes it in one shape (format 3).
666
666
  *
667
667
  * @param {string} owner - who declares it, for the message
668
668
  * @param {*} sticky - `meta.js`'s `sticky`
@@ -672,7 +672,7 @@ function refuseStickyDeclaration(owner, sticky) {
672
672
  try {
673
673
  stickyDeclaration(sticky)
674
674
  } catch (err) {
675
- throw new Error(`[uniweb] ${owner}: ${err.message.replace(/^\[uniweb\] /, '')}`)
675
+ throw new Error(`[uniweb] ${owner}: ${err.message}`)
676
676
  }
677
677
  }
678
678