@teleporthq/teleport-code-generator 0.44.1-alpha.0 → 0.44.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/__tests__/index.ts +2 -2
- package/__tests__/packproject-html-motion.test.ts +70 -0
- package/__tests__/packproject-html-state.test.ts +58 -0
- package/__tests__/packproject-widget-deps.test.ts +87 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +51 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +53 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -23
- package/src/index.ts +72 -11
package/__tests__/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { readFileSync, existsSync, readdirSync, unlinkSync, statSync, rmdirSync
|
|
|
2
2
|
import { join } from 'path'
|
|
3
3
|
import { performance } from 'perf_hooks'
|
|
4
4
|
import projectJson from '../../../examples/test-samples/project-sample.json'
|
|
5
|
-
import htmlProjectJson from '../../../examples/uidl-samples/
|
|
5
|
+
import htmlProjectJson from '../../../examples/uidl-samples/tests.json'
|
|
6
6
|
import {
|
|
7
7
|
ProjectUIDL,
|
|
8
8
|
GenerateOptions,
|
|
@@ -137,7 +137,7 @@ describe('code generator', () => {
|
|
|
137
137
|
|
|
138
138
|
const { success } = await packProject(htmlProjectJson as unknown as ProjectUIDL, options)
|
|
139
139
|
expect(success).toBeTruthy()
|
|
140
|
-
})
|
|
140
|
+
}, 30000)
|
|
141
141
|
|
|
142
142
|
it('creates a react component', async () => {
|
|
143
143
|
const options: GenerateOptions = {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import { ProjectType, ProjectUIDL, PublisherType } from '@teleporthq/teleport-types'
|
|
4
|
+
import uidlSample from '../../../examples/uidl-samples/tests.json'
|
|
5
|
+
import { packProject } from '../src/index'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The HTML download goes through `packProject`, which clears the generator's
|
|
9
|
+
* plugins and lists the HTML ones by hand. A behaviour plugin that is only
|
|
10
|
+
* registered on the generator factory never runs for a real download, so the
|
|
11
|
+
* motion runtime is checked here, on the path the editor's download uses.
|
|
12
|
+
*/
|
|
13
|
+
const outputPath = join(__dirname, 'packproject-html-motion-tmp')
|
|
14
|
+
const projectSlug = 'motion-html-site'
|
|
15
|
+
|
|
16
|
+
const SCENE = {
|
|
17
|
+
type: 'element',
|
|
18
|
+
content: {
|
|
19
|
+
elementType: 'scroll-scene-node',
|
|
20
|
+
name: 'story',
|
|
21
|
+
attrs: { sceneLength: { type: 'static', content: '300vh' } },
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
type: 'element',
|
|
25
|
+
content: {
|
|
26
|
+
elementType: 'container',
|
|
27
|
+
attrs: { 'data-scroll-bind': { type: 'static', content: 'rise-in' } },
|
|
28
|
+
children: [] as unknown[],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
afterAll(() => {
|
|
36
|
+
rmSync(outputPath, { recursive: true, force: true })
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('packProject, HTML: a downloaded site plays its motion', () => {
|
|
40
|
+
it('writes the runtime file next to the stylesheet, links it from the pages and carries the page transition', async () => {
|
|
41
|
+
const uidl = JSON.parse(JSON.stringify(uidlSample)) as ProjectUIDL
|
|
42
|
+
const firstPage = (uidl.root.node.content.children || [])[0] as {
|
|
43
|
+
content: { node: { content: { children: unknown[] } } }
|
|
44
|
+
}
|
|
45
|
+
firstPage.content.node.content.children.push(SCENE)
|
|
46
|
+
;(uidl.globals.settings as Record<string, unknown>).pageTransition = {
|
|
47
|
+
preset: 'slide-left',
|
|
48
|
+
duration: 0.3,
|
|
49
|
+
easing: 'ease-out',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { success } = await packProject(uidl, {
|
|
53
|
+
projectType: ProjectType.HTML,
|
|
54
|
+
publisher: PublisherType.DISK,
|
|
55
|
+
publishOptions: { outputPath, projectSlug },
|
|
56
|
+
})
|
|
57
|
+
expect(success).toBeTruthy()
|
|
58
|
+
|
|
59
|
+
const root = join(outputPath, projectSlug)
|
|
60
|
+
expect(existsSync(join(root, 'tq-motion.js'))).toBe(true)
|
|
61
|
+
const home = readFileSync(join(root, 'index.html'), 'utf8')
|
|
62
|
+
expect(home).toContain('data-scene-stage="true"')
|
|
63
|
+
expect(home).toContain('<script defer src="./tq-motion.js"></script>')
|
|
64
|
+
const css = readFileSync(join(root, 'style.css'), 'utf8')
|
|
65
|
+
expect(css).toContain('position: sticky !important;')
|
|
66
|
+
// the site's page transition travels too, with the back-button script in the page head
|
|
67
|
+
expect(css).toContain('@view-transition')
|
|
68
|
+
expect(home).toContain("root.setAttribute('data-tq-nav', 'back')")
|
|
69
|
+
})
|
|
70
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import { load } from 'cheerio'
|
|
4
|
+
import { ProjectType, PublisherType } from '@teleporthq/teleport-types'
|
|
5
|
+
import {
|
|
6
|
+
plainSite,
|
|
7
|
+
stateSite,
|
|
8
|
+
} from '../../teleport-project-generator-html/__tests__/_helpers/state-site'
|
|
9
|
+
import { packProject } from '../src/index'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The HTML download goes through `packProject`, which clears the generator's
|
|
13
|
+
* plugins and lists the HTML ones by hand, so the state runtime is checked on
|
|
14
|
+
* the path the editor's download takes (strict whitespace on, as by default).
|
|
15
|
+
*/
|
|
16
|
+
const outputPath = join(__dirname, 'packproject-html-state-tmp')
|
|
17
|
+
|
|
18
|
+
afterAll(() => {
|
|
19
|
+
rmSync(outputPath, { recursive: true, force: true })
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const download = async (projectSlug: string, uidl = stateSite()) => {
|
|
23
|
+
const { success } = await packProject(uidl, {
|
|
24
|
+
projectType: ProjectType.HTML,
|
|
25
|
+
publisher: PublisherType.DISK,
|
|
26
|
+
publishOptions: { outputPath, projectSlug },
|
|
27
|
+
})
|
|
28
|
+
expect(success).toBeTruthy()
|
|
29
|
+
return join(outputPath, projectSlug)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('packProject, HTML: a downloaded site runs its conditions and clicks', () => {
|
|
33
|
+
it('writes tq-state.js next to the stylesheet and links it from the page that binds state', async () => {
|
|
34
|
+
const root = await download('state-html-site')
|
|
35
|
+
|
|
36
|
+
expect(existsSync(join(root, 'tq-state.js'))).toBe(true)
|
|
37
|
+
const home = readFileSync(join(root, 'index.html'), 'utf8')
|
|
38
|
+
expect(home.match(/<script defer src="\.\/tq-state\.js"><\/script>/g)).toHaveLength(1)
|
|
39
|
+
expect(home.search(/tq-state\.js/)).toBeLessThan(home.search(/<\/head\s*>/))
|
|
40
|
+
|
|
41
|
+
const $ = load(home)
|
|
42
|
+
expect($('#burger').first().attr('data-tq-on-click')).toBe('menuOpen = !menuOpen')
|
|
43
|
+
expect($('#tab-1').attr('data-tq-on-click')).toBe('activeTabIndex = 1')
|
|
44
|
+
expect($('#panel-1').attr('hidden')).toBeDefined()
|
|
45
|
+
expect($('#panel-0').attr('hidden')).toBeUndefined()
|
|
46
|
+
expect(readFileSync(join(root, 'style.css'), 'utf8')).toContain(
|
|
47
|
+
'[data-tq-if][hidden] {\n display: none !important;\n}'
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('a site without state bindings downloads as it did before', async () => {
|
|
52
|
+
const root = await download('plain-html-site', plainSite())
|
|
53
|
+
|
|
54
|
+
expect(readdirSync(root)).not.toContain('tq-state.js')
|
|
55
|
+
expect(readFileSync(join(root, 'index.html'), 'utf8')).not.toContain('tq-state')
|
|
56
|
+
expect(readFileSync(join(root, 'style.css'), 'utf8')).not.toContain('data-tq-if')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import { ProjectType, ProjectUIDL, PublisherType } from '@teleporthq/teleport-types'
|
|
4
|
+
import uidlSample from '../../../examples/test-samples/project-sample.json'
|
|
5
|
+
import { packProject } from '../src/index'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Regression guard for the "Module not found: Can't resolve 'framer-motion'"
|
|
9
|
+
* class of bug.
|
|
10
|
+
*
|
|
11
|
+
* `packProject` calls `cleanPlugins()` and rebuilds the Next project-plugin list
|
|
12
|
+
* from scratch. That list used to be hand-duplicated from
|
|
13
|
+
* createNextProjectGenerator, and the two drifted: the npm-backed widget
|
|
14
|
+
* primitives (motion / qr-code / …) were dropped from packProject, so the
|
|
15
|
+
* generated project shipped `components/tq-motion.js` (which imports
|
|
16
|
+
* framer-motion) WITHOUT adding framer-motion to package.json — `next build`
|
|
17
|
+
* then failed.
|
|
18
|
+
*
|
|
19
|
+
* Unlike the motion end2end test in teleport-project-generator-next (which goes
|
|
20
|
+
* through createNextProjectGenerator directly), this test exercises the real
|
|
21
|
+
* `packProject` entry point — the one the GUI/worker publish path uses — so a
|
|
22
|
+
* future regression that drops a widget plugin from packProject is caught here.
|
|
23
|
+
*/
|
|
24
|
+
const outputPath = join(__dirname, 'packproject-widget-deps-tmp')
|
|
25
|
+
const projectSlug = 'motion-widget-app'
|
|
26
|
+
|
|
27
|
+
const MOTION_ELEMENT_NODE = {
|
|
28
|
+
type: 'element',
|
|
29
|
+
content: {
|
|
30
|
+
elementType: 'motion-node',
|
|
31
|
+
name: 'motion',
|
|
32
|
+
attrs: {
|
|
33
|
+
preset: { type: 'static', content: 'slide-up' },
|
|
34
|
+
trigger: { type: 'static', content: 'in-view' },
|
|
35
|
+
},
|
|
36
|
+
children: [
|
|
37
|
+
{
|
|
38
|
+
type: 'element',
|
|
39
|
+
content: {
|
|
40
|
+
elementType: 'container',
|
|
41
|
+
attrs: { id: { type: 'static', content: 'motion-inner-child' } },
|
|
42
|
+
children: [] as unknown[],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const buildUidlWithMotion = (): ProjectUIDL => {
|
|
50
|
+
const uidl = JSON.parse(JSON.stringify(uidlSample)) as ProjectUIDL
|
|
51
|
+
const indexPage = (uidl.root.node.content.children || []).find(
|
|
52
|
+
(child) =>
|
|
53
|
+
child.type === 'conditional' && (child.content as { value?: string }).value === 'index'
|
|
54
|
+
)
|
|
55
|
+
const pageElement = (indexPage as { content: { node: { content: { children: unknown[] } } } })
|
|
56
|
+
.content.node.content
|
|
57
|
+
pageElement.children.push(MOTION_ELEMENT_NODE)
|
|
58
|
+
return uidl
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
afterAll(() => {
|
|
62
|
+
rmSync(outputPath, { recursive: true, force: true })
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('packProject registers npm deps for the widget primitives it emits', () => {
|
|
66
|
+
it('adds framer-motion (and bumps react to 18) when the UIDL uses a motion node', async () => {
|
|
67
|
+
const { success } = await packProject(buildUidlWithMotion(), {
|
|
68
|
+
projectType: ProjectType.NEXT,
|
|
69
|
+
publisher: PublisherType.DISK,
|
|
70
|
+
publishOptions: { outputPath, projectSlug },
|
|
71
|
+
})
|
|
72
|
+
expect(success).toBeTruthy()
|
|
73
|
+
|
|
74
|
+
const projectRoot = join(outputPath, projectSlug)
|
|
75
|
+
|
|
76
|
+
// The wrapper that imports framer-motion was emitted...
|
|
77
|
+
const motionWrapper = join(projectRoot, 'components', 'tq-motion.js')
|
|
78
|
+
expect(existsSync(motionWrapper)).toBe(true)
|
|
79
|
+
expect(readFileSync(motionWrapper, 'utf8')).toContain("from 'framer-motion'")
|
|
80
|
+
|
|
81
|
+
// ...so its dependency MUST be declared, otherwise `next build` cannot resolve it.
|
|
82
|
+
const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'))
|
|
83
|
+
expect(pkg.dependencies['framer-motion']).toBe('^11.18.0')
|
|
84
|
+
expect(pkg.dependencies.react).toBe('^18.3.1')
|
|
85
|
+
expect(pkg.dependencies['react-dom']).toBe('^18.3.1')
|
|
86
|
+
})
|
|
87
|
+
})
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAgB1B,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAgB1B,MAAM,4BAA4B,CAAA;AAsGnC,eAAO,MAAM,WAAW,EAAE,mBA6HzB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,yBA6B/B,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -79,8 +79,8 @@ var teleport_component_generator_react_1 = require("@teleporthq/teleport-compone
|
|
|
79
79
|
var teleport_component_generator_vue_1 = require("@teleporthq/teleport-component-generator-vue");
|
|
80
80
|
var teleport_component_generator_angular_1 = require("@teleporthq/teleport-component-generator-angular");
|
|
81
81
|
var teleport_component_generator_html_1 = require("@teleporthq/teleport-component-generator-html");
|
|
82
|
+
var teleport_project_plugin_i18n_files_1 = require("@teleporthq/teleport-project-plugin-i18n-files");
|
|
82
83
|
var utils_1 = require("./utils");
|
|
83
|
-
var teleport_project_plugin_inline_fetch_1 = require("@teleporthq/teleport-project-plugin-inline-fetch");
|
|
84
84
|
var componentGeneratorFactories = (_a = {},
|
|
85
85
|
_a[teleport_types_1.ComponentType.REACT] = teleport_component_generator_react_1.createReactComponentGenerator,
|
|
86
86
|
_a[teleport_types_1.ComponentType.ANGULAR] = teleport_component_generator_angular_1.createAngularComponentGenerator,
|
|
@@ -118,39 +118,70 @@ var projectPublisherFactories = (_e = {},
|
|
|
118
118
|
_e[teleport_types_1.PublisherType.CODESANDBOX] = teleport_publisher_codesandbox_1.createCodesandboxPublisher,
|
|
119
119
|
_e);
|
|
120
120
|
var packProject = function (projectUIDL, _a) {
|
|
121
|
-
var projectType = _a.projectType, publisherType = _a.publisher, _b = _a.publishOptions, publishOptions = _b === void 0 ? {} : _b, _c = _a.assets, assets = _c === void 0 ? [] : _c, _d = _a.plugins, plugins = _d === void 0 ? [] : _d, _e = _a.assetsFolder, assetsFolder = _e === void 0 ? [teleport_shared_1.Constants.ASSETS_IDENTIFIER] : _e;
|
|
121
|
+
var projectType = _a.projectType, publisherType = _a.publisher, _b = _a.publishOptions, publishOptions = _b === void 0 ? {} : _b, _c = _a.assets, assets = _c === void 0 ? [] : _c, _d = _a.plugins, plugins = _d === void 0 ? [] : _d, _e = _a.assetsFolder, assetsFolder = _e === void 0 ? [teleport_shared_1.Constants.ASSETS_IDENTIFIER] : _e, excludeGlobalsFromHTMLComponents = _a.excludeGlobalsFromHTMLComponents, _f = _a.strictHtmlWhitespaceSensitivity, strictHtmlWhitespaceSensitivity = _f === void 0 ? true : _f, _g = _a.standaloneHtmlComponents, standaloneHtmlComponents = _g === void 0 ? false : _g, _h = _a.excludeHtmlComponentFiles, excludeHtmlComponentFiles = _h === void 0 ? false : _h, _j = _a.generateSitemap, generateSitemap = _j === void 0 ? true : _j, targetLocale = _a.targetLocale;
|
|
122
122
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
-
var packer, publisher, createDiskPublisher, projectGeneratorFactory, projectTemplate, publisherFactory, projectPublisher;
|
|
124
|
-
return __generator(this, function (
|
|
125
|
-
switch (
|
|
123
|
+
var shouldExcludeGlobals, shouldexcludeHtmlComponentFiles, packer, publisher, createDiskPublisher, projectGeneratorFactory, projectTemplate, publisherFactory, projectPublisher;
|
|
124
|
+
return __generator(this, function (_k) {
|
|
125
|
+
switch (_k.label) {
|
|
126
126
|
case 0:
|
|
127
|
+
shouldExcludeGlobals = excludeGlobalsFromHTMLComponents !== null && excludeGlobalsFromHTMLComponents !== void 0 ? excludeGlobalsFromHTMLComponents : (standaloneHtmlComponents ? true : false);
|
|
128
|
+
shouldexcludeHtmlComponentFiles = excludeHtmlComponentFiles !== null && excludeHtmlComponentFiles !== void 0 ? excludeHtmlComponentFiles : (standaloneHtmlComponents ? true : false);
|
|
127
129
|
packer = (0, teleport_project_packer_1.createProjectPacker)();
|
|
128
130
|
if (!(publisherType === teleport_types_1.PublisherType.DISK)) return [3 /*break*/, 4];
|
|
129
131
|
if (!(0, utils_1.isNodeProcess)()) return [3 /*break*/, 2];
|
|
130
132
|
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('@teleporthq/teleport-publisher-disk')); }).then(function (mod) { return mod.createDiskPublisher; })];
|
|
131
133
|
case 1:
|
|
132
|
-
createDiskPublisher =
|
|
134
|
+
createDiskPublisher = _k.sent();
|
|
133
135
|
publisher = createDiskPublisher;
|
|
134
136
|
return [3 /*break*/, 3];
|
|
135
137
|
case 2: throw Error("".concat(teleport_types_1.PublisherType.DISK, " can only be used inside node environments"));
|
|
136
138
|
case 3: return [3 /*break*/, 5];
|
|
137
139
|
case 4:
|
|
138
140
|
publisher = projectPublisherFactories[publisherType];
|
|
139
|
-
|
|
141
|
+
_k.label = 5;
|
|
140
142
|
case 5:
|
|
141
|
-
projectGeneratorFactory =
|
|
143
|
+
projectGeneratorFactory = projectType === teleport_types_1.ProjectType.HTML
|
|
144
|
+
? projectGeneratorFactories[projectType]({
|
|
145
|
+
standaloneHtmlComponents: standaloneHtmlComponents,
|
|
146
|
+
excludeHtmlComponentFiles: shouldexcludeHtmlComponentFiles,
|
|
147
|
+
})
|
|
148
|
+
: projectGeneratorFactories[projectType]();
|
|
142
149
|
projectGeneratorFactory.cleanPlugins();
|
|
150
|
+
projectGeneratorFactory.addPlugin(new teleport_project_plugin_i18n_files_1.ProjectPlugini18nFiles({ projectType: projectType }));
|
|
143
151
|
if (projectType === teleport_types_1.ProjectType.HTML) {
|
|
144
152
|
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginHomeReplace);
|
|
145
|
-
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.
|
|
153
|
+
projectGeneratorFactory.addPlugin(new teleport_project_generator_html_1.ProjectPluginCloneGlobals({
|
|
154
|
+
excludeGlobalsFromComponents: shouldExcludeGlobals,
|
|
155
|
+
strictHtmlWhitespaceSensitivity: strictHtmlWhitespaceSensitivity,
|
|
156
|
+
}));
|
|
146
157
|
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.htmlErrorPageMapping);
|
|
158
|
+
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginSnapIntoView);
|
|
159
|
+
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginScrollRail);
|
|
160
|
+
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginMotionRuntime);
|
|
161
|
+
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginStateRuntime);
|
|
162
|
+
projectGeneratorFactory.addPlugin(teleport_project_generator_html_1.pluginPageTransition);
|
|
163
|
+
}
|
|
164
|
+
if (projectType === teleport_types_1.ProjectType.NEXT) {
|
|
165
|
+
// packProject calls cleanPlugins() above and rebuilds the NEXT project-plugin
|
|
166
|
+
// list from scratch, so this packProject-only plugin (which needs the
|
|
167
|
+
// runtime `generateSitemap` option) is added explicitly here.
|
|
168
|
+
// NOTE: the forms-captcha provider script is no longer injected globally
|
|
169
|
+
// here — it's loaded per-page by the form ComponentPlugin
|
|
170
|
+
// (createNextFormSubmissionPlugin), so it only loads on pages with forms.
|
|
171
|
+
projectGeneratorFactory.addPlugin(new teleport_project_generator_next_1.NextProjectPlugini18nConfig({ generateSitemap: generateSitemap }));
|
|
172
|
+
// Everything else — data-source, workflow/auth, ecommerce, analytics, the
|
|
173
|
+
// interactive-library primitives (calendar / drag-and-drop / kanban /
|
|
174
|
+
// countdown) and the npm-backed widget primitives (incl. motion) — comes
|
|
175
|
+
// from the SINGLE shared list so this can never drift from
|
|
176
|
+
// createNextProjectGenerator. Previously this block duplicated that list by
|
|
177
|
+
// hand; a plugin missing here (or lost to a stale build) silently dropped
|
|
178
|
+
// its wrapper file's npm dependency, breaking `next build` with e.g.
|
|
179
|
+
// "Module not found: Can't resolve 'framer-motion'".
|
|
180
|
+
(0, teleport_project_generator_next_1.createNextProjectPlugins)().forEach(function (plugin) { return projectGeneratorFactory.addPlugin(plugin); });
|
|
147
181
|
}
|
|
148
182
|
if (projectType === teleport_types_1.ProjectType.NUXT) {
|
|
149
183
|
projectGeneratorFactory.addPlugin(teleport_project_generator_nuxt_1.nuxtErrorPageMapper);
|
|
150
184
|
}
|
|
151
|
-
if (projectType === teleport_types_1.ProjectType.NEXT) {
|
|
152
|
-
projectGeneratorFactory.addPlugin(new teleport_project_plugin_inline_fetch_1.ProjectPluginInlineFetch({ framework: projectType }));
|
|
153
|
-
}
|
|
154
185
|
if ((plugins === null || plugins === void 0 ? void 0 : plugins.length) > 0) {
|
|
155
186
|
plugins.forEach(function (plugin) {
|
|
156
187
|
projectGeneratorFactory.addPlugin(plugin);
|
|
@@ -176,14 +207,16 @@ var packProject = function (projectUIDL, _a) {
|
|
|
176
207
|
// @ts-ignore
|
|
177
208
|
packer.setPublisher(projectPublisher);
|
|
178
209
|
}
|
|
179
|
-
return [2 /*return*/, packer.pack(projectUIDL)];
|
|
210
|
+
return [2 /*return*/, packer.pack(projectUIDL, { strictHtmlWhitespaceSensitivity: strictHtmlWhitespaceSensitivity, targetLocale: targetLocale })];
|
|
180
211
|
}
|
|
181
212
|
});
|
|
182
213
|
});
|
|
183
214
|
};
|
|
184
215
|
exports.packProject = packProject;
|
|
185
216
|
var generateComponent = function (componentUIDL, _a) {
|
|
186
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.componentType, componentType = _c === void 0 ? teleport_types_1.ComponentType.REACT : _c, _d = _b.styleVariation, styleVariation = _d === void 0 ? teleport_types_1.ReactStyleVariation.CSSModules : _d, _e = _b.componentGeneratorOptions, componentGeneratorOptions = _e === void 0 ? {
|
|
217
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.componentType, componentType = _c === void 0 ? teleport_types_1.ComponentType.REACT : _c, _d = _b.styleVariation, styleVariation = _d === void 0 ? teleport_types_1.ReactStyleVariation.CSSModules : _d, _e = _b.componentGeneratorOptions, componentGeneratorOptions = _e === void 0 ? {
|
|
218
|
+
extractedResources: {},
|
|
219
|
+
} : _e, _f = _b.plugins, plugins = _f === void 0 ? [] : _f;
|
|
187
220
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
188
221
|
var generator, projectMapping, moduleComponents;
|
|
189
222
|
return __generator(this, function (_g) {
|
|
@@ -192,7 +225,10 @@ var generateComponent = function (componentUIDL, _a) {
|
|
|
192
225
|
generator.addMapping(projectMapping);
|
|
193
226
|
if (componentType === teleport_types_1.ComponentType.HTML) {
|
|
194
227
|
moduleComponents = componentGeneratorOptions.moduleComponents;
|
|
195
|
-
generator.addExternalComponents({
|
|
228
|
+
generator.addExternalComponents({
|
|
229
|
+
externals: moduleComponents,
|
|
230
|
+
options: {},
|
|
231
|
+
});
|
|
196
232
|
}
|
|
197
233
|
return [2 /*return*/, generator.generateComponent(componentUIDL, componentGeneratorOptions)];
|
|
198
234
|
});
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAkBmC;AACnC,+DAAuD;AAEvD,+EAAyE;AACz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