@ricsam/quickjs-runtime 0.0.1 → 0.2.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/README.md CHANGED
@@ -1,45 +1,23 @@
1
1
  # @ricsam/quickjs-runtime
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@ricsam/quickjs-runtime`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
3
+ Umbrella package that combines all APIs.
4
+
5
+ ```typescript
6
+ import { setupRuntime } from "@ricsam/quickjs-runtime";
7
+
8
+ const handle = setupRuntime(context, {
9
+ fetch: {
10
+ onFetch: async (req) => fetch(req),
11
+ },
12
+ fs: {
13
+ getDirectory: async (path) => createNodeDirectoryHandle(`./sandbox${path}`),
14
+ },
15
+ });
16
+
17
+ // Access individual handles
18
+ handle.core; // CoreHandle
19
+ handle.fetch; // FetchHandle
20
+ handle.fs; // FsHandle
21
+
22
+ handle.dispose(); // Cleanup all
23
+ ```
@@ -0,0 +1,89 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __reExport = (target, mod, secondTarget) => {
7
+ for (let key of __getOwnPropNames(mod))
8
+ if (!__hasOwnProp.call(target, key) && key !== "default")
9
+ __defProp(target, key, {
10
+ get: () => mod[key],
11
+ enumerable: true
12
+ });
13
+ if (secondTarget) {
14
+ for (let key of __getOwnPropNames(mod))
15
+ if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
16
+ __defProp(secondTarget, key, {
17
+ get: () => mod[key],
18
+ enumerable: true
19
+ });
20
+ return secondTarget;
21
+ }
22
+ };
23
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
24
+ var __toCommonJS = (from) => {
25
+ var entry = __moduleCache.get(from), desc;
26
+ if (entry)
27
+ return entry;
28
+ entry = __defProp({}, "__esModule", { value: true });
29
+ if (from && typeof from === "object" || typeof from === "function")
30
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
31
+ get: () => from[key],
32
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
+ }));
34
+ __moduleCache.set(from, entry);
35
+ return entry;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, {
40
+ get: all[name],
41
+ enumerable: true,
42
+ configurable: true,
43
+ set: (newValue) => all[name] = () => newValue
44
+ });
45
+ };
46
+
47
+ // packages/runtime/src/index.ts
48
+ var exports_src = {};
49
+ __export(exports_src, {
50
+ setupRuntime: () => setupRuntime
51
+ });
52
+ module.exports = __toCommonJS(exports_src);
53
+ __reExport(exports_src, require("@ricsam/quickjs-core"), module.exports);
54
+ __reExport(exports_src, require("@ricsam/quickjs-fetch"), module.exports);
55
+ __reExport(exports_src, require("@ricsam/quickjs-fs"), module.exports);
56
+ var import_quickjs_core = require("@ricsam/quickjs-core");
57
+ var import_quickjs_fetch = require("@ricsam/quickjs-fetch");
58
+ var import_quickjs_fs = require("@ricsam/quickjs-fs");
59
+ function setupRuntime(context, options = {}) {
60
+ const stateMap = import_quickjs_core.createStateMap();
61
+ const core = import_quickjs_core.setupCore(context, { stateMap });
62
+ let fetch;
63
+ let fs;
64
+ if (options.fetch) {
65
+ const fetchOptions = options.fetch === true ? { stateMap, coreHandle: core } : { ...options.fetch, stateMap, coreHandle: core };
66
+ fetch = import_quickjs_fetch.setupFetch(context, fetchOptions);
67
+ }
68
+ if (options.fs) {
69
+ fs = import_quickjs_fs.setupFs(context, {
70
+ ...options.fs,
71
+ stateMap,
72
+ coreHandle: core
73
+ });
74
+ }
75
+ return {
76
+ core,
77
+ fetch,
78
+ fs,
79
+ stateMap,
80
+ dispose() {
81
+ fs?.dispose();
82
+ fetch?.dispose();
83
+ core.dispose();
84
+ }
85
+ };
86
+ }
87
+ })
88
+
89
+ //# debugId=17426326EF41B9C964756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": [
5
+ "// Re-export everything from sub-packages\nexport * from \"@ricsam/quickjs-core\";\nexport * from \"@ricsam/quickjs-fetch\";\nexport * from \"@ricsam/quickjs-fs\";\n\nimport type { QuickJSContext } from \"quickjs-emscripten\";\nimport {\n setupCore,\n createStateMap,\n type StateMap,\n type CoreHandle,\n} from \"@ricsam/quickjs-core\";\nimport {\n setupFetch,\n type SetupFetchOptions,\n type FetchHandle,\n} from \"@ricsam/quickjs-fetch\";\nimport {\n setupFs,\n type SetupFsOptions,\n type FsHandle,\n} from \"@ricsam/quickjs-fs\";\n\n/**\n * Options for setting up the runtime\n */\nexport interface SetupRuntimeOptions {\n /**\n * Fetch API options\n * Pass `true` to enable with defaults\n * Pass `false` or omit to disable\n */\n fetch?: SetupFetchOptions | boolean;\n\n /**\n * File system options\n * Pass options object to enable\n * Pass `false` or omit to disable\n */\n fs?: SetupFsOptions | false;\n}\n\n/**\n * Handle returned from setupRuntime\n */\nexport interface RuntimeHandle {\n /** Core handle (always present) */\n core: CoreHandle;\n\n /** Fetch handle (if enabled) */\n fetch?: FetchHandle;\n\n /** File system handle (if enabled) */\n fs?: FsHandle;\n\n /** Shared state map */\n readonly stateMap: StateMap;\n\n /** Dispose all handles and cleanup */\n dispose(): void;\n}\n\n/**\n * Setup multiple APIs in a QuickJS context\n *\n * @example\n * const handle = setupRuntime(context, {\n * fetch: {\n * onFetch: async (req) => fetch(req),\n * },\n * fs: {\n * getDirectory: async (path) => createNodeDirectoryHandle(`/sandbox${path}`),\n * },\n * });\n *\n * // Use the context...\n *\n * handle.dispose();\n */\nexport function setupRuntime(\n context: QuickJSContext,\n options: SetupRuntimeOptions = {}\n): RuntimeHandle {\n const stateMap = createStateMap();\n\n // Always setup core\n const core = setupCore(context, { stateMap });\n\n let fetch: FetchHandle | undefined;\n let fs: FsHandle | undefined;\n\n // Setup fetch if enabled\n if (options.fetch) {\n const fetchOptions: SetupFetchOptions =\n options.fetch === true\n ? { stateMap, coreHandle: core }\n : { ...options.fetch, stateMap, coreHandle: core };\n\n fetch = setupFetch(context, fetchOptions);\n }\n\n // Setup fs if provided\n if (options.fs) {\n fs = setupFs(context, {\n ...options.fs,\n stateMap,\n coreHandle: core,\n });\n }\n\n return {\n core,\n fetch,\n fs,\n stateMap,\n dispose() {\n fs?.dispose();\n fetch?.dispose();\n core.dispose();\n },\n };\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;AAQO,IALP;AAUO,IAJP;AASO,IAJP;AA8DO,SAAS,YAAY,CAC1B,SACA,UAA+B,CAAC,GACjB;AAAA,EACf,MAAM,WAAW,mCAAe;AAAA,EAGhC,MAAM,OAAO,8BAAU,SAAS,EAAE,SAAS,CAAC;AAAA,EAE5C,IAAI;AAAA,EACJ,IAAI;AAAA,EAGJ,IAAI,QAAQ,OAAO;AAAA,IACjB,MAAM,eACJ,QAAQ,UAAU,OACd,EAAE,UAAU,YAAY,KAAK,IAC7B,KAAK,QAAQ,OAAO,UAAU,YAAY,KAAK;AAAA,IAErD,QAAQ,gCAAW,SAAS,YAAY;AAAA,EAC1C;AAAA,EAGA,IAAI,QAAQ,IAAI;AAAA,IACd,KAAK,0BAAQ,SAAS;AAAA,SACjB,QAAQ;AAAA,MACX;AAAA,MACA,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAAA,EAEA,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,GAAG;AAAA,MACR,IAAI,QAAQ;AAAA,MACZ,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA;AAAA,EAEjB;AAAA;",
8
+ "debugId": "17426326EF41B9C964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@ricsam/quickjs-runtime",
3
+ "version": "0.2.0",
4
+ "type": "commonjs"
5
+ }
@@ -0,0 +1,48 @@
1
+ // @bun
2
+ // packages/runtime/src/index.ts
3
+ export * from "@ricsam/quickjs-core";
4
+ export * from "@ricsam/quickjs-fetch";
5
+ export * from "@ricsam/quickjs-fs";
6
+ import {
7
+ setupCore,
8
+ createStateMap
9
+ } from "@ricsam/quickjs-core";
10
+ import {
11
+ setupFetch
12
+ } from "@ricsam/quickjs-fetch";
13
+ import {
14
+ setupFs
15
+ } from "@ricsam/quickjs-fs";
16
+ function setupRuntime(context, options = {}) {
17
+ const stateMap = createStateMap();
18
+ const core = setupCore(context, { stateMap });
19
+ let fetch;
20
+ let fs;
21
+ if (options.fetch) {
22
+ const fetchOptions = options.fetch === true ? { stateMap, coreHandle: core } : { ...options.fetch, stateMap, coreHandle: core };
23
+ fetch = setupFetch(context, fetchOptions);
24
+ }
25
+ if (options.fs) {
26
+ fs = setupFs(context, {
27
+ ...options.fs,
28
+ stateMap,
29
+ coreHandle: core
30
+ });
31
+ }
32
+ return {
33
+ core,
34
+ fetch,
35
+ fs,
36
+ stateMap,
37
+ dispose() {
38
+ fs?.dispose();
39
+ fetch?.dispose();
40
+ core.dispose();
41
+ }
42
+ };
43
+ }
44
+ export {
45
+ setupRuntime
46
+ };
47
+
48
+ //# debugId=323EC9DA1EDD873164756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": [
5
+ "// Re-export everything from sub-packages\nexport * from \"@ricsam/quickjs-core\";\nexport * from \"@ricsam/quickjs-fetch\";\nexport * from \"@ricsam/quickjs-fs\";\n\nimport type { QuickJSContext } from \"quickjs-emscripten\";\nimport {\n setupCore,\n createStateMap,\n type StateMap,\n type CoreHandle,\n} from \"@ricsam/quickjs-core\";\nimport {\n setupFetch,\n type SetupFetchOptions,\n type FetchHandle,\n} from \"@ricsam/quickjs-fetch\";\nimport {\n setupFs,\n type SetupFsOptions,\n type FsHandle,\n} from \"@ricsam/quickjs-fs\";\n\n/**\n * Options for setting up the runtime\n */\nexport interface SetupRuntimeOptions {\n /**\n * Fetch API options\n * Pass `true` to enable with defaults\n * Pass `false` or omit to disable\n */\n fetch?: SetupFetchOptions | boolean;\n\n /**\n * File system options\n * Pass options object to enable\n * Pass `false` or omit to disable\n */\n fs?: SetupFsOptions | false;\n}\n\n/**\n * Handle returned from setupRuntime\n */\nexport interface RuntimeHandle {\n /** Core handle (always present) */\n core: CoreHandle;\n\n /** Fetch handle (if enabled) */\n fetch?: FetchHandle;\n\n /** File system handle (if enabled) */\n fs?: FsHandle;\n\n /** Shared state map */\n readonly stateMap: StateMap;\n\n /** Dispose all handles and cleanup */\n dispose(): void;\n}\n\n/**\n * Setup multiple APIs in a QuickJS context\n *\n * @example\n * const handle = setupRuntime(context, {\n * fetch: {\n * onFetch: async (req) => fetch(req),\n * },\n * fs: {\n * getDirectory: async (path) => createNodeDirectoryHandle(`/sandbox${path}`),\n * },\n * });\n *\n * // Use the context...\n *\n * handle.dispose();\n */\nexport function setupRuntime(\n context: QuickJSContext,\n options: SetupRuntimeOptions = {}\n): RuntimeHandle {\n const stateMap = createStateMap();\n\n // Always setup core\n const core = setupCore(context, { stateMap });\n\n let fetch: FetchHandle | undefined;\n let fs: FsHandle | undefined;\n\n // Setup fetch if enabled\n if (options.fetch) {\n const fetchOptions: SetupFetchOptions =\n options.fetch === true\n ? { stateMap, coreHandle: core }\n : { ...options.fetch, stateMap, coreHandle: core };\n\n fetch = setupFetch(context, fetchOptions);\n }\n\n // Setup fs if provided\n if (options.fs) {\n fs = setupFs(context, {\n ...options.fs,\n stateMap,\n coreHandle: core,\n });\n }\n\n return {\n core,\n fetch,\n fs,\n stateMap,\n dispose() {\n fs?.dispose();\n fetch?.dispose();\n core.dispose();\n },\n };\n}\n"
6
+ ],
7
+ "mappings": ";;AACA;AACA;AACA;AAGA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAKA;AAAA;AAAA;AA8DO,SAAS,YAAY,CAC1B,SACA,UAA+B,CAAC,GACjB;AAAA,EACf,MAAM,WAAW,eAAe;AAAA,EAGhC,MAAM,OAAO,UAAU,SAAS,EAAE,SAAS,CAAC;AAAA,EAE5C,IAAI;AAAA,EACJ,IAAI;AAAA,EAGJ,IAAI,QAAQ,OAAO;AAAA,IACjB,MAAM,eACJ,QAAQ,UAAU,OACd,EAAE,UAAU,YAAY,KAAK,IAC7B,KAAK,QAAQ,OAAO,UAAU,YAAY,KAAK;AAAA,IAErD,QAAQ,WAAW,SAAS,YAAY;AAAA,EAC1C;AAAA,EAGA,IAAI,QAAQ,IAAI;AAAA,IACd,KAAK,QAAQ,SAAS;AAAA,SACjB,QAAQ;AAAA,MACX;AAAA,MACA,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAAA,EAEA,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,GAAG;AAAA,MACR,IAAI,QAAQ;AAAA,MACZ,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA;AAAA,EAEjB;AAAA;",
8
+ "debugId": "323EC9DA1EDD873164756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@ricsam/quickjs-runtime",
3
+ "version": "0.2.0",
4
+ "type": "module"
5
+ }
@@ -0,0 +1,57 @@
1
+ export * from "@ricsam/quickjs-core";
2
+ export * from "@ricsam/quickjs-fetch";
3
+ export * from "@ricsam/quickjs-fs";
4
+ import type { QuickJSContext } from "quickjs-emscripten";
5
+ import { type StateMap, type CoreHandle } from "@ricsam/quickjs-core";
6
+ import { type SetupFetchOptions, type FetchHandle } from "@ricsam/quickjs-fetch";
7
+ import { type SetupFsOptions, type FsHandle } from "@ricsam/quickjs-fs";
8
+ /**
9
+ * Options for setting up the runtime
10
+ */
11
+ export interface SetupRuntimeOptions {
12
+ /**
13
+ * Fetch API options
14
+ * Pass `true` to enable with defaults
15
+ * Pass `false` or omit to disable
16
+ */
17
+ fetch?: SetupFetchOptions | boolean;
18
+ /**
19
+ * File system options
20
+ * Pass options object to enable
21
+ * Pass `false` or omit to disable
22
+ */
23
+ fs?: SetupFsOptions | false;
24
+ }
25
+ /**
26
+ * Handle returned from setupRuntime
27
+ */
28
+ export interface RuntimeHandle {
29
+ /** Core handle (always present) */
30
+ core: CoreHandle;
31
+ /** Fetch handle (if enabled) */
32
+ fetch?: FetchHandle;
33
+ /** File system handle (if enabled) */
34
+ fs?: FsHandle;
35
+ /** Shared state map */
36
+ readonly stateMap: StateMap;
37
+ /** Dispose all handles and cleanup */
38
+ dispose(): void;
39
+ }
40
+ /**
41
+ * Setup multiple APIs in a QuickJS context
42
+ *
43
+ * @example
44
+ * const handle = setupRuntime(context, {
45
+ * fetch: {
46
+ * onFetch: async (req) => fetch(req),
47
+ * },
48
+ * fs: {
49
+ * getDirectory: async (path) => createNodeDirectoryHandle(`/sandbox${path}`),
50
+ * },
51
+ * });
52
+ *
53
+ * // Use the context...
54
+ *
55
+ * handle.dispose();
56
+ */
57
+ export declare function setupRuntime(context: QuickJSContext, options?: SetupRuntimeOptions): RuntimeHandle;
package/package.json CHANGED
@@ -1,10 +1,57 @@
1
1
  {
2
2
  "name": "@ricsam/quickjs-runtime",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @ricsam/quickjs-runtime",
3
+ "version": "0.2.0",
4
+ "main": "./dist/cjs/index.cjs",
5
+ "types": "./dist/types/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/types/index.d.ts",
9
+ "require": "./dist/cjs/index.cjs",
10
+ "import": "./dist/mjs/index.mjs"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun",
15
+ "test": "bun test",
16
+ "typecheck": "tsc --noEmit"
17
+ },
18
+ "dependencies": {
19
+ "@ricsam/quickjs-core": "^0.2.0",
20
+ "@ricsam/quickjs-fetch": "^0.2.0",
21
+ "@ricsam/quickjs-fs": "^0.2.0",
22
+ "quickjs-emscripten": "^0.31.0"
23
+ },
24
+ "peerDependencies": {
25
+ "quickjs-emscripten": "^0.31.0"
26
+ },
27
+ "author": "Richard Samuelsson",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/ricsam/richie-qjs.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/ricsam/richie-qjs/issues"
35
+ },
36
+ "homepage": "https://github.com/ricsam/richie-qjs#readme",
5
37
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
38
+ "quickjs",
39
+ "sandbox",
40
+ "javascript",
41
+ "runtime",
42
+ "fetch",
43
+ "filesystem",
44
+ "streams",
45
+ "wasm",
46
+ "emscripten"
47
+ ],
48
+ "description": "Complete QuickJS runtime with fetch, fs, and core bindings",
49
+ "module": "./dist/mjs/index.mjs",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "files": [
54
+ "dist",
55
+ "README.md"
9
56
  ]
10
- }
57
+ }