@plasmicpkgs/plasmic-link-preview 1.0.83
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.md +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +8 -0
- package/dist/lib/html-metadata-parser.d.ts +11 -0
- package/dist/lib/utils.d.ts +24 -0
- package/dist/plasmic-link-preview.cjs.development.js +582 -0
- package/dist/plasmic-link-preview.cjs.development.js.map +1 -0
- package/dist/plasmic-link-preview.cjs.production.min.js +2 -0
- package/dist/plasmic-link-preview.cjs.production.min.js.map +1 -0
- package/dist/plasmic-link-preview.esm.js +573 -0
- package/dist/plasmic-link-preview.esm.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
3
|
+
import '@plasmicapp/host/registerGlobalContext';
|
|
4
|
+
import { usePlasmicCanvasContext, DataProvider } from '@plasmicapp/host';
|
|
5
|
+
import { parse } from 'node-html-parser';
|
|
6
|
+
|
|
7
|
+
function registerComponentHelper(loader, component, meta) {
|
|
8
|
+
if (loader) {
|
|
9
|
+
loader.registerComponent(component, meta);
|
|
10
|
+
} else {
|
|
11
|
+
registerComponent(component, meta);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function _regeneratorRuntime() {
|
|
16
|
+
_regeneratorRuntime = function () {
|
|
17
|
+
return e;
|
|
18
|
+
};
|
|
19
|
+
var t,
|
|
20
|
+
e = {},
|
|
21
|
+
r = Object.prototype,
|
|
22
|
+
n = r.hasOwnProperty,
|
|
23
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
24
|
+
t[e] = r.value;
|
|
25
|
+
},
|
|
26
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
27
|
+
a = i.iterator || "@@iterator",
|
|
28
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
29
|
+
u = i.toStringTag || "@@toStringTag";
|
|
30
|
+
function define(t, e, r) {
|
|
31
|
+
return Object.defineProperty(t, e, {
|
|
32
|
+
value: r,
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0
|
|
36
|
+
}), t[e];
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
define({}, "");
|
|
40
|
+
} catch (t) {
|
|
41
|
+
define = function (t, e, r) {
|
|
42
|
+
return t[e] = r;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function wrap(t, e, r, n) {
|
|
46
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
47
|
+
a = Object.create(i.prototype),
|
|
48
|
+
c = new Context(n || []);
|
|
49
|
+
return o(a, "_invoke", {
|
|
50
|
+
value: makeInvokeMethod(t, r, c)
|
|
51
|
+
}), a;
|
|
52
|
+
}
|
|
53
|
+
function tryCatch(t, e, r) {
|
|
54
|
+
try {
|
|
55
|
+
return {
|
|
56
|
+
type: "normal",
|
|
57
|
+
arg: t.call(e, r)
|
|
58
|
+
};
|
|
59
|
+
} catch (t) {
|
|
60
|
+
return {
|
|
61
|
+
type: "throw",
|
|
62
|
+
arg: t
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
e.wrap = wrap;
|
|
67
|
+
var h = "suspendedStart",
|
|
68
|
+
l = "suspendedYield",
|
|
69
|
+
f = "executing",
|
|
70
|
+
s = "completed",
|
|
71
|
+
y = {};
|
|
72
|
+
function Generator() {}
|
|
73
|
+
function GeneratorFunction() {}
|
|
74
|
+
function GeneratorFunctionPrototype() {}
|
|
75
|
+
var p = {};
|
|
76
|
+
define(p, a, function () {
|
|
77
|
+
return this;
|
|
78
|
+
});
|
|
79
|
+
var d = Object.getPrototypeOf,
|
|
80
|
+
v = d && d(d(values([])));
|
|
81
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
82
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
83
|
+
function defineIteratorMethods(t) {
|
|
84
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
85
|
+
define(t, e, function (t) {
|
|
86
|
+
return this._invoke(e, t);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function AsyncIterator(t, e) {
|
|
91
|
+
function invoke(r, o, i, a) {
|
|
92
|
+
var c = tryCatch(t[r], t, o);
|
|
93
|
+
if ("throw" !== c.type) {
|
|
94
|
+
var u = c.arg,
|
|
95
|
+
h = u.value;
|
|
96
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
97
|
+
invoke("next", t, i, a);
|
|
98
|
+
}, function (t) {
|
|
99
|
+
invoke("throw", t, i, a);
|
|
100
|
+
}) : e.resolve(h).then(function (t) {
|
|
101
|
+
u.value = t, i(u);
|
|
102
|
+
}, function (t) {
|
|
103
|
+
return invoke("throw", t, i, a);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
a(c.arg);
|
|
107
|
+
}
|
|
108
|
+
var r;
|
|
109
|
+
o(this, "_invoke", {
|
|
110
|
+
value: function (t, n) {
|
|
111
|
+
function callInvokeWithMethodAndArg() {
|
|
112
|
+
return new e(function (e, r) {
|
|
113
|
+
invoke(t, n, e, r);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function makeInvokeMethod(e, r, n) {
|
|
121
|
+
var o = h;
|
|
122
|
+
return function (i, a) {
|
|
123
|
+
if (o === f) throw new Error("Generator is already running");
|
|
124
|
+
if (o === s) {
|
|
125
|
+
if ("throw" === i) throw a;
|
|
126
|
+
return {
|
|
127
|
+
value: t,
|
|
128
|
+
done: !0
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
for (n.method = i, n.arg = a;;) {
|
|
132
|
+
var c = n.delegate;
|
|
133
|
+
if (c) {
|
|
134
|
+
var u = maybeInvokeDelegate(c, n);
|
|
135
|
+
if (u) {
|
|
136
|
+
if (u === y) continue;
|
|
137
|
+
return u;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
141
|
+
if (o === h) throw o = s, n.arg;
|
|
142
|
+
n.dispatchException(n.arg);
|
|
143
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
144
|
+
o = f;
|
|
145
|
+
var p = tryCatch(e, r, n);
|
|
146
|
+
if ("normal" === p.type) {
|
|
147
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
148
|
+
return {
|
|
149
|
+
value: p.arg,
|
|
150
|
+
done: n.done
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function maybeInvokeDelegate(e, r) {
|
|
158
|
+
var n = r.method,
|
|
159
|
+
o = e.iterator[n];
|
|
160
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
161
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
162
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
163
|
+
var a = i.arg;
|
|
164
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
165
|
+
}
|
|
166
|
+
function pushTryEntry(t) {
|
|
167
|
+
var e = {
|
|
168
|
+
tryLoc: t[0]
|
|
169
|
+
};
|
|
170
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
171
|
+
}
|
|
172
|
+
function resetTryEntry(t) {
|
|
173
|
+
var e = t.completion || {};
|
|
174
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
175
|
+
}
|
|
176
|
+
function Context(t) {
|
|
177
|
+
this.tryEntries = [{
|
|
178
|
+
tryLoc: "root"
|
|
179
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
180
|
+
}
|
|
181
|
+
function values(e) {
|
|
182
|
+
if (e || "" === e) {
|
|
183
|
+
var r = e[a];
|
|
184
|
+
if (r) return r.call(e);
|
|
185
|
+
if ("function" == typeof e.next) return e;
|
|
186
|
+
if (!isNaN(e.length)) {
|
|
187
|
+
var o = -1,
|
|
188
|
+
i = function next() {
|
|
189
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
190
|
+
return next.value = t, next.done = !0, next;
|
|
191
|
+
};
|
|
192
|
+
return i.next = i;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
196
|
+
}
|
|
197
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
198
|
+
value: GeneratorFunctionPrototype,
|
|
199
|
+
configurable: !0
|
|
200
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
201
|
+
value: GeneratorFunction,
|
|
202
|
+
configurable: !0
|
|
203
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
204
|
+
var e = "function" == typeof t && t.constructor;
|
|
205
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
206
|
+
}, e.mark = function (t) {
|
|
207
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
208
|
+
}, e.awrap = function (t) {
|
|
209
|
+
return {
|
|
210
|
+
__await: t
|
|
211
|
+
};
|
|
212
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
213
|
+
return this;
|
|
214
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
215
|
+
void 0 === i && (i = Promise);
|
|
216
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
217
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
218
|
+
return t.done ? t.value : a.next();
|
|
219
|
+
});
|
|
220
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
221
|
+
return this;
|
|
222
|
+
}), define(g, "toString", function () {
|
|
223
|
+
return "[object Generator]";
|
|
224
|
+
}), e.keys = function (t) {
|
|
225
|
+
var e = Object(t),
|
|
226
|
+
r = [];
|
|
227
|
+
for (var n in e) r.push(n);
|
|
228
|
+
return r.reverse(), function next() {
|
|
229
|
+
for (; r.length;) {
|
|
230
|
+
var t = r.pop();
|
|
231
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
232
|
+
}
|
|
233
|
+
return next.done = !0, next;
|
|
234
|
+
};
|
|
235
|
+
}, e.values = values, Context.prototype = {
|
|
236
|
+
constructor: Context,
|
|
237
|
+
reset: function (e) {
|
|
238
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
239
|
+
},
|
|
240
|
+
stop: function () {
|
|
241
|
+
this.done = !0;
|
|
242
|
+
var t = this.tryEntries[0].completion;
|
|
243
|
+
if ("throw" === t.type) throw t.arg;
|
|
244
|
+
return this.rval;
|
|
245
|
+
},
|
|
246
|
+
dispatchException: function (e) {
|
|
247
|
+
if (this.done) throw e;
|
|
248
|
+
var r = this;
|
|
249
|
+
function handle(n, o) {
|
|
250
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
251
|
+
}
|
|
252
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
253
|
+
var i = this.tryEntries[o],
|
|
254
|
+
a = i.completion;
|
|
255
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
256
|
+
if (i.tryLoc <= this.prev) {
|
|
257
|
+
var c = n.call(i, "catchLoc"),
|
|
258
|
+
u = n.call(i, "finallyLoc");
|
|
259
|
+
if (c && u) {
|
|
260
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
261
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
262
|
+
} else if (c) {
|
|
263
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
264
|
+
} else {
|
|
265
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
266
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
abrupt: function (t, e) {
|
|
272
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
273
|
+
var o = this.tryEntries[r];
|
|
274
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
275
|
+
var i = o;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
280
|
+
var a = i ? i.completion : {};
|
|
281
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
282
|
+
},
|
|
283
|
+
complete: function (t, e) {
|
|
284
|
+
if ("throw" === t.type) throw t.arg;
|
|
285
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
286
|
+
},
|
|
287
|
+
finish: function (t) {
|
|
288
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
289
|
+
var r = this.tryEntries[e];
|
|
290
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
catch: function (t) {
|
|
294
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
295
|
+
var r = this.tryEntries[e];
|
|
296
|
+
if (r.tryLoc === t) {
|
|
297
|
+
var n = r.completion;
|
|
298
|
+
if ("throw" === n.type) {
|
|
299
|
+
var o = n.arg;
|
|
300
|
+
resetTryEntry(r);
|
|
301
|
+
}
|
|
302
|
+
return o;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
throw new Error("illegal catch attempt");
|
|
306
|
+
},
|
|
307
|
+
delegateYield: function (e, r, n) {
|
|
308
|
+
return this.delegate = {
|
|
309
|
+
iterator: values(e),
|
|
310
|
+
resultName: r,
|
|
311
|
+
nextLoc: n
|
|
312
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
313
|
+
}
|
|
314
|
+
}, e;
|
|
315
|
+
}
|
|
316
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
317
|
+
try {
|
|
318
|
+
var info = gen[key](arg);
|
|
319
|
+
var value = info.value;
|
|
320
|
+
} catch (error) {
|
|
321
|
+
reject(error);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (info.done) {
|
|
325
|
+
resolve(value);
|
|
326
|
+
} else {
|
|
327
|
+
Promise.resolve(value).then(_next, _throw);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function _asyncToGenerator(fn) {
|
|
331
|
+
return function () {
|
|
332
|
+
var self = this,
|
|
333
|
+
args = arguments;
|
|
334
|
+
return new Promise(function (resolve, reject) {
|
|
335
|
+
var gen = fn.apply(self, args);
|
|
336
|
+
function _next(value) {
|
|
337
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
338
|
+
}
|
|
339
|
+
function _throw(err) {
|
|
340
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
341
|
+
}
|
|
342
|
+
_next(undefined);
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function _extends() {
|
|
347
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
348
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
349
|
+
var source = arguments[i];
|
|
350
|
+
for (var key in source) {
|
|
351
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
352
|
+
target[key] = source[key];
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return target;
|
|
357
|
+
};
|
|
358
|
+
return _extends.apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var readMT = function readMT(el, name) {
|
|
362
|
+
var prop = el.getAttribute("name") || el.getAttribute("property");
|
|
363
|
+
return prop == name ? el.getAttribute("content") : null;
|
|
364
|
+
};
|
|
365
|
+
var isValidUrl = function isValidUrl(url) {
|
|
366
|
+
return /(^http(s?):\/\/[^\s$.?#].[^\s]*)/i.test(url);
|
|
367
|
+
};
|
|
368
|
+
var getMetadata = /*#__PURE__*/function () {
|
|
369
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
|
370
|
+
var contents, $, getHostname, getTitle, metas, meta, _loop, i, metadata;
|
|
371
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
372
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
373
|
+
case 0:
|
|
374
|
+
if (isValidUrl(url)) {
|
|
375
|
+
_context2.next = 2;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
return _context2.abrupt("return", {});
|
|
379
|
+
case 2:
|
|
380
|
+
_context2.next = 4;
|
|
381
|
+
return fetch("https://corsproxy.io/?" + url).then(function (res) {
|
|
382
|
+
return res.text();
|
|
383
|
+
});
|
|
384
|
+
case 4:
|
|
385
|
+
contents = _context2.sent;
|
|
386
|
+
$ = parse(contents);
|
|
387
|
+
getHostname = function getHostname() {
|
|
388
|
+
var _URL = new URL(url),
|
|
389
|
+
hostname = _URL.hostname;
|
|
390
|
+
return hostname;
|
|
391
|
+
};
|
|
392
|
+
getTitle = function getTitle() {
|
|
393
|
+
var title = $.querySelector("title");
|
|
394
|
+
return title == null ? void 0 : title.text;
|
|
395
|
+
};
|
|
396
|
+
metas = $.querySelectorAll("meta");
|
|
397
|
+
meta = {};
|
|
398
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
399
|
+
var el;
|
|
400
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
401
|
+
while (1) switch (_context.prev = _context.next) {
|
|
402
|
+
case 0:
|
|
403
|
+
el = metas[i];
|
|
404
|
+
["title", "description", "image"].forEach(function (s) {
|
|
405
|
+
var val = readMT(el, s);
|
|
406
|
+
if (val) meta[s] = val;
|
|
407
|
+
});
|
|
408
|
+
["og:title", "og:description", "og:image", "og:url", "og:site_name", "og:type"].forEach(function (s) {
|
|
409
|
+
var val = readMT(el, s);
|
|
410
|
+
if (val) meta[s.split(":")[1]] = val;
|
|
411
|
+
});
|
|
412
|
+
case 3:
|
|
413
|
+
case "end":
|
|
414
|
+
return _context.stop();
|
|
415
|
+
}
|
|
416
|
+
}, _loop);
|
|
417
|
+
});
|
|
418
|
+
i = 0;
|
|
419
|
+
case 12:
|
|
420
|
+
if (!(i < metas.length)) {
|
|
421
|
+
_context2.next = 17;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
return _context2.delegateYield(_loop(), "t0", 14);
|
|
425
|
+
case 14:
|
|
426
|
+
i++;
|
|
427
|
+
_context2.next = 12;
|
|
428
|
+
break;
|
|
429
|
+
case 17:
|
|
430
|
+
// images
|
|
431
|
+
$.querySelectorAll("img").every(function (el) {
|
|
432
|
+
var src = el.getAttribute("src");
|
|
433
|
+
if (src) {
|
|
434
|
+
meta.image = new URL(src, url).href;
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
return true;
|
|
438
|
+
});
|
|
439
|
+
metadata = _extends({
|
|
440
|
+
hostname: getHostname(),
|
|
441
|
+
title: getTitle()
|
|
442
|
+
}, meta);
|
|
443
|
+
return _context2.abrupt("return", metadata);
|
|
444
|
+
case 20:
|
|
445
|
+
case "end":
|
|
446
|
+
return _context2.stop();
|
|
447
|
+
}
|
|
448
|
+
}, _callee);
|
|
449
|
+
}));
|
|
450
|
+
return function getMetadata(_x) {
|
|
451
|
+
return _ref.apply(this, arguments);
|
|
452
|
+
};
|
|
453
|
+
}();
|
|
454
|
+
|
|
455
|
+
var LinkPreview = function LinkPreview(_ref) {
|
|
456
|
+
var _metadata$title;
|
|
457
|
+
var url = _ref.url,
|
|
458
|
+
children = _ref.children,
|
|
459
|
+
loadingMessage = _ref.loadingMessage,
|
|
460
|
+
noPreviewMessage = _ref.noPreviewMessage,
|
|
461
|
+
showLoading = _ref.showLoading,
|
|
462
|
+
showNoPreview = _ref.showNoPreview;
|
|
463
|
+
var _isMounted = useRef(true);
|
|
464
|
+
var _useState = useState({}),
|
|
465
|
+
metadata = _useState[0],
|
|
466
|
+
setMetadata = _useState[1];
|
|
467
|
+
var _useState2 = useState(false),
|
|
468
|
+
isLoading = _useState2[0],
|
|
469
|
+
setIsLoading = _useState2[1];
|
|
470
|
+
var isEditMode = !!usePlasmicCanvasContext();
|
|
471
|
+
var resetMetadata = useCallback(function () {
|
|
472
|
+
setMetadata({
|
|
473
|
+
title: "",
|
|
474
|
+
description: "",
|
|
475
|
+
image: "",
|
|
476
|
+
siteName: "",
|
|
477
|
+
hostname: ""
|
|
478
|
+
});
|
|
479
|
+
}, []);
|
|
480
|
+
useEffect(function () {
|
|
481
|
+
_isMounted.current = true;
|
|
482
|
+
if (!url) return;
|
|
483
|
+
setIsLoading(true);
|
|
484
|
+
resetMetadata();
|
|
485
|
+
getMetadata(url).then(function (res) {
|
|
486
|
+
if (_isMounted.current) {
|
|
487
|
+
setMetadata(res);
|
|
488
|
+
setIsLoading(false);
|
|
489
|
+
}
|
|
490
|
+
})["catch"](function (err) {
|
|
491
|
+
console.error(err);
|
|
492
|
+
console.error("No metadata could be found for the given URL.");
|
|
493
|
+
if (_isMounted.current) {
|
|
494
|
+
resetMetadata();
|
|
495
|
+
setIsLoading(false);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
return function () {
|
|
499
|
+
_isMounted.current = false;
|
|
500
|
+
};
|
|
501
|
+
}, [resetMetadata, url]);
|
|
502
|
+
var showLoadingProp = isEditMode ? showLoading : false;
|
|
503
|
+
var showNoPreviewProp = isEditMode ? showNoPreview : false;
|
|
504
|
+
var hasChildren = children == null ? void 0 : children.props.children;
|
|
505
|
+
var hasMetadata = (metadata == null || (_metadata$title = metadata.title) == null ? void 0 : _metadata$title.length) && !metadata.title.startsWith("Origin DNS error");
|
|
506
|
+
var body = hasChildren ? React.createElement(React.Fragment, null, children) : React.createElement("p", null, metadata.title);
|
|
507
|
+
var hidePreview = isLoading || showLoadingProp || showNoPreviewProp || !hasMetadata;
|
|
508
|
+
var hasNoPreview = !isLoading && !hasMetadata;
|
|
509
|
+
return React.createElement("div", null, React.createElement(DataProvider, {
|
|
510
|
+
name: "metadata",
|
|
511
|
+
data: metadata
|
|
512
|
+
}, React.createElement("div", {
|
|
513
|
+
style: hidePreview ? {
|
|
514
|
+
display: "none"
|
|
515
|
+
} : {}
|
|
516
|
+
}, body), (hasNoPreview || showNoPreviewProp) && noPreviewMessage, (isLoading || showLoadingProp) && loadingMessage));
|
|
517
|
+
};
|
|
518
|
+
var rlpComponentName = "plasmic-link-preview";
|
|
519
|
+
function registerLinkPreview(loader) {
|
|
520
|
+
registerComponentHelper(loader, LinkPreview, {
|
|
521
|
+
name: rlpComponentName,
|
|
522
|
+
providesData: true,
|
|
523
|
+
displayName: "Link Preview",
|
|
524
|
+
props: {
|
|
525
|
+
url: {
|
|
526
|
+
type: "string",
|
|
527
|
+
displayName: "URL",
|
|
528
|
+
defaultValue: "https://plasmic.app",
|
|
529
|
+
defaultValueHint: "https://example.com",
|
|
530
|
+
validator: function validator(value) {
|
|
531
|
+
if (isValidUrl(value)) return true;
|
|
532
|
+
return "Invalid URL";
|
|
533
|
+
},
|
|
534
|
+
description: "The URL for which you want to generate the link preview."
|
|
535
|
+
},
|
|
536
|
+
children: {
|
|
537
|
+
type: "slot",
|
|
538
|
+
hidePlaceholder: true
|
|
539
|
+
},
|
|
540
|
+
noPreviewMessage: {
|
|
541
|
+
type: "slot",
|
|
542
|
+
displayName: "'No Preview' Message",
|
|
543
|
+
hidePlaceholder: true,
|
|
544
|
+
defaultValue: [{
|
|
545
|
+
type: "text",
|
|
546
|
+
value: "no preview..."
|
|
547
|
+
}]
|
|
548
|
+
},
|
|
549
|
+
showLoading: {
|
|
550
|
+
type: "boolean",
|
|
551
|
+
description: "You can enable this prop to show the loading message, so you can easily customize it. This prop has no effect in the live app."
|
|
552
|
+
},
|
|
553
|
+
showNoPreview: {
|
|
554
|
+
type: "boolean",
|
|
555
|
+
description: "You can enable this prop to show the 'No Preview' message, so you can easily customize it. This prop has no effect in the live app."
|
|
556
|
+
},
|
|
557
|
+
loadingMessage: {
|
|
558
|
+
type: "slot",
|
|
559
|
+
displayName: "Loading Message",
|
|
560
|
+
hidePlaceholder: true,
|
|
561
|
+
defaultValue: [{
|
|
562
|
+
type: "text",
|
|
563
|
+
value: "loading preview..."
|
|
564
|
+
}]
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
importPath: "@plasmicpkgs/plasmic-link-preview",
|
|
568
|
+
importName: "LinkPreview"
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export { LinkPreview, registerLinkPreview, rlpComponentName };
|
|
573
|
+
//# sourceMappingURL=plasmic-link-preview.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plasmic-link-preview.esm.js","sources":["../src/lib/utils.ts","../src/lib/html-metadata-parser.ts","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport {\n default as registerGlobalContext,\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function makeRegisterComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n return function (loader?: Registerable) {\n registerComponentHelper(loader, component, meta);\n };\n}\n\nexport function makeRegisterGlobalContext<T extends React.ComponentType<any>>(\n component: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n) {\n return function (loader?: Registerable) {\n if (loader) {\n loader.registerGlobalContext(component, meta);\n } else {\n registerGlobalContext(component, meta);\n }\n };\n}\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n\ntype ReactElt = {\n children: ReactElt | ReactElt[];\n props: {\n children: ReactElt | ReactElt[];\n [prop: string]: any;\n } | null;\n type: React.ComponentType<any> | null;\n key: string | null;\n} | null;\n\nexport function traverseReactEltTree(\n children: React.ReactNode,\n callback: (elt: ReactElt) => void\n) {\n const rec = (elts: ReactElt | ReactElt[] | null) => {\n (Array.isArray(elts) ? elts : [elts]).forEach((elt) => {\n if (elt) {\n callback(elt);\n if (elt.children) {\n rec(elt.children);\n }\n if (elt.props?.children && elt.props.children !== elt.children) {\n rec(elt.props.children);\n }\n }\n });\n };\n rec(children as any);\n}\n\nexport function asArray<T>(x: T[] | T | undefined | null) {\n if (Array.isArray(x)) {\n return x;\n } else if (x == null) {\n return [];\n } else {\n return [x];\n }\n}\n","import { HTMLElement, parse as HTML } from \"node-html-parser\";\n\ninterface Meta {\n title?: string;\n description?: string;\n image?: string;\n url?: string;\n type?: string;\n site_name?: string;\n}\n\nexport interface Metadata {\n title?: string;\n description?: string;\n image?: string;\n siteName?: string;\n hostname?: string;\n}\n\nconst readMT = (el: HTMLElement, name: string) => {\n const prop = el.getAttribute(\"name\") || el.getAttribute(\"property\");\n return prop == name ? el.getAttribute(\"content\") : null;\n};\n\nconst isValidUrl = (url: string) => {\n return /(^http(s?):\\/\\/[^\\s$.?#].[^\\s]*)/i.test(url);\n};\n\nconst getMetadata = async (url: string): Promise<Metadata> => {\n if (!isValidUrl(url)) return {};\n\n const contents = await fetch(`https://corsproxy.io/?${url}`).then((res) =>\n res.text()\n );\n\n const $ = HTML(contents);\n\n const getHostname = () => {\n const { hostname } = new URL(url);\n return hostname;\n };\n\n const getTitle = () => {\n const title = $.querySelector(\"title\");\n return title?.text;\n };\n\n const metas = $.querySelectorAll(\"meta\");\n const meta: Meta = {};\n\n for (let i = 0; i < metas.length; i++) {\n const el = metas[i];\n\n [\"title\", \"description\", \"image\"].forEach((s) => {\n const val = readMT(el, s);\n if (val) meta[s as keyof Meta] = val;\n });\n\n [\n \"og:title\",\n \"og:description\",\n \"og:image\",\n \"og:url\",\n \"og:site_name\",\n \"og:type\",\n ].forEach((s) => {\n const val = readMT(el, s);\n if (val) meta[s.split(\":\")[1] as keyof Meta] = val;\n });\n }\n\n // images\n $.querySelectorAll(\"img\").every((el) => {\n const src: string | undefined = el.getAttribute(\"src\");\n if (src) {\n meta.image = new URL(src, url).href;\n return false;\n }\n return true;\n });\n\n const metadata: Metadata = {\n hostname: getHostname(),\n title: getTitle(),\n ...meta,\n };\n\n return metadata;\n};\n\nexport default getMetadata;\nexport { isValidUrl };\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Registerable, registerComponentHelper } from \"./lib/utils\";\n\nimport { DataProvider, usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport getMetadata, { isValidUrl, Metadata } from \"./lib/html-metadata-parser\";\n\nexport type LinkPreviewProps = {\n url: string;\n children: React.ReactNode;\n loadingMessage: React.ReactNode;\n noPreviewMessage: React.ReactNode;\n showLoading: boolean;\n showNoPreview: boolean;\n};\n\nexport const LinkPreview: React.FC<LinkPreviewProps> = ({\n url,\n children,\n loadingMessage,\n noPreviewMessage,\n showLoading,\n showNoPreview,\n}) => {\n const _isMounted = useRef(true);\n const [metadata, setMetadata] = useState<Metadata>({});\n const [isLoading, setIsLoading] = useState(false);\n\n const isEditMode = !!usePlasmicCanvasContext();\n\n const resetMetadata = useCallback(() => {\n setMetadata({\n title: \"\",\n description: \"\",\n image: \"\",\n siteName: \"\",\n hostname: \"\",\n });\n }, []);\n\n useEffect(() => {\n _isMounted.current = true;\n if (!url) return;\n\n setIsLoading(true);\n resetMetadata();\n getMetadata(url)\n .then((res) => {\n if (_isMounted.current) {\n setMetadata(res);\n setIsLoading(false);\n }\n })\n .catch((err) => {\n console.error(err);\n console.error(\"No metadata could be found for the given URL.\");\n if (_isMounted.current) {\n resetMetadata();\n setIsLoading(false);\n }\n });\n return () => {\n _isMounted.current = false;\n };\n }, [resetMetadata, url]);\n\n const showLoadingProp = isEditMode ? showLoading : false;\n const showNoPreviewProp = isEditMode ? showNoPreview : false;\n const hasChildren = (children as any)?.props.children;\n const hasMetadata =\n metadata?.title?.length && !metadata.title.startsWith(\"Origin DNS error\");\n const body = hasChildren ? <>{children}</> : <p>{metadata.title}</p>;\n const hidePreview =\n isLoading || showLoadingProp || showNoPreviewProp || !hasMetadata;\n const hasNoPreview = !isLoading && !hasMetadata;\n\n return (\n <div>\n <DataProvider name=\"metadata\" data={metadata}>\n {/* We want the metadata to always be available to the elements inside children slot. So we use CSS to hide it */}\n <div style={hidePreview ? { display: \"none\" } : {}}>{body}</div>\n {(hasNoPreview || showNoPreviewProp) && noPreviewMessage}\n {(isLoading || showLoadingProp) && loadingMessage}\n </DataProvider>\n </div>\n );\n};\n\nexport const rlpComponentName = \"plasmic-link-preview\";\n\nexport function registerLinkPreview(loader?: Registerable) {\n registerComponentHelper(loader, LinkPreview, {\n name: rlpComponentName,\n providesData: true,\n displayName: \"Link Preview\",\n props: {\n url: {\n type: \"string\",\n displayName: \"URL\",\n defaultValue: \"https://plasmic.app\",\n defaultValueHint: \"https://example.com\",\n validator: (value) => {\n if (isValidUrl(value)) return true;\n return \"Invalid URL\";\n },\n description: \"The URL for which you want to generate the link preview.\",\n },\n children: {\n type: \"slot\",\n hidePlaceholder: true,\n },\n noPreviewMessage: {\n type: \"slot\",\n displayName: \"'No Preview' Message\",\n hidePlaceholder: true,\n defaultValue: [\n {\n type: \"text\",\n value: \"no preview...\",\n },\n ],\n },\n showLoading: {\n type: \"boolean\",\n description:\n \"You can enable this prop to show the loading message, so you can easily customize it. This prop has no effect in the live app.\",\n },\n showNoPreview: {\n type: \"boolean\",\n description:\n \"You can enable this prop to show the 'No Preview' message, so you can easily customize it. This prop has no effect in the live app.\",\n },\n loadingMessage: {\n type: \"slot\",\n displayName: \"Loading Message\",\n hidePlaceholder: true,\n defaultValue: [\n {\n type: \"text\",\n value: \"loading preview...\",\n },\n ],\n },\n },\n importPath: \"@plasmicpkgs/plasmic-link-preview\",\n importName: \"LinkPreview\",\n });\n}\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","readMT","el","name","prop","getAttribute","isValidUrl","url","test","getMetadata","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","contents","$","getHostname","getTitle","metas","_loop","i","metadata","wrap","_callee$","_context2","prev","next","abrupt","fetch","then","res","text","sent","HTML","_URL","URL","hostname","title","querySelector","querySelectorAll","_loop$","_context","forEach","s","val","split","stop","length","delegateYield","every","src","image","href","_extends","_x","apply","arguments","LinkPreview","children","loadingMessage","noPreviewMessage","showLoading","showNoPreview","_isMounted","useRef","_useState","useState","setMetadata","_useState2","isLoading","setIsLoading","isEditMode","usePlasmicCanvasContext","resetMetadata","useCallback","description","siteName","useEffect","current","err","console","error","showLoadingProp","showNoPreviewProp","hasChildren","props","hasMetadata","_metadata$title","startsWith","body","React","hidePreview","hasNoPreview","DataProvider","data","style","display","rlpComponentName","registerLinkPreview","providesData","displayName","type","defaultValue","defaultValueHint","validator","value","hidePlaceholder","importPath","importName"],"mappings":";;;;;;SAuCgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAA4C;EAE5C,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9BA,IAAME,MAAM,GAAG,SAATA,MAAMA,CAAIC,EAAe,EAAEC,IAAY;EAC3C,IAAMC,IAAI,GAAGF,EAAE,CAACG,YAAY,CAAC,MAAM,CA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CM,eAAe,EAAE,IAAI;QACrBJ,YAAY,EAAE,CACZ;UACED,IAAI,EAAE,MAAM;UACZI,KAAK,EAAE;SACR;OAEJ;MACD5C,WAAW,EAAE;QACXwC,IAAI,EAAE,SAAS;QACf1B,WAAW,EACT;OACH;MACDb,aAAa,EAAE;QACbuC,IAAI,EAAE,SAAS;QACf1B,WAAW,EACT;OACH;MACDhB,cAAc,EAAE;QACd0C,IAAI,EAAE,MAAM;QACZD,WAAW,EAAE,iBAAiB;QAC9BM,eAAe,EAAE,IAAI;QACrBJ,YAAY,EAAE,CACZ;UACED,IAAI,EAAE,MAAM;UACZI,KAAK,EAAE;SACR;;KAGN;IACDE,UAAU,EAAE,mCAAmC;IAC/CC,UAAU,EAAE;GACb,CAAC;AACJ;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plasmicpkgs/plasmic-link-preview",
|
|
3
|
+
"version": "1.0.83",
|
|
4
|
+
"description": "A React component that renders beautiful, fully-customizable link previews.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/plasmic-link-preview.esm.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"size-limit": [
|
|
12
|
+
{
|
|
13
|
+
"path": "dist/plasmic-link-preview.cjs.production.min.js",
|
|
14
|
+
"limit": "10 KB"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "dist/plasmic-link-preview.esm.js",
|
|
18
|
+
"limit": "10 KB"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsdx build",
|
|
23
|
+
"start": "tsdx watch",
|
|
24
|
+
"test": "yarn --cwd=../.. test --passWithNoTests",
|
|
25
|
+
"lint": "tsdx lint",
|
|
26
|
+
"prepublishOnly": "npm run build",
|
|
27
|
+
"size": "size-limit",
|
|
28
|
+
"analyze": "size-limit --why"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@plasmicapp/data-sources": "0.1.136",
|
|
32
|
+
"@plasmicapp/host": "1.0.178",
|
|
33
|
+
"@size-limit/preset-small-lib": "^4.11.0",
|
|
34
|
+
"@types/node": "^14.0.26",
|
|
35
|
+
"@types/react": "^18.2.33",
|
|
36
|
+
"size-limit": "^4.11.0",
|
|
37
|
+
"tsdx": "^0.14.1",
|
|
38
|
+
"tslib": "^2.2.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@plasmicapp/data-sources": ">=0.1.52",
|
|
42
|
+
"@plasmicapp/host": ">=1.0.0",
|
|
43
|
+
"react": ">=16.8.0",
|
|
44
|
+
"react-dom": ">=16.8.0"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"node-html-parser": "^6.1.11"
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "a834834304554aa592ea1c434ac41e0d2503557a"
|
|
53
|
+
}
|