[generated] sandpack files from: codesandbox-client
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
32712
sandpack-generated/static/js/prettier/1.15.1/parser-postcss.js
Normal file
32712
sandpack-generated/static/js/prettier/1.15.1/parser-postcss.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
30120
sandpack-generated/static/js/prettier/1.15.1/standalone.js
Normal file
30120
sandpack-generated/static/js/prettier/1.15.1/standalone.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
32300
sandpack-generated/static/js/prettier/1.16.4/parser-postcss.js
Normal file
32300
sandpack-generated/static/js/prettier/1.16.4/parser-postcss.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
30742
sandpack-generated/static/js/prettier/1.16.4/standalone.js
Normal file
30742
sandpack-generated/static/js/prettier/1.16.4/standalone.js
Normal file
File diff suppressed because one or more lines are too long
650
sandpack-generated/static/js/prettier/2.0.5/parser-angular.js
Normal file
650
sandpack-generated/static/js/prettier/2.0.5/parser-angular.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
113
sandpack-generated/static/js/prettier/2.0.5/parser-html.js
Normal file
113
sandpack-generated/static/js/prettier/2.0.5/parser-html.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
16
sandpack-generated/static/js/prettier/2.0.5/parser-yaml.js
Normal file
16
sandpack-generated/static/js/prettier/2.0.5/parser-yaml.js
Normal file
File diff suppressed because one or more lines are too long
32923
sandpack-generated/static/js/prettier/2.0.5/standalone.js
Normal file
32923
sandpack-generated/static/js/prettier/2.0.5/standalone.js
Normal file
File diff suppressed because one or more lines are too long
170
sandpack-generated/static/js/prettier/worker-1.15.1.js
Normal file
170
sandpack-generated/static/js/prettier/worker-1.15.1.js
Normal file
@@ -0,0 +1,170 @@
|
||||
/* eslint-env worker */
|
||||
/* eslint no-var: off, vars-on-top: off, strict: off, no-use-before-define: off */
|
||||
/* globals prettier prettierPlugins */
|
||||
|
||||
var imported = Object.create(null);
|
||||
function importScriptOnce(url) {
|
||||
if (!imported[url]) {
|
||||
imported[url] = true;
|
||||
importScripts(url);
|
||||
}
|
||||
}
|
||||
|
||||
// this is required to only load parsers when we need them
|
||||
var parsers = {
|
||||
// JS - Babylon
|
||||
get babylon() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.babylon;
|
||||
},
|
||||
get json() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.json;
|
||||
},
|
||||
get json5() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.json5;
|
||||
},
|
||||
get "json-stringify"() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers["json-stringify"];
|
||||
},
|
||||
get __js_expression() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.__js_expression;
|
||||
},
|
||||
get __vue_expression() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.__vue_expression;
|
||||
},
|
||||
// JS - Flow
|
||||
get flow() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-flow.js");
|
||||
return prettierPlugins.flow.parsers.flow;
|
||||
},
|
||||
// JS - TypeScript
|
||||
get typescript() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-typescript.js");
|
||||
return prettierPlugins.typescript.parsers.typescript;
|
||||
},
|
||||
// JS - Angular Action
|
||||
get __ng_action() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_action;
|
||||
},
|
||||
// JS - Angular Binding
|
||||
get __ng_binding() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_binding;
|
||||
},
|
||||
// JS - Angular Interpolation
|
||||
get __ng_interpolation() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_interpolation;
|
||||
},
|
||||
// JS - Angular Directive
|
||||
get __ng_directive() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_directive;
|
||||
},
|
||||
|
||||
// CSS
|
||||
get css() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get less() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get scss() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
|
||||
// GraphQL
|
||||
get graphql() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-graphql.js");
|
||||
return prettierPlugins.graphql.parsers.graphql;
|
||||
},
|
||||
|
||||
// Markdown
|
||||
get markdown() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.remark;
|
||||
},
|
||||
get mdx() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.mdx;
|
||||
},
|
||||
|
||||
// YAML
|
||||
get yaml() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-yaml.js");
|
||||
return prettierPlugins.yaml.parsers.yaml;
|
||||
},
|
||||
|
||||
// Handlebars
|
||||
get glimmer() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-glimmer.js");
|
||||
return prettierPlugins.glimmer.parsers.glimmer;
|
||||
},
|
||||
|
||||
// HTML
|
||||
get html() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-html.js");
|
||||
return prettierPlugins.html.parsers.html;
|
||||
},
|
||||
// Vue
|
||||
get vue() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-html.js");
|
||||
return prettierPlugins.html.parsers.vue;
|
||||
},
|
||||
// Angular
|
||||
get angular() {
|
||||
importScriptOnce("/static/js/prettier/1.15.1/parser-html.js");
|
||||
return prettierPlugins.html.parsers.angular;
|
||||
}
|
||||
};
|
||||
|
||||
importScripts("/static/js/prettier/1.15.1/standalone.js");
|
||||
|
||||
self.onmessage = function(event) {
|
||||
const message = handleMessage(event.data);
|
||||
self.postMessage({
|
||||
uid: event.data.uid,
|
||||
result: message,
|
||||
text: event.data.text
|
||||
});
|
||||
};
|
||||
|
||||
function handleMessage(message) {
|
||||
var options = message.options || {};
|
||||
|
||||
delete options.ast;
|
||||
delete options.doc;
|
||||
delete options.output2;
|
||||
|
||||
var plugins = [{ parsers }];
|
||||
options.plugins = plugins;
|
||||
|
||||
var response = {
|
||||
formatted: formatCode(message.text, options),
|
||||
debug: {
|
||||
ast: null,
|
||||
doc: null,
|
||||
reformatted: null
|
||||
}
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
function formatCode(text, options) {
|
||||
try {
|
||||
return prettier.format(text, options);
|
||||
} catch (e) {
|
||||
self.postMessage({ error: e.message, text });
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
188
sandpack-generated/static/js/prettier/worker-1.16.4.js
Normal file
188
sandpack-generated/static/js/prettier/worker-1.16.4.js
Normal file
@@ -0,0 +1,188 @@
|
||||
/* eslint-env worker */
|
||||
/* eslint no-var: off, vars-on-top: off, strict: off, no-use-before-define: off */
|
||||
/* globals prettier prettierPlugins */
|
||||
|
||||
var imported = Object.create(null);
|
||||
function importScriptOnce(url) {
|
||||
if (!imported[url]) {
|
||||
imported[url] = true;
|
||||
importScripts(url);
|
||||
}
|
||||
}
|
||||
|
||||
// this is required to only load parsers when we need them
|
||||
var parsers = {
|
||||
// JS - Babel
|
||||
get babel() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.babel;
|
||||
},
|
||||
get "babel-flow"() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers["babel-flow"];
|
||||
},
|
||||
// backward compatibility
|
||||
get babylon() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.babylon;
|
||||
},
|
||||
get json() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.json;
|
||||
},
|
||||
get json5() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.json5;
|
||||
},
|
||||
get "json-stringify"() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers["json-stringify"];
|
||||
},
|
||||
get __js_expression() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.__js_expression;
|
||||
},
|
||||
get __vue_expression() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.__vue_expression;
|
||||
},
|
||||
get __vue_event_binding() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-babylon.js");
|
||||
return prettierPlugins.babylon.parsers.__vue_event_binding;
|
||||
},
|
||||
// JS - Flow
|
||||
get flow() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-flow.js");
|
||||
return prettierPlugins.flow.parsers.flow;
|
||||
},
|
||||
// JS - TypeScript
|
||||
get typescript() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-typescript.js");
|
||||
return prettierPlugins.typescript.parsers.typescript;
|
||||
},
|
||||
// JS - Angular Action
|
||||
get __ng_action() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_action;
|
||||
},
|
||||
// JS - Angular Binding
|
||||
get __ng_binding() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_binding;
|
||||
},
|
||||
// JS - Angular Interpolation
|
||||
get __ng_interpolation() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_interpolation;
|
||||
},
|
||||
// JS - Angular Directive
|
||||
get __ng_directive() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_directive;
|
||||
},
|
||||
|
||||
// CSS
|
||||
get css() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get less() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get scss() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
|
||||
// GraphQL
|
||||
get graphql() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-graphql.js");
|
||||
return prettierPlugins.graphql.parsers.graphql;
|
||||
},
|
||||
|
||||
// Markdown
|
||||
get markdown() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.remark;
|
||||
},
|
||||
get mdx() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.mdx;
|
||||
},
|
||||
|
||||
// YAML
|
||||
get yaml() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-yaml.js");
|
||||
return prettierPlugins.yaml.parsers.yaml;
|
||||
},
|
||||
|
||||
// Handlebars
|
||||
get glimmer() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-glimmer.js");
|
||||
return prettierPlugins.glimmer.parsers.glimmer;
|
||||
},
|
||||
|
||||
// HTML
|
||||
get html() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-html.js");
|
||||
return prettierPlugins.html.parsers.html;
|
||||
},
|
||||
// Vue
|
||||
get vue() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-html.js");
|
||||
return prettierPlugins.html.parsers.vue;
|
||||
},
|
||||
// Angular
|
||||
get angular() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-html.js");
|
||||
return prettierPlugins.html.parsers.angular;
|
||||
},
|
||||
// Lightning Web Components
|
||||
get lwc() {
|
||||
importScriptOnce("/static/js/prettier/1.16.4/parser-html.js");
|
||||
return prettierPlugins.html.parsers.lwc;
|
||||
}
|
||||
};
|
||||
|
||||
importScripts("/static/js/prettier/1.16.4/standalone.js");
|
||||
|
||||
self.onmessage = function(event) {
|
||||
const message = handleMessage(event.data);
|
||||
self.postMessage({
|
||||
uid: event.data.uid,
|
||||
result: message,
|
||||
text: event.data.text
|
||||
});
|
||||
};
|
||||
|
||||
function handleMessage(message) {
|
||||
var options = message.options || {};
|
||||
|
||||
delete options.ast;
|
||||
delete options.doc;
|
||||
delete options.output2;
|
||||
|
||||
var plugins = [{ parsers }];
|
||||
options.plugins = plugins;
|
||||
|
||||
var response = {
|
||||
formatted: formatCode(message.text, options),
|
||||
debug: {
|
||||
ast: null,
|
||||
doc: null,
|
||||
reformatted: null
|
||||
}
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
function formatCode(text, options) {
|
||||
try {
|
||||
return prettier.format(text, options);
|
||||
} catch (e) {
|
||||
self.postMessage({ error: e.message, text });
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
187
sandpack-generated/static/js/prettier/worker-2.0.5.js
Normal file
187
sandpack-generated/static/js/prettier/worker-2.0.5.js
Normal file
@@ -0,0 +1,187 @@
|
||||
/* eslint-env worker */
|
||||
/* eslint no-var: off, strict: off */
|
||||
/* globals prettier prettierPlugins */
|
||||
|
||||
var imported = Object.create(null);
|
||||
function importScriptOnce(url) {
|
||||
if (!imported[url]) {
|
||||
imported[url] = true;
|
||||
importScripts(url);
|
||||
}
|
||||
}
|
||||
|
||||
// this is required to only load parsers when we need them
|
||||
var parsers = {
|
||||
// JS - Babel
|
||||
get babel() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.babel;
|
||||
},
|
||||
get "babel-flow"() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers["babel-flow"];
|
||||
},
|
||||
get "babel-ts"() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers["babel-ts"];
|
||||
},
|
||||
get json() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.json;
|
||||
},
|
||||
get json5() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.json5;
|
||||
},
|
||||
get "json-stringify"() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers["json-stringify"];
|
||||
},
|
||||
get __js_expression() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.__js_expression;
|
||||
},
|
||||
get __vue_expression() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.__vue_expression;
|
||||
},
|
||||
get __vue_event_binding() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-babel.js");
|
||||
return prettierPlugins.babel.parsers.__vue_event_binding;
|
||||
},
|
||||
// JS - Flow
|
||||
get flow() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-flow.js");
|
||||
return prettierPlugins.flow.parsers.flow;
|
||||
},
|
||||
// JS - TypeScript
|
||||
get typescript() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-typescript.js");
|
||||
return prettierPlugins.typescript.parsers.typescript;
|
||||
},
|
||||
// JS - Angular Action
|
||||
get __ng_action() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_action;
|
||||
},
|
||||
// JS - Angular Binding
|
||||
get __ng_binding() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_binding;
|
||||
},
|
||||
// JS - Angular Interpolation
|
||||
get __ng_interpolation() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_interpolation;
|
||||
},
|
||||
// JS - Angular Directive
|
||||
get __ng_directive() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-angular.js");
|
||||
return prettierPlugins.angular.parsers.__ng_directive;
|
||||
},
|
||||
|
||||
// CSS
|
||||
get css() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get less() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
get scss() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-postcss.js");
|
||||
return prettierPlugins.postcss.parsers.css;
|
||||
},
|
||||
|
||||
// GraphQL
|
||||
get graphql() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-graphql.js");
|
||||
return prettierPlugins.graphql.parsers.graphql;
|
||||
},
|
||||
|
||||
// Markdown
|
||||
get markdown() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.remark;
|
||||
},
|
||||
get mdx() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-markdown.js");
|
||||
return prettierPlugins.markdown.parsers.mdx;
|
||||
},
|
||||
|
||||
// YAML
|
||||
get yaml() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-yaml.js");
|
||||
return prettierPlugins.yaml.parsers.yaml;
|
||||
},
|
||||
|
||||
// Handlebars
|
||||
get glimmer() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-glimmer.js");
|
||||
return prettierPlugins.glimmer.parsers.glimmer;
|
||||
},
|
||||
|
||||
// HTML
|
||||
get html() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-html.js");
|
||||
return prettierPlugins.html.parsers.html;
|
||||
},
|
||||
// Vue
|
||||
get vue() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-html.js");
|
||||
return prettierPlugins.html.parsers.vue;
|
||||
},
|
||||
// Angular
|
||||
get angular() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-html.js");
|
||||
return prettierPlugins.html.parsers.angular;
|
||||
},
|
||||
// Lightning Web Components
|
||||
get lwc() {
|
||||
importScriptOnce("/static/js/prettier/2.0.5/parser-html.js");
|
||||
return prettierPlugins.html.parsers.lwc;
|
||||
},
|
||||
};
|
||||
|
||||
importScripts("/static/js/prettier/2.0.5/standalone.js");
|
||||
|
||||
self.onmessage = function (event) {
|
||||
self.postMessage({
|
||||
uid: event.data.uid,
|
||||
result: handleMessage(event.data),
|
||||
text: event.data.text
|
||||
});
|
||||
};
|
||||
|
||||
function handleMessage(message) {
|
||||
var options = message.options || {};
|
||||
|
||||
delete options.ast;
|
||||
delete options.doc;
|
||||
delete options.output2;
|
||||
|
||||
var plugins = [{ parsers }];
|
||||
options.plugins = plugins;
|
||||
|
||||
var response = {
|
||||
formatted: formatCode(message.text, options),
|
||||
debug: {
|
||||
ast: null,
|
||||
doc: null,
|
||||
reformatted: null,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
function formatCode(text, options) {
|
||||
try {
|
||||
return prettier.format(text, options);
|
||||
} catch (e) {
|
||||
self.postMessage({ error: e.message, text });
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
96
sandpack-generated/static/js/prettier/worker.js
Normal file
96
sandpack-generated/static/js/prettier/worker.js
Normal file
@@ -0,0 +1,96 @@
|
||||
/* eslint-env worker */
|
||||
/* eslint no-var: off, strict: off */
|
||||
|
||||
const parsersLoaded = {};
|
||||
|
||||
const loadParser = parser => {
|
||||
if (!parsersLoaded[parser]) {
|
||||
if (parser === "vue") {
|
||||
loadParser("typescript");
|
||||
loadParser("babylon");
|
||||
loadParser("postcss");
|
||||
}
|
||||
|
||||
importScripts("/static/js/prettier/1.13.0/parser-" + parser + ".js");
|
||||
parsersLoaded[parser] = true;
|
||||
}
|
||||
};
|
||||
|
||||
importScripts("/static/js/prettier/1.13.0/standalone.js");
|
||||
if (typeof prettier === "undefined") {
|
||||
prettier = module.exports; // eslint-disable-line
|
||||
}
|
||||
if (typeof prettier === "undefined") {
|
||||
prettier = index; // eslint-disable-line
|
||||
}
|
||||
|
||||
function formatCode(text, options) {
|
||||
try {
|
||||
const useCursorOffset = options.cursorOffset !== undefined;
|
||||
|
||||
if (useCursorOffset) {
|
||||
return self.prettier.formatWithCursor(text, options);
|
||||
}
|
||||
|
||||
const formatted = self.prettier.format(text, options);
|
||||
return { formatted };
|
||||
} catch (e) {
|
||||
if (e.constructor && e.constructor.name === "SyntaxError") {
|
||||
// Likely something wrong with the user's code
|
||||
throw e;
|
||||
}
|
||||
// Likely a bug in Prettier
|
||||
// Provide the whole stack for debugging
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
self.onmessage = message => {
|
||||
var options = message.data.options || {};
|
||||
options.parser = options.parser || "babylon";
|
||||
|
||||
loadParser(options.parser);
|
||||
|
||||
let result;
|
||||
options.plugins = self.prettierPlugins;
|
||||
try {
|
||||
result = formatCode(message.data.text, options);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
self.postMessage({ error: e.message, text: message.data.text });
|
||||
return;
|
||||
}
|
||||
var doc;
|
||||
var ast;
|
||||
|
||||
if (message.data.ast) {
|
||||
try {
|
||||
ast = JSON.stringify(
|
||||
prettier.__debug.parse(message.data.text, options),
|
||||
null,
|
||||
2
|
||||
);
|
||||
} catch (e) {
|
||||
ast = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (message.data.doc) {
|
||||
lazyLoadParser("babylon");
|
||||
try {
|
||||
doc = prettier.__debug.formatDoc(
|
||||
prettier.__debug.printToDoc(message.data.text, options),
|
||||
{ parser: "babylon" }
|
||||
);
|
||||
} catch (e) {
|
||||
doc = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
self.postMessage({
|
||||
result,
|
||||
text: message.data.text,
|
||||
doc: doc,
|
||||
ast: ast
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user