knitting 0.1.55 → 0.1.60

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 (157) hide show
  1. package/README.md +254 -40
  2. package/knitting.d.ts +7 -797
  3. package/knitting.js +6 -9780
  4. package/map.md +31 -15
  5. package/package.json +20 -6
  6. package/process-shared-buffer.d.ts +1 -0
  7. package/process-shared-buffer.js +1 -0
  8. package/scripts/build-compiled-worker.ts +276 -0
  9. package/scripts/compiled-worker/porffor.d.ts +5 -0
  10. package/scripts/compiled-worker/runtime.ts +529 -0
  11. package/scripts/compiled-worker/task-shim.ts +32 -0
  12. package/shared-memory.d.ts +1 -155
  13. package/shared-memory.js +1 -1342
  14. package/src/api.d.ts +92 -0
  15. package/src/api.js +798 -0
  16. package/src/common/envelope.d.ts +17 -0
  17. package/src/common/envelope.js +22 -0
  18. package/src/common/module-url.d.ts +2 -0
  19. package/src/common/module-url.js +52 -0
  20. package/src/common/node-compat.d.ts +22 -0
  21. package/src/common/node-compat.js +24 -0
  22. package/src/common/path-canonical.d.ts +6 -0
  23. package/src/common/path-canonical.js +55 -0
  24. package/src/common/runtime.d.ts +16 -0
  25. package/src/common/runtime.js +105 -0
  26. package/src/common/shared-buffer-region.d.ts +11 -0
  27. package/src/common/shared-buffer-region.js +21 -0
  28. package/src/common/shared-buffer-text.d.ts +16 -0
  29. package/src/common/shared-buffer-text.js +65 -0
  30. package/src/common/task-source.d.ts +5 -0
  31. package/src/common/task-source.js +100 -0
  32. package/src/common/task-symbol.d.ts +1 -0
  33. package/src/common/task-symbol.js +1 -0
  34. package/src/common/with-resolvers.d.ts +9 -0
  35. package/src/common/with-resolvers.js +23 -0
  36. package/src/common/worker-runtime.d.ts +42 -0
  37. package/src/common/worker-runtime.js +70 -0
  38. package/src/connections/buffer-reference-native.d.ts +56 -0
  39. package/src/connections/buffer-reference-native.js +241 -0
  40. package/src/connections/buffer-reference.d.ts +99 -0
  41. package/src/connections/buffer-reference.js +575 -0
  42. package/src/connections/bun.d.ts +22 -0
  43. package/src/connections/bun.js +225 -0
  44. package/src/connections/deno.d.ts +24 -0
  45. package/src/connections/deno.js +226 -0
  46. package/src/connections/external-array-buffer.d.ts +2 -0
  47. package/src/connections/external-array-buffer.js +33 -0
  48. package/src/connections/file-descriptor.d.ts +39 -0
  49. package/src/connections/file-descriptor.js +161 -0
  50. package/src/connections/index.d.ts +4 -0
  51. package/src/connections/index.js +4 -0
  52. package/src/connections/node-addons.d.ts +16 -0
  53. package/src/connections/node-addons.js +92 -0
  54. package/src/connections/node-buffer-pointer.d.ts +20 -0
  55. package/src/connections/node-buffer-pointer.js +16 -0
  56. package/src/connections/node-ffi-api.d.ts +19 -0
  57. package/src/connections/node-ffi-api.js +28 -0
  58. package/src/connections/node-ffi.d.ts +27 -0
  59. package/src/connections/node-ffi.js +262 -0
  60. package/src/connections/node.d.ts +30 -0
  61. package/src/connections/node.js +62 -0
  62. package/src/connections/numeric-array.d.ts +5 -0
  63. package/src/connections/numeric-array.js +17 -0
  64. package/src/connections/package-assets.d.ts +2 -0
  65. package/src/connections/package-assets.js +55 -0
  66. package/src/connections/posix.d.ts +74 -0
  67. package/src/connections/posix.js +178 -0
  68. package/src/connections/process-shared-buffer.d.ts +76 -0
  69. package/src/connections/process-shared-buffer.js +245 -0
  70. package/src/connections/shared-array-buffer-payload.d.ts +36 -0
  71. package/src/connections/shared-array-buffer-payload.js +235 -0
  72. package/src/connections/types.d.ts +54 -0
  73. package/src/connections/types.js +37 -0
  74. package/src/connections/windows.d.ts +37 -0
  75. package/src/connections/windows.js +245 -0
  76. package/src/debug/env-diff.d.ts +26 -0
  77. package/src/debug/env-diff.js +49 -0
  78. package/src/debug/gate.d.ts +18 -0
  79. package/src/debug/gate.js +69 -0
  80. package/src/debug/handle.d.ts +23 -0
  81. package/src/debug/handle.js +48 -0
  82. package/src/error.d.ts +14 -0
  83. package/src/error.js +50 -0
  84. package/src/ipc/tools/ring-queue.d.ts +33 -0
  85. package/src/ipc/tools/ring-queue.js +159 -0
  86. package/src/ipc/transport/shared-memory.d.ts +23 -0
  87. package/src/ipc/transport/shared-memory.js +35 -0
  88. package/src/memory/byte-carpet.d.ts +73 -0
  89. package/src/memory/byte-carpet.js +157 -0
  90. package/src/memory/lock.d.ts +213 -0
  91. package/src/memory/lock.js +760 -0
  92. package/src/memory/payload-config.d.ts +31 -0
  93. package/src/memory/payload-config.js +67 -0
  94. package/src/memory/payloadCodec.d.ts +55 -0
  95. package/src/memory/payloadCodec.js +1473 -0
  96. package/src/memory/regionRegistry.d.ts +17 -0
  97. package/src/memory/regionRegistry.js +285 -0
  98. package/src/memory/shared-buffer-io.d.ts +55 -0
  99. package/src/memory/shared-buffer-io.js +403 -0
  100. package/src/permission/compatibility.d.ts +28 -0
  101. package/src/permission/compatibility.js +239 -0
  102. package/src/permission/index.d.ts +4 -0
  103. package/src/permission/index.js +3 -0
  104. package/src/permission/protocol.d.ts +167 -0
  105. package/src/permission/protocol.js +690 -0
  106. package/src/runtime/balancer.d.ts +19 -0
  107. package/src/runtime/balancer.js +149 -0
  108. package/src/runtime/compiled-artifact.d.ts +21 -0
  109. package/src/runtime/compiled-artifact.js +260 -0
  110. package/src/runtime/compiled-builder.d.ts +8 -0
  111. package/src/runtime/compiled-builder.js +42 -0
  112. package/src/runtime/compiled-worker.d.ts +27 -0
  113. package/src/runtime/compiled-worker.js +562 -0
  114. package/src/runtime/dispatcher.d.ts +40 -0
  115. package/src/runtime/dispatcher.js +142 -0
  116. package/src/runtime/inline-executor.d.ts +10 -0
  117. package/src/runtime/inline-executor.js +294 -0
  118. package/src/runtime/pool.d.ts +44 -0
  119. package/src/runtime/pool.js +472 -0
  120. package/src/runtime/process-worker.d.ts +92 -0
  121. package/src/runtime/process-worker.js +713 -0
  122. package/src/runtime/tx-queue.d.ts +28 -0
  123. package/src/runtime/tx-queue.js +158 -0
  124. package/src/shared/abortSignal.d.ts +23 -0
  125. package/src/shared/abortSignal.js +134 -0
  126. package/src/types.d.ts +399 -0
  127. package/src/types.js +2 -0
  128. package/src/utils/http.d.ts +29 -0
  129. package/src/utils/http.js +100 -0
  130. package/src/worker/bootstrap.d.ts +5 -0
  131. package/src/worker/bootstrap.js +78 -0
  132. package/src/worker/composable-runners.d.ts +12 -0
  133. package/src/worker/composable-runners.js +98 -0
  134. package/src/worker/loop.d.ts +3 -0
  135. package/src/worker/loop.js +395 -0
  136. package/src/worker/process-worker-bootstrap.d.ts +8 -0
  137. package/src/worker/process-worker-bootstrap.js +160 -0
  138. package/src/worker/rx-queue.d.ts +25 -0
  139. package/src/worker/rx-queue.js +173 -0
  140. package/src/worker/safety/index.d.ts +4 -0
  141. package/src/worker/safety/index.js +4 -0
  142. package/src/worker/safety/performance.d.ts +1 -0
  143. package/src/worker/safety/performance.js +17 -0
  144. package/src/worker/safety/process.d.ts +2 -0
  145. package/src/worker/safety/process.js +79 -0
  146. package/src/worker/safety/startup.d.ts +16 -0
  147. package/src/worker/safety/startup.js +30 -0
  148. package/src/worker/safety/worker-data.d.ts +2 -0
  149. package/src/worker/safety/worker-data.js +36 -0
  150. package/src/worker/task-loader.d.ts +28 -0
  151. package/src/worker/task-loader.js +76 -0
  152. package/src/worker/timers.d.ts +18 -0
  153. package/src/worker/timers.js +118 -0
  154. package/unsafe.d.ts +1 -71
  155. package/unsafe.js +1 -878
  156. package/utils.d.ts +1 -31
  157. package/utils.js +1 -116
@@ -0,0 +1,167 @@
1
+ type PermissionPath = string | URL;
2
+ type NodePermissionSettings = {
3
+ allowWorker?: boolean;
4
+ allowChildProcess?: boolean;
5
+ allowAddons?: boolean;
6
+ allowFfi?: boolean;
7
+ allowWasi?: boolean;
8
+ };
9
+ type DenoPermissionSettings = {
10
+ lock?: boolean | PermissionPath;
11
+ frozen?: boolean;
12
+ /**
13
+ * Legacy compatibility: superseded by top-level `run`.
14
+ */
15
+ allowRun?: boolean;
16
+ };
17
+ type SysApiName = "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" | "systemMemoryInfo" | "uid" | "gid";
18
+ type PermissionEnvironment = {
19
+ allow?: string[] | true;
20
+ deny?: string[];
21
+ files?: PermissionPath | PermissionPath[];
22
+ };
23
+ type PermissionMode = "strict" | "unsafe" | "custom";
24
+ type PermissionLegacyMode = "off";
25
+ type PermissionProtocol = {
26
+ /**
27
+ * `strict` = hardened defaults, `unsafe` = full access,
28
+ * `custom` = strict baseline with user overrides.
29
+ */
30
+ mode?: PermissionMode;
31
+ /**
32
+ * Console access for worker task code.
33
+ * Defaults to `false` in strict/custom mode, `true` in unsafe mode.
34
+ */
35
+ console?: boolean;
36
+ /**
37
+ * Base directory used to resolve relative paths.
38
+ * Defaults to the current shell working directory.
39
+ */
40
+ cwd?: string;
41
+ /**
42
+ * Read allow-list. `true` means unrestricted access.
43
+ */
44
+ read?: PermissionPath[] | true;
45
+ /**
46
+ * Write allow-list. `true` means unrestricted access.
47
+ */
48
+ write?: PermissionPath[] | true;
49
+ /**
50
+ * Explicit deny-read entries.
51
+ */
52
+ denyRead?: PermissionPath[];
53
+ /**
54
+ * Explicit deny-write entries.
55
+ */
56
+ denyWrite?: PermissionPath[];
57
+ /**
58
+ * Network allow-list. `true` means unrestricted access.
59
+ */
60
+ net?: string[] | true;
61
+ /**
62
+ * Explicit network deny-list.
63
+ */
64
+ denyNet?: string[];
65
+ /**
66
+ * Allowed import hostnames. `true` means unrestricted import hosts.
67
+ */
68
+ allowImport?: string[] | true;
69
+ /**
70
+ * Environment permission settings.
71
+ */
72
+ env?: PermissionEnvironment;
73
+ /**
74
+ * Subprocess allow-list. `true` means unrestricted access.
75
+ */
76
+ run?: string[] | true;
77
+ /**
78
+ * Explicit subprocess deny-list.
79
+ */
80
+ denyRun?: string[];
81
+ /**
82
+ * Whether worker spawning is allowed.
83
+ */
84
+ workers?: boolean;
85
+ /**
86
+ * FFI allow-list or toggle.
87
+ */
88
+ ffi?: PermissionPath[] | boolean;
89
+ /**
90
+ * Explicit FFI deny-list.
91
+ */
92
+ denyFfi?: PermissionPath[];
93
+ /**
94
+ * System API allow-list. `true` means unrestricted access.
95
+ */
96
+ sys?: SysApiName[] | true;
97
+ /**
98
+ * Explicit system API deny-list.
99
+ */
100
+ denySys?: SysApiName[];
101
+ /**
102
+ * Whether WASI is allowed.
103
+ */
104
+ wasi?: boolean;
105
+ /**
106
+ * Backward-compat runtime overrides.
107
+ */
108
+ node?: NodePermissionSettings;
109
+ deno?: DenoPermissionSettings;
110
+ };
111
+ type PermissionProtocolInput = PermissionMode | PermissionLegacyMode | PermissionProtocol;
112
+ type L3RuntimeKeys = {
113
+ deno: string[];
114
+ node: string[];
115
+ };
116
+ type ResolvedPermissionProtocol = {
117
+ enabled: boolean;
118
+ mode: PermissionMode;
119
+ unsafe: boolean;
120
+ allowConsole: boolean;
121
+ cwd: string;
122
+ read: string[];
123
+ readAll: boolean;
124
+ write: string[];
125
+ writeAll: boolean;
126
+ denyRead: string[];
127
+ denyWrite: string[];
128
+ net: string[];
129
+ netAll: boolean;
130
+ denyNet: string[];
131
+ allowImport: string[];
132
+ allowImportAll: boolean;
133
+ env: {
134
+ allow: string[];
135
+ allowAll: boolean;
136
+ deny: string[];
137
+ files: string[];
138
+ };
139
+ envFiles: string[];
140
+ run: string[];
141
+ runAll: boolean;
142
+ denyRun: string[];
143
+ workers: boolean;
144
+ ffi: string[];
145
+ ffiAll: boolean;
146
+ denyFfi: string[];
147
+ sys: SysApiName[];
148
+ sysAll: boolean;
149
+ denySys: SysApiName[];
150
+ wasi: boolean;
151
+ lockFiles: {
152
+ deno?: string;
153
+ };
154
+ node: Required<NodePermissionSettings> & {
155
+ flags: string[];
156
+ };
157
+ deno: Required<Omit<DenoPermissionSettings, "lock">> & {
158
+ flags: string[];
159
+ };
160
+ l3: L3RuntimeKeys;
161
+ };
162
+ export declare const resolvePermissionProtocol: ({ permission, modules, }: {
163
+ permission?: PermissionProtocolInput;
164
+ modules?: string[];
165
+ }) => ResolvedPermissionProtocol | undefined;
166
+ export declare const toRuntimePermissionFlags: (protocol: ResolvedPermissionProtocol | undefined) => string[];
167
+ export type { DenoPermissionSettings, NodePermissionSettings, PermissionEnvironment, PermissionLegacyMode, PermissionMode, PermissionPath, PermissionProtocol, PermissionProtocolInput, ResolvedPermissionProtocol, SysApiName, };