@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.
Files changed (113) hide show
  1. package/LICENSE.org +22 -0
  2. package/dist/index.d.ts +11 -5
  3. package/dist/lib/compile.d.ts +45 -0
  4. package/dist/lib/condition.browser.d.ts +1 -0
  5. package/dist/lib/condition.d.ts +1 -0
  6. package/dist/lib/core.d.ts +57 -0
  7. package/dist/lib/evaluate.d.ts +27 -0
  8. package/dist/lib/plugin/recma-document.d.ts +63 -0
  9. package/dist/lib/plugin/recma-jsx-build.d.ts +14 -0
  10. package/dist/lib/plugin/recma-jsx-rewrite.d.ts +50 -0
  11. package/dist/lib/plugin/recma-stringify.d.ts +13 -0
  12. package/dist/lib/plugin/rehype-recma.d.ts +49 -0
  13. package/dist/lib/run.d.ts +26 -0
  14. package/dist/lib/util/estree-util-create.d.ts +13 -0
  15. package/dist/lib/util/estree-util-declaration-to-expression.d.ts +19 -0
  16. package/dist/lib/util/estree-util-is-declaration.d.ts +15 -0
  17. package/dist/lib/util/estree-util-specifiers-to-declarations.d.ts +14 -0
  18. package/dist/lib/util/estree-util-to-binary-addition.d.ts +8 -0
  19. package/dist/lib/util/estree-util-to-id-or-member-expression.d.ts +11 -0
  20. package/dist/lib/util/render-error.d.ts +2 -0
  21. package/dist/lib/util/resolve-evaluate-options.d.ts +66 -0
  22. package/dist/lib/util/resolve-file-and-options.d.ts +16 -0
  23. package/index.js +14 -0
  24. package/lib/compile.js +54 -0
  25. package/lib/condition.browser.js +1 -0
  26. package/lib/condition.js +3 -0
  27. package/lib/core.js +100 -0
  28. package/lib/evaluate.js +41 -0
  29. package/lib/plugin/recma-document.js +607 -0
  30. package/lib/plugin/recma-jsx-build.js +53 -0
  31. package/lib/plugin/recma-jsx-rewrite.js +616 -0
  32. package/lib/plugin/recma-stringify.js +42 -0
  33. package/lib/plugin/rehype-recma.js +218 -0
  34. package/lib/run.js +31 -0
  35. package/lib/types.d.ts +46 -0
  36. package/lib/util/estree-util-create.js +27 -0
  37. package/lib/util/estree-util-declaration-to-expression.js +32 -0
  38. package/lib/util/estree-util-is-declaration.js +20 -0
  39. package/lib/util/estree-util-specifiers-to-declarations.js +90 -0
  40. package/lib/util/estree-util-to-binary-addition.js +23 -0
  41. package/lib/util/estree-util-to-id-or-member-expression.js +108 -0
  42. package/lib/util/render-error.js +91 -0
  43. package/lib/util/resolve-evaluate-options.js +64 -0
  44. package/lib/util/resolve-file-and-options.js +40 -0
  45. package/package.json +36 -29
  46. package/CHANGELOG.md +0 -71
  47. package/dist/compile.d.ts +0 -6
  48. package/dist/compile.d.ts.map +0 -1
  49. package/dist/compile.js +0 -12
  50. package/dist/compile.js.map +0 -1
  51. package/dist/estree/create.d.ts +0 -2
  52. package/dist/estree/create.d.ts.map +0 -1
  53. package/dist/estree/create.js +0 -14
  54. package/dist/estree/create.js.map +0 -1
  55. package/dist/estree/declaration-to-expression.d.ts +0 -3
  56. package/dist/estree/declaration-to-expression.d.ts.map +0 -1
  57. package/dist/estree/declaration-to-expression.js +0 -12
  58. package/dist/estree/declaration-to-expression.js.map +0 -1
  59. package/dist/estree/error.d.ts +0 -61
  60. package/dist/estree/error.d.ts.map +0 -1
  61. package/dist/estree/error.js +0 -87
  62. package/dist/estree/error.js.map +0 -1
  63. package/dist/estree/is-declaration.d.ts +0 -3
  64. package/dist/estree/is-declaration.d.ts.map +0 -1
  65. package/dist/estree/is-declaration.js +0 -9
  66. package/dist/estree/is-declaration.js.map +0 -1
  67. package/dist/estree/position-from-estree.d.ts +0 -13
  68. package/dist/estree/position-from-estree.d.ts.map +0 -1
  69. package/dist/estree/position-from-estree.js +0 -34
  70. package/dist/estree/position-from-estree.js.map +0 -1
  71. package/dist/estree/specifiers-to-object-pattern.d.ts +0 -5
  72. package/dist/estree/specifiers-to-object-pattern.d.ts.map +0 -1
  73. package/dist/estree/specifiers-to-object-pattern.js +0 -33
  74. package/dist/estree/specifiers-to-object-pattern.js.map +0 -1
  75. package/dist/evaluate.d.ts +0 -22
  76. package/dist/evaluate.d.ts.map +0 -1
  77. package/dist/evaluate.js +0 -27
  78. package/dist/evaluate.js.map +0 -1
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/index.js +0 -11
  81. package/dist/index.js.map +0 -1
  82. package/dist/plugin/estree-jsx-build.d.ts +0 -6
  83. package/dist/plugin/estree-jsx-build.d.ts.map +0 -1
  84. package/dist/plugin/estree-jsx-build.js +0 -38
  85. package/dist/plugin/estree-jsx-build.js.map +0 -1
  86. package/dist/plugin/estree-jsx-rewrite.d.ts +0 -6
  87. package/dist/plugin/estree-jsx-rewrite.d.ts.map +0 -1
  88. package/dist/plugin/estree-jsx-rewrite.js +0 -214
  89. package/dist/plugin/estree-jsx-rewrite.js.map +0 -1
  90. package/dist/plugin/estree-stringify.d.ts +0 -2
  91. package/dist/plugin/estree-stringify.d.ts.map +0 -1
  92. package/dist/plugin/estree-stringify.js +0 -127
  93. package/dist/plugin/estree-stringify.js.map +0 -1
  94. package/dist/plugin/estree-wrap-in-content.d.ts +0 -18
  95. package/dist/plugin/estree-wrap-in-content.d.ts.map +0 -1
  96. package/dist/plugin/estree-wrap-in-content.js +0 -375
  97. package/dist/plugin/estree-wrap-in-content.js.map +0 -1
  98. package/dist/plugin/rehype-estree.d.ts +0 -12
  99. package/dist/plugin/rehype-estree.d.ts.map +0 -1
  100. package/dist/plugin/rehype-estree.js +0 -122
  101. package/dist/plugin/rehype-estree.js.map +0 -1
  102. package/dist/plugin/rehype-set-layout.d.ts +0 -6
  103. package/dist/plugin/rehype-set-layout.d.ts.map +0 -1
  104. package/dist/plugin/rehype-set-layout.js +0 -30
  105. package/dist/plugin/rehype-set-layout.js.map +0 -1
  106. package/dist/processor.d.ts +0 -14
  107. package/dist/processor.d.ts.map +0 -1
  108. package/dist/processor.js +0 -52
  109. package/dist/processor.js.map +0 -1
  110. package/dist/utils/remove-quotes.d.ts +0 -3
  111. package/dist/utils/remove-quotes.d.ts.map +0 -1
  112. package/dist/utils/remove-quotes.js +0 -6
  113. package/dist/utils/remove-quotes.js.map +0 -1
@@ -1,375 +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.estreeWrapInContent = void 0;
6
- const periscopic_1 = require("periscopic");
7
- const unist_util_stringify_position_1 = __importDefault(require("unist-util-stringify-position"));
8
- const url_1 = require("url");
9
- const create_1 = __importDefault(require("../estree/create"));
10
- const declaration_to_expression_1 = __importDefault(require("../estree/declaration-to-expression"));
11
- const is_declaration_1 = __importDefault(require("../estree/is-declaration"));
12
- const position_from_estree_1 = __importDefault(require("../estree/position-from-estree"));
13
- const specifiers_to_object_pattern_1 = __importDefault(require("../estree/specifiers-to-object-pattern"));
14
- function mergeImports(imports) {
15
- const map = imports.reduce((all, current) => {
16
- if (typeof current.source.value !== 'string') {
17
- throw new Error(`expecting source value to be string, got ${current.source.value}`);
18
- }
19
- if (!all[current.source.value]) {
20
- all[current.source.value] = current;
21
- }
22
- else {
23
- all[current.source.value].specifiers.push(...current.specifiers);
24
- }
25
- return all;
26
- }, {});
27
- return Object.values(map);
28
- }
29
- function estreeWrapInContent(options) {
30
- const { baseUrl, outputFormat, useDynamicImport, jsxRuntime, pragma, pragmaFrag, jsxImportSource, passNamedExportsToLayout, } = options;
31
- const pragmas = [];
32
- let content;
33
- let exportAllCount = 0;
34
- let layout;
35
- const exportedIdentifiers = [];
36
- const replacement = [];
37
- return (tree, file) => {
38
- const program = tree;
39
- if (!tree.comments)
40
- tree.comments = [];
41
- if (jsxRuntime) {
42
- pragmas.push('@jsxRuntime ' + jsxRuntime);
43
- }
44
- if (jsxRuntime === 'automatic' && jsxImportSource) {
45
- pragmas.push('@jsxImportSource ' + jsxImportSource);
46
- }
47
- if (jsxRuntime === 'classic' && pragma) {
48
- pragmas.push('@jsx ' + pragma.name);
49
- }
50
- if (jsxRuntime === 'classic' && pragmaFrag) {
51
- if (pragmaFrag) {
52
- pragmas.push('@jsxFrag ' + pragmaFrag.name);
53
- }
54
- }
55
- if (pragmas.length > 0) {
56
- tree.comments.unshift({ type: 'Block', value: pragmas.join(' ') });
57
- }
58
- if (jsxRuntime === 'classic') {
59
- const imports = [pragma, pragmaFrag].map(({ name, source }) => ({
60
- type: 'ImportDeclaration',
61
- specifiers: [
62
- {
63
- type: 'ImportSpecifier',
64
- imported: { type: 'Identifier', name },
65
- local: { type: 'Identifier', name },
66
- },
67
- ],
68
- source: { type: 'Literal', value: source },
69
- }));
70
- mergeImports(imports).forEach(handleEsm);
71
- }
72
- for (const child of program.body) {
73
- if (child.type === 'ExportDefaultDeclaration') {
74
- if (layout) {
75
- file.fail('Cannot specify multiple layouts (previous: ' +
76
- unist_util_stringify_position_1.default(position_from_estree_1.default(layout)) +
77
- ')', position_from_estree_1.default(child), 'recma-document:duplicate-layout');
78
- }
79
- layout = child;
80
- replacement.push({
81
- type: 'VariableDeclaration',
82
- kind: 'const',
83
- declarations: [
84
- {
85
- type: 'VariableDeclarator',
86
- id: { type: 'Identifier', name: 'OrgaLayout' },
87
- init: is_declaration_1.default(child.declaration)
88
- ? declaration_to_expression_1.default(child.declaration)
89
- : child.declaration,
90
- },
91
- ],
92
- });
93
- }
94
- else if (child.type === 'ExportNamedDeclaration' && child.source) {
95
- const source = child.source;
96
- child.specifiers = child.specifiers.filter((specifier) => {
97
- if (specifier.exported.name === 'default') {
98
- if (layout) {
99
- file.fail('Cannot specify multiple layouts (previous: ' +
100
- unist_util_stringify_position_1.default(position_from_estree_1.default(layout)) +
101
- ')', position_from_estree_1.default(child), 'recma-document:duplicate-layout');
102
- }
103
- layout = specifier;
104
- handleEsm(create_1.default(specifier, {
105
- type: 'ImportDeclaration',
106
- specifiers: [
107
- specifier.local.name === 'default'
108
- ? {
109
- type: 'ImportDefaultSpecifier',
110
- local: { type: 'Identifier', name: 'OrgaLayout' },
111
- }
112
- : create_1.default(specifier.local, {
113
- type: 'ImportSpecifier',
114
- imported: specifier.local,
115
- local: { type: 'Identifier', name: 'OrgaLayout' },
116
- }),
117
- ],
118
- source: create_1.default(source, {
119
- type: 'Literal',
120
- value: source.value,
121
- }),
122
- }));
123
- return false;
124
- }
125
- return true;
126
- });
127
- if (child.specifiers.length > 0) {
128
- handleExport(child);
129
- }
130
- }
131
- else if (child.type === 'ExportNamedDeclaration' ||
132
- child.type === 'ExportAllDeclaration') {
133
- handleExport(child);
134
- }
135
- else if (child.type === 'ImportDeclaration') {
136
- handleEsm(child);
137
- }
138
- else if (child.type === 'ExpressionStatement' &&
139
- (child.expression.type === 'JSXFragment' ||
140
- child.expression.type === 'JSXElement')) {
141
- content = true;
142
- replacement.push(createOrgaContent(child.expression));
143
- }
144
- else {
145
- replacement.push(child);
146
- }
147
- }
148
- if (!content) {
149
- replacement.push(createOrgaContent());
150
- }
151
- exportedIdentifiers.push(['OrgaContent', 'default']);
152
- if (outputFormat === 'function-body') {
153
- replacement.push({
154
- type: 'ReturnStatement',
155
- argument: {
156
- type: 'ObjectExpression',
157
- properties: [
158
- ...Array.from({ length: exportAllCount }).map((_, index) => ({
159
- type: 'SpreadElement',
160
- argument: {
161
- type: 'Identifier',
162
- name: '_exportAll' + (index + 1),
163
- },
164
- })),
165
- ...exportedIdentifiers.map((d) => {
166
- const prop = {
167
- type: 'Property',
168
- kind: 'init',
169
- method: false,
170
- computed: false,
171
- shorthand: typeof d === 'string',
172
- key: {
173
- type: 'Identifier',
174
- name: typeof d === 'string' ? d : d[1],
175
- },
176
- value: {
177
- type: 'Identifier',
178
- name: typeof d === 'string' ? d : d[0],
179
- },
180
- };
181
- return prop;
182
- }),
183
- ],
184
- },
185
- });
186
- }
187
- else {
188
- replacement.push({
189
- type: 'ExportDefaultDeclaration',
190
- declaration: { type: 'Identifier', name: 'OrgaContent' },
191
- });
192
- }
193
- program.body = replacement;
194
- function handleExport(node) {
195
- if (node.type === 'ExportNamedDeclaration') {
196
- if (node.declaration) {
197
- exportedIdentifiers.push(...periscopic_1.analyze(node.declaration).scope.declarations.keys());
198
- }
199
- for (const child of node.specifiers) {
200
- exportedIdentifiers.push(child.exported.name);
201
- }
202
- }
203
- handleEsm(node);
204
- }
205
- function handleEsm(node) {
206
- if (baseUrl && node.source) {
207
- let value = String(node.source.value);
208
- try {
209
- value = String(new url_1.URL(value));
210
- }
211
- catch {
212
- if (/^\.{0,2}\//.test(value)) {
213
- value = String(new url_1.URL(value, baseUrl));
214
- }
215
- }
216
- node.source = create_1.default(node.source, { type: 'Literal', value });
217
- }
218
- let replace;
219
- let init;
220
- if (outputFormat === 'function-body') {
221
- if (node.type === 'ImportDeclaration' ||
222
- node.type === 'ExportAllDeclaration' ||
223
- (node.type === 'ExportNamedDeclaration' && node.source)) {
224
- if (!useDynamicImport) {
225
- file.fail('Cannot use `import` or `export … from` in `evaluate` (outputting a function body) by default: please set `useDynamicImport: true` (and probably specify a `baseUrl`)', position_from_estree_1.default(node), 'recma-document:invalid-esm-statement');
226
- }
227
- if (!node.source) {
228
- throw new Error('Expected `node.source` to be defined');
229
- }
230
- init = {
231
- type: 'AwaitExpression',
232
- argument: create_1.default(node, {
233
- type: 'ImportExpression',
234
- source: node.source,
235
- }),
236
- };
237
- if ((node.type === 'ImportDeclaration' ||
238
- node.type === 'ExportNamedDeclaration') &&
239
- node.specifiers.length === 0) {
240
- replace = { type: 'ExpressionStatement', expression: init };
241
- }
242
- else {
243
- replace = {
244
- type: 'VariableDeclaration',
245
- kind: 'const',
246
- declarations: [
247
- {
248
- type: 'VariableDeclarator',
249
- id: node.type === 'ImportDeclaration' ||
250
- node.type === 'ExportNamedDeclaration'
251
- ? specifiers_to_object_pattern_1.default(node.specifiers)
252
- : {
253
- type: 'Identifier',
254
- name: '_exportAll' + ++exportAllCount,
255
- },
256
- init,
257
- },
258
- ],
259
- };
260
- }
261
- }
262
- else if (node.declaration) {
263
- replace = node.declaration;
264
- }
265
- else {
266
- const declarators = node.specifiers
267
- .filter((specifier) => specifier.local.name !== specifier.exported.name)
268
- .map((specifier) => ({
269
- type: 'VariableDeclarator',
270
- id: specifier.exported,
271
- init: specifier.local,
272
- }));
273
- if (declarators.length > 0) {
274
- replace = {
275
- type: 'VariableDeclaration',
276
- kind: 'const',
277
- declarations: declarators,
278
- };
279
- }
280
- }
281
- }
282
- else {
283
- replace = node;
284
- }
285
- if (replace) {
286
- replacement.push(replace);
287
- }
288
- }
289
- };
290
- function createOrgaContent(content = undefined) {
291
- const props = [];
292
- const inject = (name) => {
293
- props.push({
294
- type: 'JSXAttribute',
295
- name: {
296
- type: 'JSXIdentifier',
297
- name,
298
- },
299
- value: {
300
- type: 'JSXExpressionContainer',
301
- expression: { type: 'Identifier', name },
302
- },
303
- });
304
- };
305
- if (passNamedExportsToLayout) {
306
- exportedIdentifiers.forEach((id) => {
307
- (typeof id === 'string' ? [id] : id).forEach(inject);
308
- });
309
- }
310
- const element = {
311
- type: 'JSXElement',
312
- openingElement: {
313
- type: 'JSXOpeningElement',
314
- name: { type: 'JSXIdentifier', name: 'OrgaLayout' },
315
- attributes: [
316
- ...props,
317
- {
318
- type: 'JSXSpreadAttribute',
319
- argument: { type: 'Identifier', name: 'props' },
320
- },
321
- ],
322
- selfClosing: false,
323
- },
324
- closingElement: {
325
- type: 'JSXClosingElement',
326
- name: { type: 'JSXIdentifier', name: 'OrgaLayout' },
327
- },
328
- children: [
329
- {
330
- type: 'JSXExpressionContainer',
331
- expression: { type: 'Identifier', name: '_content' },
332
- },
333
- ],
334
- };
335
- const consequent = element;
336
- return {
337
- type: 'FunctionDeclaration',
338
- id: { type: 'Identifier', name: 'OrgaContent' },
339
- params: [
340
- {
341
- type: 'AssignmentPattern',
342
- left: { type: 'Identifier', name: 'props' },
343
- right: { type: 'ObjectExpression', properties: [] },
344
- },
345
- ],
346
- body: {
347
- type: 'BlockStatement',
348
- body: [
349
- {
350
- type: 'VariableDeclaration',
351
- kind: 'const',
352
- declarations: [
353
- {
354
- type: 'VariableDeclarator',
355
- id: { type: 'Identifier', name: '_content' },
356
- init: content || { type: 'Literal', value: null },
357
- },
358
- ],
359
- },
360
- {
361
- type: 'ReturnStatement',
362
- argument: {
363
- type: 'ConditionalExpression',
364
- test: { type: 'Identifier', name: 'OrgaLayout' },
365
- consequent,
366
- alternate: { type: 'Identifier', name: '_content' },
367
- },
368
- },
369
- ],
370
- },
371
- };
372
- }
373
- }
374
- exports.estreeWrapInContent = estreeWrapInContent;
375
- //# sourceMappingURL=estree-wrap-in-content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estree-wrap-in-content.js","sourceRoot":"","sources":["../../src/plugin/estree-wrap-in-content.ts"],"names":[],"mappings":";;;;;AAcA,2CAAoC;AACpC,kGAA6D;AAC7D,6BAAyB;AACzB,8DAAqC;AACrC,oGAAyE;AACzE,8EAAoD;AACpD,0FAA+D;AAC/D,0GAA8E;AAa9E,SAAS,YAAY,CAAC,OAA4B;IAChD,MAAM,GAAG,GAAsC,OAAO,CAAC,MAAM,CAC3D,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACf,IAAI,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE;YAC5C,MAAM,IAAI,KAAK,CACb,4CAA4C,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CACnE,CAAA;SACF;QACD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC9B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAA;SACpC;aAAM;YACL,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;SACjE;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,EAAuC,CACxC,CAAA;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;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IAAI,EAAE,YAAY,EAAE;4BAChD,UAAU;4BACV,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE;yBACpD;qBACF;iBACF;aACF;SACF,CAAA;IACH,CAAC;AACH,CAAC;AAndD,kDAmdC"}
@@ -1,12 +0,0 @@
1
- import { BaseExpression } from 'estree-jsx';
2
- import { Node as HastNode } from 'hast';
3
- import type { Plugin } from 'unified';
4
- export declare type Handler = (node: HastNode, context: any) => BaseExpression | BaseExpression[];
5
- export declare type Options = {
6
- space: 'html' | 'svg';
7
- parseJSX: string[];
8
- skipImport: boolean;
9
- handlers: Record<string, Handler>;
10
- };
11
- export declare const rehypeEstree: Plugin;
12
- //# sourceMappingURL=rehype-estree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rehype-estree.d.ts","sourceRoot":"","sources":["../../src/plugin/rehype-estree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAgC,MAAM,YAAY,CAAA;AACzE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAQ,MAAM,MAAM,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAkBrC,oBAAY,OAAO,GAAG,CACpB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,GAAG,KACT,cAAc,GAAG,cAAc,EAAE,CAAA;AAStC,oBAAY,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAA;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,MAyG1B,CAAA"}
@@ -1,122 +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.rehypeEstree = void 0;
6
- const acorn_1 = require("acorn");
7
- const acorn_jsx_1 = __importDefault(require("acorn-jsx"));
8
- const hast_util_to_estree_1 = __importDefault(require("hast-util-to-estree"));
9
- const error_1 = __importDefault(require("../estree/error"));
10
- const remove_quotes_1 = __importDefault(require("../utils/remove-quotes"));
11
- const deepGet = (p) => (o) => p.split('.').reduce((a, v) => a[v], o);
12
- const parse = (code) => {
13
- try {
14
- return acorn_1.Parser.extend(acorn_jsx_1.default()).parse(code, {
15
- sourceType: 'module',
16
- ecmaVersion: 2020,
17
- });
18
- }
19
- catch (err) {
20
- return error_1.default(err);
21
- }
22
- };
23
- const defaultOptions = {
24
- space: 'html',
25
- parseJSX: ['jsx.value'],
26
- skipImport: false,
27
- handlers: {},
28
- };
29
- const rehypeEstree = (options) => {
30
- const { space, parseJSX, skipImport, handlers } = options;
31
- for (const p of parseJSX) {
32
- const [key, ...rest] = p.split('.');
33
- if (!key) {
34
- throw new Error('somethings wrong');
35
- }
36
- const path = rest.length > 0 ? rest.join('.') : 'value';
37
- const getJSXHandler = ({ path, skipImport, }) => {
38
- const handler = (node, context) => {
39
- const estree = parse(deepGet(path)(node));
40
- const expressions = [];
41
- estree.body.forEach((child) => {
42
- if (child.type === 'ImportDeclaration') {
43
- if (!skipImport) {
44
- context.esm.push(child);
45
- }
46
- return false;
47
- }
48
- else if (child.type === 'ExpressionStatement') {
49
- expressions.push(child.expression);
50
- }
51
- else if (child.type === 'ExportDefaultDeclaration' ||
52
- child.type === 'ExportNamedDeclaration') {
53
- context.esm.push(child);
54
- }
55
- else {
56
- throw new Error(`unexpected node: ${child.type}`);
57
- }
58
- });
59
- return expressions;
60
- };
61
- return handler;
62
- };
63
- handlers[key] = getJSXHandler({ path, skipImport });
64
- }
65
- return (tree) => {
66
- const data = tree.data || {};
67
- const estree = hast_util_to_estree_1.default(tree, { space, handlers });
68
- const prepand = [];
69
- const { layout, ...rest } = data;
70
- if (typeof layout === 'string') {
71
- prepand.push({
72
- type: 'ImportDeclaration',
73
- specifiers: [
74
- {
75
- type: 'ImportDefaultSpecifier',
76
- local: {
77
- type: 'Identifier',
78
- name: 'OrgaLayout',
79
- },
80
- },
81
- ],
82
- source: {
83
- type: 'Literal',
84
- value: `${layout}`,
85
- raw: `'${layout}'`,
86
- },
87
- });
88
- }
89
- Object.entries(rest).forEach(([k, v]) => {
90
- const createLiteral = (text) => {
91
- const value = remove_quotes_1.default(`${text}`);
92
- return { type: 'Literal', value, raw: `'${value}'` };
93
- };
94
- const init = Array.isArray(v)
95
- ? {
96
- type: 'ArrayExpression',
97
- elements: v.map(createLiteral),
98
- }
99
- : createLiteral(v);
100
- prepand.push({
101
- type: 'ExportNamedDeclaration',
102
- declaration: {
103
- type: 'VariableDeclaration',
104
- declarations: [
105
- {
106
- type: 'VariableDeclarator',
107
- id: { type: 'Identifier', name: k },
108
- init,
109
- },
110
- ],
111
- kind: 'const',
112
- },
113
- specifiers: [],
114
- source: null,
115
- });
116
- });
117
- estree.body.unshift(...prepand);
118
- return estree;
119
- };
120
- };
121
- exports.rehypeEstree = rehypeEstree;
122
- //# sourceMappingURL=rehype-estree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rehype-estree.js","sourceRoot":"","sources":["../../src/plugin/rehype-estree.ts"],"names":[],"mappings":";;;;;AAAA,iCAA8B;AAC9B,0DAA2B;AAG3B,8EAA0C;AAE1C,4DAAyC;AACzC,2EAAiD;AAEjD,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAM,EAAE,EAAE,CACxC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAExC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;IAC7B,IAAI;QACF,OAAO,cAAM,CAAC,MAAM,CAAC,mBAAG,EAAE,CAAC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}
@@ -1,6 +0,0 @@
1
- import type { Plugin, Settings } from 'unified';
2
- export interface Options extends Settings {
3
- defaultLayout?: string;
4
- }
5
- export declare const rehypeSetLayout: Plugin;
6
- //# sourceMappingURL=rehype-set-layout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rehype-set-layout.d.ts","sourceRoot":"","sources":["../../src/plugin/rehype-set-layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,WAAW,OAAQ,SAAQ,QAAQ;IACvC,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,eAAe,EAAE,MAqB7B,CAAA"}
@@ -1,30 +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.rehypeSetLayout = void 0;
6
- const remove_quotes_1 = __importDefault(require("../utils/remove-quotes"));
7
- const rehypeSetLayout = (options) => {
8
- const { defaultLayout } = options;
9
- return (tree) => {
10
- const { layout } = tree.data;
11
- if (layout && typeof layout === 'string') {
12
- const _layout = remove_quotes_1.default(layout).trim();
13
- switch (_layout) {
14
- case 'nil':
15
- case 'null':
16
- case 'undefined':
17
- case '':
18
- tree.data.layout = undefined;
19
- break;
20
- default:
21
- tree.data.layout = _layout;
22
- }
23
- }
24
- else if (defaultLayout) {
25
- tree.data.layout = defaultLayout;
26
- }
27
- };
28
- };
29
- exports.rehypeSetLayout = rehypeSetLayout;
30
- //# sourceMappingURL=rehype-set-layout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rehype-set-layout.js","sourceRoot":"","sources":["../../src/plugin/rehype-set-layout.ts"],"names":[],"mappings":";;;;;AACA,2EAAiD;AAM1C,MAAM,eAAe,GAAW,CAAC,OAAgB,EAAE,EAAE;IAC1D,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;IACjC,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAA;QAE5B,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YACxC,MAAM,OAAO,GAAG,uBAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;YAC3C,QAAQ,OAAO,EAAE;gBACf,KAAK,KAAK,CAAC;gBACX,KAAK,MAAM,CAAC;gBACZ,KAAK,WAAW,CAAC;gBACjB,KAAK,EAAE;oBACL,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;oBAC5B,MAAK;gBACP;oBACE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAA;aAC7B;SACF;aAAM,IAAI,aAAa,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAA;SACjC;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,eAAe,mBAqB3B"}
@@ -1,14 +0,0 @@
1
- import unified, { PluggableList } from 'unified';
2
- import { Options as EstreeJsxBuildOptions } from './plugin/estree-jsx-build';
3
- import { Options as JSXRewriteOptions } from './plugin/estree-jsx-rewrite';
4
- import { Options as EstreeWrapInContentOptions } from './plugin/estree-wrap-in-content';
5
- import { Options as RehypeEstreeOptions } from './plugin/rehype-estree';
6
- import { Options as RehypeSetLayoutOptions } from './plugin/rehype-set-layout';
7
- export interface ProcessorOptions extends RehypeEstreeOptions, EstreeWrapInContentOptions, JSXRewriteOptions, RehypeSetLayoutOptions, EstreeJsxBuildOptions {
8
- jsx: boolean;
9
- reorgPlugins: PluggableList;
10
- rehypePlugins: PluggableList;
11
- estreePlugins: PluggableList;
12
- }
13
- export declare function createProcessor(processorOptions?: Partial<ProcessorOptions>): unified.Processor<unified.Settings>;
14
- //# sourceMappingURL=processor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAEL,OAAO,IAAI,qBAAqB,EACjC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAEL,OAAO,IAAI,iBAAiB,EAC7B,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAEL,OAAO,IAAI,0BAA0B,EACtC,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACL,OAAO,IAAI,mBAAmB,EAE/B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,OAAO,IAAI,sBAAsB,EAElC,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,gBACf,SAAQ,mBAAmB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB;IACvB,GAAG,EAAE,OAAO,CAAA;IACZ,YAAY,EAAE,aAAa,CAAA;IAC3B,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,EAAE,aAAa,CAAA;CAC7B;AAyBD,wBAAgB,eAAe,CAC7B,gBAAgB,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAC/C,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAoBrC"}
package/dist/processor.js DELETED
@@ -1,52 +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.createProcessor = void 0;
6
- const reorg_parse_1 = __importDefault(require("@orgajs/reorg-parse"));
7
- const reorg_rehype_1 = __importDefault(require("@orgajs/reorg-rehype"));
8
- const unified_1 = __importDefault(require("unified"));
9
- const estree_jsx_build_1 = require("./plugin/estree-jsx-build");
10
- const estree_jsx_rewrite_1 = require("./plugin/estree-jsx-rewrite");
11
- const estree_stringify_1 = require("./plugin/estree-stringify");
12
- const estree_wrap_in_content_1 = require("./plugin/estree-wrap-in-content");
13
- const rehype_estree_1 = require("./plugin/rehype-estree");
14
- const rehype_set_layout_1 = require("./plugin/rehype-set-layout");
15
- const defaultOptions = {
16
- jsx: false,
17
- reorgPlugins: [],
18
- rehypePlugins: [],
19
- estreePlugins: [],
20
- outputFormat: 'program',
21
- space: 'html',
22
- parseJSX: ['jsx.value'],
23
- skipImport: false,
24
- handlers: {},
25
- baseUrl: undefined,
26
- useDynamicImport: false,
27
- pragma: { name: 'createElement', source: 'react' },
28
- pragmaFrag: { name: 'Fragment', source: 'react' },
29
- jsxImportSource: 'react',
30
- jsxRuntime: 'automatic',
31
- passNamedExportsToLayout: true,
32
- };
33
- function createProcessor(processorOptions = {}) {
34
- const { jsx, ...options } = { ...defaultOptions, ...processorOptions };
35
- const pipeline = unified_1.default()
36
- .use(reorg_parse_1.default)
37
- .use(options.reorgPlugins)
38
- .use(reorg_rehype_1.default)
39
- .use(rehype_set_layout_1.rehypeSetLayout, options)
40
- .use(options.rehypePlugins)
41
- .use(rehype_estree_1.rehypeEstree, options)
42
- .use(estree_wrap_in_content_1.estreeWrapInContent, options)
43
- .use(options.estreePlugins)
44
- .use(estree_jsx_rewrite_1.estreeJsxRewrite, options);
45
- if (!jsx) {
46
- pipeline.use(estree_jsx_build_1.estreeJsxBuild, options);
47
- }
48
- pipeline.use(estree_stringify_1.estreeStringify);
49
- return pipeline;
50
- }
51
- exports.createProcessor = createProcessor;
52
- //# sourceMappingURL=processor.js.map