@orgajs/orgx 1.0.7 → 2.0.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.org +22 -0
- package/dist/index.d.ts +11 -5
- package/dist/lib/compile.d.ts +45 -0
- package/dist/lib/condition.browser.d.ts +1 -0
- package/dist/lib/condition.d.ts +1 -0
- package/dist/lib/core.d.ts +57 -0
- package/dist/lib/evaluate.d.ts +27 -0
- package/dist/lib/plugin/recma-document.d.ts +63 -0
- package/dist/lib/plugin/recma-jsx-build.d.ts +14 -0
- package/dist/lib/plugin/recma-jsx-rewrite.d.ts +50 -0
- package/dist/lib/plugin/recma-stringify.d.ts +13 -0
- package/dist/lib/plugin/rehype-recma.d.ts +49 -0
- package/dist/lib/run.d.ts +26 -0
- package/dist/lib/util/estree-util-create.d.ts +13 -0
- package/dist/lib/util/estree-util-declaration-to-expression.d.ts +19 -0
- package/dist/lib/util/estree-util-is-declaration.d.ts +15 -0
- package/dist/lib/util/estree-util-specifiers-to-declarations.d.ts +14 -0
- package/dist/lib/util/estree-util-to-binary-addition.d.ts +8 -0
- package/dist/lib/util/estree-util-to-id-or-member-expression.d.ts +11 -0
- package/dist/lib/util/render-error.d.ts +2 -0
- package/dist/lib/util/resolve-evaluate-options.d.ts +66 -0
- package/dist/lib/util/resolve-file-and-options.d.ts +16 -0
- package/index.js +14 -0
- package/lib/compile.js +54 -0
- package/lib/condition.browser.js +1 -0
- package/lib/condition.js +3 -0
- package/lib/core.js +100 -0
- package/lib/evaluate.js +41 -0
- package/lib/plugin/recma-document.js +607 -0
- package/lib/plugin/recma-jsx-build.js +53 -0
- package/lib/plugin/recma-jsx-rewrite.js +616 -0
- package/lib/plugin/recma-stringify.js +42 -0
- package/lib/plugin/rehype-recma.js +218 -0
- package/lib/run.js +31 -0
- package/lib/types.d.ts +46 -0
- package/lib/util/estree-util-create.js +27 -0
- package/lib/util/estree-util-declaration-to-expression.js +32 -0
- package/lib/util/estree-util-is-declaration.js +20 -0
- package/lib/util/estree-util-specifiers-to-declarations.js +90 -0
- package/lib/util/estree-util-to-binary-addition.js +23 -0
- package/lib/util/estree-util-to-id-or-member-expression.js +108 -0
- package/lib/util/render-error.js +91 -0
- package/lib/util/resolve-evaluate-options.js +64 -0
- package/lib/util/resolve-file-and-options.js +40 -0
- package/package.json +36 -29
- package/CHANGELOG.md +0 -71
- package/dist/compile.d.ts +0 -6
- package/dist/compile.d.ts.map +0 -1
- package/dist/compile.js +0 -12
- package/dist/compile.js.map +0 -1
- package/dist/estree/create.d.ts +0 -2
- package/dist/estree/create.d.ts.map +0 -1
- package/dist/estree/create.js +0 -14
- package/dist/estree/create.js.map +0 -1
- package/dist/estree/declaration-to-expression.d.ts +0 -3
- package/dist/estree/declaration-to-expression.d.ts.map +0 -1
- package/dist/estree/declaration-to-expression.js +0 -12
- package/dist/estree/declaration-to-expression.js.map +0 -1
- package/dist/estree/error.d.ts +0 -61
- package/dist/estree/error.d.ts.map +0 -1
- package/dist/estree/error.js +0 -87
- package/dist/estree/error.js.map +0 -1
- package/dist/estree/is-declaration.d.ts +0 -3
- package/dist/estree/is-declaration.d.ts.map +0 -1
- package/dist/estree/is-declaration.js +0 -9
- package/dist/estree/is-declaration.js.map +0 -1
- package/dist/estree/position-from-estree.d.ts +0 -13
- package/dist/estree/position-from-estree.d.ts.map +0 -1
- package/dist/estree/position-from-estree.js +0 -34
- package/dist/estree/position-from-estree.js.map +0 -1
- package/dist/estree/specifiers-to-object-pattern.d.ts +0 -5
- package/dist/estree/specifiers-to-object-pattern.d.ts.map +0 -1
- package/dist/estree/specifiers-to-object-pattern.js +0 -33
- package/dist/estree/specifiers-to-object-pattern.js.map +0 -1
- package/dist/evaluate.d.ts +0 -22
- package/dist/evaluate.d.ts.map +0 -1
- package/dist/evaluate.js +0 -27
- package/dist/evaluate.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/plugin/estree-jsx-build.d.ts +0 -6
- package/dist/plugin/estree-jsx-build.d.ts.map +0 -1
- package/dist/plugin/estree-jsx-build.js +0 -38
- package/dist/plugin/estree-jsx-build.js.map +0 -1
- package/dist/plugin/estree-jsx-rewrite.d.ts +0 -6
- package/dist/plugin/estree-jsx-rewrite.d.ts.map +0 -1
- package/dist/plugin/estree-jsx-rewrite.js +0 -214
- package/dist/plugin/estree-jsx-rewrite.js.map +0 -1
- package/dist/plugin/estree-stringify.d.ts +0 -2
- package/dist/plugin/estree-stringify.d.ts.map +0 -1
- package/dist/plugin/estree-stringify.js +0 -127
- package/dist/plugin/estree-stringify.js.map +0 -1
- package/dist/plugin/estree-wrap-in-content.d.ts +0 -18
- package/dist/plugin/estree-wrap-in-content.d.ts.map +0 -1
- package/dist/plugin/estree-wrap-in-content.js +0 -375
- package/dist/plugin/estree-wrap-in-content.js.map +0 -1
- package/dist/plugin/rehype-estree.d.ts +0 -12
- package/dist/plugin/rehype-estree.d.ts.map +0 -1
- package/dist/plugin/rehype-estree.js +0 -122
- package/dist/plugin/rehype-estree.js.map +0 -1
- package/dist/plugin/rehype-set-layout.d.ts +0 -6
- package/dist/plugin/rehype-set-layout.d.ts.map +0 -1
- package/dist/plugin/rehype-set-layout.js +0 -30
- package/dist/plugin/rehype-set-layout.js.map +0 -1
- package/dist/processor.d.ts +0 -14
- package/dist/processor.d.ts.map +0 -1
- package/dist/processor.js +0 -52
- package/dist/processor.js.map +0 -1
- package/dist/utils/remove-quotes.d.ts +0 -3
- package/dist/utils/remove-quotes.d.ts.map +0 -1
- package/dist/utils/remove-quotes.js +0 -6
- package/dist/utils/remove-quotes.js.map +0 -1
package/dist/evaluate.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { VFileCompatible } from 'vfile';
|
|
2
|
-
import { ProcessorOptions } from './processor';
|
|
3
|
-
declare type EvaluateProcessorOptions = Omit<ProcessorOptions, 'jsx' | 'jsxImportSource'>;
|
|
4
|
-
interface OrgaContentProps extends Record<string, unknown> {
|
|
5
|
-
components: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
declare type OrgaContent = (props: OrgaContentProps) => unknown;
|
|
8
|
-
interface ExportMap extends Record<string, unknown> {
|
|
9
|
-
default: OrgaContent;
|
|
10
|
-
}
|
|
11
|
-
export interface EvaluateOptions extends RuntimeOptions, Partial<EvaluateProcessorOptions> {
|
|
12
|
-
}
|
|
13
|
-
export interface RuntimeOptions {
|
|
14
|
-
Fragment: unknown;
|
|
15
|
-
jsx: unknown;
|
|
16
|
-
jsxs: unknown;
|
|
17
|
-
useOrgaComponents?: unknown;
|
|
18
|
-
}
|
|
19
|
-
export declare const evaluate: (file: VFileCompatible, options: EvaluateOptions) => Promise<ExportMap>;
|
|
20
|
-
export declare const evaluateSync: (file: VFileCompatible, options: EvaluateOptions) => ExportMap;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=evaluate.d.ts.map
|
package/dist/evaluate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,aAAK,wBAAwB,GAAG,IAAI,CAClC,gBAAgB,EAChB,KAAK,GAAG,iBAAiB,CAC1B,CAAA;AAED,UAAU,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AACD,aAAK,WAAW,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAA;AACvD,UAAU,SAAU,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjD,OAAO,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,eACf,SAAQ,cAAc,EACpB,OAAO,CAAC,wBAAwB,CAAC;CAAG;AAExC,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,OAAO,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;IACb,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAmBD,eAAO,MAAM,QAAQ,SACb,eAAe,WACZ,eAAe,KACvB,QAAQ,SAAS,CAInB,CAAA;AAED,eAAO,MAAM,YAAY,SACjB,eAAe,WACZ,eAAe,KACvB,SAIF,CAAA"}
|
package/dist/evaluate.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.evaluateSync = exports.evaluate = void 0;
|
|
3
|
-
const compile_1 = require("./compile");
|
|
4
|
-
const resolveOptions = (options) => {
|
|
5
|
-
const { jsx, Fragment, jsxs, useOrgaComponents, ...rest } = options;
|
|
6
|
-
return {
|
|
7
|
-
compiletime: {
|
|
8
|
-
...rest,
|
|
9
|
-
outputFormat: 'function-body',
|
|
10
|
-
providerImportSource: useOrgaComponents ? '#' : undefined,
|
|
11
|
-
},
|
|
12
|
-
runtime: { jsx, Fragment, jsxs, useOrgaComponents },
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const evaluate = async (file, options) => {
|
|
16
|
-
const { compiletime, runtime } = resolveOptions(options);
|
|
17
|
-
const code = await compile_1.compile(file, compiletime);
|
|
18
|
-
return new Function(String(code))(runtime);
|
|
19
|
-
};
|
|
20
|
-
exports.evaluate = evaluate;
|
|
21
|
-
const evaluateSync = (file, options) => {
|
|
22
|
-
const { compiletime, runtime } = resolveOptions(options);
|
|
23
|
-
const code = compile_1.compileSync(file, compiletime);
|
|
24
|
-
return new Function(String(code))(runtime);
|
|
25
|
-
};
|
|
26
|
-
exports.evaluateSync = evaluateSync;
|
|
27
|
-
//# sourceMappingURL=evaluate.js.map
|
package/dist/evaluate.js.map
DELETED
|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.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACnE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.evaluateSync = exports.evaluate = exports.compileSync = exports.compile = exports.createProcessor = void 0;
|
|
3
|
-
var processor_1 = require("./processor");
|
|
4
|
-
Object.defineProperty(exports, "createProcessor", { enumerable: true, get: function () { return processor_1.createProcessor; } });
|
|
5
|
-
var compile_1 = require("./compile");
|
|
6
|
-
Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
|
|
7
|
-
Object.defineProperty(exports, "compileSync", { enumerable: true, get: function () { return compile_1.compileSync; } });
|
|
8
|
-
var evaluate_1 = require("./evaluate");
|
|
9
|
-
Object.defineProperty(exports, "evaluate", { enumerable: true, get: function () { return evaluate_1.evaluate; } });
|
|
10
|
-
Object.defineProperty(exports, "evaluateSync", { enumerable: true, get: function () { return evaluate_1.evaluateSync; } });
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAA6C;AAApC,4GAAA,eAAe,OAAA;AACxB,qCAAgD;AAAvC,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC7B,uCAAmE;AAA1D,oGAAA,QAAQ,OAAA;AAAE,wGAAA,YAAY,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-jsx-build.d.ts","sourceRoot":"","sources":["../../src/plugin/estree-jsx-build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,WAAW,OAAQ,SAAQ,QAAQ;IACvC,YAAY,EAAE,SAAS,GAAG,eAAe,CAAA;CAC1C;AAED,eAAO,MAAM,cAAc,EAAE,MAmC5B,CAAA"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
-
};
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.estreeJsxBuild = void 0;
|
|
6
|
-
const estree_util_build_jsx_1 = __importDefault(require("estree-util-build-jsx"));
|
|
7
|
-
const specifiers_to_object_pattern_1 = __importDefault(require("../estree/specifiers-to-object-pattern"));
|
|
8
|
-
const estreeJsxBuild = (options) => {
|
|
9
|
-
const { outputFormat } = options;
|
|
10
|
-
return (tree) => {
|
|
11
|
-
estree_util_build_jsx_1.default(tree);
|
|
12
|
-
if (outputFormat === 'function-body' &&
|
|
13
|
-
tree.body[0] &&
|
|
14
|
-
tree.body[0].type === 'ImportDeclaration' &&
|
|
15
|
-
typeof tree.body[0].source.value === 'string' &&
|
|
16
|
-
/\/jsx-runtime$/.test(tree.body[0].source.value)) {
|
|
17
|
-
tree.body[0] = {
|
|
18
|
-
type: 'VariableDeclaration',
|
|
19
|
-
kind: 'const',
|
|
20
|
-
declarations: [
|
|
21
|
-
{
|
|
22
|
-
type: 'VariableDeclarator',
|
|
23
|
-
id: specifiers_to_object_pattern_1.default(tree.body[0].specifiers),
|
|
24
|
-
init: {
|
|
25
|
-
type: 'MemberExpression',
|
|
26
|
-
object: { type: 'Identifier', name: 'arguments' },
|
|
27
|
-
property: { type: 'Literal', value: 0 },
|
|
28
|
-
computed: true,
|
|
29
|
-
optional: false,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.estreeJsxBuild = estreeJsxBuild;
|
|
38
|
-
//# sourceMappingURL=estree-jsx-build.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-jsx-build.js","sourceRoot":"","sources":["../../src/plugin/estree-jsx-build.ts"],"names":[],"mappings":";;;;;AAAA,kFAA4C;AAE5C,0GAA8E;AAMvE,MAAM,cAAc,GAAW,CAAC,OAAgB,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;IAEhC,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,+BAAQ,CAAC,IAAI,CAAC,CAAA;QAKd,IACE,YAAY,KAAK,eAAe;YAChC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACZ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB;YACzC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ;YAC7C,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAChD;YACA,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;gBACb,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,OAAO;gBACb,YAAY,EAAE;oBACZ;wBACE,IAAI,EAAE,oBAAoB;wBAC1B,EAAE,EAAE,sCAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;wBACtD,IAAI,EAAE;4BACJ,IAAI,EAAE,kBAAkB;4BACxB,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE;4BACjD,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE;4BACvC,QAAQ,EAAE,IAAI;4BACd,QAAQ,EAAE,KAAK;yBAChB;qBACF;iBACF;aACF,CAAA;SACF;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAnCY,QAAA,cAAc,kBAmC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-jsx-rewrite.d.ts","sourceRoot":"","sources":["../../src/plugin/estree-jsx-rewrite.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,OAAO;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,YAAY,EAAE,SAAS,GAAG,eAAe,CAAA;CAC1C;AAmBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,uBAoOhD"}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
-
};
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.estreeJsxRewrite = void 0;
|
|
6
|
-
const estree_util_is_identifier_name_1 = require("estree-util-is-identifier-name");
|
|
7
|
-
const estree_walker_1 = require("estree-walker");
|
|
8
|
-
const periscopic_1 = require("periscopic");
|
|
9
|
-
const specifiers_to_object_pattern_1 = __importDefault(require("../estree/specifiers-to-object-pattern"));
|
|
10
|
-
function isJSXElement(node) {
|
|
11
|
-
return node.type === 'JSXElement';
|
|
12
|
-
}
|
|
13
|
-
function isFunctionDeclaration(node) {
|
|
14
|
-
return node.type === 'FunctionDeclaration';
|
|
15
|
-
}
|
|
16
|
-
function estreeJsxRewrite(options) {
|
|
17
|
-
const { providerImportSource, outputFormat } = options;
|
|
18
|
-
return (tree) => {
|
|
19
|
-
const topScope = periscopic_1.analyze(tree).scope.declarations;
|
|
20
|
-
const stack = [];
|
|
21
|
-
let importProvider = false;
|
|
22
|
-
estree_walker_1.walk(tree, {
|
|
23
|
-
enter(node) {
|
|
24
|
-
if (node.type === 'FunctionDeclaration' ||
|
|
25
|
-
node.type === 'FunctionExpression' ||
|
|
26
|
-
node.type === 'ArrowFunctionExpression') {
|
|
27
|
-
stack.push({ objects: [], components: [], tags: [] });
|
|
28
|
-
}
|
|
29
|
-
if (isJSXElement(node) && stack.length > 0) {
|
|
30
|
-
const element = node;
|
|
31
|
-
const scope = stack[0];
|
|
32
|
-
let name = node.openingElement.name;
|
|
33
|
-
if (name.type === 'JSXMemberExpression') {
|
|
34
|
-
while (name.type === 'JSXMemberExpression')
|
|
35
|
-
name = name.object;
|
|
36
|
-
if (!scope.objects.includes(name.name) &&
|
|
37
|
-
!topScope.has(name.name)) {
|
|
38
|
-
scope.objects.push(name.name);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (name.type === 'JSXNamespacedName') {
|
|
42
|
-
}
|
|
43
|
-
else if (estree_util_is_identifier_name_1.name(name.name) && !/^[a-z]/.test(name.name)) {
|
|
44
|
-
if (!scope.components.includes(name.name) &&
|
|
45
|
-
!topScope.has(name.name)) {
|
|
46
|
-
scope.components.push(name.name);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (element.data && element.data._xdmExplicitJsx) {
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (!scope.tags.includes(name.name)) {
|
|
53
|
-
scope.tags.push(name.name);
|
|
54
|
-
}
|
|
55
|
-
element.openingElement.name = {
|
|
56
|
-
type: 'JSXMemberExpression',
|
|
57
|
-
object: { type: 'JSXIdentifier', name: '_components' },
|
|
58
|
-
property: name,
|
|
59
|
-
};
|
|
60
|
-
if (element.closingElement) {
|
|
61
|
-
element.closingElement.name = {
|
|
62
|
-
type: 'JSXMemberExpression',
|
|
63
|
-
object: { type: 'JSXIdentifier', name: '_components' },
|
|
64
|
-
property: { type: 'JSXIdentifier', name: name.name },
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
leave(node) {
|
|
71
|
-
const defaults = [];
|
|
72
|
-
const actual = [];
|
|
73
|
-
const parameters = [];
|
|
74
|
-
const declarations = [];
|
|
75
|
-
if (node.type === 'FunctionDeclaration' ||
|
|
76
|
-
node.type === 'FunctionExpression' ||
|
|
77
|
-
node.type === 'ArrowFunctionExpression') {
|
|
78
|
-
const fn = node;
|
|
79
|
-
const scope = stack.pop();
|
|
80
|
-
let name;
|
|
81
|
-
if (!scope)
|
|
82
|
-
throw new Error('Expected scope on stack');
|
|
83
|
-
for (name of scope.tags) {
|
|
84
|
-
defaults.push({
|
|
85
|
-
type: 'Property',
|
|
86
|
-
kind: 'init',
|
|
87
|
-
key: { type: 'Identifier', name },
|
|
88
|
-
value: { type: 'Literal', value: name },
|
|
89
|
-
method: false,
|
|
90
|
-
shorthand: false,
|
|
91
|
-
computed: false,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
actual.push(...scope.components);
|
|
95
|
-
for (name of scope.objects) {
|
|
96
|
-
if (!actual.includes(name)) {
|
|
97
|
-
actual.push(name);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (defaults.length > 0 || actual.length > 0) {
|
|
101
|
-
parameters.push({ type: 'ObjectExpression', properties: defaults });
|
|
102
|
-
if (providerImportSource) {
|
|
103
|
-
importProvider = true;
|
|
104
|
-
parameters.push({
|
|
105
|
-
type: 'CallExpression',
|
|
106
|
-
callee: { type: 'Identifier', name: '_provideComponents' },
|
|
107
|
-
arguments: [],
|
|
108
|
-
optional: false,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (isFunctionDeclaration(fn) &&
|
|
112
|
-
fn.id &&
|
|
113
|
-
fn.id.name === 'OrgaContent') {
|
|
114
|
-
parameters.push({
|
|
115
|
-
type: 'MemberExpression',
|
|
116
|
-
object: { type: 'Identifier', name: 'props' },
|
|
117
|
-
property: { type: 'Identifier', name: 'components' },
|
|
118
|
-
computed: false,
|
|
119
|
-
optional: false,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
declarations.push({
|
|
123
|
-
type: 'VariableDeclarator',
|
|
124
|
-
id: { type: 'Identifier', name: '_components' },
|
|
125
|
-
init: parameters.length > 1
|
|
126
|
-
? {
|
|
127
|
-
type: 'CallExpression',
|
|
128
|
-
callee: {
|
|
129
|
-
type: 'MemberExpression',
|
|
130
|
-
object: { type: 'Identifier', name: 'Object' },
|
|
131
|
-
property: { type: 'Identifier', name: 'assign' },
|
|
132
|
-
computed: false,
|
|
133
|
-
optional: false,
|
|
134
|
-
},
|
|
135
|
-
arguments: parameters,
|
|
136
|
-
optional: false,
|
|
137
|
-
}
|
|
138
|
-
: parameters[0],
|
|
139
|
-
});
|
|
140
|
-
if (actual.length > 0) {
|
|
141
|
-
declarations.push({
|
|
142
|
-
type: 'VariableDeclarator',
|
|
143
|
-
id: {
|
|
144
|
-
type: 'ObjectPattern',
|
|
145
|
-
properties: actual.map((name) => ({
|
|
146
|
-
type: 'Property',
|
|
147
|
-
kind: 'init',
|
|
148
|
-
key: {
|
|
149
|
-
type: 'Identifier',
|
|
150
|
-
name: name === 'OrgaLayout' ? 'wrapper' : name,
|
|
151
|
-
},
|
|
152
|
-
value: { type: 'Identifier', name },
|
|
153
|
-
method: false,
|
|
154
|
-
shorthand: name !== 'OrgaLayout',
|
|
155
|
-
computed: false,
|
|
156
|
-
})),
|
|
157
|
-
},
|
|
158
|
-
init: { type: 'Identifier', name: '_components' },
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (fn.body.type !== 'BlockStatement') {
|
|
162
|
-
fn.body = {
|
|
163
|
-
type: 'BlockStatement',
|
|
164
|
-
body: [{ type: 'ReturnStatement', argument: fn.body }],
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
fn.body.body.unshift({
|
|
168
|
-
type: 'VariableDeclaration',
|
|
169
|
-
kind: 'const',
|
|
170
|
-
declarations,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
if (importProvider && providerImportSource) {
|
|
177
|
-
tree.body.unshift(createImportProvider(providerImportSource, outputFormat));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
exports.estreeJsxRewrite = estreeJsxRewrite;
|
|
182
|
-
function createImportProvider(providerImportSource, outputFormat) {
|
|
183
|
-
const specifiers = [
|
|
184
|
-
{
|
|
185
|
-
type: 'ImportSpecifier',
|
|
186
|
-
imported: { type: 'Identifier', name: 'useOrgaComponents' },
|
|
187
|
-
local: { type: 'Identifier', name: '_provideComponents' },
|
|
188
|
-
},
|
|
189
|
-
];
|
|
190
|
-
return outputFormat === 'function-body'
|
|
191
|
-
? {
|
|
192
|
-
type: 'VariableDeclaration',
|
|
193
|
-
kind: 'const',
|
|
194
|
-
declarations: [
|
|
195
|
-
{
|
|
196
|
-
type: 'VariableDeclarator',
|
|
197
|
-
id: specifiers_to_object_pattern_1.default(specifiers),
|
|
198
|
-
init: {
|
|
199
|
-
type: 'MemberExpression',
|
|
200
|
-
object: { type: 'Identifier', name: 'arguments' },
|
|
201
|
-
property: { type: 'Literal', value: 0 },
|
|
202
|
-
computed: true,
|
|
203
|
-
optional: false,
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
}
|
|
208
|
-
: {
|
|
209
|
-
type: 'ImportDeclaration',
|
|
210
|
-
specifiers,
|
|
211
|
-
source: { type: 'Literal', value: providerImportSource },
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
//# sourceMappingURL=estree-jsx-rewrite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-jsx-rewrite.js","sourceRoot":"","sources":["../../src/plugin/estree-jsx-rewrite.ts"],"names":[],"mappings":";;;;;AAEA,mFAAyE;AACzE,iD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
|
|
1
|
-
{"version":3,"file":"estree-stringify.d.ts","sourceRoot":"","sources":["../../src/plugin/estree-stringify.ts"],"names":[],"mappings":"AAqBA,wBAAgB,eAAe,CAAC,OAAO,KAAK,QAW3C"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.estreeStringify = void 0;
|
|
3
|
-
const astring_1 = require("astring");
|
|
4
|
-
const customGenerator = {
|
|
5
|
-
...astring_1.GENERATOR,
|
|
6
|
-
JSXAttribute,
|
|
7
|
-
JSXClosingElement,
|
|
8
|
-
JSXClosingFragment,
|
|
9
|
-
JSXElement,
|
|
10
|
-
JSXEmptyExpression,
|
|
11
|
-
JSXExpressionContainer,
|
|
12
|
-
JSXFragment,
|
|
13
|
-
JSXIdentifier,
|
|
14
|
-
JSXMemberExpression,
|
|
15
|
-
JSXNamespacedName,
|
|
16
|
-
JSXOpeningElement,
|
|
17
|
-
JSXOpeningFragment,
|
|
18
|
-
JSXSpreadAttribute,
|
|
19
|
-
JSXText,
|
|
20
|
-
};
|
|
21
|
-
function estreeStringify(options = {}) {
|
|
22
|
-
Object.assign(this, { Compiler: compiler });
|
|
23
|
-
function compiler(tree, file) {
|
|
24
|
-
const result = astring_1.generate(tree, {
|
|
25
|
-
generator: customGenerator,
|
|
26
|
-
comments: true,
|
|
27
|
-
});
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.estreeStringify = estreeStringify;
|
|
32
|
-
function JSXAttribute(node, state) {
|
|
33
|
-
this[node.name.type](node.name, state);
|
|
34
|
-
if (node.value !== undefined && node.value !== null) {
|
|
35
|
-
state.write('=');
|
|
36
|
-
if (node.value.type === 'Literal') {
|
|
37
|
-
state.write('"' + encodeJsx(String(node.value.value)).replace(/"/g, '"') + '"');
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this[node.value.type](node.value, state);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function JSXClosingElement(node, state) {
|
|
45
|
-
state.write('</');
|
|
46
|
-
this[node.name.type](node.name, state);
|
|
47
|
-
state.write('>');
|
|
48
|
-
}
|
|
49
|
-
function JSXClosingFragment(node, state) {
|
|
50
|
-
state.write('</>');
|
|
51
|
-
}
|
|
52
|
-
function JSXElement(node, state) {
|
|
53
|
-
let index = -1;
|
|
54
|
-
this[node.openingElement.type](node.openingElement, state);
|
|
55
|
-
if (node.children) {
|
|
56
|
-
while (++index < node.children.length) {
|
|
57
|
-
const child = node.children[index];
|
|
58
|
-
if (child.type === 'JSXSpreadChild') {
|
|
59
|
-
throw new Error('JSX spread children are not supported');
|
|
60
|
-
}
|
|
61
|
-
this[child.type](child, state);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (node.closingElement) {
|
|
65
|
-
this[node.closingElement.type](node.closingElement, state);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function JSXEmptyExpression() { }
|
|
69
|
-
function JSXExpressionContainer(node, state) {
|
|
70
|
-
state.write('{');
|
|
71
|
-
this[node.expression.type](node.expression, state);
|
|
72
|
-
state.write('}');
|
|
73
|
-
}
|
|
74
|
-
function JSXFragment(node, state) {
|
|
75
|
-
let index = -1;
|
|
76
|
-
this[node.openingFragment.type](node.openingFragment, state);
|
|
77
|
-
if (node.children) {
|
|
78
|
-
while (++index < node.children.length) {
|
|
79
|
-
const child = node.children[index];
|
|
80
|
-
if (child.type === 'JSXSpreadChild') {
|
|
81
|
-
throw new Error('JSX spread children are not supported');
|
|
82
|
-
}
|
|
83
|
-
this[child.type](child, state);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
this[node.closingFragment.type](node.closingFragment, state);
|
|
87
|
-
}
|
|
88
|
-
function JSXIdentifier(node, state) {
|
|
89
|
-
state.write(node.name, node);
|
|
90
|
-
}
|
|
91
|
-
function JSXMemberExpression(node, state) {
|
|
92
|
-
this[node.object.type](node.object, state);
|
|
93
|
-
state.write('.');
|
|
94
|
-
this[node.property.type](node.property, state);
|
|
95
|
-
}
|
|
96
|
-
function JSXNamespacedName(node, state) {
|
|
97
|
-
this[node.namespace.type](node.namespace, state);
|
|
98
|
-
state.write(':');
|
|
99
|
-
this[node.name.type](node.name, state);
|
|
100
|
-
}
|
|
101
|
-
function JSXOpeningElement(node, state) {
|
|
102
|
-
let index = -1;
|
|
103
|
-
state.write('<');
|
|
104
|
-
this[node.name.type](node.name, state);
|
|
105
|
-
if (node.attributes) {
|
|
106
|
-
while (++index < node.attributes.length) {
|
|
107
|
-
state.write(' ');
|
|
108
|
-
this[node.attributes[index].type](node.attributes[index], state);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
state.write(node.selfClosing ? ' />' : '>');
|
|
112
|
-
}
|
|
113
|
-
function JSXOpeningFragment(node, state) {
|
|
114
|
-
state.write('<>', node);
|
|
115
|
-
}
|
|
116
|
-
function JSXSpreadAttribute(node, state) {
|
|
117
|
-
state.write('{');
|
|
118
|
-
this.SpreadElement(node, state);
|
|
119
|
-
state.write('}');
|
|
120
|
-
}
|
|
121
|
-
function JSXText(node, state) {
|
|
122
|
-
state.write(encodeJsx(node.value).replace(/<|{/g, ($0) => $0 === '<' ? '<' : '{'), node);
|
|
123
|
-
}
|
|
124
|
-
function encodeJsx(value) {
|
|
125
|
-
return value.replace(/&(?=[#a-z])/gi, '&');
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=estree-stringify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-stringify.js","sourceRoot":"","sources":["../../src/plugin/estree-stringify.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AAGpD,MAAM,eAAe,GAAG;IACtB,GAAG,mBAAS;IACZ,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,kBAAkB;IAClB,sBAAsB;IACtB,WAAW;IACX,aAAa;IACb,mBAAmB;IACnB,iBAAiB;IACjB,iBAAiB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CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAC3C,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAC/B,EACD,IAAI,CACL,CAAA;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAK;IACtB,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Options {
|
|
2
|
-
baseUrl?: string;
|
|
3
|
-
useDynamicImport: boolean;
|
|
4
|
-
outputFormat: 'program' | 'function-body';
|
|
5
|
-
pragma: {
|
|
6
|
-
name: string;
|
|
7
|
-
source: string;
|
|
8
|
-
};
|
|
9
|
-
pragmaFrag: {
|
|
10
|
-
name: string;
|
|
11
|
-
source: string;
|
|
12
|
-
};
|
|
13
|
-
jsxImportSource: string;
|
|
14
|
-
jsxRuntime: 'automatic' | 'classic';
|
|
15
|
-
passNamedExportsToLayout: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare function estreeWrapInContent(options: Options): (tree: any, file: any) => void;
|
|
18
|
-
//# sourceMappingURL=estree-wrap-in-content.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estree-wrap-in-content.d.ts","sourceRoot":"","sources":["../../src/plugin/estree-wrap-in-content.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,OAAO,CAAA;IACzB,YAAY,EAAE,SAAS,GAAG,eAAe,CAAA;IACzC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAA;IACnC,wBAAwB,EAAE,OAAO,CAAA;CAClC;AAuBD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,kCAmdnD"}
|