funcity 0.8.0 → 0.9.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/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/node.cjs +26 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.mjs +26 -3
- package/dist/node.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
"use strict";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Blob as Blob_2 } from 'node:buffer';
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
var __defProp = Object.defineProperty;
|
package/dist/node.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
"use strict";
|
|
12
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
13
13
|
const path = require("path");
|
|
14
|
-
const
|
|
14
|
+
const __screwUpDefaultImportModule0 = require("process");
|
|
15
15
|
const nodeReadline = require("readline");
|
|
16
16
|
const module$1 = require("module");
|
|
17
17
|
function _interopNamespaceDefault(e) {
|
|
@@ -32,6 +32,29 @@ function _interopNamespaceDefault(e) {
|
|
|
32
32
|
}
|
|
33
33
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
34
34
|
const nodeReadline__namespace = /* @__PURE__ */ _interopNamespaceDefault(nodeReadline);
|
|
35
|
+
const process = __resolveDefaultExport(__screwUpDefaultImportModule0);
|
|
36
|
+
globalThis.__screwUpIsInCJS_f1eb7fee58a1 = true;
|
|
37
|
+
function __resolveDefaultExport(module2, isESM) {
|
|
38
|
+
const __isInCJS = typeof globalThis !== "undefined" && globalThis.__screwUpIsInCJS_f1eb7fee58a1 === true;
|
|
39
|
+
const maybe = module2;
|
|
40
|
+
const hasDefault = !!(maybe && typeof maybe === "object" && "default" in maybe);
|
|
41
|
+
const unwrapNamespaceDefault = (value) => {
|
|
42
|
+
if (!value || typeof value !== "object") {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
const inner = value;
|
|
46
|
+
const isModule = inner.__esModule === true || typeof Symbol !== "undefined" && inner[Symbol.toStringTag] === "Module";
|
|
47
|
+
if (isModule && "default" in inner) {
|
|
48
|
+
return inner.default;
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
const resolvedDefault = hasDefault ? unwrapNamespaceDefault(maybe.default) : void 0;
|
|
53
|
+
if (__isInCJS) {
|
|
54
|
+
return hasDefault ? resolvedDefault != null ? resolvedDefault : module2 : module2;
|
|
55
|
+
}
|
|
56
|
+
return hasDefault ? resolvedDefault != null ? resolvedDefault : module2 : module2;
|
|
57
|
+
}
|
|
35
58
|
const isPathSpecifier = (moduleId) => {
|
|
36
59
|
if (moduleId === "." || moduleId === "..") {
|
|
37
60
|
return true;
|
package/dist/node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.cjs","sources":["../src/variables/nodejs-variables.ts"],"sourcesContent":["// funcity - A functional language interpreter with text processing\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/funcity/\n\nimport * as path from 'path';\nimport process from 'process';\nimport * as nodeReadline from 'readline';\nimport { createRequire } from 'module';\n\nimport type { FunCityFunctionContext } from '../types';\n\n//////////////////////////////////////////////////////////////////////////////\n\n// Helper utilities for filtering module specifiers.\nconst isPathSpecifier = (moduleId: string): boolean => {\n if (moduleId === '.' || moduleId === '..') {\n return true;\n }\n return (\n moduleId.startsWith('./') ||\n moduleId.startsWith('../') ||\n moduleId.startsWith('file:') ||\n path.isAbsolute(moduleId)\n );\n};\n\nconst getBaseModuleName = (moduleId: string): string | undefined => {\n if (moduleId.startsWith('@')) {\n const segments = moduleId.split('/');\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : moduleId;\n }\n const slashIndex = moduleId.indexOf('/');\n return slashIndex >= 0 ? moduleId.slice(0, slashIndex) : moduleId;\n};\n\n/**\n * Create a Node.js require function bound to a base directory.\n * @param basePath - Base directory for module resolution.\n * @param acceptModules - Allowed module names. When omitted, any module is allowed.\n * @returns The require function bound to basePath.\n */\nexport const createRequireFunction = (\n basePath?: string,\n acceptModules?: readonly string[]\n): ReturnType<typeof createRequire> => {\n const baseDir = path.resolve(basePath ?? process.cwd());\n const entryPath = path.join(baseDir, '__funcity__.js');\n const baseRequire = createRequire(entryPath);\n\n if (!acceptModules || acceptModules.length === 0) {\n return baseRequire;\n }\n\n const allowedModules = new Set(acceptModules);\n\n const isAllowedModule = (moduleId: string): boolean => {\n if (allowedModules.has(moduleId)) {\n return true;\n }\n\n const normalizedId = moduleId.startsWith('node:')\n ? moduleId.slice('node:'.length)\n : moduleId;\n\n if (allowedModules.has(normalizedId)) {\n return true;\n }\n\n if (isPathSpecifier(normalizedId)) {\n return false;\n }\n\n const baseModule = getBaseModuleName(normalizedId);\n if (!baseModule) {\n return false;\n }\n\n return (\n allowedModules.has(baseModule) || allowedModules.has(`node:${baseModule}`)\n );\n };\n\n const requireWithFilter = ((moduleId: string) => {\n if (typeof moduleId === 'string' && !isAllowedModule(moduleId)) {\n const error = new Error(`Module is not allowed: ${moduleId}`);\n (error as { code?: string }).code = 'MODULE_NOT_ALLOWED';\n throw error;\n }\n return baseRequire(moduleId);\n }) as ReturnType<typeof createRequire>;\n\n requireWithFilter.resolve = baseRequire.resolve;\n requireWithFilter.cache = baseRequire.cache;\n requireWithFilter.extensions = baseRequire.extensions;\n requireWithFilter.main = baseRequire.main;\n\n return requireWithFilter;\n};\n\n/**\n * Built-in Node.js variables and functions.\n */\nexport const nodeJsVariables = Object.freeze({\n readline: async function (this: FunCityFunctionContext, prompt?: unknown) {\n const question = prompt === undefined ? '' : this.convertToString(prompt);\n const signal = this.abortSignal;\n\n return await new Promise<string>((resolve, reject) => {\n const rl = nodeReadline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n let settled = false;\n\n const cleanup = () => {\n if (signal) {\n signal.removeEventListener('abort', onAbort);\n }\n rl.close();\n };\n\n const finishResolve = (value: string) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n resolve(value);\n };\n\n const finishReject = (error: Error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n reject(error);\n };\n\n const onAbort = () => {\n const abortError = new Error('Aborted');\n (abortError as { name?: string }).name = 'AbortError';\n finishReject(abortError);\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n return;\n }\n signal.addEventListener('abort', onAbort, { once: true });\n }\n\n rl.question(question, (answer) => {\n finishResolve(answer);\n });\n });\n },\n} as const);\n"],"names":["path","createRequire","nodeReadline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"node.cjs","sources":["../src/variables/nodejs-variables.ts"],"sourcesContent":["// funcity - A functional language interpreter with text processing\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/funcity/\n\nimport * as path from 'path';\nimport process from 'process';\nimport * as nodeReadline from 'readline';\nimport { createRequire } from 'module';\n\nimport type { FunCityFunctionContext } from '../types';\n\n//////////////////////////////////////////////////////////////////////////////\n\n// Helper utilities for filtering module specifiers.\nconst isPathSpecifier = (moduleId: string): boolean => {\n if (moduleId === '.' || moduleId === '..') {\n return true;\n }\n return (\n moduleId.startsWith('./') ||\n moduleId.startsWith('../') ||\n moduleId.startsWith('file:') ||\n path.isAbsolute(moduleId)\n );\n};\n\nconst getBaseModuleName = (moduleId: string): string | undefined => {\n if (moduleId.startsWith('@')) {\n const segments = moduleId.split('/');\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : moduleId;\n }\n const slashIndex = moduleId.indexOf('/');\n return slashIndex >= 0 ? moduleId.slice(0, slashIndex) : moduleId;\n};\n\n/**\n * Create a Node.js require function bound to a base directory.\n * @param basePath - Base directory for module resolution.\n * @param acceptModules - Allowed module names. When omitted, any module is allowed.\n * @returns The require function bound to basePath.\n */\nexport const createRequireFunction = (\n basePath?: string,\n acceptModules?: readonly string[]\n): ReturnType<typeof createRequire> => {\n const baseDir = path.resolve(basePath ?? process.cwd());\n const entryPath = path.join(baseDir, '__funcity__.js');\n const baseRequire = createRequire(entryPath);\n\n if (!acceptModules || acceptModules.length === 0) {\n return baseRequire;\n }\n\n const allowedModules = new Set(acceptModules);\n\n const isAllowedModule = (moduleId: string): boolean => {\n if (allowedModules.has(moduleId)) {\n return true;\n }\n\n const normalizedId = moduleId.startsWith('node:')\n ? moduleId.slice('node:'.length)\n : moduleId;\n\n if (allowedModules.has(normalizedId)) {\n return true;\n }\n\n if (isPathSpecifier(normalizedId)) {\n return false;\n }\n\n const baseModule = getBaseModuleName(normalizedId);\n if (!baseModule) {\n return false;\n }\n\n return (\n allowedModules.has(baseModule) || allowedModules.has(`node:${baseModule}`)\n );\n };\n\n const requireWithFilter = ((moduleId: string) => {\n if (typeof moduleId === 'string' && !isAllowedModule(moduleId)) {\n const error = new Error(`Module is not allowed: ${moduleId}`);\n (error as { code?: string }).code = 'MODULE_NOT_ALLOWED';\n throw error;\n }\n return baseRequire(moduleId);\n }) as ReturnType<typeof createRequire>;\n\n requireWithFilter.resolve = baseRequire.resolve;\n requireWithFilter.cache = baseRequire.cache;\n requireWithFilter.extensions = baseRequire.extensions;\n requireWithFilter.main = baseRequire.main;\n\n return requireWithFilter;\n};\n\n/**\n * Built-in Node.js variables and functions.\n */\nexport const nodeJsVariables = Object.freeze({\n readline: async function (this: FunCityFunctionContext, prompt?: unknown) {\n const question = prompt === undefined ? '' : this.convertToString(prompt);\n const signal = this.abortSignal;\n\n return await new Promise<string>((resolve, reject) => {\n const rl = nodeReadline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n let settled = false;\n\n const cleanup = () => {\n if (signal) {\n signal.removeEventListener('abort', onAbort);\n }\n rl.close();\n };\n\n const finishResolve = (value: string) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n resolve(value);\n };\n\n const finishReject = (error: Error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n reject(error);\n };\n\n const onAbort = () => {\n const abortError = new Error('Aborted');\n (abortError as { name?: string }).name = 'AbortError';\n finishReject(abortError);\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n return;\n }\n signal.addEventListener('abort', onAbort, { once: true });\n }\n\n rl.question(question, (answer) => {\n finishResolve(answer);\n });\n });\n },\n} as const);\n"],"names":["module","path","createRequire","nodeReadline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,UAAU,uBAAuB,6BAAoC;AAM3E,WAAW,gCAAgC;AAC3C,SAAS,uBAA0BA,SAA6B,OAAmB;AACjF,QAAM,YACJ,OAAO,eAAe,eACrB,WAAmB,kCAAkC;AACxD,QAAM,QAAQA;AACd,QAAM,aAAa,CAAC,EAAE,SAAS,OAAO,UAAU,YAAY,aAAa;AACzE,QAAM,yBAAyB,CAAC,UAA4B;AAC1D,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,aAAO;AAAA,IACT;AACA,UAAM,QAAQ;AACd,UAAM,WACJ,MAAM,eAAe,QACpB,OAAO,WAAW,eAChB,MAAc,OAAO,WAAW,MAAM;AAC3C,QAAI,YAAY,aAAa,OAAO;AAClC,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT;AACA,QAAM,kBAAkB,aACpB,uBAAwB,MAAc,OAAO,IAC7C;AAEJ,MAAI,WAAW;AACb,WAAO,aAAe,4CAA0BA,UAAiBA;AAAA,EACnE;AASA,SAAO,aAAe,4CAA0BA,UAAiBA;AACnE;AAMA,MAAM,kBAAkB,CAAC,aAA8B;AACrD,MAAI,aAAa,OAAO,aA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AAU,CAAC,WAAW;AAChC,sBAAc,MAAM;AAAA,MACtB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF,CAAU;;;"}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { createRequire } from 'module';
|
package/dist/node.mjs
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: funcity
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.9.0
|
|
4
4
|
* description: A functional language interpreter with text processing
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/funcity
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import * as path from "path";
|
|
12
|
-
import
|
|
12
|
+
import __screwUpDefaultImportModule0 from "process";
|
|
13
13
|
import * as nodeReadline from "readline";
|
|
14
14
|
import { createRequire } from "module";
|
|
15
|
+
const process = __resolveDefaultExport(__screwUpDefaultImportModule0);
|
|
16
|
+
globalThis.__screwUpIsInCJS_f1eb7fee58a1 = false;
|
|
17
|
+
function __resolveDefaultExport(module, isESM) {
|
|
18
|
+
const __isInCJS = typeof globalThis !== "undefined" && globalThis.__screwUpIsInCJS_f1eb7fee58a1 === true;
|
|
19
|
+
const maybe = module;
|
|
20
|
+
const hasDefault = !!(maybe && typeof maybe === "object" && "default" in maybe);
|
|
21
|
+
const unwrapNamespaceDefault = (value) => {
|
|
22
|
+
if (!value || typeof value !== "object") {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
const inner = value;
|
|
26
|
+
const isModule = inner.__esModule === true || typeof Symbol !== "undefined" && inner[Symbol.toStringTag] === "Module";
|
|
27
|
+
if (isModule && "default" in inner) {
|
|
28
|
+
return inner.default;
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
const resolvedDefault = hasDefault ? unwrapNamespaceDefault(maybe.default) : void 0;
|
|
33
|
+
if (__isInCJS) {
|
|
34
|
+
return hasDefault ? resolvedDefault != null ? resolvedDefault : module : module;
|
|
35
|
+
}
|
|
36
|
+
return hasDefault ? resolvedDefault != null ? resolvedDefault : module : module;
|
|
37
|
+
}
|
|
15
38
|
const isPathSpecifier = (moduleId) => {
|
|
16
39
|
if (moduleId === "." || moduleId === "..") {
|
|
17
40
|
return true;
|
package/dist/node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.mjs","sources":["../src/variables/nodejs-variables.ts"],"sourcesContent":["// funcity - A functional language interpreter with text processing\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/funcity/\n\nimport * as path from 'path';\nimport process from 'process';\nimport * as nodeReadline from 'readline';\nimport { createRequire } from 'module';\n\nimport type { FunCityFunctionContext } from '../types';\n\n//////////////////////////////////////////////////////////////////////////////\n\n// Helper utilities for filtering module specifiers.\nconst isPathSpecifier = (moduleId: string): boolean => {\n if (moduleId === '.' || moduleId === '..') {\n return true;\n }\n return (\n moduleId.startsWith('./') ||\n moduleId.startsWith('../') ||\n moduleId.startsWith('file:') ||\n path.isAbsolute(moduleId)\n );\n};\n\nconst getBaseModuleName = (moduleId: string): string | undefined => {\n if (moduleId.startsWith('@')) {\n const segments = moduleId.split('/');\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : moduleId;\n }\n const slashIndex = moduleId.indexOf('/');\n return slashIndex >= 0 ? moduleId.slice(0, slashIndex) : moduleId;\n};\n\n/**\n * Create a Node.js require function bound to a base directory.\n * @param basePath - Base directory for module resolution.\n * @param acceptModules - Allowed module names. When omitted, any module is allowed.\n * @returns The require function bound to basePath.\n */\nexport const createRequireFunction = (\n basePath?: string,\n acceptModules?: readonly string[]\n): ReturnType<typeof createRequire> => {\n const baseDir = path.resolve(basePath ?? process.cwd());\n const entryPath = path.join(baseDir, '__funcity__.js');\n const baseRequire = createRequire(entryPath);\n\n if (!acceptModules || acceptModules.length === 0) {\n return baseRequire;\n }\n\n const allowedModules = new Set(acceptModules);\n\n const isAllowedModule = (moduleId: string): boolean => {\n if (allowedModules.has(moduleId)) {\n return true;\n }\n\n const normalizedId = moduleId.startsWith('node:')\n ? moduleId.slice('node:'.length)\n : moduleId;\n\n if (allowedModules.has(normalizedId)) {\n return true;\n }\n\n if (isPathSpecifier(normalizedId)) {\n return false;\n }\n\n const baseModule = getBaseModuleName(normalizedId);\n if (!baseModule) {\n return false;\n }\n\n return (\n allowedModules.has(baseModule) || allowedModules.has(`node:${baseModule}`)\n );\n };\n\n const requireWithFilter = ((moduleId: string) => {\n if (typeof moduleId === 'string' && !isAllowedModule(moduleId)) {\n const error = new Error(`Module is not allowed: ${moduleId}`);\n (error as { code?: string }).code = 'MODULE_NOT_ALLOWED';\n throw error;\n }\n return baseRequire(moduleId);\n }) as ReturnType<typeof createRequire>;\n\n requireWithFilter.resolve = baseRequire.resolve;\n requireWithFilter.cache = baseRequire.cache;\n requireWithFilter.extensions = baseRequire.extensions;\n requireWithFilter.main = baseRequire.main;\n\n return requireWithFilter;\n};\n\n/**\n * Built-in Node.js variables and functions.\n */\nexport const nodeJsVariables = Object.freeze({\n readline: async function (this: FunCityFunctionContext, prompt?: unknown) {\n const question = prompt === undefined ? '' : this.convertToString(prompt);\n const signal = this.abortSignal;\n\n return await new Promise<string>((resolve, reject) => {\n const rl = nodeReadline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n let settled = false;\n\n const cleanup = () => {\n if (signal) {\n signal.removeEventListener('abort', onAbort);\n }\n rl.close();\n };\n\n const finishResolve = (value: string) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n resolve(value);\n };\n\n const finishReject = (error: Error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n reject(error);\n };\n\n const onAbort = () => {\n const abortError = new Error('Aborted');\n (abortError as { name?: string }).name = 'AbortError';\n finishReject(abortError);\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n return;\n }\n signal.addEventListener('abort', onAbort, { once: true });\n }\n\n rl.question(question, (answer) => {\n finishResolve(answer);\n });\n });\n },\n} as const);\n"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"node.mjs","sources":["../src/variables/nodejs-variables.ts"],"sourcesContent":["// funcity - A functional language interpreter with text processing\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/funcity/\n\nimport * as path from 'path';\nimport process from 'process';\nimport * as nodeReadline from 'readline';\nimport { createRequire } from 'module';\n\nimport type { FunCityFunctionContext } from '../types';\n\n//////////////////////////////////////////////////////////////////////////////\n\n// Helper utilities for filtering module specifiers.\nconst isPathSpecifier = (moduleId: string): boolean => {\n if (moduleId === '.' || moduleId === '..') {\n return true;\n }\n return (\n moduleId.startsWith('./') ||\n moduleId.startsWith('../') ||\n moduleId.startsWith('file:') ||\n path.isAbsolute(moduleId)\n );\n};\n\nconst getBaseModuleName = (moduleId: string): string | undefined => {\n if (moduleId.startsWith('@')) {\n const segments = moduleId.split('/');\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : moduleId;\n }\n const slashIndex = moduleId.indexOf('/');\n return slashIndex >= 0 ? moduleId.slice(0, slashIndex) : moduleId;\n};\n\n/**\n * Create a Node.js require function bound to a base directory.\n * @param basePath - Base directory for module resolution.\n * @param acceptModules - Allowed module names. When omitted, any module is allowed.\n * @returns The require function bound to basePath.\n */\nexport const createRequireFunction = (\n basePath?: string,\n acceptModules?: readonly string[]\n): ReturnType<typeof createRequire> => {\n const baseDir = path.resolve(basePath ?? process.cwd());\n const entryPath = path.join(baseDir, '__funcity__.js');\n const baseRequire = createRequire(entryPath);\n\n if (!acceptModules || acceptModules.length === 0) {\n return baseRequire;\n }\n\n const allowedModules = new Set(acceptModules);\n\n const isAllowedModule = (moduleId: string): boolean => {\n if (allowedModules.has(moduleId)) {\n return true;\n }\n\n const normalizedId = moduleId.startsWith('node:')\n ? moduleId.slice('node:'.length)\n : moduleId;\n\n if (allowedModules.has(normalizedId)) {\n return true;\n }\n\n if (isPathSpecifier(normalizedId)) {\n return false;\n }\n\n const baseModule = getBaseModuleName(normalizedId);\n if (!baseModule) {\n return false;\n }\n\n return (\n allowedModules.has(baseModule) || allowedModules.has(`node:${baseModule}`)\n );\n };\n\n const requireWithFilter = ((moduleId: string) => {\n if (typeof moduleId === 'string' && !isAllowedModule(moduleId)) {\n const error = new Error(`Module is not allowed: ${moduleId}`);\n (error as { code?: string }).code = 'MODULE_NOT_ALLOWED';\n throw error;\n }\n return baseRequire(moduleId);\n }) as ReturnType<typeof createRequire>;\n\n requireWithFilter.resolve = baseRequire.resolve;\n requireWithFilter.cache = baseRequire.cache;\n requireWithFilter.extensions = baseRequire.extensions;\n requireWithFilter.main = baseRequire.main;\n\n return requireWithFilter;\n};\n\n/**\n * Built-in Node.js variables and functions.\n */\nexport const nodeJsVariables = Object.freeze({\n readline: async function (this: FunCityFunctionContext, prompt?: unknown) {\n const question = prompt === undefined ? '' : this.convertToString(prompt);\n const signal = this.abortSignal;\n\n return await new Promise<string>((resolve, reject) => {\n const rl = nodeReadline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n let settled = false;\n\n const cleanup = () => {\n if (signal) {\n signal.removeEventListener('abort', onAbort);\n }\n rl.close();\n };\n\n const finishResolve = (value: string) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n resolve(value);\n };\n\n const finishReject = (error: Error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n reject(error);\n };\n\n const onAbort = () => {\n const abortError = new Error('Aborted');\n (abortError as { name?: string }).name = 'AbortError';\n finishReject(abortError);\n };\n\n if (signal) {\n if (signal.aborted) {\n onAbort();\n return;\n }\n signal.addEventListener('abort', onAbort, { once: true });\n }\n\n rl.question(question, (answer) => {\n finishResolve(answer);\n });\n });\n },\n} as const);\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,MAAM,UAAU,uBAAuB,6BAAoC;AAM3E,WAAW,gCAAgC;AAC3C,SAAS,uBAA0B,QAA6B,OAAmB;AACjF,QAAM,YACJ,OAAO,eAAe,eACrB,WAAmB,kCAAkC;AACxD,QAAM,QAAQ;AACd,QAAM,aAAa,CAAC,EAAE,SAAS,OAAO,UAAU,YAAY,aAAa;AACzE,QAAM,yBAAyB,CAAC,UAA4B;AAC1D,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,aAAO;AAAA,IACT;AACA,UAAM,QAAQ;AACd,UAAM,WACJ,MAAM,eAAe,QACpB,OAAO,WAAW,eAChB,MAAc,OAAO,WAAW,MAAM;AAC3C,QAAI,YAAY,aAAa,OAAO;AAClC,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT;AACA,QAAM,kBAAkB,aACpB,uBAAwB,MAAc,OAAO,IAC7C;AAEJ,MAAI,WAAW;AACb,WAAO,aAAe,4CAA0B,SAAiB;AAAA,EACnE;AASA,SAAO,aAAe,4CAA0B,SAAiB;AACnE;AAMA,MAAM,kBAAkB,CAAC,aAA8B;AACrD,MAAI,aAAa,OAAO,aAAa,MAAM;AACzC,WAAO;AAAA,EACT;AACA,SACE,SAAS,WAAW,IAAI,KACxB,SAAS,WAAW,KAAK,KACzB,SAAS,WAAW,OAAO,KAC3B,KAAK,W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
1
1
|
{
|
|
2
2
|
"git": {
|
|
3
3
|
"tags": [
|
|
4
|
-
"0.
|
|
4
|
+
"0.9.0"
|
|
5
5
|
],
|
|
6
6
|
"branches": [
|
|
7
7
|
"main"
|
|
8
8
|
],
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.9.0",
|
|
10
10
|
"commit": {
|
|
11
|
-
"hash": "
|
|
12
|
-
"shortHash": "
|
|
13
|
-
"date": "2026-01-
|
|
11
|
+
"hash": "44d20b9861b32b8f70452b8a5bd2a39e3484ba26",
|
|
12
|
+
"shortHash": "44d20b9",
|
|
13
|
+
"date": "2026-01-23T01:17:43+09:00",
|
|
14
14
|
"message": "Merge branch 'develop'"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.9.0",
|
|
18
18
|
"author": "Kouji Matsui (@kekyo@mi.kekyo.net)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"repository": {
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": ">=20.0.0",
|
|
62
62
|
"prettier-max": ">=1.13.0",
|
|
63
|
-
"screw-up": ">=1.
|
|
63
|
+
"screw-up": ">=1.26.0",
|
|
64
64
|
"typescript": ">=5.0.0",
|
|
65
65
|
"vite": ">=5.0.0",
|
|
66
66
|
"vite-plugin-dts": ">=3.0.0",
|
|
67
67
|
"vitest": ">=1.0.0"
|
|
68
68
|
},
|
|
69
|
-
"buildDate": "2026-01-
|
|
69
|
+
"buildDate": "2026-01-23T01:18:29+09:00"
|
|
70
70
|
}
|