pyret-embed 0.1.6 → 0.1.8

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.
@@ -4,7 +4,39 @@
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
5
  <title>{{APP_NAME}}</title>
6
6
  {{^PYRET_GZIPPED}}<link crossorigin="anonymous" rel="preload" href="{{&PYRET}}" as="script">{{/PYRET_GZIPPED}}
7
- <script>window.PYRET = "{{&PYRET}}"; window.PYRET_GZIPPED = "{{ PYRET_GZIPPED }}" === "true"; window.APP_NAME = "{{APP_NAME}}"; window.APP_DOMAIN = "{{APP_DOMAIN}}";</script>
7
+ <script>
8
+ window.PYRET = "{{&PYRET}}"; window.PYRET_GZIPPED = "{{ PYRET_GZIPPED }}" === "true"; window.APP_NAME = "{{APP_NAME}}"; window.APP_DOMAIN = "{{APP_DOMAIN}}";
9
+ // Opt-in TypeScript-compiler flavor: chosen by ?compiler=ts (or the
10
+ // server-side CPO_COMPILER env default). Swaps in the cpo-main-ts jarr
11
+ // and loads the TS compiler bundle; default behavior is unchanged.
12
+ //
13
+ // The ts asset URLs are never configured -- they are derived from PYRET's
14
+ // directory plus canonical names, a contract every host satisfies by
15
+ // publishing the three files side by side (deploys upload them together;
16
+ // static/webview builds copy them together). Both ts assets are gzip bytes
17
+ // at rest everywhere. No PYRET means no ts flavor: ?compiler=ts silently
18
+ // serves the stock compiler.
19
+ window.CPO_COMPILER = "{{&CPO_COMPILER}}" || "pyret";
20
+ (function() {
21
+ var dir = window.PYRET ? window.PYRET.slice(0, window.PYRET.lastIndexOf("/") + 1) : "";
22
+ window.PYRET_TS = window.PYRET ? dir + "cpo-main-ts.jarr.gz.js" : "";
23
+ window.PYRET_TS_COMPILER = window.PYRET ? dir + "ts-compiler.gz.js" : "";
24
+ var m = /[?&]compiler=([^&]*)/.exec(window.location.search);
25
+ if(m) { window.CPO_COMPILER = decodeURIComponent(m[1]); }
26
+ if(window.CPO_COMPILER === "ts" && window.PYRET_TS) {
27
+ window.PYRET = window.PYRET_TS;
28
+ // Lets pure CSS show ts-only chrome (the "(ts mode)" badge in the
29
+ // REPL corner) without another script running at DOM-ready.
30
+ document.documentElement.classList.add("ts-mode");
31
+ // In gzipped mode the host may serve assets without an executable MIME
32
+ // type (nosniff), which refuses a <script src> load outright --
33
+ // beforePyret.js fetches the compiler bundle alongside the jarr instead.
34
+ if(!window.PYRET_GZIPPED) {
35
+ document.write('<script src="' + window.PYRET_TS_COMPILER + '"><\/script>');
36
+ }
37
+ }
38
+ })();
39
+ </script>
8
40
  <link rel="stylesheet" href="{{ &BASE_URL }}/css/reset.css" />
9
41
  <link rel="stylesheet" href="{{ &BASE_URL }}/css/smoothness-jquery-ui.css" />
10
42
  <link rel="stylesheet" href="{{ &BASE_URL }}/css/fira-mono.css" />
@@ -362,6 +394,7 @@
362
394
  </div>
363
395
  <div id="REPL" class="replContainer" role="region" aria-label="Interactions">
364
396
  <div id="handle" class="ui-resizable-handle ui-resizable-w"></div>
397
+ <div id="compilerFlavorBadge" title="This session uses the TypeScript version of Pyret. Visit /settings/clear-ts to turn it off.">(ts mode)</div>
365
398
  </div>
366
399
  <div id="help-keys">
367
400
  <p><b>Press <kbd>Esc</kbd> to close this help window</b></p>