@knapsack/doctor 4.100.0 → 4.100.1--canary.7985.eb739a3.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.
@@ -2,10 +2,10 @@ $ tsc -p tsconfig.test.json && vitest run
2
2
 
3
3
   RUN  v4.1.9 /home/runner/work/app-monorepo/app-monorepo/libs/doctor
4
4
 
5
- ✓ src/v4/detect/ui.test.ts (6 tests) 13ms
5
+ ✓ src/v4/detect/ui.test.ts (6 tests) 25ms
6
6
  stderr | src/fix-app-client-data.test.ts > orphaned blocks
7
7
  Block with id "4f3tc2Ymq6" does not exist, removing.
8
- Block with id "wzaf3l9yVS" does not exist, removing.
8
+ Block with id "9PQniJhbfQ" does not exist, removing.
9
9
 
10
10
  stderr | src/fix-app-client-data.test.ts > orphaned demos
11
11
  Block with id "4f3tc2Ymq6" does not exist, removing.
@@ -19,12 +19,10 @@ Block with id "wzaf3l9yVS" does not exist, removing.
19
19
  stderr | src/fix-app-client-data.test.ts > fixes bad navstate
20
20
  Block with id "4f3tc2Ymq6" does not exist, removing.
21
21
 
22
- ✓ src/fix-app-client-data.test.ts (5 tests) 48ms
23
- ✓ src/detect-unrecognized-tiptap-content.test.ts (7 tests) 18ms
24
- ✓ src/strip-unrecognized-tiptap-content.test.ts (4 tests) 7ms
22
+ ✓ src/fix-app-client-data.test.ts (5 tests) 89ms
25
23
 
26
-  Test Files  4 passed (4)
27
-  Tests  22 passed (22)
28
-  Start at  16:54:15
29
-  Duration  1.10s (transform 767ms, setup 0ms, import 3.11s, tests 86ms, environment 0ms)
24
+  Test Files  2 passed (2)
25
+  Tests  11 passed (11)
26
+  Start at  23:27:11
27
+  Duration  1.35s (transform 801ms, setup 0ms, import 2.09s, tests 113ms, environment 0ms)
30
28
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  export * from './v4/detect/ui.js';
2
2
  export * from './v4/detect/cli.js';
3
3
  export * from './fix-app-client-data.js';
4
- export * from './detect-unrecognized-tiptap-content.js';
5
- export * from './strip-unrecognized-tiptap-content.js';
6
- export * from './tiptap-content-fields.js';
7
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  export * from './v4/detect/ui.js';
2
2
  export * from './v4/detect/cli.js';
3
3
  export * from './fix-app-client-data.js';
4
- export * from './detect-unrecognized-tiptap-content.js';
5
- export * from './strip-unrecognized-tiptap-content.js';
6
- export * from './tiptap-content-fields.js';
7
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knapsack/doctor",
3
3
  "description": "",
4
- "version": "4.100.0",
4
+ "version": "4.100.1--canary.7985.eb739a3.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -19,14 +19,13 @@
19
19
  "test": "tsc -p tsconfig.test.json && vitest run"
20
20
  },
21
21
  "dependencies": {
22
- "@knapsack/tiptap-utils": "4.100.0",
23
- "@knapsack/utils": "4.100.0"
22
+ "@knapsack/utils": "4.100.1--canary.7985.eb739a3.0"
24
23
  },
25
24
  "devDependencies": {
26
- "@knapsack/eslint-config-starter": "4.100.0",
27
- "@knapsack/prettier-config": "4.100.0",
28
- "@knapsack/types": "4.100.0",
29
- "@knapsack/typescript-config-starter": "4.100.0",
25
+ "@knapsack/eslint-config-starter": "4.100.1--canary.7985.eb739a3.0",
26
+ "@knapsack/prettier-config": "4.100.1--canary.7985.eb739a3.0",
27
+ "@knapsack/types": "4.100.1--canary.7985.eb739a3.0",
28
+ "@knapsack/typescript-config-starter": "4.100.1--canary.7985.eb739a3.0",
30
29
  "@types/node": "^24.13.2",
31
30
  "eslint": "^9.20.0",
32
31
  "typescript": "^6.0.3",
@@ -41,5 +40,5 @@
41
40
  "directory": "libs/doctor",
42
41
  "type": "git"
43
42
  },
44
- "gitHead": "a144d5fca0e3b5d3a89353adf2ac5d108d20ae73"
43
+ "gitHead": "eb739a3cd2db8ea086b59da709826b3d73cb8607"
45
44
  }
package/src/index.ts CHANGED
@@ -1,6 +1,3 @@
1
1
  export * from './v4/detect/ui.js';
2
2
  export * from './v4/detect/cli.js';
3
3
  export * from './fix-app-client-data.js';
4
- export * from './detect-unrecognized-tiptap-content.js';
5
- export * from './strip-unrecognized-tiptap-content.js';
6
- export * from './tiptap-content-fields.js';
@@ -1,20 +0,0 @@
1
- import type { BlockConfig, KsAppClientDataNoMeta } from '@knapsack/types';
2
- export type UnrecognizedTiptapContentReport = {
3
- blockId: string;
4
- blockType: BlockConfig['blockType'];
5
- /** Which JSONContent field on the block, e.g. 'content' or 'guidelines[2].content' */
6
- fieldPath: string;
7
- unrecognizedTypes: readonly string[];
8
- };
9
- /**
10
- * Non-mutating. Walks every block in appClientData.db.blocks.byId that can
11
- * carry JSONContent, and reports any unrecognized node/mark type names
12
- * found. Does NOT resolve page/pattern location - callers already have
13
- * buildBlockLocationMap()/BlockCollectionLocation for that (this package
14
- * cannot import from app-ui).
15
- */
16
- export declare function detectUnrecognizedTiptapContent({ appClientData, recognizedTypeNames, }: {
17
- appClientData: KsAppClientDataNoMeta;
18
- recognizedTypeNames?: ReadonlySet<string>;
19
- }): UnrecognizedTiptapContentReport[];
20
- //# sourceMappingURL=detect-unrecognized-tiptap-content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detect-unrecognized-tiptap-content.d.ts","sourceRoot":"","sources":["../src/detect-unrecognized-tiptap-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAQ1E,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACpC,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAsCF;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,EAC9C,aAAa,EACb,mBAA+C,GAChD,EAAE;IACD,aAAa,EAAE,qBAAqB,CAAC;IACrC,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3C,GAAG,+BAA+B,EAAE,CAmBpC"}
@@ -1,55 +0,0 @@
1
- import { findUnrecognizedTiptapTypes, recognizedTiptapTypeNames, } from '@knapsack/tiptap-utils';
2
- import { getTiptapContentFields } from './tiptap-content-fields.js';
3
- // Immer's structural sharing means a block's JSONContent field reference is
4
- // unchanged across appClientData versions unless that specific block was
5
- // edited - so after any single edit, this cache is a hit for every other
6
- // block, avoiding a full site-wide re-walk on every debounced content change.
7
- // Keyed on `recognizedTypeNames` first (production always passes the same
8
- // singleton default, so this outer lookup is effectively free) so that a
9
- // caller passing a different set - e.g. tests - can never read back a
10
- // result computed under a different set for the same content reference.
11
- const unrecognizedTypesCache = new WeakMap();
12
- function findUnrecognizedTypesCached(content, recognizedTypeNames) {
13
- if (!content)
14
- return [];
15
- let cacheForSet = unrecognizedTypesCache.get(recognizedTypeNames);
16
- if (!cacheForSet) {
17
- cacheForSet = new WeakMap();
18
- unrecognizedTypesCache.set(recognizedTypeNames, cacheForSet);
19
- }
20
- const cached = cacheForSet.get(content);
21
- if (cached)
22
- return cached;
23
- // Frozen before caching - this array is handed out by reference to every
24
- // caller sharing this content reference for the module's lifetime, so an
25
- // accidental downstream mutation must fail loudly instead of silently
26
- // corrupting results for every other block.
27
- const found = Object.freeze(findUnrecognizedTiptapTypes(content, recognizedTypeNames));
28
- cacheForSet.set(content, found);
29
- return found;
30
- }
31
- /**
32
- * Non-mutating. Walks every block in appClientData.db.blocks.byId that can
33
- * carry JSONContent, and reports any unrecognized node/mark type names
34
- * found. Does NOT resolve page/pattern location - callers already have
35
- * buildBlockLocationMap()/BlockCollectionLocation for that (this package
36
- * cannot import from app-ui).
37
- */
38
- export function detectUnrecognizedTiptapContent({ appClientData, recognizedTypeNames = recognizedTiptapTypeNames, }) {
39
- const reports = [];
40
- for (const block of Object.values(appClientData.db.blocks.byId)) {
41
- for (const { fieldPath, content } of getTiptapContentFields(block)) {
42
- const unrecognizedTypes = findUnrecognizedTypesCached(content, recognizedTypeNames);
43
- if (unrecognizedTypes.length > 0) {
44
- reports.push({
45
- blockId: block.id,
46
- blockType: block.blockType,
47
- fieldPath,
48
- unrecognizedTypes,
49
- });
50
- }
51
- }
52
- }
53
- return reports;
54
- }
55
- //# sourceMappingURL=detect-unrecognized-tiptap-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detect-unrecognized-tiptap-content.js","sourceRoot":"","sources":["../src/detect-unrecognized-tiptap-content.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAUpE,4EAA4E;AAC5E,yEAAyE;AACzE,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AACxE,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAGvC,CAAC;AAEJ,SAAS,2BAA2B,CAClC,OAAuC,EACvC,mBAAwC;IAExC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,WAAW,GAAG,sBAAsB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAClE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;QAC5B,sBAAsB,CAAC,GAAG,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,yEAAyE;IACzE,yEAAyE;IACzE,sEAAsE;IACtE,4CAA4C;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAC1D,CAAC;IACF,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAAC,EAC9C,aAAa,EACb,mBAAmB,GAAG,yBAAyB,GAIhD;IACC,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAChE,KAAK,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;YACnE,MAAM,iBAAiB,GAAG,2BAA2B,CACnD,OAAO,EACP,mBAAmB,CACpB,CAAC;YACF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,IAAI,CAAC;oBACX,OAAO,EAAE,KAAK,CAAC,EAAE;oBACjB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,SAAS;oBACT,iBAAiB;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { Draft } from '@knapsack/utils';
2
- import type { BlockConfig } from '@knapsack/types';
3
- /**
4
- * Per-block-shape-aware counterpart to `stripUnrecognizedTiptapContent`
5
- * (from `@knapsack/tiptap-utils`, which only knows JSONContent, not
6
- * BlockConfig). Mutates the draft in place, only touching fields that
7
- * actually had something unrecognized - never makes a patch if there's
8
- * nothing to strip.
9
- */
10
- export declare function stripUnrecognizedTiptapContentFromBlock(block: Draft<BlockConfig>, recognizedTypeNames?: ReadonlySet<string>): void;
11
- //# sourceMappingURL=strip-unrecognized-tiptap-content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strip-unrecognized-tiptap-content.d.ts","sourceRoot":"","sources":["../src/strip-unrecognized-tiptap-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOnD;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EACzB,mBAAmB,GAAE,WAAW,CAAC,MAAM,CAA6B,GACnE,IAAI,CAUN"}
@@ -1,18 +0,0 @@
1
- import { stripUnrecognizedTiptapContent, recognizedTiptapTypeNames, } from '@knapsack/tiptap-utils';
2
- import { getTiptapContentFields } from './tiptap-content-fields.js';
3
- /**
4
- * Per-block-shape-aware counterpart to `stripUnrecognizedTiptapContent`
5
- * (from `@knapsack/tiptap-utils`, which only knows JSONContent, not
6
- * BlockConfig). Mutates the draft in place, only touching fields that
7
- * actually had something unrecognized - never makes a patch if there's
8
- * nothing to strip.
9
- */
10
- export function stripUnrecognizedTiptapContentFromBlock(block, recognizedTypeNames = recognizedTiptapTypeNames) {
11
- for (const field of getTiptapContentFields(block)) {
12
- const { content, removedTypes } = stripUnrecognizedTiptapContent(field.content, recognizedTypeNames);
13
- if (removedTypes.length > 0) {
14
- field.setContent(content);
15
- }
16
- }
17
- }
18
- //# sourceMappingURL=strip-unrecognized-tiptap-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strip-unrecognized-tiptap-content.js","sourceRoot":"","sources":["../src/strip-unrecognized-tiptap-content.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,uCAAuC,CACrD,KAAyB,EACzB,sBAA2C,yBAAyB;IAEpE,KAAK,MAAM,KAAK,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,8BAA8B,CAC9D,KAAK,CAAC,OAAO,EACb,mBAAmB,CACpB,CAAC;QACF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { BlockConfig } from '@knapsack/types';
2
- import type { JSONContent } from '@knapsack/tiptap-utils';
3
- export type TiptapContentField = {
4
- fieldPath: string;
5
- content: JSONContent | null | undefined;
6
- setContent: (content: JSONContent | null | undefined) => void;
7
- };
8
- /**
9
- * Every JSONContent-bearing field on a block - the single source of truth
10
- * for both detection (reads `content`) and stripping (calls `setContent`),
11
- * so a block type gaining a new tiptap field only needs updating here once,
12
- * not in two independently-maintained switches that could silently drift.
13
- */
14
- export declare function getTiptapContentFields(block: BlockConfig): TiptapContentField[];
15
- //# sourceMappingURL=tiptap-content-fields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-content-fields.d.ts","sourceRoot":"","sources":["../src/tiptap-content-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,GACjB,kBAAkB,EAAE,CAuCtB"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Every JSONContent-bearing field on a block - the single source of truth
3
- * for both detection (reads `content`) and stripping (calls `setContent`),
4
- * so a block type gaining a new tiptap field only needs updating here once,
5
- * not in two independently-maintained switches that could silently drift.
6
- */
7
- export function getTiptapContentFields(block) {
8
- switch (block.blockType) {
9
- case 'text-editor':
10
- case 'callout':
11
- case 'code-snippet':
12
- case 'table':
13
- return [
14
- {
15
- fieldPath: 'content',
16
- content: block.data.content,
17
- setContent: (content) => {
18
- block.data.content = content;
19
- },
20
- },
21
- ];
22
- case 'guidelines':
23
- return (block.data.guidelines || []).map((guideline, index) => ({
24
- fieldPath: `guidelines[${index}].content`,
25
- content: guideline.content,
26
- setContent: (content) => {
27
- const target = block.data.guidelines?.[index];
28
- if (target)
29
- target.content = content;
30
- },
31
- }));
32
- case 'design-src-tiles':
33
- // Not rendered through TextEditor anywhere today - included here for
34
- // detection completeness, but the live-editor safety net doesn't
35
- // reach it. Flagged as informational in the Doctor listing.
36
- return (block.data.items || []).map((item, index) => ({
37
- fieldPath: `items[${index}].description`,
38
- content: item.description,
39
- setContent: (content) => {
40
- const target = block.data.items?.[index];
41
- if (target)
42
- target.description = content;
43
- },
44
- }));
45
- default:
46
- return [];
47
- }
48
- }
49
- //# sourceMappingURL=tiptap-content-fields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-content-fields.js","sourceRoot":"","sources":["../src/tiptap-content-fields.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAkB;IAElB,QAAQ,KAAK,CAAC,SAAS,EAAE,CAAC;QACxB,KAAK,aAAa,CAAC;QACnB,KAAK,SAAS,CAAC;QACf,KAAK,cAAc,CAAC;QACpB,KAAK,OAAO;YACV,OAAO;gBACL;oBACE,SAAS,EAAE,SAAS;oBACpB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO;oBAC3B,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE;wBACtB,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;oBAC/B,CAAC;iBACF;aACF,CAAC;QACJ,KAAK,YAAY;YACf,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC9D,SAAS,EAAE,cAAc,KAAK,WAAW;gBACzC,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE;oBACtB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;oBAC9C,IAAI,MAAM;wBAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;gBACvC,CAAC;aACF,CAAC,CAAC,CAAC;QACN,KAAK,kBAAkB;YACrB,qEAAqE;YACrE,iEAAiE;YACjE,4DAA4D;YAC5D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBACpD,SAAS,EAAE,SAAS,KAAK,eAAe;gBACxC,OAAO,EAAE,IAAI,CAAC,WAAW;gBACzB,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE;oBACtB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;oBACzC,IAAI,MAAM;wBAAE,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC;gBAC3C,CAAC;aACF,CAAC,CAAC,CAAC;QACN;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,85 +0,0 @@
1
- import type { BlockConfig, KsAppClientDataNoMeta } from '@knapsack/types';
2
- import {
3
- type JSONContent,
4
- findUnrecognizedTiptapTypes,
5
- recognizedTiptapTypeNames,
6
- } from '@knapsack/tiptap-utils';
7
- import { getTiptapContentFields } from './tiptap-content-fields.js';
8
-
9
- export type UnrecognizedTiptapContentReport = {
10
- blockId: string;
11
- blockType: BlockConfig['blockType'];
12
- /** Which JSONContent field on the block, e.g. 'content' or 'guidelines[2].content' */
13
- fieldPath: string;
14
- unrecognizedTypes: readonly string[];
15
- };
16
-
17
- // Immer's structural sharing means a block's JSONContent field reference is
18
- // unchanged across appClientData versions unless that specific block was
19
- // edited - so after any single edit, this cache is a hit for every other
20
- // block, avoiding a full site-wide re-walk on every debounced content change.
21
- // Keyed on `recognizedTypeNames` first (production always passes the same
22
- // singleton default, so this outer lookup is effectively free) so that a
23
- // caller passing a different set - e.g. tests - can never read back a
24
- // result computed under a different set for the same content reference.
25
- const unrecognizedTypesCache = new WeakMap<
26
- ReadonlySet<string>,
27
- WeakMap<JSONContent, readonly string[]>
28
- >();
29
-
30
- function findUnrecognizedTypesCached(
31
- content: JSONContent | null | undefined,
32
- recognizedTypeNames: ReadonlySet<string>,
33
- ): readonly string[] {
34
- if (!content) return [];
35
- let cacheForSet = unrecognizedTypesCache.get(recognizedTypeNames);
36
- if (!cacheForSet) {
37
- cacheForSet = new WeakMap();
38
- unrecognizedTypesCache.set(recognizedTypeNames, cacheForSet);
39
- }
40
- const cached = cacheForSet.get(content);
41
- if (cached) return cached;
42
- // Frozen before caching - this array is handed out by reference to every
43
- // caller sharing this content reference for the module's lifetime, so an
44
- // accidental downstream mutation must fail loudly instead of silently
45
- // corrupting results for every other block.
46
- const found = Object.freeze(
47
- findUnrecognizedTiptapTypes(content, recognizedTypeNames),
48
- );
49
- cacheForSet.set(content, found);
50
- return found;
51
- }
52
-
53
- /**
54
- * Non-mutating. Walks every block in appClientData.db.blocks.byId that can
55
- * carry JSONContent, and reports any unrecognized node/mark type names
56
- * found. Does NOT resolve page/pattern location - callers already have
57
- * buildBlockLocationMap()/BlockCollectionLocation for that (this package
58
- * cannot import from app-ui).
59
- */
60
- export function detectUnrecognizedTiptapContent({
61
- appClientData,
62
- recognizedTypeNames = recognizedTiptapTypeNames,
63
- }: {
64
- appClientData: KsAppClientDataNoMeta;
65
- recognizedTypeNames?: ReadonlySet<string>;
66
- }): UnrecognizedTiptapContentReport[] {
67
- const reports: UnrecognizedTiptapContentReport[] = [];
68
- for (const block of Object.values(appClientData.db.blocks.byId)) {
69
- for (const { fieldPath, content } of getTiptapContentFields(block)) {
70
- const unrecognizedTypes = findUnrecognizedTypesCached(
71
- content,
72
- recognizedTypeNames,
73
- );
74
- if (unrecognizedTypes.length > 0) {
75
- reports.push({
76
- blockId: block.id,
77
- blockType: block.blockType,
78
- fieldPath,
79
- unrecognizedTypes,
80
- });
81
- }
82
- }
83
- }
84
- return reports;
85
- }
@@ -1,29 +0,0 @@
1
- import type { Draft } from '@knapsack/utils';
2
- import type { BlockConfig } from '@knapsack/types';
3
- import {
4
- stripUnrecognizedTiptapContent,
5
- recognizedTiptapTypeNames,
6
- } from '@knapsack/tiptap-utils';
7
- import { getTiptapContentFields } from './tiptap-content-fields.js';
8
-
9
- /**
10
- * Per-block-shape-aware counterpart to `stripUnrecognizedTiptapContent`
11
- * (from `@knapsack/tiptap-utils`, which only knows JSONContent, not
12
- * BlockConfig). Mutates the draft in place, only touching fields that
13
- * actually had something unrecognized - never makes a patch if there's
14
- * nothing to strip.
15
- */
16
- export function stripUnrecognizedTiptapContentFromBlock(
17
- block: Draft<BlockConfig>,
18
- recognizedTypeNames: ReadonlySet<string> = recognizedTiptapTypeNames,
19
- ): void {
20
- for (const field of getTiptapContentFields(block)) {
21
- const { content, removedTypes } = stripUnrecognizedTiptapContent(
22
- field.content,
23
- recognizedTypeNames,
24
- );
25
- if (removedTypes.length > 0) {
26
- field.setContent(content);
27
- }
28
- }
29
- }
@@ -1,57 +0,0 @@
1
- import type { BlockConfig } from '@knapsack/types';
2
- import type { JSONContent } from '@knapsack/tiptap-utils';
3
-
4
- export type TiptapContentField = {
5
- fieldPath: string;
6
- content: JSONContent | null | undefined;
7
- setContent: (content: JSONContent | null | undefined) => void;
8
- };
9
-
10
- /**
11
- * Every JSONContent-bearing field on a block - the single source of truth
12
- * for both detection (reads `content`) and stripping (calls `setContent`),
13
- * so a block type gaining a new tiptap field only needs updating here once,
14
- * not in two independently-maintained switches that could silently drift.
15
- */
16
- export function getTiptapContentFields(
17
- block: BlockConfig,
18
- ): TiptapContentField[] {
19
- switch (block.blockType) {
20
- case 'text-editor':
21
- case 'callout':
22
- case 'code-snippet':
23
- case 'table':
24
- return [
25
- {
26
- fieldPath: 'content',
27
- content: block.data.content,
28
- setContent: (content) => {
29
- block.data.content = content;
30
- },
31
- },
32
- ];
33
- case 'guidelines':
34
- return (block.data.guidelines || []).map((guideline, index) => ({
35
- fieldPath: `guidelines[${index}].content`,
36
- content: guideline.content,
37
- setContent: (content) => {
38
- const target = block.data.guidelines?.[index];
39
- if (target) target.content = content;
40
- },
41
- }));
42
- case 'design-src-tiles':
43
- // Not rendered through TextEditor anywhere today - included here for
44
- // detection completeness, but the live-editor safety net doesn't
45
- // reach it. Flagged as informational in the Doctor listing.
46
- return (block.data.items || []).map((item, index) => ({
47
- fieldPath: `items[${index}].description`,
48
- content: item.description,
49
- setContent: (content) => {
50
- const target = block.data.items?.[index];
51
- if (target) target.description = content;
52
- },
53
- }));
54
- default:
55
- return [];
56
- }
57
- }