@mojir/lits 2.6.1 → 2.6.3

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/dist/cli/cli.js CHANGED
@@ -7,7 +7,7 @@ var readline = require('node:readline');
7
7
  var os = require('node:os');
8
8
  var process$1 = require('node:process');
9
9
 
10
- var version = "2.6.1";
10
+ var version = "2.6.3";
11
11
 
12
12
  function getCodeMarker(sourceCodeInfo) {
13
13
  if (!sourceCodeInfo.position || !sourceCodeInfo.code)
@@ -5503,9 +5503,6 @@ const condSpecialExpression = {
5503
5503
  getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1].flat(), contextStack, builtin, evaluateNode),
5504
5504
  };
5505
5505
 
5506
- function isJsFunction(fn) {
5507
- return typeof fn === 'object' && fn !== null && 'fn' in fn && typeof fn.fn === 'function';
5508
- }
5509
5506
  const bindingTargetTypes = {
5510
5507
  symbol: 11,
5511
5508
  rest: 12,
@@ -7545,9 +7542,8 @@ function createContextStack(params = {}, modules, pure) {
7545
7542
  throw new LitsError(`Dots are not allowed in binding keys: "${identifier}"`, undefined);
7546
7543
  }
7547
7544
  const isFunction = typeof entry === 'function';
7548
- const isJsFunctionObject = isJsFunction(entry);
7549
- if (isFunction || isJsFunctionObject) {
7550
- const jsFunction = isJsFunctionObject ? entry : { fn: entry };
7545
+ if (isFunction) {
7546
+ const jsFunction = { fn: entry };
7551
7547
  assertNotShadowingBuiltin(identifier);
7552
7548
  if (!nativeJsFunctions) {
7553
7549
  nativeJsFunctions = {};
@@ -9759,9 +9755,11 @@ class Lits {
9759
9755
  const ast = this.generateAst(source, params);
9760
9756
  const moduleContextStack = contextStack.create({});
9761
9757
  const result = evaluate(ast, moduleContextStack);
9762
- if (result instanceof Promise) {
9763
- throw new TypeError('Unexpected async result in synchronous runBundle(). Use lits.async.run() for async operations.');
9764
- }
9758
+ // TODO: When async functions in file modules are able to mark themselves as pure and
9759
+ // are returning a Promise, uncomment the following check, and make sure a test is verifying the behaviour.
9760
+ // if (result instanceof Promise) {
9761
+ // throw new TypeError('Unexpected async result in synchronous runBundle(). Use lits.async.run() for async operations.')
9762
+ // }
9765
9763
  contextStack.registerValueModule(name, result);
9766
9764
  }
9767
9765
  contextStack.pure = savedPure;
@@ -34908,24 +34906,6 @@ function getLitsExpressionRules(cli) {
34908
34906
  function getLitsFormatter(fmt) {
34909
34907
  return createFormatter(getLitsExpressionRules(fmt));
34910
34908
  }
34911
- function getInlineLitsExpressionRule(fmt) {
34912
- return (text, index) => {
34913
- if (text.slice(index, index + 2) === '``') {
34914
- let count = 2;
34915
- let body = '';
34916
- while (index + count < text.length && text.slice(index + count, index + count + 2) !== '``') {
34917
- body += text[index + count];
34918
- count += 1;
34919
- }
34920
- if (text.slice(index + count, index + count + 2) !== '``')
34921
- throw new Error(`No end \` found for rule inlineLitsCodeRule: ${text}`);
34922
- count += 2;
34923
- const formattedText = getLitsFormatter(fmt)(body);
34924
- return { count, formattedText };
34925
- }
34926
- return { count: 0, formattedText: '' };
34927
- };
34928
- }
34929
34909
  const italicRule = createRule({
34930
34910
  name: 'italic',
34931
34911
  startPattern: /^\*\*\*/,
@@ -34942,7 +34922,6 @@ const boldRule = createRule({
34942
34922
  });
34943
34923
  function getMdRules(fmt) {
34944
34924
  return [
34945
- getInlineLitsExpressionRule(fmt),
34946
34925
  getInlineCodeRule(fmt),
34947
34926
  italicRule,
34948
34927
  boldRule,
@@ -1,7 +1,7 @@
1
1
  import type { Any } from '../interface';
2
2
  import type { ContextParams } from '../Lits/Lits';
3
3
  import type { LitsModule } from '../builtin/modules/interface';
4
- import { type NativeJsFunction, type SymbolNode, type UserDefinedSymbolNode } from '../parser/types';
4
+ import type { NativeJsFunction, SymbolNode, UserDefinedSymbolNode } from '../parser/types';
5
5
  import type { SourceCodeInfo } from '../tokenizer/token';
6
6
  import type { Context, LookUpResult } from './interface';
7
7
  export type ContextStack = ContextStackImpl;
@@ -27,8 +27,6 @@ export interface NativeJsFunction extends GenericLitsFunction {
27
27
  nativeFn: JsFunction;
28
28
  docString: string;
29
29
  }
30
- export declare function isJsFunction(fn: unknown): fn is JsFunction;
31
- export declare function assertJsFunction(fn: unknown): asserts fn is JsFunction;
32
30
  export interface UserDefinedFunction extends GenericLitsFunction {
33
31
  functionType: 'UserDefined';
34
32
  name: string | undefined;