@knapsack/rendering-utils 4.69.15--canary.4532.e420d28.0 → 4.69.15--canary.4771.9877e61.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/rendering.d.ts +5 -1
- package/dist/rendering.d.ts.map +1 -1
- package/dist/rendering.js +30 -0
- package/dist/rendering.js.map +1 -1
- package/package.json +7 -7
- package/src/rendering.ts +46 -1
package/dist/rendering.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
import type { KsAppClientData, RenderDataDemo } from '@knapsack/types';
|
1
|
+
import type { KsAppClientData, KsAppClientDataNoMeta, RenderDataDemo, ContentStateForRendering } from '@knapsack/types';
|
2
|
+
export declare function getContentStateFromAppClientData({ patterns, demosById, }: {
|
3
|
+
patterns: KsAppClientDataNoMeta['patternsState']['patterns'];
|
4
|
+
demosById: KsAppClientDataNoMeta['db']['demos']['byId'];
|
5
|
+
}): ContentStateForRendering;
|
2
6
|
/**
|
3
7
|
* What we're going to here is look at all the slots data and grab
|
4
8
|
* the ACTUAL demo data we have locally here instead of just sending up the
|
package/dist/rendering.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAGzB,wBAAgB,gCAAgC,CAAC,EAC/C,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;IAC7D,SAAS,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD,GAAG,wBAAwB,CAgC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,IAAI,EACJ,oBAAoB,GACrB,EAAE;IACD,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;CAC9B,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAkC5C"}
|
package/dist/rendering.js
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
import { isEmpty, produce } from '@knapsack/utils';
|
2
2
|
import { convertSlotOptions } from './slot-layout-options-utils.js';
|
3
|
+
export function getContentStateFromAppClientData({ patterns, demosById, }) {
|
4
|
+
return {
|
5
|
+
patterns: Object.values(patterns).reduce((acc, pattern) => {
|
6
|
+
var _a, _b;
|
7
|
+
acc[pattern.id] = {
|
8
|
+
id: pattern.id,
|
9
|
+
templateDemos: ((_a = pattern.templates) === null || _a === void 0 ? void 0 : _a.flatMap((t) => {
|
10
|
+
return t.demoIds
|
11
|
+
.map((demoId) => {
|
12
|
+
const demo = demosById[demoId];
|
13
|
+
return {
|
14
|
+
...demo,
|
15
|
+
templateId: t.id,
|
16
|
+
templateLanguageId: t.templateLanguageId,
|
17
|
+
};
|
18
|
+
})
|
19
|
+
.filter((d) => d.type === 'template');
|
20
|
+
})) || [],
|
21
|
+
templates: ((_b = pattern.templates) === null || _b === void 0 ? void 0 : _b.map(({ id, alias, path, templateLanguageId, spec }) => ({
|
22
|
+
id,
|
23
|
+
alias,
|
24
|
+
path,
|
25
|
+
templateLanguageId,
|
26
|
+
spec,
|
27
|
+
}))) || [],
|
28
|
+
};
|
29
|
+
return acc;
|
30
|
+
}, {}),
|
31
|
+
};
|
32
|
+
}
|
3
33
|
/**
|
4
34
|
* What we're going to here is look at all the slots data and grab
|
5
35
|
* the ACTUAL demo data we have locally here instead of just sending up the
|
package/dist/rendering.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rendering.js","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"rendering.js","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAOnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,UAAU,gCAAgC,CAAC,EAC/C,QAAQ,EACR,SAAS,GAIV;IACC,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;;YACxD,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;gBAChB,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,aAAa,EACX,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;oBAC/B,OAAO,CAAC,CAAC,OAAO;yBACb,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;wBACd,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;wBAC/B,OAAO;4BACL,GAAG,IAAI;4BACP,UAAU,EAAE,CAAC,CAAC,EAAE;4BAChB,kBAAkB,EAAE,CAAC,CAAC,kBAAkB;yBACzC,CAAC;oBACJ,CAAC,CAAC;yBACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;gBAC1C,CAAC,CAAC,KAAI,EAAE;gBACV,SAAS,EACP,CAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,GAAG,CACpB,CAAC,EAAE,EAAE,EAA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gBAClD,IAAI,CAAC,WAAW,EAAE,CAAC;oBACjB,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,CAAC,MAAM,iBAAiB,KAAK,CAAC,EAAE,EAAE,CAC9D,CAAC;gBACJ,CAAC;gBAED,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBAChC,wEAAwE;oBACxE,WAAW,CAAC,IAAI,GAAG,cAAc,CAAC;wBAChC,SAAS;wBACT,IAAI,EAAE,WAAW;wBACjB,oBAAoB;qBACrB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@knapsack/rendering-utils",
|
3
3
|
"description": "",
|
4
|
-
"version": "4.69.15--canary.
|
4
|
+
"version": "4.69.15--canary.4771.9877e61.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
7
7
|
".": {
|
@@ -18,13 +18,13 @@
|
|
18
18
|
"lint": "eslint ./"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@knapsack/utils": "4.69.15--canary.
|
21
|
+
"@knapsack/utils": "4.69.15--canary.4771.9877e61.0"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
-
"@knapsack/eslint-config-starter": "4.69.15--canary.
|
25
|
-
"@knapsack/prettier-config": "4.69.15--canary.
|
26
|
-
"@knapsack/types": "4.69.15--canary.
|
27
|
-
"@knapsack/typescript-config-starter": "4.69.15--canary.
|
24
|
+
"@knapsack/eslint-config-starter": "4.69.15--canary.4771.9877e61.0",
|
25
|
+
"@knapsack/prettier-config": "4.69.15--canary.4771.9877e61.0",
|
26
|
+
"@knapsack/types": "4.69.15--canary.4771.9877e61.0",
|
27
|
+
"@knapsack/typescript-config-starter": "4.69.15--canary.4771.9877e61.0",
|
28
28
|
"eslint": "^8.57.0",
|
29
29
|
"typescript": "^5.5.4"
|
30
30
|
},
|
@@ -37,5 +37,5 @@
|
|
37
37
|
"directory": "libs/rendering-utils",
|
38
38
|
"type": "git"
|
39
39
|
},
|
40
|
-
"gitHead": "
|
40
|
+
"gitHead": "9877e612f2b63bc8dba31726acd0c019c1b57457"
|
41
41
|
}
|
package/src/rendering.ts
CHANGED
@@ -1,7 +1,52 @@
|
|
1
1
|
import { isEmpty, produce } from '@knapsack/utils';
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
KsAppClientData,
|
4
|
+
KsAppClientDataNoMeta,
|
5
|
+
RenderDataDemo,
|
6
|
+
ContentStateForRendering,
|
7
|
+
} from '@knapsack/types';
|
3
8
|
import { convertSlotOptions } from './slot-layout-options-utils.js';
|
4
9
|
|
10
|
+
export function getContentStateFromAppClientData({
|
11
|
+
patterns,
|
12
|
+
demosById,
|
13
|
+
}: {
|
14
|
+
patterns: KsAppClientDataNoMeta['patternsState']['patterns'];
|
15
|
+
demosById: KsAppClientDataNoMeta['db']['demos']['byId'];
|
16
|
+
}): ContentStateForRendering {
|
17
|
+
return {
|
18
|
+
patterns: Object.values(patterns).reduce((acc, pattern) => {
|
19
|
+
acc[pattern.id] = {
|
20
|
+
id: pattern.id,
|
21
|
+
templateDemos:
|
22
|
+
pattern.templates?.flatMap((t) => {
|
23
|
+
return t.demoIds
|
24
|
+
.map((demoId) => {
|
25
|
+
const demo = demosById[demoId];
|
26
|
+
return {
|
27
|
+
...demo,
|
28
|
+
templateId: t.id,
|
29
|
+
templateLanguageId: t.templateLanguageId,
|
30
|
+
};
|
31
|
+
})
|
32
|
+
.filter((d) => d.type === 'template');
|
33
|
+
}) || [],
|
34
|
+
templates:
|
35
|
+
pattern.templates?.map(
|
36
|
+
({ id, alias, path, templateLanguageId, spec }) => ({
|
37
|
+
id,
|
38
|
+
alias,
|
39
|
+
path,
|
40
|
+
templateLanguageId,
|
41
|
+
spec,
|
42
|
+
}),
|
43
|
+
) || [],
|
44
|
+
};
|
45
|
+
return acc;
|
46
|
+
}, {} as ContentStateForRendering['patterns']),
|
47
|
+
};
|
48
|
+
}
|
49
|
+
|
5
50
|
/**
|
6
51
|
* What we're going to here is look at all the slots data and grab
|
7
52
|
* the ACTUAL demo data we have locally here instead of just sending up the
|