@teleporthq/teleport-shared 0.43.68 → 0.43.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/_helpers/embed-runtime-emitter.ts +197 -0
- package/__tests__/utils/inline-script-error-guard.ts +121 -0
- package/__tests__/utils/rich-text-embeds-runtime-module.ts +34 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/inline-script-error-guard.d.ts +29 -0
- package/dist/cjs/utils/inline-script-error-guard.d.ts.map +1 -0
- package/dist/cjs/utils/inline-script-error-guard.js +38 -0
- package/dist/cjs/utils/inline-script-error-guard.js.map +1 -0
- package/dist/cjs/utils/rich-text-embeds-codegen.d.ts +13 -0
- package/dist/cjs/utils/rich-text-embeds-codegen.d.ts.map +1 -1
- package/dist/cjs/utils/rich-text-embeds-codegen.js +15 -104
- package/dist/cjs/utils/rich-text-embeds-codegen.js.map +1 -1
- package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts +2 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.js +409 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/inline-script-error-guard.d.ts +29 -0
- package/dist/esm/utils/inline-script-error-guard.d.ts.map +1 -0
- package/dist/esm/utils/inline-script-error-guard.js +34 -0
- package/dist/esm/utils/inline-script-error-guard.js.map +1 -0
- package/dist/esm/utils/rich-text-embeds-codegen.d.ts +13 -0
- package/dist/esm/utils/rich-text-embeds-codegen.d.ts.map +1 -1
- package/dist/esm/utils/rich-text-embeds-codegen.js +16 -105
- package/dist/esm/utils/rich-text-embeds-codegen.js.map +1 -1
- package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts +2 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.js +406 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/utils/inline-script-error-guard.ts +51 -0
- package/src/utils/rich-text-embeds-codegen.ts +16 -183
- package/src/utils/rich-text-embeds-runtime-source.ts +405 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UIDLGlobalProjectValues } from '@teleporthq/teleport-types';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps an error thrown by the project's OWN inline scripts from surfacing as an
|
|
4
|
+
* unhandled error of the generated app.
|
|
5
|
+
*
|
|
6
|
+
* The project's custom code (Project settings → Custom code) and its inline
|
|
7
|
+
* script assets are pasted into the document as inline `<script>`s. When one of
|
|
8
|
+
* them throws — a custom accordion script calling `addEventListener` on a header
|
|
9
|
+
* the markup no longer has — the browser reports the error as uncaught, and the
|
|
10
|
+
* generated app's development server (Next.js) covers the page with its error
|
|
11
|
+
* overlay, on every page and again after every navigation. The app is fine; the
|
|
12
|
+
* script is not.
|
|
13
|
+
*
|
|
14
|
+
* An inline script reports the URL of the document it was parsed with as its
|
|
15
|
+
* file, both for an error thrown while it runs and for one thrown later by a
|
|
16
|
+
* callback it registered; the app's bundles and external scripts report their
|
|
17
|
+
* own URLs. The guard is the first script of the document, so its capture
|
|
18
|
+
* listener runs before every other `error` listener (the overlay's included):
|
|
19
|
+
* it stops such an error there and logs it as a warning instead. The scripts
|
|
20
|
+
* themselves are not wrapped or rewritten, so a top-level declaration one script
|
|
21
|
+
* shares with the next keeps working.
|
|
22
|
+
*/
|
|
23
|
+
export declare const INLINE_SCRIPT_ERROR_GUARD = "(function () {\n var documentUrl = String(document.URL).split('#')[0]\n window.addEventListener(\n 'error',\n function (event) {\n if (!event.error || String(event.filename || '').split('#')[0] !== documentUrl) {\n return\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n console.warn('A custom code script on this page failed:', event.error)\n },\n true\n )\n})()";
|
|
24
|
+
/**
|
|
25
|
+
* Whether the document runs scripts the project wrote itself — the only case the
|
|
26
|
+
* guard is emitted in, so a project without any comes out exactly as before.
|
|
27
|
+
*/
|
|
28
|
+
export declare const documentRunsProjectScripts: (globals: Pick<UIDLGlobalProjectValues, 'customCode' | 'assets'>) => boolean;
|
|
29
|
+
//# sourceMappingURL=inline-script-error-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-script-error-guard.d.ts","sourceRoot":"","sources":["../../../src/utils/inline-script-error-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,gbAcjC,CAAA;AAIL;;;GAGG;AACH,eAAO,MAAM,0BAA0B,YAC5B,KAAK,uBAAuB,EAAE,YAAY,GAAG,QAAQ,CAAC,KAC9D,OAGoF,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.documentRunsProjectScripts = exports.INLINE_SCRIPT_ERROR_GUARD = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Keeps an error thrown by the project's OWN inline scripts from surfacing as an
|
|
6
|
+
* unhandled error of the generated app.
|
|
7
|
+
*
|
|
8
|
+
* The project's custom code (Project settings → Custom code) and its inline
|
|
9
|
+
* script assets are pasted into the document as inline `<script>`s. When one of
|
|
10
|
+
* them throws — a custom accordion script calling `addEventListener` on a header
|
|
11
|
+
* the markup no longer has — the browser reports the error as uncaught, and the
|
|
12
|
+
* generated app's development server (Next.js) covers the page with its error
|
|
13
|
+
* overlay, on every page and again after every navigation. The app is fine; the
|
|
14
|
+
* script is not.
|
|
15
|
+
*
|
|
16
|
+
* An inline script reports the URL of the document it was parsed with as its
|
|
17
|
+
* file, both for an error thrown while it runs and for one thrown later by a
|
|
18
|
+
* callback it registered; the app's bundles and external scripts report their
|
|
19
|
+
* own URLs. The guard is the first script of the document, so its capture
|
|
20
|
+
* listener runs before every other `error` listener (the overlay's included):
|
|
21
|
+
* it stops such an error there and logs it as a warning instead. The scripts
|
|
22
|
+
* themselves are not wrapped or rewritten, so a top-level declaration one script
|
|
23
|
+
* shares with the next keeps working.
|
|
24
|
+
*/
|
|
25
|
+
exports.INLINE_SCRIPT_ERROR_GUARD = "(function () {\n var documentUrl = String(document.URL).split('#')[0]\n window.addEventListener(\n 'error',\n function (event) {\n if (!event.error || String(event.filename || '').split('#')[0] !== documentUrl) {\n return\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n console.warn('A custom code script on this page failed:', event.error)\n },\n true\n )\n})()";
|
|
26
|
+
var SCRIPT_TAG = /<script\b/i;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the document runs scripts the project wrote itself — the only case the
|
|
29
|
+
* guard is emitted in, so a project without any comes out exactly as before.
|
|
30
|
+
*/
|
|
31
|
+
var documentRunsProjectScripts = function (globals) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return SCRIPT_TAG.test(((_a = globals.customCode) === null || _a === void 0 ? void 0 : _a.head) || '') ||
|
|
34
|
+
SCRIPT_TAG.test(((_b = globals.customCode) === null || _b === void 0 ? void 0 : _b.body) || '') ||
|
|
35
|
+
(globals.assets || []).some(function (asset) { return asset.type === 'script' && 'content' in asset; });
|
|
36
|
+
};
|
|
37
|
+
exports.documentRunsProjectScripts = documentRunsProjectScripts;
|
|
38
|
+
//# sourceMappingURL=inline-script-error-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-script-error-guard.js","sourceRoot":"","sources":["../../../src/utils/inline-script-error-guard.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,yBAAyB,GAAG,6aAcpC,CAAA;AAEL,IAAM,UAAU,GAAG,YAAY,CAAA;AAE/B;;;GAGG;AACI,IAAM,0BAA0B,GAAG,UACxC,OAA+D;;IAE/D,OAAA,UAAU,CAAC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,UAAU,0CAAE,IAAI,KAAI,EAAE,CAAC;QAC/C,UAAU,CAAC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,UAAU,0CAAE,IAAI,KAAI,EAAE,CAAC;QAC/C,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAA7C,CAA6C,CAAC,CAAA;CAAA,CAAA;AAL1E,QAAA,0BAA0B,8BAKgD"}
|
|
@@ -5,5 +5,18 @@
|
|
|
5
5
|
* flattens a `RegExp` to `{}`.
|
|
6
6
|
*/
|
|
7
7
|
export declare function serializeEmbedProvidersForRuntime(): string;
|
|
8
|
+
/**
|
|
9
|
+
* `components/embed-runtime.js` for the generated project: the helpers its
|
|
10
|
+
* rich-text editor builds embeds with and its activator mounts them with.
|
|
11
|
+
*
|
|
12
|
+
* A STRING committed beside this file, not printed from the functions with
|
|
13
|
+
* `Function.prototype.toString` at generation time: teleport-gui runs this
|
|
14
|
+
* generator inside a minified bundle, where the minifier renames every one of
|
|
15
|
+
* those functions and the constants they read, so the emitted module exported
|
|
16
|
+
* none of the names the activator imports. A minifier never rewrites a string
|
|
17
|
+
* literal. `__tests__/utils/rich-text-embeds-runtime-module.ts` fails when the
|
|
18
|
+
* string drifts from `rich-text-embeds.ts` and regenerates it with
|
|
19
|
+
* UPDATE_EMBED_RUNTIME=1.
|
|
20
|
+
*/
|
|
8
21
|
export declare function generateEmbedRuntimeModuleSource(): string;
|
|
9
22
|
//# sourceMappingURL=rich-text-embeds-codegen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-embeds-codegen.d.ts","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-codegen.d.ts","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,MAAM,CAe1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CAEzD"}
|
|
@@ -5,11 +5,11 @@ exports.generateEmbedRuntimeModuleSource = exports.serializeEmbedProvidersForRun
|
|
|
5
5
|
* Code-generation helpers for the rich-text embed contract.
|
|
6
6
|
*
|
|
7
7
|
* Kept apart from `rich-text-embeds.ts` on purpose: that module is imported by
|
|
8
|
-
* the studio editor and the canvas renderer, which are BROWSER bundles
|
|
9
|
-
*
|
|
10
|
-
* of them can be tree-shaken. Only the project generator imports this file.
|
|
8
|
+
* the studio editor and the canvas renderer, which are BROWSER bundles. Only
|
|
9
|
+
* the project generator imports this file.
|
|
11
10
|
*/
|
|
12
11
|
var rich_text_embeds_1 = require("./rich-text-embeds");
|
|
12
|
+
var rich_text_embeds_runtime_source_1 = require("./rich-text-embeds-runtime-source");
|
|
13
13
|
/**
|
|
14
14
|
* The provider registry as a JavaScript literal, so the component the Next
|
|
15
15
|
* generator writes is built from THIS array rather than a hand-copied one.
|
|
@@ -30,110 +30,21 @@ function serializeEmbedProvidersForRuntime() {
|
|
|
30
30
|
return "[\n ".concat(entries.join(',\n '), "\n]");
|
|
31
31
|
}
|
|
32
32
|
exports.serializeEmbedProvidersForRuntime = serializeEmbedProvidersForRuntime;
|
|
33
|
-
/* ── The generated runtime module ───────────────────────────────────────────
|
|
34
|
-
*
|
|
35
|
-
* The exported project needs these same helpers at runtime: its rich-text
|
|
36
|
-
* editor builds embeds with them and its activator mounts them. Rather than
|
|
37
|
-
* hand-copying the logic into a code-generator template — where it would drift
|
|
38
|
-
* from this file the first time a provider is added — the module is EMITTED
|
|
39
|
-
* from the very functions above: the constants are serialized, the functions
|
|
40
|
-
* are printed with `Function.prototype.toString`, and the result is written to
|
|
41
|
-
* the generated project as `components/embed-runtime.js`.
|
|
42
|
-
*
|
|
43
|
-
* Two rules keep that safe, and `__tests__/utils/rich-text-embeds.ts` pins both:
|
|
44
|
-
* - every emitted function may only reference other emitted functions and the
|
|
45
|
-
* constants below, never a module-private helper or an import;
|
|
46
|
-
* - the emitted module must parse and behave identically to this one.
|
|
47
|
-
*/
|
|
48
33
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
rich_text_embeds_1.clampEmbedWidth,
|
|
61
|
-
rich_text_embeds_1.normalizeEmbedAlign,
|
|
62
|
-
rich_text_embeds_1.escapeEmbedAttribute,
|
|
63
|
-
rich_text_embeds_1.escapeEmbedText,
|
|
64
|
-
rich_text_embeds_1.encodeEmbedCode,
|
|
65
|
-
rich_text_embeds_1.decodeEmbedCode,
|
|
66
|
-
rich_text_embeds_1.createEmbedValue,
|
|
67
|
-
rich_text_embeds_1.embedBlockStyle,
|
|
68
|
-
rich_text_embeds_1.embedFrameStyle,
|
|
69
|
-
rich_text_embeds_1.buildEmbedElementHtml,
|
|
70
|
-
rich_text_embeds_1.buildEmbedFrameChildren,
|
|
71
|
-
rich_text_embeds_1.findEmbedFrame,
|
|
72
|
-
rich_text_embeds_1.readEmbedValueFromElement,
|
|
73
|
-
rich_text_embeds_1.readEncodedEmbedCode,
|
|
74
|
-
rich_text_embeds_1.normalizeEmbedsForStorage,
|
|
75
|
-
rich_text_embeds_1.resolveEmbedSandboxFlags,
|
|
76
|
-
rich_text_embeds_1.buildEmbedSandboxDocument,
|
|
77
|
-
rich_text_embeds_1.parseEmbedHeightMessage,
|
|
78
|
-
rich_text_embeds_1.createEmbedToken,
|
|
79
|
-
];
|
|
80
|
-
var runtimeConstant = function (name, literal) { return ({ name: name, literal: literal }); };
|
|
81
|
-
/**
|
|
82
|
-
* TypeScript's CommonJS emit rewrites every reference to an exported CONSTANT
|
|
83
|
-
* as `exports.NAME` (exported functions keep their bare names, which is why
|
|
84
|
-
* they can call each other). The generator runs against that CommonJS build, so
|
|
85
|
-
* printed function bodies arrive carrying `exports.` prefixes that mean nothing
|
|
86
|
-
* in the emitted module — where each constant is re-declared as a plain
|
|
87
|
-
* top-level binding of the same name. Rewriting them back is therefore exact,
|
|
88
|
-
* not a heuristic: only names this module emits are rewritten, and
|
|
89
|
-
* `generateEmbedRuntimeModuleSource` asserts nothing module-scoped is left.
|
|
34
|
+
* `components/embed-runtime.js` for the generated project: the helpers its
|
|
35
|
+
* rich-text editor builds embeds with and its activator mounts them with.
|
|
36
|
+
*
|
|
37
|
+
* A STRING committed beside this file, not printed from the functions with
|
|
38
|
+
* `Function.prototype.toString` at generation time: teleport-gui runs this
|
|
39
|
+
* generator inside a minified bundle, where the minifier renames every one of
|
|
40
|
+
* those functions and the constants they read, so the emitted module exported
|
|
41
|
+
* none of the names the activator imports. A minifier never rewrites a string
|
|
42
|
+
* literal. `__tests__/utils/rich-text-embeds-runtime-module.ts` fails when the
|
|
43
|
+
* string drifts from `rich-text-embeds.ts` and regenerates it with
|
|
44
|
+
* UPDATE_EMBED_RUNTIME=1.
|
|
90
45
|
*/
|
|
91
|
-
var bindRuntimeConstantReferences = function (source, names) {
|
|
92
|
-
return names.reduce(function (acc, name) { return acc.replace(new RegExp("\\bexports\\.".concat(name, "\\b"), 'g'), name); }, source);
|
|
93
|
-
};
|
|
94
46
|
function generateEmbedRuntimeModuleSource() {
|
|
95
|
-
|
|
96
|
-
runtimeConstant('EMBED_CLASS_NAME', JSON.stringify(rich_text_embeds_1.EMBED_CLASS_NAME)),
|
|
97
|
-
runtimeConstant('EMBED_FRAME_CLASS_NAME', JSON.stringify(rich_text_embeds_1.EMBED_FRAME_CLASS_NAME)),
|
|
98
|
-
runtimeConstant('EMBED_CAPTION_CLASS_NAME', JSON.stringify(rich_text_embeds_1.EMBED_CAPTION_CLASS_NAME)),
|
|
99
|
-
runtimeConstant('EMBED_BLOT_NAME', JSON.stringify(rich_text_embeds_1.EMBED_BLOT_NAME)),
|
|
100
|
-
runtimeConstant('EMBED_ATTR', JSON.stringify(rich_text_embeds_1.EMBED_ATTR, null, 2)),
|
|
101
|
-
runtimeConstant('EMBED_ALIGNMENTS', JSON.stringify(rich_text_embeds_1.EMBED_ALIGNMENTS)),
|
|
102
|
-
runtimeConstant('CUSTOM_EMBED_PROVIDER_ID', JSON.stringify(rich_text_embeds_1.CUSTOM_EMBED_PROVIDER_ID)),
|
|
103
|
-
runtimeConstant('GENERIC_EMBED_PROVIDER_ID', JSON.stringify(rich_text_embeds_1.GENERIC_EMBED_PROVIDER_ID)),
|
|
104
|
-
runtimeConstant('DEFAULT_EMBED_WIDTH', String(rich_text_embeds_1.DEFAULT_EMBED_WIDTH)),
|
|
105
|
-
runtimeConstant('DEFAULT_EMBED_ALIGN', JSON.stringify(rich_text_embeds_1.DEFAULT_EMBED_ALIGN)),
|
|
106
|
-
runtimeConstant('DEFAULT_EMBED_SANDBOX_LEVEL', JSON.stringify(rich_text_embeds_1.DEFAULT_EMBED_SANDBOX_LEVEL)),
|
|
107
|
-
runtimeConstant('WIDESCREEN_EMBED_RATIO', String(rich_text_embeds_1.WIDESCREEN_EMBED_RATIO)),
|
|
108
|
-
runtimeConstant('EMBED_CAPTION_STYLE', JSON.stringify(rich_text_embeds_1.EMBED_CAPTION_STYLE)),
|
|
109
|
-
runtimeConstant('EMBED_PROVIDERS', serializeEmbedProvidersForRuntime()),
|
|
110
|
-
runtimeConstant('EMBED_SANDBOX_FLAGS_STRICT', JSON.stringify(rich_text_embeds_1.EMBED_SANDBOX_FLAGS_STRICT)),
|
|
111
|
-
runtimeConstant('EMBED_SANDBOX_FLAGS_TRUSTED', JSON.stringify(rich_text_embeds_1.EMBED_SANDBOX_FLAGS_TRUSTED)),
|
|
112
|
-
runtimeConstant('EMBED_HEIGHT_MESSAGE_TYPE', JSON.stringify(rich_text_embeds_1.EMBED_HEIGHT_MESSAGE_TYPE)),
|
|
113
|
-
runtimeConstant('EMBED_TOKEN_PLACEHOLDER', JSON.stringify(rich_text_embeds_1.EMBED_TOKEN_PLACEHOLDER)),
|
|
114
|
-
runtimeConstant('EMBED_MIN_HEIGHT', String(rich_text_embeds_1.EMBED_MIN_HEIGHT)),
|
|
115
|
-
runtimeConstant('EMBED_MAX_HEIGHT', String(rich_text_embeds_1.EMBED_MAX_HEIGHT)),
|
|
116
|
-
runtimeConstant('EMBED_INITIAL_HEIGHT', String(rich_text_embeds_1.EMBED_INITIAL_HEIGHT)),
|
|
117
|
-
runtimeConstant('EMBED_SANDBOX_DOC_HEAD', JSON.stringify(rich_text_embeds_1.EMBED_SANDBOX_DOC_HEAD)),
|
|
118
|
-
runtimeConstant('EMBED_SANDBOX_DOC_TAIL', JSON.stringify(rich_text_embeds_1.EMBED_SANDBOX_DOC_TAIL)),
|
|
119
|
-
// `createEmbedToken` closes over this counter.
|
|
120
|
-
runtimeConstant('embedTokenCounter', '0'),
|
|
121
|
-
];
|
|
122
|
-
var names = constants.map(function (entry) { return entry.name; });
|
|
123
|
-
var declarations = constants.map(function (entry) { return "export var ".concat(entry.name, " = ").concat(entry.literal); });
|
|
124
|
-
var functions = RUNTIME_EXPORTS.map(function (fn) { return "export ".concat(bindRuntimeConstantReferences(fn.toString(), names)); });
|
|
125
|
-
var source = "".concat(RUNTIME_MODULE_HEADER, "\n").concat(declarations.join('\n\n'), "\n\n").concat(functions.join('\n\n'), "\n");
|
|
126
|
-
// An `exports.` reference that survived means a function reached for a
|
|
127
|
-
// constant left off the list above. That crashes every generated project at
|
|
128
|
-
// runtime, so it fails here instead. (Import leakage is covered by the
|
|
129
|
-
// emitted module being evaluated in this package's tests — this module has
|
|
130
|
-
// no imports, and must not gain any.)
|
|
131
|
-
var leaked = source.match(/\bexports\.[A-Za-z_$][\w$]*/g);
|
|
132
|
-
if (leaked) {
|
|
133
|
-
throw new Error("Embed runtime module cannot be emitted: unresolved module references ".concat(leaked.join(', ')));
|
|
134
|
-
}
|
|
135
|
-
return source;
|
|
47
|
+
return rich_text_embeds_runtime_source_1.EMBED_RUNTIME_MODULE_SOURCE;
|
|
136
48
|
}
|
|
137
49
|
exports.generateEmbedRuntimeModuleSource = generateEmbedRuntimeModuleSource;
|
|
138
|
-
var RUNTIME_MODULE_HEADER = "/**\n * Code embeds inside rich-text content \u2014 the shape the editor writes and the\n * page reads back. Generated from @teleporthq/teleport-shared; edit it there.\n *\n * An embed is stored inside the content HTML as a <figure class=\"tq-embed\">.\n * Passive markup (a provider iframe) lives in the figure as real children, so\n * it renders server-side with no JavaScript. Markup that can execute \u2014 a\n * <script>, an on* handler, a javascript: URL \u2014 is base64-encoded onto the\n * element instead, and mounted at runtime inside a sandboxed iframe so it can\n * never reach this page.\n */\n";
|
|
139
50
|
//# sourceMappingURL=rich-text-embeds-codegen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-embeds-codegen.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-codegen.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,uDAAoD;AACpD,qFAA+E;AAE/E;;;;;GAKG;AACH,SAAgB,iCAAiC;IAC/C,IAAM,OAAO,GAAG,kCAAe,CAAC,GAAG,CAAC,UAAC,QAAQ;QAC3C,IAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ;aAC/B,GAAG,CACF,UAAC,OAAO;YACN,OAAA,qBAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,eAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAG;QAAjF,CAAiF,CACpF;aACA,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,CACL,gBAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,sBAAY,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAI;YAClF,qBAAc,QAAQ,0BAAgB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAI;YAC3E,iBAAU,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAI,CACxE,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,eAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAK,CAAA;AAC3C,CAAC;AAfD,8EAeC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,gCAAgC;IAC9C,OAAO,6DAA2B,CAAA;AACpC,CAAC;AAFD,4EAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-runtime-source.d.ts","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-runtime-source.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,2BAA2B,QAgZ5B,CAAA"}
|