@knapsack/renderer-react 4.71.16--canary.5224.facfa79.0 → 4.71.16--canary.5234.673513c.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/ava.config.cjs +1 -7
  3. package/dist/client/init.d.mts +2 -2
  4. package/dist/client/init.d.ts +2 -0
  5. package/dist/client/init.js +5 -0
  6. package/dist/client/init.js.map +1 -0
  7. package/dist/client/init.mjs +3 -39
  8. package/dist/client/init.mjs.map +1 -1
  9. package/dist/demo-wrapper.d.mts +7 -0
  10. package/dist/demo-wrapper.d.ts +7 -0
  11. package/dist/demo-wrapper.js +2 -0
  12. package/dist/demo-wrapper.js.map +1 -0
  13. package/dist/demo-wrapper.mjs +2 -0
  14. package/dist/demo-wrapper.mjs.map +1 -0
  15. package/dist/error-catcher.d.mts +20 -0
  16. package/dist/error-catcher.d.ts +20 -0
  17. package/dist/error-catcher.js +2 -0
  18. package/dist/error-catcher.js.map +1 -0
  19. package/dist/error-catcher.mjs +2 -0
  20. package/dist/error-catcher.mjs.map +1 -0
  21. package/dist/{renderer-react.d.ts → index.d.mts} +5 -2
  22. package/dist/index.d.ts +45 -3
  23. package/dist/index.js +31 -16
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +33 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/prototype-template.d.mts +7 -0
  28. package/dist/prototype-template.d.ts +7 -0
  29. package/dist/prototype-template.js +2 -0
  30. package/dist/prototype-template.js.map +1 -0
  31. package/dist/prototype-template.mjs +2 -0
  32. package/dist/prototype-template.mjs.map +1 -0
  33. package/dist/types-CivTHEEo.d.mts +10 -0
  34. package/dist/types-CivTHEEo.d.ts +10 -0
  35. package/package.json +27 -23
  36. package/tsconfig.json +2 -2
  37. package/tsup.config.cjs +5 -0
  38. package/dist/analyze/infer-spec.test.d.ts +0 -2
  39. package/dist/analyze/infer-spec.test.d.ts.map +0 -1
  40. package/dist/analyze/infer-spec.test.js +0 -112
  41. package/dist/analyze/infer-spec.test.js.map +0 -1
  42. package/dist/analyze/mui.test.d.ts +0 -2
  43. package/dist/analyze/mui.test.d.ts.map +0 -1
  44. package/dist/analyze/mui.test.js +0 -60
  45. package/dist/analyze/mui.test.js.map +0 -1
  46. package/dist/analyze/pkg-basic.test.d.ts +0 -2
  47. package/dist/analyze/pkg-basic.test.d.ts.map +0 -1
  48. package/dist/analyze/pkg-basic.test.js +0 -33
  49. package/dist/analyze/pkg-basic.test.js.map +0 -1
  50. package/dist/analyze/pkg-diff-types.test.d.ts +0 -2
  51. package/dist/analyze/pkg-diff-types.test.d.ts.map +0 -1
  52. package/dist/analyze/pkg-diff-types.test.js +0 -43
  53. package/dist/analyze/pkg-diff-types.test.js.map +0 -1
  54. package/dist/client/init.d.mts.map +0 -1
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/react-creators.d.ts +0 -20
  57. package/dist/react-creators.d.ts.map +0 -1
  58. package/dist/react-creators.js +0 -170
  59. package/dist/react-creators.js.map +0 -1
  60. package/dist/renderer-react.d.ts.map +0 -1
  61. package/dist/renderer-react.js +0 -569
  62. package/dist/renderer-react.js.map +0 -1
  63. package/dist/types.d.ts +0 -19
  64. package/dist/types.d.ts.map +0 -1
  65. package/dist/types.js +0 -5
  66. package/dist/types.js.map +0 -1
  67. package/dist/utils.d.ts +0 -28
  68. package/dist/utils.d.ts.map +0 -1
  69. package/dist/utils.js +0 -500
  70. package/dist/utils.js.map +0 -1
  71. package/dist/utils.test.d.ts +0 -2
  72. package/dist/utils.test.d.ts.map +0 -1
  73. package/dist/utils.test.js +0 -59
  74. package/dist/utils.test.js.map +0 -1
  75. package/prototype-template.d.mts +0 -3
  76. package/prototype-template.mjs +0 -3
  77. package/test-fixtures/pkg-diff-types/button.js +0 -10
  78. package/test-fixtures/pkg-diff-types/package.json +0 -4
  79. package/test-fixtures/pkg-diff-types/readme.md +0 -1
  80. package/test-fixtures/pkg-diff-types/types/button.d.ts +0 -5
@@ -1,569 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- var _KnapsackReactRenderer_demoWrapperPath, _KnapsackReactRenderer_disableReactStrictMode;
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.KnapsackReactRenderer = void 0;
19
- const sleep_promise_1 = __importDefault(require("sleep-promise"));
20
- const renderer_webpack_base_1 = require("@knapsack/renderer-webpack-base");
21
- const utils_1 = require("@knapsack/utils");
22
- const app_1 = require("@knapsack/app");
23
- const renderers_1 = require("@knapsack/app/renderers");
24
- const types_1 = require("@knapsack/types");
25
- const file_utils_1 = require("@knapsack/file-utils");
26
- const path_1 = require("path");
27
- const utils_2 = require("./utils");
28
- const react_creators_1 = require("./react-creators");
29
- const types_2 = require("./types");
30
- const { pkg } = (0, file_utils_1.findUpPkgJson)(__dirname);
31
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
32
- app_1.log.setupUpdateNotifier({ ...pkg, name: pkg.name, version: pkg.version });
33
- class KnapsackReactRenderer extends renderer_webpack_base_1.RendererWebpackBase {
34
- constructor({ webpackConfig, demoWrapperPath, id = types_1.rendererIds.react, disableReactStrictMode, } = {}) {
35
- super({
36
- id,
37
- language: 'jsx',
38
- webpackConfig,
39
- extraScripts: [
40
- // this is the code in `./client/init.mts`
41
- '@knapsack/renderer-react/client',
42
- ],
43
- });
44
- _KnapsackReactRenderer_demoWrapperPath.set(this, void 0);
45
- _KnapsackReactRenderer_disableReactStrictMode.set(this, void 0);
46
- this.setConfig = (opt) => {
47
- super.setConfig(opt);
48
- const { absolutePath, exists: demoWrapperPathExists, type, } = this.resolvePathSync({
49
- path: __classPrivateFieldGet(this, _KnapsackReactRenderer_demoWrapperPath, "f"),
50
- resolveFromDir: this.userConfigDir,
51
- });
52
- if (!demoWrapperPathExists) {
53
- throw new Error(`Could not find demo wrapper at: "${__classPrivateFieldGet(this, _KnapsackReactRenderer_demoWrapperPath, "f")}"\nPlease adjust setting in "knapsack.config.js" or pass a different path when creating the React Renderer.`);
54
- }
55
- this.registerExtraJsImports({
56
- DemoWrapper: {
57
- exportName: 'DemoWrapper',
58
- isDefaultExport: true,
59
- path: type === 'package' ? __classPrivateFieldGet(this, _KnapsackReactRenderer_demoWrapperPath, "f") : absolutePath,
60
- },
61
- });
62
- };
63
- this.init = async () => {
64
- this.assets = await (0, utils_2.copyReactAssets)(this.outputDir, this.publicPath);
65
- };
66
- this.hydrate = async (opt) => {
67
- await super.hydrate(opt);
68
- await this.init({ missingFileVerbosity: 'silent' });
69
- };
70
- this.getMeta = () => ({
71
- id: this.id,
72
- title: 'React',
73
- aliasUse: 'optional',
74
- aliasTitle: 'Named Export',
75
- aliasIsJsNamedExport: true,
76
- aliasDescription: 'If `export X` was used instead of `export default`, then provide X.',
77
- enableDataDemos: true,
78
- enableTemplateDemos: true,
79
- hasSlotsSupport: true,
80
- hasSlotOptionsSupport: true,
81
- version: pkg.version,
82
- hasInferSpecSupport: true,
83
- syntaxHighlightingLanguage: 'jsx',
84
- hasTemplateSuggestionsSupport: true,
85
- prototypingTemplate: {
86
- path: '@knapsack/renderer-react/prototype-template',
87
- spec: {
88
- isInferred: false,
89
- props: {
90
- type: 'object',
91
- properties: {},
92
- },
93
- slots: {
94
- children: { title: 'Children' },
95
- },
96
- },
97
- },
98
- });
99
- this.changeCase = (str) => (0, utils_1.pascalCase)(str);
100
- this.createWebpackConfig = () => {
101
- const config = super.createWebpackConfig();
102
- config.externals = {
103
- react: 'React',
104
- 'react-dom': 'ReactDOM',
105
- };
106
- return config;
107
- };
108
- this.render = async (opt) => {
109
- var _a, _b;
110
- if (((_a = opt.demo) === null || _a === void 0 ? void 0 : _a.type) === 'template') {
111
- // when getting a template demos path sometimes we have a race condition where the client asks for it before the server knows about it.
112
- // so we try several times in a row to get it
113
- /** The amount of time in ms to wait between attempts; when we run out of array items, we give up and throw the error */
114
- const waits = [5, 10, 20, 50, 100, 1000, 1000];
115
- let templateDemoPath;
116
- let attempt = 0;
117
- while (true) {
118
- try {
119
- const { absolutePath, exists } = await this.resolvePath(opt.demo.templateInfo.path);
120
- if (!exists) {
121
- throw new Error(`Template demo file does not exist: ${absolutePath}`);
122
- }
123
- templateDemoPath = absolutePath;
124
- // got it!
125
- break;
126
- }
127
- catch (e) {
128
- const waitTime = waits[attempt];
129
- if (!waitTime) {
130
- throw new Error(e);
131
- }
132
- attempt += 1;
133
- // eslint-disable-next-line no-await-in-loop
134
- await (0, sleep_promise_1.default)(waitTime);
135
- }
136
- }
137
- const [templateFileContents, { usage, importMap }] = await Promise.all([
138
- (0, file_utils_1.readFile)(templateDemoPath),
139
- this.getUsageAndImports({
140
- ...opt,
141
- importMap: new Map(),
142
- }),
143
- ]);
144
- const demoApp = await (0, utils_2.getDemoAppUsage)({
145
- children: usage,
146
- });
147
- const results = await this.prepClientRenderResults({
148
- usage: templateFileContents,
149
- demoApp,
150
- renderOptions: opt,
151
- importMap,
152
- });
153
- return results;
154
- }
155
- if (((_b = opt.demo) === null || _b === void 0 ? void 0 : _b.type) === 'data') {
156
- const { usage, importMap } = await this.getUsageAndImports({
157
- ...opt,
158
- importMap: new Map(),
159
- });
160
- const importCode = renderer_webpack_base_1.RendererWebpackBase.createJsImportCodeBlock({
161
- importMap,
162
- });
163
- const [demoAppUsage, demoApp] = await Promise.all([
164
- (0, utils_2.getDemoAppUsage)({
165
- children: usage,
166
- imports: importCode,
167
- format: true,
168
- }),
169
- (0, utils_2.getDemoAppUsage)({
170
- children: usage,
171
- }),
172
- ]);
173
- return this.prepClientRenderResults({
174
- demoApp,
175
- usage: demoAppUsage,
176
- renderOptions: opt,
177
- importMap,
178
- });
179
- }
180
- };
181
- this.getUsageAndImports = async ({ patternId, templateId, demo, state, importMap, }) => {
182
- if (!demo) {
183
- throw new Error(`No demo provided while rendering ${patternId} ${templateId}`);
184
- }
185
- const pattern = state.patterns[patternId];
186
- if (!pattern) {
187
- throw new Error(`Could not find pattern: ${patternId}`);
188
- }
189
- if (demo.type === 'data') {
190
- const template = pattern.templates.find((t) => t.id === templateId);
191
- if (!template) {
192
- throw new Error(`Could not find template: ${templateId}`);
193
- }
194
- const { data: { props, slots, slotsOptionsComputed }, } = demo;
195
- const { name: templateName } = await this.addUniqueValueToImportMap({
196
- importMap,
197
- path: template.path,
198
- alias: template.alias || 'default',
199
- });
200
- const children = [];
201
- const extraProps = [];
202
- if (slots) {
203
- const slotNames = Object.keys(slots);
204
- const slotUsages = await Promise.all(slotNames.map(async (slotName) => {
205
- const slotItems = slots[slotName];
206
- const slotItemsUsages = await Promise.all(slotItems
207
- // remove any incomplete item - happens when users are filling out form
208
- .filter((slotItem) => {
209
- if (!slotItem)
210
- return false;
211
- if (slotItem.type !== 'text') {
212
- if (!slotItem.patternId)
213
- return false;
214
- if (!slotItem.templateId)
215
- return false;
216
- if (slotItem.type === 'template-demo' && !slotItem.demoId) {
217
- return false;
218
- }
219
- }
220
- return true;
221
- })
222
- .map(async (slotItem) => {
223
- var _a;
224
- if (slotItem.type === 'text') {
225
- if (slotItems.length === 1 && slotName !== 'children') {
226
- // The ` prevents multi-line strings from causing error (even though they don't show a line break)
227
- return `\`${slotItem.text}\``;
228
- }
229
- return slotItem.text;
230
- }
231
- if (slotItem.type === 'template-reference') {
232
- const slottedTemplate = (_a = state.patterns[slotItem.patternId]) === null || _a === void 0 ? void 0 : _a.templates.find((t) => t.id === slotItem.templateId);
233
- if (!slottedTemplate) {
234
- throw new Error(`Could not find slotted template: ${slotItem.patternId} ${slotItem.templateId}`);
235
- }
236
- const templateRefImport = await this.addUniqueValueToImportMap({
237
- importMap,
238
- path: slottedTemplate.path,
239
- alias: slottedTemplate.alias || 'default',
240
- });
241
- /**
242
- * i.e. Given a React Component, `Button`, normally this would be `<Button>` with a demo, but since there is none this will just be a reference to it: `Button`
243
- * @see {KsSlotInfo['isTemplateReference']}
244
- * @see {SlottedTemplate}
245
- */
246
- return templateRefImport.name;
247
- }
248
- if (slotItem.type === 'template-demo') {
249
- const thisDemo = slotItem.demo;
250
- if (!thisDemo) {
251
- throw new Error(`Could not find slotted template demo ${JSON.stringify(slotItem)}`);
252
- }
253
- const { usage } = await this.getUsageAndImports({
254
- patternId: thisDemo.patternId,
255
- templateId: thisDemo.templateId,
256
- demo: thisDemo,
257
- state,
258
- importMap,
259
- });
260
- return usage;
261
- }
262
- const _exhaustiveCheck = slotItem;
263
- throw new Error(`Unknown slot item: ${JSON.stringify(slotItem)}`);
264
- }));
265
- return {
266
- slotName,
267
- slotItemsUsages,
268
- };
269
- }));
270
- slotUsages.forEach(({ slotName, slotItemsUsages }) => {
271
- const slotOptionsComputed = slotsOptionsComputed === null || slotsOptionsComputed === void 0 ? void 0 : slotsOptionsComputed[slotName];
272
- const { openTag, closeTag } = (0, renderers_1.createSlotOptionsHtmlTags)({
273
- slotOptionsComputed,
274
- classAttributeName: 'className',
275
- stylesValueType: 'object',
276
- });
277
- if (openTag) {
278
- if (slotName === 'children') {
279
- children.push(openTag);
280
- }
281
- else {
282
- extraProps.push({
283
- key: slotName,
284
- value: openTag,
285
- });
286
- }
287
- }
288
- slotItemsUsages.forEach((usage) => {
289
- if (slotName === 'children') {
290
- children.push(usage);
291
- }
292
- else {
293
- extraProps.push({
294
- key: slotName,
295
- value: usage,
296
- });
297
- }
298
- });
299
- if (closeTag) {
300
- if (slotName === 'children') {
301
- children.push(closeTag);
302
- }
303
- else {
304
- extraProps.push({
305
- key: slotName,
306
- value: closeTag,
307
- });
308
- }
309
- }
310
- });
311
- }
312
- const usage = await (0, utils_2.getUsage)({
313
- templateName,
314
- props,
315
- children: children.join('\n'),
316
- extraProps,
317
- });
318
- return {
319
- usage,
320
- importMap,
321
- };
322
- }
323
- if (demo.type === 'template') {
324
- const { templateInfo } = demo;
325
- const { name: templateName } = await this.addUniqueValueToImportMap({
326
- importMap,
327
- path: templateInfo.path,
328
- alias: templateInfo.alias || 'default',
329
- });
330
- const usage = await (0, utils_2.getUsage)({ templateName });
331
- return {
332
- usage,
333
- importMap,
334
- };
335
- }
336
- const _exhaustiveCheck = demo;
337
- throw new Error(`Unhandled demo type for ${patternId}-${templateId}: ${JSON.stringify(demo)}`);
338
- };
339
- this.inferSpec = async ({ template, templatePath, }) => {
340
- var _a;
341
- const spec = await (0, utils_2.getReactDocs)({
342
- src: template.path,
343
- exportName: template.alias || 'default',
344
- resolveFromDir: this.config.data,
345
- });
346
- if (spec !== false) {
347
- const totalProps = Object.keys(((_a = spec === null || spec === void 0 ? void 0 : spec.props) === null || _a === void 0 ? void 0 : _a.properties) || {}).length;
348
- const totalSlots = Object.keys((spec === null || spec === void 0 ? void 0 : spec.slots) || {}).length;
349
- if (totalProps === 0 && totalSlots === 0) {
350
- return false;
351
- }
352
- }
353
- return spec;
354
- };
355
- this.watch = async () => {
356
- super.watch();
357
- app_1.knapsackEvents.onPatternTemplateChanged(() => {
358
- (0, utils_2.clearInferSpecCache)();
359
- });
360
- };
361
- this.getTemplateMeta = async ({ pattern, template, }) => {
362
- var _a, _b;
363
- const files = [];
364
- if ((_a = template === null || template === void 0 ? void 0 : template.spec) === null || _a === void 0 ? void 0 : _a.props) {
365
- const schema = JSON.parse(JSON.stringify(template.spec.props));
366
- if ((_b = template === null || template === void 0 ? void 0 : template.spec) === null || _b === void 0 ? void 0 : _b.slots) {
367
- Object.entries(template.spec.slots).forEach(([id, info]) => {
368
- var _a;
369
- schema.properties[id] = {
370
- typeof: 'function',
371
- tsType: 'React.ReactNode',
372
- description: info.allowedPatternIds
373
- ? `${info.description}. Only use: ${info.allowedPatternIds.join(', ')}`
374
- : info.description,
375
- };
376
- schema.required = (_a = schema.required) !== null && _a !== void 0 ? _a : [];
377
- if (info.isRequired)
378
- schema.required.push(id);
379
- });
380
- }
381
- const typeDefs = await KnapsackReactRenderer.convertSchemaToTypeScriptDefs({
382
- schema,
383
- title: `${this.changeCase(pattern.id)}Props`,
384
- // @todo pull in base url
385
- description: `[Knapsack Docs](http://localhost:3999/pattern/${pattern.id}/${template.id})`,
386
- patternId: pattern.id,
387
- templateId: template.id,
388
- postBanner: `import * as React from 'react';`,
389
- });
390
- files.push({
391
- contents: typeDefs,
392
- encoding: 'utf8',
393
- path: `${pattern.id}.${template.id}.spec.d.ts`,
394
- });
395
- files.push({
396
- contents: JSON.stringify(schema, null, ' '),
397
- encoding: 'utf8',
398
- path: `${pattern.id}.${template.id}.spec.json`,
399
- });
400
- }
401
- return files;
402
- };
403
- this.alterTemplateMetaFiles = async ({ files, metaDir, }) => {
404
- const imports = [];
405
- const ext = '.spec.d.ts';
406
- files.forEach((file) => {
407
- if (file.path.endsWith(ext)) {
408
- const { base } = (0, path_1.parse)(file.path);
409
- const [patternId, templateId] = base.split('.');
410
- const isFirst = templateId === this.id;
411
- const exportName = this.changeCase(`${patternId}Props`);
412
- const exportNameWithTemplateId = this.changeCase(`${patternId}-${templateId}Props`);
413
- imports.push(`export { ${isFirst
414
- ? exportName
415
- : `${exportName} as ${exportNameWithTemplateId}`} } from './${(0, path_1.relative)(metaDir, file.path).replace('.d.ts', '')}';`);
416
- }
417
- });
418
- // extra line at end of file
419
- imports.push('');
420
- return [
421
- ...files,
422
- {
423
- contents: imports.join('\n'),
424
- encoding: 'utf8',
425
- path: (0, path_1.join)(metaDir, 'react.d.ts'),
426
- },
427
- ];
428
- };
429
- this.getTemplateSuggestions = async ({ newPath, state, }) => {
430
- // Deduplicate suggestions using Map with stringified path/alias as keys.
431
- // Map values are suggestion objects, Array.from(map.values()) returns deduplicated array.
432
- const usedSuggestions = Array.from(new Map(Object.values(state.patterns).reduce((acc, { templateDemos, templates }) => {
433
- templates.forEach(({ path, alias, templateLanguageId }) => {
434
- if (templateLanguageId !== this.id)
435
- return;
436
- acc.push([JSON.stringify({ path, alias }), { path, alias }]);
437
- });
438
- templateDemos.forEach(({ templateInfo: { path, alias }, templateLanguageId }) => {
439
- if (templateLanguageId !== this.id)
440
- return;
441
- acc.push([JSON.stringify({ path, alias }), { path, alias }]);
442
- });
443
- return acc;
444
- }, [])).values());
445
- const codeSrcs = new Set(this.getCodeSrcs().map(({ path }) => path));
446
- const allPaths = [
447
- ...new Set([
448
- newPath,
449
- ...Object.keys(this.pkgPathAliases || {}),
450
- ...codeSrcs,
451
- ]),
452
- ];
453
- const allSuggestions = await Promise.all(allPaths.map(async (path) => {
454
- if (!path)
455
- return [];
456
- try {
457
- const { exports, errorMsg } = await (0, file_utils_1.getJsExportNames)({
458
- path,
459
- resolveFromDir: this.dataDir,
460
- pkgPathAliases: this.pkgPathAliases,
461
- });
462
- if (errorMsg) {
463
- throw new Error(errorMsg);
464
- }
465
- return (exports
466
- // only allow names that start with a capital letter (i.e. React Component names)
467
- // will exclude helper functions and custom hooks
468
- .filter((e) => e === 'default' || (0, utils_1.isFirstLetterCapital)(e))
469
- .map((name) => ({
470
- alias: name,
471
- path,
472
- })));
473
- }
474
- catch (e) {
475
- // only want this showing with verbose since template suggestions are not critical
476
- app_1.log.verbose(`Error getting import names for ${path}: ${e.message}`, null, this.logPrefix);
477
- return [];
478
- }
479
- })).then((results) => {
480
- // sadly `Promise.all` & `.flatMap` just don't work, so this:
481
- return results.flat();
482
- });
483
- const suggestions = allSuggestions.filter((s) => {
484
- return !usedSuggestions.find((us) => us.alias === s.alias && us.path === s.path);
485
- });
486
- const connectedSuggestions = usedSuggestions.map((s) => ({
487
- ...s,
488
- connected: true,
489
- }));
490
- return {
491
- suggestions: [...suggestions, ...connectedSuggestions],
492
- };
493
- };
494
- this.language = 'jsx';
495
- this.assets = [];
496
- __classPrivateFieldSet(this, _KnapsackReactRenderer_disableReactStrictMode, disableReactStrictMode, "f");
497
- this.creators = [react_creators_1.createReactPattern];
498
- if (demoWrapperPath) {
499
- __classPrivateFieldSet(this, _KnapsackReactRenderer_demoWrapperPath, demoWrapperPath, "f");
500
- }
501
- else {
502
- const defaultDemoWrapperPath = '@knapsack/renderer-react-components/demo-wrapper';
503
- const { absolutePath, exists } = this.resolvePathSync({
504
- path: defaultDemoWrapperPath,
505
- // we need to resolve this from this file since the demo wrapper's package is a dependency of this package
506
- // if we resolved it from `this.userConfigDir` then the path would be incorrect for NPM installs that do not hoist sub-dependencies to the top-level
507
- resolveFromDir: __dirname,
508
- });
509
- if (!exists) {
510
- throw new Error(`Could not locate the default Demo Wrapper component at "${defaultDemoWrapperPath}". This is an internal error and may be caused by a NPM install issue.`);
511
- }
512
- __classPrivateFieldSet(this, _KnapsackReactRenderer_demoWrapperPath, absolutePath, "f");
513
- }
514
- }
515
- async prepClientRenderResults({ usage, demoApp, importMap, renderOptions: { demo, state, patternId, templateId }, }) {
516
- const meta = {
517
- demo,
518
- disableReactStrictMode: __classPrivateFieldGet(this, _KnapsackReactRenderer_disableReactStrictMode, "f"),
519
- neededImportsByCodeSrcId: (0, renderer_webpack_base_1.convertImportMapToNeededImportsByCodeSrcId)(importMap),
520
- demoWrapperProps: {
521
- patternId,
522
- templateId,
523
- demo,
524
- },
525
- };
526
- let code = `
527
- window.knapsack = window.knapsack || {};
528
- window.knapsack.getDemoApp = ({ ${[...importMap.keys()].join(', ')} }) => {
529
- ${demoApp}
530
- return ${utils_2.demoAppName}
531
- }
532
- `;
533
- let errorHtmlMsg = '';
534
- try {
535
- code = await (0, renderers_1.babelCodeForBrowser)({ code });
536
- }
537
- catch (e) {
538
- console.log(code);
539
- console.log('---original code before babel error ^---');
540
- console.trace(e.message);
541
- code = `console.error(${JSON.stringify(e.message)});`;
542
- errorHtmlMsg = `<pre><code>${e.message}</code></pre>`;
543
- }
544
- const html = `
545
- <script type="application/json" id="${types_2.rendererMetaScriptTagId}">${JSON.stringify(meta)}</script>
546
- <script type="application/javascript">${code}</script>
547
- <div id="render-root" class="knapsack-pattern-direct-parent" data-dev-note="Knapsack React Template Wrapper"></div>
548
- ${this.assets.map((asset) => `<script src="${asset}"></script>`).join('\n')}
549
- ${renderer_webpack_base_1.RendererWebpackBase.createHtmlTagsForAssetPaths({
550
- assets: this.getWebpackAssetPaths(),
551
- // we need the scripts to finish adding methods to the global knapsack object synchronously before the client-side code runs that is in the <script> tag below
552
- scriptTagsAreAsync: false,
553
- })}
554
- ${errorHtmlMsg}
555
- `;
556
- return {
557
- ok: !errorHtmlMsg,
558
- html: await (0, file_utils_1.formatCode)({
559
- contents: html,
560
- path: 'x.html', // doing this to set format language
561
- }),
562
- usage,
563
- templateLanguage: this.language,
564
- };
565
- }
566
- }
567
- exports.KnapsackReactRenderer = KnapsackReactRenderer;
568
- _KnapsackReactRenderer_demoWrapperPath = new WeakMap(), _KnapsackReactRenderer_disableReactStrictMode = new WeakMap();
569
- //# sourceMappingURL=renderer-react.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderer-react.js","sourceRoot":"","sources":["../src/renderer-react.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kEAAkC;AAClC,2EAKyC;AACzC,2CAAmE;AACnE,uCAAoD;AACpD,uDAIiC;AACjC,2CAOyB;AACzB,qDAK8B;AAC9B,+BAA6C;AAC7C,mCAOiB;AACjB,qDAAsD;AACtD,mCAIiB;AAEjB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,0BAAa,EAAC,SAAS,CAAC,CAAC;AACzC,oEAAoE;AACpE,SAAG,CAAC,mBAAmB,CAAC,E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AEF,OAAO;YACL,EAAE,EAAE,CAAC,YAAY;YACjB,IAAI,EAAE,MAAM,IAAA,uBAAU,EAAC;gBACrB,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,QAAQ,EAAE,oCAAoC;aACrD,CAAC;YACF,KAAK;YACL,gBAAgB,EAAE,IAAI,CAAC,QAAQ;SAChC,CAAC;IACJ,CAAC;CA4dF;AA7qBD,sDA6qBC"}
package/dist/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import type { Demo, Except } from '@knapsack/types';
2
- import type { ComponentType } from 'react';
3
- import type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';
4
- import type { DemoWrapperProps } from '@knapsack/renderer-react-components/demo-wrapper';
5
- export type Component = ComponentType<Record<string, unknown>>;
6
- export type ExtraJsImportNames = 'DemoWrapper';
7
- /**
8
- * Found as JSON in HTML `#ks-react-meta`
9
- */
10
- export type KsReactMeta = {
11
- disableReactStrictMode: boolean;
12
- demo: Demo;
13
- demoWrapperProps: Except<DemoWrapperProps, 'children'>;
14
- } & RendererMetaBase;
15
- export declare const rendererMetaScriptTagId = "ks-react-meta";
16
- export type RendererMethods = {
17
- getDemoApp: (components: Record<string, Component>) => Component;
18
- };
19
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,kDAAkD,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAC/C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;CACxD,GAAG,gBAAgB,CAAC;AAErB,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,SAAS,CAAC;CAClE,CAAC"}
package/dist/types.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rendererMetaScriptTagId = void 0;
4
- exports.rendererMetaScriptTagId = 'ks-react-meta';
5
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuBa,QAAA,uBAAuB,GAAG,eAAe,CAAC"}