@teleporthq/teleport-plugin-jsx-next-image 0.18.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/LICENSE +21 -0
- package/Readme.md +0 -0
- package/__tests__/index.ts +157 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +130 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +107 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +32 -0
- package/src/index.ts +91 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 teleporthq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Readme.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { component, elementNode, staticNode } from '@teleporthq/teleport-uidl-builders'
|
|
2
|
+
import { createNextImagePlugin } from '../src'
|
|
3
|
+
import {
|
|
4
|
+
ChunkDefinition,
|
|
5
|
+
ChunkType,
|
|
6
|
+
FileType,
|
|
7
|
+
ComponentStructure,
|
|
8
|
+
} from '@teleporthq/teleport-types'
|
|
9
|
+
import * as types from '@babel/types'
|
|
10
|
+
|
|
11
|
+
describe('plugin-jsx-next-image', () => {
|
|
12
|
+
const plugin = createNextImagePlugin()
|
|
13
|
+
const element = elementNode(
|
|
14
|
+
'img',
|
|
15
|
+
{
|
|
16
|
+
src: staticNode('/playground_assets/image.png'),
|
|
17
|
+
alt: staticNode('Demo Picture'),
|
|
18
|
+
},
|
|
19
|
+
[],
|
|
20
|
+
null,
|
|
21
|
+
{
|
|
22
|
+
width: staticNode('100px'),
|
|
23
|
+
height: staticNode('100px'),
|
|
24
|
+
},
|
|
25
|
+
{}
|
|
26
|
+
)
|
|
27
|
+
element.content.key = 'container'
|
|
28
|
+
|
|
29
|
+
it(`When a local asset is having only width and height,
|
|
30
|
+
the jsx-next-image converts it to use Image Component`, async () => {
|
|
31
|
+
const componentChunk: ChunkDefinition = {
|
|
32
|
+
name: 'jsx-component',
|
|
33
|
+
meta: {
|
|
34
|
+
nodesLookup: {
|
|
35
|
+
container: {
|
|
36
|
+
openingElement: {
|
|
37
|
+
name: {
|
|
38
|
+
name: 'img',
|
|
39
|
+
},
|
|
40
|
+
attributes: [],
|
|
41
|
+
},
|
|
42
|
+
closingElement: {
|
|
43
|
+
name: {
|
|
44
|
+
name: 'img',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
type: ChunkType.AST,
|
|
51
|
+
fileType: FileType.JS,
|
|
52
|
+
linkAfter: ['import-local'],
|
|
53
|
+
content: {},
|
|
54
|
+
}
|
|
55
|
+
const structureMock: ComponentStructure = {
|
|
56
|
+
uidl: component('App', element),
|
|
57
|
+
options: {},
|
|
58
|
+
chunks: [componentChunk],
|
|
59
|
+
dependencies: {},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { chunks, dependencies } = await plugin(structureMock)
|
|
63
|
+
const nodeChunk = (chunks[0].meta.nodesLookup as Record<string, types.JSXElement>)?.container
|
|
64
|
+
|
|
65
|
+
expect(nodeChunk).toBeDefined()
|
|
66
|
+
expect((nodeChunk.openingElement.name as types.JSXIdentifier).name).toBe('Image')
|
|
67
|
+
expect(Object.keys(dependencies).length).toBe(1)
|
|
68
|
+
expect(Object.keys(dependencies).includes('Image')).toBe(true)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('Does not convert images with remote souce to use Next Image component', async () => {
|
|
72
|
+
const componentChunk: ChunkDefinition = {
|
|
73
|
+
name: 'jsx-component',
|
|
74
|
+
meta: {
|
|
75
|
+
nodesLookup: {
|
|
76
|
+
container: {
|
|
77
|
+
openingElement: {
|
|
78
|
+
name: {
|
|
79
|
+
name: 'img',
|
|
80
|
+
},
|
|
81
|
+
attributes: [],
|
|
82
|
+
},
|
|
83
|
+
closingElement: {
|
|
84
|
+
name: {
|
|
85
|
+
name: 'img',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
type: ChunkType.AST,
|
|
92
|
+
fileType: FileType.JS,
|
|
93
|
+
linkAfter: ['import-local'],
|
|
94
|
+
content: {},
|
|
95
|
+
}
|
|
96
|
+
element.content.attrs.src.content = `https://via.placeholder.com/150`
|
|
97
|
+
const uidl = component('App', element)
|
|
98
|
+
const structure = {
|
|
99
|
+
uidl,
|
|
100
|
+
options: {},
|
|
101
|
+
chunks: [componentChunk],
|
|
102
|
+
dependencies: {},
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { chunks, dependencies } = await plugin(structure)
|
|
106
|
+
const nodeChunk = (chunks[0].meta.nodesLookup as Record<string, types.JSXElement>)?.container
|
|
107
|
+
|
|
108
|
+
expect(nodeChunk).toBeDefined()
|
|
109
|
+
expect((nodeChunk.openingElement.name as types.JSXIdentifier).name).toBe('img')
|
|
110
|
+
expect(Object.keys(dependencies).length).toBe(0)
|
|
111
|
+
expect(Object.keys(dependencies).includes('Image')).toBe(false)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('Does not convert images with different css unit identifiers', async () => {
|
|
115
|
+
const componentChunk: ChunkDefinition = {
|
|
116
|
+
name: 'jsx-component',
|
|
117
|
+
meta: {
|
|
118
|
+
nodesLookup: {
|
|
119
|
+
container: {
|
|
120
|
+
openingElement: {
|
|
121
|
+
name: {
|
|
122
|
+
name: 'img',
|
|
123
|
+
},
|
|
124
|
+
attributes: [],
|
|
125
|
+
},
|
|
126
|
+
closingElement: {
|
|
127
|
+
name: {
|
|
128
|
+
name: 'img',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
type: ChunkType.AST,
|
|
135
|
+
fileType: FileType.JS,
|
|
136
|
+
linkAfter: ['import-local'],
|
|
137
|
+
content: {},
|
|
138
|
+
}
|
|
139
|
+
element.content.attrs.src.content = '/playground_assets/image.png'
|
|
140
|
+
element.content.style.width.content = '100%'
|
|
141
|
+
const uidl = component('App', element)
|
|
142
|
+
const structure = {
|
|
143
|
+
uidl,
|
|
144
|
+
options: {},
|
|
145
|
+
chunks: [componentChunk],
|
|
146
|
+
dependencies: {},
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const { chunks, dependencies } = await plugin(structure)
|
|
150
|
+
const nodeChunk = (chunks[0].meta.nodesLookup as Record<string, types.JSXElement>)?.container
|
|
151
|
+
|
|
152
|
+
expect(nodeChunk).toBeDefined()
|
|
153
|
+
expect((nodeChunk.openingElement.name as types.JSXIdentifier).name).toBe('img')
|
|
154
|
+
expect(Object.keys(dependencies).length).toBe(0)
|
|
155
|
+
expect(Object.keys(dependencies).includes('Image')).toBe(false)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentPluginFactory, ComponentPlugin } from '@teleporthq/teleport-types';
|
|
2
|
+
interface NextImagePluginConfig {
|
|
3
|
+
componentChunkName: string;
|
|
4
|
+
localAssetFolder: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const createNextImagePlugin: ComponentPluginFactory<NextImagePluginConfig>;
|
|
7
|
+
declare const _default: ComponentPlugin;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
+
function step(op) {
|
|
35
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
+
while (_) try {
|
|
37
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
+
switch (op[0]) {
|
|
40
|
+
case 0: case 1: t = op; break;
|
|
41
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
+
default:
|
|
45
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
+
if (t[2]) _.ops.pop();
|
|
50
|
+
_.trys.pop(); continue;
|
|
51
|
+
}
|
|
52
|
+
op = body.call(thisArg, _);
|
|
53
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
58
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
59
|
+
to[j] = from[i];
|
|
60
|
+
return to;
|
|
61
|
+
};
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.createNextImagePlugin = void 0;
|
|
64
|
+
var teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
65
|
+
var types = __importStar(require("@babel/types"));
|
|
66
|
+
/*
|
|
67
|
+
At the moment, the plugin is very restricted wo work only in the following cases.
|
|
68
|
+
- When both the units specified for the img match.
|
|
69
|
+
Eg - both height and width to have same 'px' identifier
|
|
70
|
+
|
|
71
|
+
- When the `img` tag has only width and height specified.
|
|
72
|
+
https://github.com/vercel/next.js/discussions/18312
|
|
73
|
+
*/
|
|
74
|
+
var CSS_REGEX = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
|
75
|
+
var NEXT_HEAD_DEPENDENCY = {
|
|
76
|
+
type: 'library',
|
|
77
|
+
path: 'next/image',
|
|
78
|
+
version: '10.2.0',
|
|
79
|
+
};
|
|
80
|
+
var createNextImagePlugin = function (config) {
|
|
81
|
+
var _a = config || {}, _b = _a.componentChunkName, componentChunkName = _b === void 0 ? 'jsx-component' : _b, _c = _a.localAssetFolder, localAssetFolder = _c === void 0 ? 'playground_assets' : _c;
|
|
82
|
+
var nextImagePlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var chunks, uidl, dependencies, componentChunk;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
chunks = structure.chunks, uidl = structure.uidl, dependencies = structure.dependencies;
|
|
86
|
+
componentChunk = chunks.find(function (chunk) { return chunk.name === componentChunkName; });
|
|
87
|
+
if (!componentChunk) {
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
teleport_shared_1.UIDLUtils.traverseElements(uidl.node, function (element) {
|
|
91
|
+
var _a;
|
|
92
|
+
var elementType = element.elementType, _b = element.attrs, attrs = _b === void 0 ? {} : _b, _c = element.style, style = _c === void 0 ? {} : _c, key = element.key;
|
|
93
|
+
if (key && elementType === 'img' && Object.keys(style).length === 2) {
|
|
94
|
+
var imageSource = (_a = attrs === null || attrs === void 0 ? void 0 : attrs.src) === null || _a === void 0 ? void 0 : _a.content.toString();
|
|
95
|
+
if (!(imageSource === null || imageSource === void 0 ? void 0 : imageSource.startsWith("/" + localAssetFolder))) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!(style.hasOwnProperty('width') && style.hasOwnProperty('height'))) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var height = style.height, width = style.width;
|
|
102
|
+
var heightUnit = String(height.content).match(CSS_REGEX)[2];
|
|
103
|
+
var widthUnit = String(width.content).match(CSS_REGEX)[2];
|
|
104
|
+
if (heightUnit.length === 0 || heightUnit !== widthUnit) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
var jsxTag = componentChunk.meta.nodesLookup[key];
|
|
108
|
+
if (!jsxTag) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
;
|
|
112
|
+
jsxTag.openingElement.name.name = 'Image';
|
|
113
|
+
jsxTag.closingElement.name.name = 'Image';
|
|
114
|
+
jsxTag.openingElement.attributes = __spreadArray(__spreadArray([], jsxTag.openingElement.attributes), [
|
|
115
|
+
types.jsxAttribute(types.jsxIdentifier('width'), types.jsxExpressionContainer(types.numericLiteral(parseInt(String(width.content), 10)))),
|
|
116
|
+
types.jsxAttribute(types.jsxIdentifier('height'), types.jsxExpressionContainer(types.numericLiteral(parseInt(String(height.content), 10)))),
|
|
117
|
+
]);
|
|
118
|
+
if (!dependencies.Image) {
|
|
119
|
+
dependencies.Image = NEXT_HEAD_DEPENDENCY;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return [2 /*return*/, structure];
|
|
124
|
+
});
|
|
125
|
+
}); };
|
|
126
|
+
return nextImagePlugin;
|
|
127
|
+
};
|
|
128
|
+
exports.createNextImagePlugin = createNextImagePlugin;
|
|
129
|
+
exports.default = exports.createNextImagePlugin();
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../teleport-shared/dist/cjs/constants/index.d.ts","../../../teleport-shared/dist/cjs/utils/string-utils.d.ts","../../../teleport-shared/dist/cjs/utils/uidl-utils.d.ts","../../../teleport-shared/dist/cjs/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../src/index.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostic_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/util/types.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/ts3.6/base.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/base.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"d1e076bd03d792a96993f458172927e0c5ac3cb8e1b566f54f925e6ef19bbebb","6a55786dc1b8e3c25bc00e1700a7eb297e20bccae7d4bb5e4a020b97daa2052f","eccf9c0b6e420c47b3e3eb87e8f0dc9df312a9583a6cce96756b18ebff176b70","75ecadee387dde7be130c85ed277fdfcee3923e452260ffaf217ebaefe7bd305","cd619820771edb23926bb084906215ab9c491255fa707488d15748b38909b747","28b22326000119f53de35f67ce3096ef475a2224274162b1283ef8718e1efdb5","18aecf77d74ed15ae1e875a0d43f2aa85387794fc447b2bc3c8ab7e2224d0ac6","fcd80368105181b1be66006da7c16a58ed993845e7b37d33302387f18e889001","d2ff55204dd4868d11a163c207d4fbe8d99cbf8cb36fa90d2a2f0bfc802b4d38","a17ba25a194979a88bfd925e849d76b63f68c4160b69a99c5d723eac5ffddaf0","14e43727cd38d78323a9f2ba63d31832cea84a05341e10ba56aa9c79c5278631","c7bdc99177a2a94d25fb13722adaaf5b3291bf70b4d1b27584ba189dd3889ba3",{"version":"d1c92b66c4105659fcad4eb76a1481f7311033e117d0678a1ec545e8ddb8d4c6","affectsGlobalScope":true},"e23424b97418eca3226fd24de079f1203eb70360622e4e093af2aff14d4be6ec","dee93c07b4df5e26010dc9ec4cdf4d6e4076bb4474d2a8371529217c8b2740a4","d55bc773f71c50f55decb39b64a5d8b9889a7c9e94305b36656ebf30e4f47469","04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef",{"version":"c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","dfc747ab8dd5f623055a4c26fd35e8cceca869fd3f1cf09701c941ca3679665a","c9f5f2920ff61d7158417b8440d5181ddc34a3dfef811a5677dd8a9fb91471e9","5cc0a492da3602510b8f5ed1852b1e0390002780d8758fbc8c0cd023ca7085f8","ec7dafafe751a5121f8f1c80201ebe7e7238c47e6329280a73c4d1ca4bb7fa28","64debeb10e4b7ae4ec9e89bfb4e04c6101ab98c3cc806d14e5488607cfec2753",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"a5782d6cea81fe43d2db7ed41e789458c933ab3ab60602f7b5b14c4da3370496","affectsGlobalScope":true},"b86b7ff709a82ef3cba2184136c025989958bad483ffb13e4ca35d720245adf4","6194335ee3353f7226ba31f31d6301d0c6be87228419c0a08976ccd9d4f1213e","5a173b7da4e6d073f9c18a02f387816a934614e7af306193995935fbb95f10b8","b447e123210c68f205f67b20c996c04a1eb64b0e591c5e06e164cd3d3a869b28","13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452","42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","c55776aa1db2b963a5fb820c0650362e721cba51ebf83b069696f2501378c0f3","e2236264a811ed1d09a2487a433e8f5216ae62378cf233954ae220cf886f6717","3ec1e108d587a5661ec790db607f482605ba9f3830e118ce578e3ffa3c42e22b","100b3bb9d39d2b1b5340f1bf45a52e94ef1692b45232b4ba00fac5c3cc56d331",{"version":"ec1a29ddaecb683aa360df0bd98ab5d4171d2d549554f7c5ab2a5c183a3dcb67","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58","2597718d91e306949d89e285bf34c44192014ef541c3bd7cbb825c022749e974","a6b0abdb67d63ebe964ba5fee31bc3daf10c12eecd46b24d778426010c04c67e","ac4801ebc2355ba32329070123b1cd15891bf71b41dcaf9e75b4744832126a59","fd2298fba0640e7295e7bd545e2dfbfcccbb00c27019e501c87965a02bbdebf6","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","71ddd49185b68f27bfac127ef5d22cb2672c278e53e5370d9020ef50ca9c377d","b1ea7a6eaa7608e0e0529aebd323b526a79c6c05a4e519ae5c779675004dcdf1","9fcb033a6208485d8f3fadde31eb5cbcaf99149cff3e40c0dc53ebc6d0dff4e9","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9","f4149f1aa299474c7040a35fe8f8ac2ad078cc1b190415adc1fff3ed52d490ea","3730099ed008776216268a97771de31753ef71e0a7d0ec650f588cba2a06ce44","8d649dbc429d7139a1d9a14ea2bf8af1dc089e0a879447539587463d4b6c248c","60c9e27816ec8ac8df7240598bb086e95b47edfb454c5cbf4003c812e0ed6e39","e361aecf17fc4034b4c122a1564471cdcd22ef3a51407803cb5a5fc020c04d02","4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"fc0ae4a8ad3c762b96f9d2c3700cb879a373458cb0bf3175478e3b4f85f7ef2f","fabbec378e1ddd86fcf2662e716c2b8318acedb664ee3a4cba6f9e8ee8269cf1","b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","efd55e8ca79171bf26c0d0e30221cb8ee1f5a31dd0c791ec4b2e886f42bab124","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":1,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96,98],[92,93],[92,93,94,95],[97],[99],[89],[88,89],[43,48],[54,55,62,71],[44,54,62],[80],[48,55,63],[71,76],[51,54,62],[52],[51],[54],[54,56,71,79],[54,55,71],[62,71,79],[54,55,57,62,71,76,79],[57,76,79],[90],[79],[51,54,71],[64],[42],[78],[69,80,83],[54,72],[71],[74],[48,62],[40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87],[62],[68],[81],[43,48,54,56,65,71,79,83],[33,37,38],[33],[34,35,36],[29],[29,30,31,32]],"referencedMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[39,39],[34,40],[37,41],[36,40],[30,42],[33,43],[32,42]],"exportedModulesMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[39,39],[34,40],[37,41],[36,40],[30,42],[33,43],[32,42]],"semanticDiagnosticsPerFile":[38,99,92,94,96,95,93,98,97,100,89,40,42,90,43,44,45,46,47,48,49,50,51,52,53,54,55,56,41,86,57,58,59,91,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,88,78,79,80,81,82,83,87,84,85,6,8,7,2,9,10,11,12,13,14,15,16,3,4,20,17,18,19,21,22,23,5,24,25,26,27,1,28,39,34,37,35,36,31,30,33,29,32]},"version":"4.3.5"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentPluginFactory, ComponentPlugin } from '@teleporthq/teleport-types';
|
|
2
|
+
interface NextImagePluginConfig {
|
|
3
|
+
componentChunkName: string;
|
|
4
|
+
localAssetFolder: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const createNextImagePlugin: ComponentPluginFactory<NextImagePluginConfig>;
|
|
7
|
+
declare const _default: ComponentPlugin;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
38
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
39
|
+
to[j] = from[i];
|
|
40
|
+
return to;
|
|
41
|
+
};
|
|
42
|
+
import { UIDLUtils } from '@teleporthq/teleport-shared';
|
|
43
|
+
import * as types from '@babel/types';
|
|
44
|
+
/*
|
|
45
|
+
At the moment, the plugin is very restricted wo work only in the following cases.
|
|
46
|
+
- When both the units specified for the img match.
|
|
47
|
+
Eg - both height and width to have same 'px' identifier
|
|
48
|
+
|
|
49
|
+
- When the `img` tag has only width and height specified.
|
|
50
|
+
https://github.com/vercel/next.js/discussions/18312
|
|
51
|
+
*/
|
|
52
|
+
var CSS_REGEX = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
|
53
|
+
var NEXT_HEAD_DEPENDENCY = {
|
|
54
|
+
type: 'library',
|
|
55
|
+
path: 'next/image',
|
|
56
|
+
version: '10.2.0',
|
|
57
|
+
};
|
|
58
|
+
export var createNextImagePlugin = function (config) {
|
|
59
|
+
var _a = config || {}, _b = _a.componentChunkName, componentChunkName = _b === void 0 ? 'jsx-component' : _b, _c = _a.localAssetFolder, localAssetFolder = _c === void 0 ? 'playground_assets' : _c;
|
|
60
|
+
var nextImagePlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var chunks, uidl, dependencies, componentChunk;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
chunks = structure.chunks, uidl = structure.uidl, dependencies = structure.dependencies;
|
|
64
|
+
componentChunk = chunks.find(function (chunk) { return chunk.name === componentChunkName; });
|
|
65
|
+
if (!componentChunk) {
|
|
66
|
+
return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
UIDLUtils.traverseElements(uidl.node, function (element) {
|
|
69
|
+
var _a;
|
|
70
|
+
var elementType = element.elementType, _b = element.attrs, attrs = _b === void 0 ? {} : _b, _c = element.style, style = _c === void 0 ? {} : _c, key = element.key;
|
|
71
|
+
if (key && elementType === 'img' && Object.keys(style).length === 2) {
|
|
72
|
+
var imageSource = (_a = attrs === null || attrs === void 0 ? void 0 : attrs.src) === null || _a === void 0 ? void 0 : _a.content.toString();
|
|
73
|
+
if (!(imageSource === null || imageSource === void 0 ? void 0 : imageSource.startsWith("/" + localAssetFolder))) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!(style.hasOwnProperty('width') && style.hasOwnProperty('height'))) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var height = style.height, width = style.width;
|
|
80
|
+
var heightUnit = String(height.content).match(CSS_REGEX)[2];
|
|
81
|
+
var widthUnit = String(width.content).match(CSS_REGEX)[2];
|
|
82
|
+
if (heightUnit.length === 0 || heightUnit !== widthUnit) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var jsxTag = componentChunk.meta.nodesLookup[key];
|
|
86
|
+
if (!jsxTag) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
;
|
|
90
|
+
jsxTag.openingElement.name.name = 'Image';
|
|
91
|
+
jsxTag.closingElement.name.name = 'Image';
|
|
92
|
+
jsxTag.openingElement.attributes = __spreadArray(__spreadArray([], jsxTag.openingElement.attributes), [
|
|
93
|
+
types.jsxAttribute(types.jsxIdentifier('width'), types.jsxExpressionContainer(types.numericLiteral(parseInt(String(width.content), 10)))),
|
|
94
|
+
types.jsxAttribute(types.jsxIdentifier('height'), types.jsxExpressionContainer(types.numericLiteral(parseInt(String(height.content), 10)))),
|
|
95
|
+
]);
|
|
96
|
+
if (!dependencies.Image) {
|
|
97
|
+
dependencies.Image = NEXT_HEAD_DEPENDENCY;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return [2 /*return*/, structure];
|
|
102
|
+
});
|
|
103
|
+
}); };
|
|
104
|
+
return nextImagePlugin;
|
|
105
|
+
};
|
|
106
|
+
export default createNextImagePlugin();
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../teleport-shared/dist/cjs/constants/index.d.ts","../../../teleport-shared/dist/cjs/utils/string-utils.d.ts","../../../teleport-shared/dist/cjs/utils/uidl-utils.d.ts","../../../teleport-shared/dist/cjs/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../src/index.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostic_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/util/types.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/ts3.6/base.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/base.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"d1e076bd03d792a96993f458172927e0c5ac3cb8e1b566f54f925e6ef19bbebb","6a55786dc1b8e3c25bc00e1700a7eb297e20bccae7d4bb5e4a020b97daa2052f","eccf9c0b6e420c47b3e3eb87e8f0dc9df312a9583a6cce96756b18ebff176b70","75ecadee387dde7be130c85ed277fdfcee3923e452260ffaf217ebaefe7bd305","cd619820771edb23926bb084906215ab9c491255fa707488d15748b38909b747","28b22326000119f53de35f67ce3096ef475a2224274162b1283ef8718e1efdb5","18aecf77d74ed15ae1e875a0d43f2aa85387794fc447b2bc3c8ab7e2224d0ac6","fcd80368105181b1be66006da7c16a58ed993845e7b37d33302387f18e889001","d2ff55204dd4868d11a163c207d4fbe8d99cbf8cb36fa90d2a2f0bfc802b4d38","a17ba25a194979a88bfd925e849d76b63f68c4160b69a99c5d723eac5ffddaf0","14e43727cd38d78323a9f2ba63d31832cea84a05341e10ba56aa9c79c5278631","c7bdc99177a2a94d25fb13722adaaf5b3291bf70b4d1b27584ba189dd3889ba3",{"version":"d1c92b66c4105659fcad4eb76a1481f7311033e117d0678a1ec545e8ddb8d4c6","affectsGlobalScope":true},"e23424b97418eca3226fd24de079f1203eb70360622e4e093af2aff14d4be6ec","dee93c07b4df5e26010dc9ec4cdf4d6e4076bb4474d2a8371529217c8b2740a4","d55bc773f71c50f55decb39b64a5d8b9889a7c9e94305b36656ebf30e4f47469","04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef",{"version":"c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","dfc747ab8dd5f623055a4c26fd35e8cceca869fd3f1cf09701c941ca3679665a","c9f5f2920ff61d7158417b8440d5181ddc34a3dfef811a5677dd8a9fb91471e9","5cc0a492da3602510b8f5ed1852b1e0390002780d8758fbc8c0cd023ca7085f8","ec7dafafe751a5121f8f1c80201ebe7e7238c47e6329280a73c4d1ca4bb7fa28","64debeb10e4b7ae4ec9e89bfb4e04c6101ab98c3cc806d14e5488607cfec2753",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"a5782d6cea81fe43d2db7ed41e789458c933ab3ab60602f7b5b14c4da3370496","affectsGlobalScope":true},"b86b7ff709a82ef3cba2184136c025989958bad483ffb13e4ca35d720245adf4","6194335ee3353f7226ba31f31d6301d0c6be87228419c0a08976ccd9d4f1213e","5a173b7da4e6d073f9c18a02f387816a934614e7af306193995935fbb95f10b8","b447e123210c68f205f67b20c996c04a1eb64b0e591c5e06e164cd3d3a869b28","13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452","42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","c55776aa1db2b963a5fb820c0650362e721cba51ebf83b069696f2501378c0f3","e2236264a811ed1d09a2487a433e8f5216ae62378cf233954ae220cf886f6717","3ec1e108d587a5661ec790db607f482605ba9f3830e118ce578e3ffa3c42e22b","100b3bb9d39d2b1b5340f1bf45a52e94ef1692b45232b4ba00fac5c3cc56d331",{"version":"ec1a29ddaecb683aa360df0bd98ab5d4171d2d549554f7c5ab2a5c183a3dcb67","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58","2597718d91e306949d89e285bf34c44192014ef541c3bd7cbb825c022749e974","a6b0abdb67d63ebe964ba5fee31bc3daf10c12eecd46b24d778426010c04c67e","ac4801ebc2355ba32329070123b1cd15891bf71b41dcaf9e75b4744832126a59","fd2298fba0640e7295e7bd545e2dfbfcccbb00c27019e501c87965a02bbdebf6","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","71ddd49185b68f27bfac127ef5d22cb2672c278e53e5370d9020ef50ca9c377d","b1ea7a6eaa7608e0e0529aebd323b526a79c6c05a4e519ae5c779675004dcdf1","9fcb033a6208485d8f3fadde31eb5cbcaf99149cff3e40c0dc53ebc6d0dff4e9","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9","f4149f1aa299474c7040a35fe8f8ac2ad078cc1b190415adc1fff3ed52d490ea","3730099ed008776216268a97771de31753ef71e0a7d0ec650f588cba2a06ce44","8d649dbc429d7139a1d9a14ea2bf8af1dc089e0a879447539587463d4b6c248c","60c9e27816ec8ac8df7240598bb086e95b47edfb454c5cbf4003c812e0ed6e39","e361aecf17fc4034b4c122a1564471cdcd22ef3a51407803cb5a5fc020c04d02","4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"fc0ae4a8ad3c762b96f9d2c3700cb879a373458cb0bf3175478e3b4f85f7ef2f","fabbec378e1ddd86fcf2662e716c2b8318acedb664ee3a4cba6f9e8ee8269cf1","b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","efd55e8ca79171bf26c0d0e30221cb8ee1f5a31dd0c791ec4b2e886f42bab124","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":99,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96,98],[92,93],[92,93,94,95],[97],[99],[89],[88,89],[43,48],[54,55,62,71],[44,54,62],[80],[48,55,63],[71,76],[51,54,62],[52],[51],[54],[54,56,71,79],[54,55,71],[62,71,79],[54,55,57,62,71,76,79],[57,76,79],[90],[79],[51,54,71],[64],[42],[78],[69,80,83],[54,72],[71],[74],[48,62],[40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87],[62],[68],[81],[43,48,54,56,65,71,79,83],[33,37,38],[33],[34,35,36],[29],[29,30,31,32]],"referencedMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[39,39],[34,40],[37,41],[36,40],[30,42],[33,43],[32,42]],"exportedModulesMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[39,39],[34,40],[37,41],[36,40],[30,42],[33,43],[32,42]],"semanticDiagnosticsPerFile":[38,99,92,94,96,95,93,98,97,100,89,40,42,90,43,44,45,46,47,48,49,50,51,52,53,54,55,56,41,86,57,58,59,91,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,88,78,79,80,81,82,83,87,84,85,6,8,7,2,9,10,11,12,13,14,15,16,3,4,20,17,18,19,21,22,23,5,24,25,26,27,1,28,39,34,37,35,36,31,30,33,29,32]},"version":"4.3.5"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teleporthq/teleport-plugin-jsx-next-image",
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "A Next-JS plugin for using next/image for images with local assets and dimensions.",
|
|
5
|
+
"author": "teleportHQ",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://teleporthq.io/",
|
|
8
|
+
"main": "dist/cjs/index.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/cjs/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+ssh://git@github.com/teleporthq/teleport-code-generators.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/teleporthq/teleport-code-generators/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rimraf dist",
|
|
24
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@babel/types": "^7.5.5",
|
|
28
|
+
"@teleporthq/teleport-shared": "^0.18.0",
|
|
29
|
+
"@teleporthq/teleport-types": "^0.18.0"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "7b47f013bf1889e19b31875a8f3abdc43b22615a"
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ComponentPluginFactory, ComponentPlugin, UIDLDependency } from '@teleporthq/teleport-types'
|
|
2
|
+
import { UIDLUtils } from '@teleporthq/teleport-shared'
|
|
3
|
+
import * as types from '@babel/types'
|
|
4
|
+
|
|
5
|
+
interface NextImagePluginConfig {
|
|
6
|
+
componentChunkName: string
|
|
7
|
+
localAssetFolder: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
At the moment, the plugin is very restricted wo work only in the following cases.
|
|
12
|
+
- When both the units specified for the img match.
|
|
13
|
+
Eg - both height and width to have same 'px' identifier
|
|
14
|
+
|
|
15
|
+
- When the `img` tag has only width and height specified.
|
|
16
|
+
https://github.com/vercel/next.js/discussions/18312
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const CSS_REGEX = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/
|
|
20
|
+
const NEXT_HEAD_DEPENDENCY: UIDLDependency = {
|
|
21
|
+
type: 'library',
|
|
22
|
+
path: 'next/image',
|
|
23
|
+
version: '10.2.0',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const createNextImagePlugin: ComponentPluginFactory<NextImagePluginConfig> = (config) => {
|
|
27
|
+
const { componentChunkName = 'jsx-component', localAssetFolder = 'playground_assets' } =
|
|
28
|
+
config || {}
|
|
29
|
+
const nextImagePlugin: ComponentPlugin = async (structure) => {
|
|
30
|
+
const { chunks, uidl, dependencies } = structure
|
|
31
|
+
const componentChunk = chunks.find((chunk) => chunk.name === componentChunkName)
|
|
32
|
+
if (!componentChunk) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
UIDLUtils.traverseElements(uidl.node, (element) => {
|
|
37
|
+
const { elementType, attrs = {}, style = {}, key } = element
|
|
38
|
+
|
|
39
|
+
if (key && elementType === 'img' && Object.keys(style).length === 2) {
|
|
40
|
+
const imageSource = attrs?.src?.content.toString()
|
|
41
|
+
if (!imageSource?.startsWith(`/${localAssetFolder}`)) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!(style.hasOwnProperty('width') && style.hasOwnProperty('height'))) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { height, width } = style
|
|
50
|
+
const heightUnit = String(height.content).match(CSS_REGEX)[2]
|
|
51
|
+
const widthUnit = String(width.content).match(CSS_REGEX)[2]
|
|
52
|
+
|
|
53
|
+
if (heightUnit.length === 0 || heightUnit !== widthUnit) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const jsxTag = (
|
|
58
|
+
componentChunk.meta.nodesLookup as unknown as Record<string, types.JSXElement>
|
|
59
|
+
)[key]
|
|
60
|
+
|
|
61
|
+
if (!jsxTag) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
;(jsxTag.openingElement.name as types.JSXIdentifier).name = 'Image'
|
|
66
|
+
;(jsxTag.closingElement.name as types.JSXIdentifier).name = 'Image'
|
|
67
|
+
jsxTag.openingElement.attributes = [
|
|
68
|
+
...jsxTag.openingElement.attributes,
|
|
69
|
+
types.jsxAttribute(
|
|
70
|
+
types.jsxIdentifier('width'),
|
|
71
|
+
types.jsxExpressionContainer(types.numericLiteral(parseInt(String(width.content), 10)))
|
|
72
|
+
),
|
|
73
|
+
types.jsxAttribute(
|
|
74
|
+
types.jsxIdentifier('height'),
|
|
75
|
+
types.jsxExpressionContainer(types.numericLiteral(parseInt(String(height.content), 10)))
|
|
76
|
+
),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
if (!dependencies.Image) {
|
|
80
|
+
dependencies.Image = NEXT_HEAD_DEPENDENCY
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return structure
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return nextImagePlugin
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default createNextImagePlugin()
|