@sbuilder/cli 0.12.0 → 0.14.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/README.md +116 -13
- package/README.vi.md +115 -13
- package/dist/bin/sb.js +221 -41
- package/dist/bin/sb.js.map +1 -1
- package/dist/src/agentdocs.js +250 -8
- package/dist/src/agentdocs.js.map +1 -1
- package/dist/src/appblocks.js +5 -1
- package/dist/src/appblocks.js.map +1 -1
- package/dist/src/components.js +400 -24
- package/dist/src/components.js.map +1 -1
- package/dist/src/doctor.js +37 -3
- package/dist/src/doctor.js.map +1 -1
- package/dist/src/envtypes.gen.js +2929 -271
- package/dist/src/envtypes.gen.js.map +1 -1
- package/dist/src/host.js +31 -0
- package/dist/src/host.js.map +1 -1
- package/dist/src/login.js +1 -1
- package/dist/src/preview.js +114 -0
- package/dist/src/preview.js.map +1 -0
- package/dist/src/route.js +4 -2
- package/dist/src/route.js.map +1 -1
- package/dist/src/site.js +164 -22
- package/dist/src/site.js.map +1 -1
- package/dist/src/siteinit.js +381 -74
- package/dist/src/siteinit.js.map +1 -1
- package/dist/src/sitekinds.js +56 -13
- package/dist/src/sitekinds.js.map +1 -1
- package/dist/src/source/derived.js +96 -0
- package/dist/src/source/derived.js.map +1 -0
- package/dist/src/source/meta.js +3 -3
- package/dist/src/source/meta.js.map +1 -1
- package/dist/src/source/parse.js +6 -2
- package/dist/src/source/parse.js.map +1 -1
- package/dist/src/source/print.js +8 -1
- package/dist/src/source/print.js.map +1 -1
- package/dist/src/structure.js +114 -0
- package/dist/src/structure.js.map +1 -0
- package/dist/src/templates.js +93 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/themediff.js +49 -0
- package/dist/src/themediff.js.map +1 -0
- package/package.json +1 -1
package/dist/src/agentdocs.js
CHANGED
|
@@ -7,8 +7,17 @@
|
|
|
7
7
|
* example below with parsePage; the app rules come from the server's own validators
|
|
8
8
|
* (server/internal/apps, webhooks.CheckURL), which tests/appblock.test.ts already runs.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { INTERACTIVE, THEME_TOKENS } from './envtypes.gen.js';
|
|
11
|
+
import { VERSION } from './login.js';
|
|
12
|
+
import { PREVIEW_TTL_MINUTES } from './preview.js';
|
|
13
|
+
const code = (xs) => xs.map((x) => `\`${x}\``).join(', ');
|
|
14
|
+
/**
|
|
15
|
+
* The CLI range the generated files pin (major.minor of THIS CLI), so CI and MCP never drift onto
|
|
16
|
+
* a version they were not written for. Derived, never typed: a literal here stayed at 0.11 while
|
|
17
|
+
* the package moved to 0.13, and every repo it wrote ran a CLI with no `sb site components`.
|
|
18
|
+
* VERSION is held to package.json by tests/auth.test.ts; tests/agentfiles.test.ts holds this to it.
|
|
19
|
+
*/
|
|
20
|
+
export const CLI_RANGE = VERSION.split('.').slice(0, 2).join('.');
|
|
12
21
|
/** Where the skills land, relative to the repo root. */
|
|
13
22
|
export const PAGE_SKILL_PATH = '.claude/skills/sbuilder-page/SKILL.md';
|
|
14
23
|
export const APP_SKILL_PATH = '.claude/skills/sbuilder-app/SKILL.md';
|
|
@@ -94,7 +103,8 @@ export default (
|
|
|
94
103
|
|
|
95
104
|
## Building a section with the tools
|
|
96
105
|
|
|
97
|
-
|
|
106
|
+
Prefer the \`sbuilder\` MCP tools when they are connected; without them, see the next section.
|
|
107
|
+
The tools edit the site's DRAFTS on the platform. Writes default to
|
|
98
108
|
\`dry_run: true\`; pass \`dry_run: false\` once you mean it.
|
|
99
109
|
|
|
100
110
|
1. \`sb_connect\`, then \`sb_page_list\` / \`sb_page_open\` the page.
|
|
@@ -110,6 +120,25 @@ The \`sbuilder\` MCP tools edit the site's DRAFTS on the platform. Writes defaul
|
|
|
110
120
|
Editing the file directly is fine for text, settings, moving or adding elements. Then push
|
|
111
121
|
and \`sb_look\` to see it.
|
|
112
122
|
|
|
123
|
+
## Without the MCP tools
|
|
124
|
+
|
|
125
|
+
The same loop with the CLI and the files alone:
|
|
126
|
+
|
|
127
|
+
1. **The catalog is \`design/sbuilder-env.d.ts\`.** Above each \`declare function <Tag>\` a comment
|
|
128
|
+
says what the element is for, when to use it and when not, which children it may hold (and
|
|
129
|
+
which part sits in \`detached\` instead), the format of props that have one, and an example.
|
|
130
|
+
Read the entry before using an element:
|
|
131
|
+
\`grep -n -B40 "declare function Accordion(" design/sbuilder-env.d.ts\`.
|
|
132
|
+
\`npx @sbuilder/cli@${CLI_RANGE} site types\` rewrites it from this CLI's schema.
|
|
133
|
+
2. **Check the structure.** \`npx @sbuilder/cli@${CLI_RANGE} doctor\` names every element that
|
|
134
|
+
sits where the schema does not allow it, with \`file:line\` and what to write instead.
|
|
135
|
+
\`site push\` refuses the same in a file it would send, and sends nothing.
|
|
136
|
+
3. **See the draft, unpublished.** \`site push\` saves it as a draft; then
|
|
137
|
+
\`npx @sbuilder/cli@${CLI_RANGE} site preview design/pages/<file>.page.tsx\` prints a link
|
|
138
|
+
(${PREVIEW_TTL_MINUTES} minutes) to the draft rendered as a visitor sees it, and \`--html\` prints
|
|
139
|
+
that HTML. Nothing is published. The repo's key in \`.env\` mints the link (it needs
|
|
140
|
+
\`pages.read\`); if it is refused, say so and ask the owner to open Preview in the editor.
|
|
141
|
+
|
|
113
142
|
## App blocks
|
|
114
143
|
|
|
115
144
|
An installed app's block has \`appBlockId\` on its root and belongs to the app. Never edit inside
|
|
@@ -132,15 +161,228 @@ each with a line like \`<Tag appBlockRef="…" />\` to paste into a page file an
|
|
|
132
161
|
\`site push --prune\` (it lists them; off a terminal it also needs \`--yes\`) — do that only when
|
|
133
162
|
the owner asked. A symlinked page file is refused.
|
|
134
163
|
- Beside \`design/pages/\`: \`design/globals/\` (shared sections, \`export const global\`), \`design/overlays/\`
|
|
135
|
-
(\`export const overlay\`), \`design/theme.json\` and \`design/translations/<locale>.json\`. Each
|
|
136
|
-
ways like a page: a change made in the editor AND in the file is named and nothing is sent.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
pushes each save as a draft.
|
|
164
|
+
(\`export const overlay\`), \`design/theme.json\` (below) and \`design/translations/<locale>.json\`. Each
|
|
165
|
+
syncs three ways like a page: a change made in the editor AND in the file is named and nothing is sent.
|
|
166
|
+
\`site status\` lists what differs and which translations are stale; \`site dev\` pushes each save as a
|
|
167
|
+
draft.
|
|
140
168
|
- \`site publish <file>\` / \`--all\` makes pages live for every visitor. **Never run it unless
|
|
141
169
|
the owner asked.** It publishes nothing by default.
|
|
142
170
|
|
|
143
171
|
Run these as \`npx @sbuilder/cli@${CLI_RANGE} site <pull|push|publish|blocks>\`.
|
|
172
|
+
|
|
173
|
+
## The theme (design/theme.json)
|
|
174
|
+
|
|
175
|
+
\`site pull\` writes it: the site's saved theme, or — while the site has saved none — the default
|
|
176
|
+
theme it renders with. It is one JSON object (theme version ${THEME_TOKENS.version}):
|
|
177
|
+
|
|
178
|
+
- \`colors\`: \`[{ id, name, value }]\`. The palette ids are ${code(THEME_TOKENS.colors)}; a page reads
|
|
179
|
+
one as \`var(${THEME_TOKENS.vars.color})\`.
|
|
180
|
+
- \`textStyles\`: \`[{ slug, name, base, responsive? }]\`, slugs ${code(THEME_TOKENS.textStyles)}; each
|
|
181
|
+
property is \`var(${THEME_TOKENS.vars.textStyle})\`.
|
|
182
|
+
- \`schemes\`: \`[{ id, name, roles }]\`, roles ${code(THEME_TOKENS.schemeRoles)}; inside a schemed
|
|
183
|
+
container they are \`var(${THEME_TOKENS.vars.schemeRole})\`. \`lightSchemeId\` / \`darkSchemeId\` pick
|
|
184
|
+
the two the page's modes use.
|
|
185
|
+
- \`presets\`: element styles by kind (${code(THEME_TOKENS.presetKinds)}).
|
|
186
|
+
|
|
187
|
+
A theme pulled as the default is THIS CLI's copy, built from the schema it shipped with: if the
|
|
188
|
+
platform's theme version has moved past ${THEME_TOKENS.version}, upgrade sb before editing it.
|
|
189
|
+
|
|
190
|
+
**A theme save is LIVE for every visitor the moment it is sent — there is no theme draft.** So:
|
|
191
|
+
|
|
192
|
+
1. Ask the owner first, and say exactly what will change.
|
|
193
|
+
2. Show it: \`npx @sbuilder/cli@${CLI_RANGE} site push --theme --dry-run\` prints every token that would
|
|
194
|
+
change (\`colors.primary: value #171717 → #e11d48\`) and sends nothing.
|
|
195
|
+
3. Only when the owner says yes: \`site push --theme\`. A plain \`site push\` never sends the theme.
|
|
196
|
+
`;
|
|
197
|
+
export const COMPONENTS_SKILL_PATH = '.claude/skills/sbuilder-components/SKILL.md';
|
|
198
|
+
/**
|
|
199
|
+
* Code components. Every number and rule here is the platform's or the CLI's own, and
|
|
200
|
+
* tests/components.test.ts holds each to its source (server/internal/codecomponents, components.ts)
|
|
201
|
+
* and BUILDS the example with the real buildComponent and parses the page snippet with parsePage.
|
|
202
|
+
*/
|
|
203
|
+
export const COMPONENTS_SKILL = `---
|
|
204
|
+
name: sbuilder-components
|
|
205
|
+
description: Use when a page needs interactivity or markup no Store Builder element covers, or when editing components/*.tsx — when to write a code component, the file and props rules, the sandbox it renders in, placing it on a page, and the push/pin/upgrade/delete loop.
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
# Code components: your own React on a Store Builder page
|
|
209
|
+
|
|
210
|
+
A code component is a React (Preact) component in \`components/<Name>.tsx\`. The CLI bundles it,
|
|
211
|
+
the platform renders it to HTML on the server and stores that HTML with the page, and the
|
|
212
|
+
published page hydrates it in the browser.
|
|
213
|
+
|
|
214
|
+
## Native first
|
|
215
|
+
|
|
216
|
+
Build with the platform's elements first (the page skill, \`sb_catalog_search\`, or the catalog in
|
|
217
|
+
\`design/sbuilder-env.d.ts\`). They are editable in the editor, responsive and translatable. These
|
|
218
|
+
are already interactive on a published page — use them before writing one:
|
|
219
|
+
|
|
220
|
+
${INTERACTIVE.map((e) => `- \`<${e.tag}>\` — ${e.what}`).join('\n')}
|
|
221
|
+
|
|
222
|
+
Write a code component only for a gap you can name: interactivity no element has (a calculator,
|
|
223
|
+
a configurator, a quiz) or markup no element can produce. It is not a way to paste a design in as
|
|
224
|
+
HTML.
|
|
225
|
+
|
|
226
|
+
## The file
|
|
227
|
+
|
|
228
|
+
\`components/<Name>.tsx\` — the name matches \`^[A-Za-z][A-Za-z0-9_]{0,63}$\` (letters, digits, \`_\`;
|
|
229
|
+
starts with a letter). A file without \`export const schema\` is not a component and is skipped
|
|
230
|
+
(Next.js keeps its own components in the same folder). It exports its props as a LITERAL schema
|
|
231
|
+
and a default function component:
|
|
232
|
+
|
|
233
|
+
\`\`\`tsx
|
|
234
|
+
import { useState } from 'preact/hooks';
|
|
235
|
+
import { defineProps, type Props } from '@sbuilder/sdk/component';
|
|
236
|
+
|
|
237
|
+
export const schema = defineProps({
|
|
238
|
+
question: { kind: 'text', default: 'Giao hàng mất bao lâu?' },
|
|
239
|
+
answer: { kind: 'richtext', default: '<p>Hai đến ba ngày trong nội thành.</p>' },
|
|
240
|
+
open: { kind: 'boolean', default: false },
|
|
241
|
+
tone: { kind: 'enum', options: ['light', 'dark'], default: 'light' },
|
|
242
|
+
'gap-size': { kind: 'css', default: '12px' },
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
export default function Faq({ question, answer, open, tone }: Props<typeof schema>) {
|
|
246
|
+
const [shown, setShown] = useState(open);
|
|
247
|
+
return (
|
|
248
|
+
<section class={\`faq faq-\${tone}\`} style="display: grid; gap: var(--gap-size, 12px)">
|
|
249
|
+
<button type="button" aria-expanded={shown} onClick={() => setShown(!shown)}>
|
|
250
|
+
{question}
|
|
251
|
+
</button>
|
|
252
|
+
{shown && <div dangerouslySetInnerHTML={{ __html: answer }} />}
|
|
253
|
+
</section>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
\`\`\`
|
|
257
|
+
|
|
258
|
+
\`sb site components init\` sets a repo up for this (esbuild, preact and \`@sbuilder/sdk\` as
|
|
259
|
+
devDependencies, and two examples to copy, \`components/Hero.tsx\` and \`components/Faq.tsx\`); run
|
|
260
|
+
\`npm install\` after it. \`site push\` does not upload an example while it is untouched AND no page
|
|
261
|
+
names it; once you edit one or place it on a page, it is uploaded like any other. Delete the ones
|
|
262
|
+
you do not want.
|
|
263
|
+
|
|
264
|
+
## Props
|
|
265
|
+
|
|
266
|
+
- **Content props** change the markup and are the same on every breakpoint: \`text\`, \`richtext\`
|
|
267
|
+
(HTML the platform sanitises), \`link\` and \`image\` (an http(s) or site-relative URL; an \`image\`
|
|
268
|
+
has no default), \`enum\` (with \`options\`), \`boolean\`, \`number\`. A prop name matches
|
|
269
|
+
\`^[A-Za-z][A-Za-z0-9_]{0,39}$\`; at most 50 props.
|
|
270
|
+
- **A length or a colour is a \`css\` prop.** It never reaches the component: the page sets it per
|
|
271
|
+
breakpoint as the custom property \`--<name>\`, and the markup reads \`var(--<name>, <default>)\`.
|
|
272
|
+
Its name is lowercase kebab-case (\`gap-size\`), never camelCase.
|
|
273
|
+
- **The schema must be a literal object.** \`sb site push\` reads it from the source without
|
|
274
|
+
running anything; a schema built by code is refused with the fix.
|
|
275
|
+
|
|
276
|
+
## Where it renders, and what that forbids
|
|
277
|
+
|
|
278
|
+
The platform renders the SSR bundle on every save that changes a node's component, version or
|
|
279
|
+
props, inside a sandbox, and the page keeps that HTML:
|
|
280
|
+
|
|
281
|
+
- the clock is frozen at 2000-01-01T00:00:00Z (\`Date.now()\`, \`new Date()\`), and \`Math.random\` is
|
|
282
|
+
seeded — the same sequence on every render;
|
|
283
|
+
- \`fetch\`, \`setTimeout\`, \`setInterval\`, \`crypto\` and \`queueMicrotask\` throw: no network, no
|
|
284
|
+
timers. Load data in the browser after hydration, or pass it in as props;
|
|
285
|
+
- no Server Components, no Suspense data, no \`use\`;
|
|
286
|
+
- one second per render.
|
|
287
|
+
|
|
288
|
+
**In the browser** the CLI's client bundle hydrates the stored markup on the PUBLISHED page with
|
|
289
|
+
the same props, so state and event handlers (\`useState\`, \`onClick\`) work there. The editor shows
|
|
290
|
+
the server-rendered markup only. A bundle that fails to load or throws while hydrating is logged
|
|
291
|
+
once and leaves the markup in place.
|
|
292
|
+
|
|
293
|
+
**Limits:** SSR bundle 512 KiB, client bundle 256 KiB (said by name before any upload), 200
|
|
294
|
+
live versions per component and 200 components per site.
|
|
295
|
+
|
|
296
|
+
## On a page
|
|
297
|
+
|
|
298
|
+
\`\`\`tsx
|
|
299
|
+
export default (
|
|
300
|
+
<Page id="ROOT">
|
|
301
|
+
<FlexSection id="fs_faq" name="FAQ">
|
|
302
|
+
<Heading id="he_faq" level={2} text="Câu hỏi thường gặp" />
|
|
303
|
+
<CodeComponent
|
|
304
|
+
id="cc_faq"
|
|
305
|
+
component="Faq"
|
|
306
|
+
props={{
|
|
307
|
+
answer: "<p>Hai đến ba ngày trong nội thành.</p>",
|
|
308
|
+
question: "Giao hàng mất bao lâu?",
|
|
309
|
+
tone: "light",
|
|
310
|
+
}}
|
|
311
|
+
version={3}
|
|
312
|
+
style={{ "--gap-size": "16px" }}
|
|
313
|
+
mobile={{ style: { "--gap-size": "8px" } }}
|
|
314
|
+
/>
|
|
315
|
+
</FlexSection>
|
|
316
|
+
</Page>
|
|
317
|
+
);
|
|
318
|
+
\`\`\`
|
|
319
|
+
|
|
320
|
+
\`component\` is the name, \`version\` the pinned number, \`props\` the content props, and each \`css\`
|
|
321
|
+
prop is a \`--<name>\` key in \`style\` (per breakpoint in \`tablet\` / \`mobile\`). **Never write \`html\`,
|
|
322
|
+
\`clientUrl\` or \`hydrateProps\`:** the platform renders them on every save, a file holding one is read without
|
|
323
|
+
it, and push says so ("rendered by the platform; your edit is ignored").
|
|
324
|
+
|
|
325
|
+
## Time and randomness
|
|
326
|
+
|
|
327
|
+
A placeholder on the server, the real value after hydration. A value
|
|
328
|
+
that depends on now (a countdown, "open now") or on chance is computed in \`useEffect\`, which runs
|
|
329
|
+
only in the browser; the server render prints a placeholder. (For a countdown, \`<Countdown>\` is
|
|
330
|
+
native — prefer it.)
|
|
331
|
+
|
|
332
|
+
\`\`\`tsx
|
|
333
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
334
|
+
import { defineProps, type Props } from '@sbuilder/sdk/component';
|
|
335
|
+
|
|
336
|
+
export const schema = defineProps({
|
|
337
|
+
endsAt: { kind: 'text', label: 'Ends (ISO 8601 with offset)', default: '2026-12-31T20:00:00+07:00' },
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
export default function SecondsLeft({ endsAt }: Props<typeof schema>) {
|
|
341
|
+
const [left, setLeft] = useState<number | null>(null); // null on the server: no clock there
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
const tick = () => setLeft(Math.max(0, Math.floor((Date.parse(endsAt) - Date.now()) / 1000)));
|
|
344
|
+
tick();
|
|
345
|
+
const t = setInterval(tick, 1000);
|
|
346
|
+
return () => clearInterval(t);
|
|
347
|
+
}, [endsAt]);
|
|
348
|
+
return <span>{left === null ? '…' : \`\${left}s\`}</span>;
|
|
349
|
+
}
|
|
350
|
+
\`\`\`
|
|
351
|
+
|
|
352
|
+
## The loop
|
|
353
|
+
|
|
354
|
+
1. Write or change \`components/<Name>.tsx\`.
|
|
355
|
+
2. \`npx @sbuilder/cli@${CLI_RANGE} doctor --build\` — the schema is a literal, esbuild is
|
|
356
|
+
installed, and every component bundles within the caps (this runs the repo's own esbuild).
|
|
357
|
+
3. \`npx @sbuilder/cli@${CLI_RANGE} site components preview <Name> --props '{"question":"Q?","open":true}'\`
|
|
358
|
+
— builds it here and has the platform render it ONCE, in the same sandbox, with those props
|
|
359
|
+
(\`--props @file.json\` reads them from a file; omitted ones take their default). It prints the
|
|
360
|
+
HTML a page save would store. A refusal prints its code and the sandbox's own message
|
|
361
|
+
(\`bundle_rejected\`, \`invalid_props\`, …) and exits 1: fix the component and preview again.
|
|
362
|
+
Nothing is uploaded and no page changes. A busy platform says when to try again; wait.
|
|
363
|
+
4. \`npx @sbuilder/cli@${CLI_RANGE} site push\` — uploads every component BEFORE any page and
|
|
364
|
+
prints the version the platform assigned (\`→ Faq version 3 (new, …)\`); identical content
|
|
365
|
+
gets the existing version back (\`unchanged\`). Preview, push and delete need the repo's API key
|
|
366
|
+
(\`.env\`).
|
|
367
|
+
5. Pin that version on the page (\`version={3}\`) and push again; the platform renders the node.
|
|
368
|
+
6. If push prints \`the platform says codeComponentRender (… nodeId …, reason …)\`, that node's
|
|
369
|
+
render failed: it is stored BLANK until a save renders it. Fix the component, preview it, push
|
|
370
|
+
it, push the page again.
|
|
371
|
+
7. A new version of a component pinned on many pages: \`site components upgrade <Name>\`
|
|
372
|
+
(or \`--to <n>\`) rewrites every pin in \`design/\`, names props the new version no longer takes,
|
|
373
|
+
and sends nothing — review the diff, then push.
|
|
374
|
+
8. \`site components list\` shows every component, its versions, sizes and which ones this repo
|
|
375
|
+
pins. \`site components delete <Name> <n> --dry-run\` first, then without it.
|
|
376
|
+
|
|
377
|
+
## Traps
|
|
378
|
+
|
|
379
|
+
- **Versions are immutable, and a number is never reused.** A deleted version's number never
|
|
380
|
+
comes back, so a pin can never come to mean different code.
|
|
381
|
+
- **A pinned version cannot be deleted:** the platform refuses while any draft or live page,
|
|
382
|
+
shared section or overlay uses it, and names the pages. Upgrade those pins first.
|
|
383
|
+
- **A failed render stores the node blank and warns** — never the old markup. Read push's output.
|
|
384
|
+
- **Nothing on a page moves by itself** when you upload a new version: pins change only by
|
|
385
|
+
\`upgrade\` or a hand edit.
|
|
144
386
|
`;
|
|
145
387
|
export const APP_SKILL = `---
|
|
146
388
|
name: sbuilder-app
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentdocs.js","sourceRoot":"","sources":["../../src/agentdocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH
|
|
1
|
+
{"version":3,"file":"agentdocs.js","sourceRoot":"","sources":["../../src/agentdocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,IAAI,GAAG,CA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EAiB9B,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuI1C,SAAS;;yBAET,SAAS;;;;;;yBAMT,SAAS;;;;;;;;;;;;;;;;;;;;;;;CAuBjC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ExB,CAAC"}
|
package/dist/src/appblocks.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { stripDerived } from './source/derived.js';
|
|
2
3
|
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
3
4
|
/** JSON with object keys sorted, so the hash does not depend on key order. */
|
|
4
5
|
function canonical(v) {
|
|
@@ -27,7 +28,10 @@ function subtree(doc, root) {
|
|
|
27
28
|
return out;
|
|
28
29
|
}
|
|
29
30
|
/** The part of a block a merchant cannot change: everything but its settings and placement. */
|
|
30
|
-
function fingerprint(
|
|
31
|
+
function fingerprint(stored, root) {
|
|
32
|
+
// The seal is taken over the stored document and checked against a parsed file, which never
|
|
33
|
+
// holds the platform's derived specials (source/derived.ts): both sides drop them.
|
|
34
|
+
const doc = stripDerived(stored).document;
|
|
31
35
|
const nodes = subtree(doc, root).map((n) => {
|
|
32
36
|
if (n.id !== root)
|
|
33
37
|
return n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appblocks.js","sourceRoot":"","sources":["../../src/appblocks.ts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