arcane-os 0.1.0-dev.5
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/CHANGELOG.md +154 -0
- package/COMMERCIAL-LICENSE.md +13 -0
- package/LICENSE +661 -0
- package/NOTICE +70 -0
- package/README.md +448 -0
- package/bin/arcane-test.mjs +741 -0
- package/bin/arcane.mjs +5 -0
- package/docs/architecture.md +234 -0
- package/docs/compatibility.md +36 -0
- package/docs/event-manager.md +166 -0
- package/docs/platform-targets.md +108 -0
- package/docs/publishing.md +203 -0
- package/docs/reference/README.md +117 -0
- package/docs/reference/arcane-ollama.md +288 -0
- package/docs/reference/availability-and-normalization.md +123 -0
- package/docs/reference/behavioral-testing.md +86 -0
- package/docs/reference/cli.md +569 -0
- package/docs/reference/core/README.md +62 -0
- package/docs/reference/core/arcane-ai-contracts.md +873 -0
- package/docs/reference/core/arcane-api.md +601 -0
- package/docs/reference/core/arcane-entities.md +65 -0
- package/docs/reference/core/arcane-events.md +134 -0
- package/docs/reference/core/ollama-module.md +181 -0
- package/docs/reference/core/reference/arcane-api/ai-and-ollama.md +1909 -0
- package/docs/reference/core/reference/arcane-api/applications-terminal-capabilities.md +1057 -0
- package/docs/reference/core/reference/arcane-api/core-and-events.md +320 -0
- package/docs/reference/core/reference/arcane-api/filesystem-storage-preferences-appearance.md +610 -0
- package/docs/reference/core/reference/arcane-api/namespaces.md +1157 -0
- package/docs/reference/core/reference/arcane-api/platform-installation-users-system.md +1423 -0
- package/docs/reference/core/reference/arcane-api/session-provisioning-diagnostics-development.md +315 -0
- package/docs/reference/event-manager.md +957 -0
- package/docs/reference/inventory/package-api.json +2632 -0
- package/docs/reference/inventory/runtime-components.json +934 -0
- package/docs/reference/inventory/runtime-entities.json +26 -0
- package/docs/reference/inventory/runtime-modules.json +1249 -0
- package/docs/reference/protocols.md +242 -0
- package/docs/reference/runtime-components.md +1098 -0
- package/docs/reference/runtime-entities.md +303 -0
- package/docs/reference/runtime-modules.md +2010 -0
- package/docs/reference/sdk-api.md +4901 -0
- package/docs/roadmap.md +79 -0
- package/docs/work-amplification.md +124 -0
- package/node_modules/event-pubsub/CHANGELOG.md +55 -0
- package/node_modules/event-pubsub/MIGRATION.md +70 -0
- package/node_modules/event-pubsub/README.md +363 -0
- package/node_modules/event-pubsub/SECURITY.md +37 -0
- package/node_modules/event-pubsub/index.js +141 -0
- package/node_modules/event-pubsub/licence +21 -0
- package/node_modules/event-pubsub/package.json +59 -0
- package/node_modules/strong-type/README.md +408 -0
- package/node_modules/strong-type/assets/strong-type-header.png +0 -0
- package/node_modules/strong-type/index.js +1151 -0
- package/node_modules/strong-type/licence +21 -0
- package/node_modules/strong-type/node.js +125 -0
- package/node_modules/strong-type/package.json +61 -0
- package/package.json +95 -0
- package/runtime/ARCANE_RUNTIME_RELEASE.json +791 -0
- package/runtime/arcane/components/app-bar.html +468 -0
- package/runtime/arcane/components/assistant-panel.html +715 -0
- package/runtime/arcane/components/calculator.html +8 -0
- package/runtime/arcane/components/chart.html +655 -0
- package/runtime/arcane/components/chat.html +1225 -0
- package/runtime/arcane/components/conversation-view.html +13 -0
- package/runtime/arcane/components/dashboard-config.html +341 -0
- package/runtime/arcane/components/data-maintenance.html +112 -0
- package/runtime/arcane/components/data-view.html +92 -0
- package/runtime/arcane/components/directory-picker.html +197 -0
- package/runtime/arcane/components/document-inspector.html +252 -0
- package/runtime/arcane/components/file-drop.html +264 -0
- package/runtime/arcane/components/file-inspector.html +293 -0
- package/runtime/arcane/components/file-manager.html +1715 -0
- package/runtime/arcane/components/header.html +142 -0
- package/runtime/arcane/components/integration-settings.html +14 -0
- package/runtime/arcane/components/local-ai-status.html +360 -0
- package/runtime/arcane/components/markdown-document.html +1048 -0
- package/runtime/arcane/components/markdown-editor.html +360 -0
- package/runtime/arcane/components/media-embed.html +8 -0
- package/runtime/arcane/components/modal.html +402 -0
- package/runtime/arcane/components/output-panel.html +259 -0
- package/runtime/arcane/components/preferences-form.html +135 -0
- package/runtime/arcane/components/record-timeline.html +105 -0
- package/runtime/arcane/components/relationship-board.html +116 -0
- package/runtime/arcane/components/screen-capture.html +8 -0
- package/runtime/arcane/components/source-code-viewer.html +441 -0
- package/runtime/arcane/components/source-explanation.html +124 -0
- package/runtime/arcane/components/speech.html +365 -0
- package/runtime/arcane/components/summary-strip.html +177 -0
- package/runtime/arcane/components/table.html +77 -0
- package/runtime/arcane/components/task-progress.html +282 -0
- package/runtime/arcane/components/terminal-workspace.html +65 -0
- package/runtime/arcane/components/theme-editor.html +41 -0
- package/runtime/arcane/components/theme-switcher.html +46 -0
- package/runtime/arcane/components/unified-inbox.html +20 -0
- package/runtime/arcane/components/voice-transcription.html +476 -0
- package/runtime/arcane/components/weather-widget.html +8 -0
- package/runtime/arcane/components/web-navigator.html +239 -0
- package/runtime/arcane/css/communications.css +1 -0
- package/runtime/arcane/css/dashboard-config.css +45 -0
- package/runtime/arcane/css/document-site.css +981 -0
- package/runtime/arcane/css/layout.css +438 -0
- package/runtime/arcane/css/primitives.css +321 -0
- package/runtime/arcane/css/theme.css +112 -0
- package/runtime/arcane/css/utility-workspace.css +1 -0
- package/runtime/arcane/entities/ApiModelRecord.js +20 -0
- package/runtime/arcane/entities/Calculation.js +13 -0
- package/runtime/arcane/entities/Chat.js +581 -0
- package/runtime/arcane/entities/CommunicationMessage.js +29 -0
- package/runtime/arcane/entities/CommunicationThread.js +21 -0
- package/runtime/arcane/entities/Document.js +10 -0
- package/runtime/arcane/entities/File.js +143 -0
- package/runtime/arcane/entities/Image.js +135 -0
- package/runtime/arcane/entities/IntentEnvelope.js +834 -0
- package/runtime/arcane/entities/Preference.js +83 -0
- package/runtime/arcane/entities/TWiNPolicyDecision.js +1092 -0
- package/runtime/arcane/entities/TerminalSession.js +46 -0
- package/runtime/arcane/entities/Theme.js +107 -0
- package/runtime/arcane/entities/User.js +1046 -0
- package/runtime/arcane/entities/Weather.js +23 -0
- package/runtime/arcane/img/arcane-os-everywhere.png +0 -0
- package/runtime/arcane/img/arrow-left.png +0 -0
- package/runtime/arcane/img/arrow-right.png +0 -0
- package/runtime/arcane/img/doc.svg +5 -0
- package/runtime/arcane/img/folder.svg +4 -0
- package/runtime/arcane/img/image.svg +5 -0
- package/runtime/arcane/img/refresh.png +0 -0
- package/runtime/arcane/img/send.svg +9 -0
- package/runtime/arcane/img/trash.svg +5 -0
- package/runtime/arcane/img/upload.svg +5 -0
- package/runtime/arcane/modules/AI.js +2048 -0
- package/runtime/arcane/modules/AIPreferenceRuntime.js +32 -0
- package/runtime/arcane/modules/AIPreferenceTuple.js +92 -0
- package/runtime/arcane/modules/AIResponseLength.js +42 -0
- package/runtime/arcane/modules/AIResponseURLPolicy.js +626 -0
- package/runtime/arcane/modules/AnsiText.js +53 -0
- package/runtime/arcane/modules/ApiModelDatabase.js +25 -0
- package/runtime/arcane/modules/AppDataScope.js +245 -0
- package/runtime/arcane/modules/AppearancePreferences.js +28 -0
- package/runtime/arcane/modules/ArcaneCommunicationBridge.js +22 -0
- package/runtime/arcane/modules/ArcaneNavigationPolicy.js +135 -0
- package/runtime/arcane/modules/ArcaneNetworkPolicy.js +255 -0
- package/runtime/arcane/modules/AsyncBoundary.js +161 -0
- package/runtime/arcane/modules/BrowserTestSuite.js +326 -0
- package/runtime/arcane/modules/CalculatorEngine.js +20 -0
- package/runtime/arcane/modules/CaseEvidenceIndexer.js +134 -0
- package/runtime/arcane/modules/ChartLibrary.js +35 -0
- package/runtime/arcane/modules/ChatRecords.js +13 -0
- package/runtime/arcane/modules/CommunicationAppController.js +43 -0
- package/runtime/arcane/modules/CommunicationHub.js +16 -0
- package/runtime/arcane/modules/CommunicationPreferences.js +13 -0
- package/runtime/arcane/modules/CommunicationProviderRegistry.js +16 -0
- package/runtime/arcane/modules/ComponentContracts.js +586 -0
- package/runtime/arcane/modules/ConfiguredAIChatSession.js +288 -0
- package/runtime/arcane/modules/ConversationActionItems.js +488 -0
- package/runtime/arcane/modules/ConversationClosingReport.js +274 -0
- package/runtime/arcane/modules/ConversationTimebox.js +527 -0
- package/runtime/arcane/modules/CoreLocalModelCatalog.js +255 -0
- package/runtime/arcane/modules/DBLS.js +171 -0
- package/runtime/arcane/modules/DBOPFS.js +1154 -0
- package/runtime/arcane/modules/DBOPFSWorker.js +116 -0
- package/runtime/arcane/modules/DataMaintenance.js +91 -0
- package/runtime/arcane/modules/DevelopmentWorkspace.js +74 -0
- package/runtime/arcane/modules/DirectoryPicker.js +109 -0
- package/runtime/arcane/modules/DocumentNavigation.js +223 -0
- package/runtime/arcane/modules/Errors.js +1025 -0
- package/runtime/arcane/modules/GifEncoder.js +29 -0
- package/runtime/arcane/modules/HTMLImport.js +114 -0
- package/runtime/arcane/modules/InMemoryCommunicationProvider.js +14 -0
- package/runtime/arcane/modules/IsolatedModelQuestionRunner.js +275 -0
- package/runtime/arcane/modules/LocalAIReadiness.js +870 -0
- package/runtime/arcane/modules/LocalAIReadinessController.js +156 -0
- package/runtime/arcane/modules/MD.js +111 -0
- package/runtime/arcane/modules/Mail.js +352 -0
- package/runtime/arcane/modules/MailTransport.mjs +180 -0
- package/runtime/arcane/modules/Marked.min.js +71 -0
- package/runtime/arcane/modules/MemoryRecords.js +44 -0
- package/runtime/arcane/modules/MessageAdvisory.js +38 -0
- package/runtime/arcane/modules/ModelDefinition.js +189 -0
- package/runtime/arcane/modules/Ollama.js +74 -0
- package/runtime/arcane/modules/OllamaModelIdentifier.js +21 -0
- package/runtime/arcane/modules/OllamaSettings.js +24 -0
- package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +14 -0
- package/runtime/arcane/modules/PreferenceStore.js +109 -0
- package/runtime/arcane/modules/QRCode.min.js +1 -0
- package/runtime/arcane/modules/Questionnaire.js +61 -0
- package/runtime/arcane/modules/RecordLinkIndex.js +24 -0
- package/runtime/arcane/modules/RecordPassageIndex.js +222 -0
- package/runtime/arcane/modules/RecordReviewStore.js +94 -0
- package/runtime/arcane/modules/RevocableProjectionLedger.js +1623 -0
- package/runtime/arcane/modules/RiskSignalAnalyzer.js +37 -0
- package/runtime/arcane/modules/ScamRiskPolicy.js +62 -0
- package/runtime/arcane/modules/ScopedOPFSCache.js +183 -0
- package/runtime/arcane/modules/ScreenCapture.js +20 -0
- package/runtime/arcane/modules/SpeechPlayback.js +581 -0
- package/runtime/arcane/modules/StaticDocumentCatalog.js +1248 -0
- package/runtime/arcane/modules/SystemAppearance.js +20 -0
- package/runtime/arcane/modules/SystemPlatformPresentation.js +51 -0
- package/runtime/arcane/modules/SystemToolRegistry.js +28 -0
- package/runtime/arcane/modules/TerminalClient.js +52 -0
- package/runtime/arcane/modules/TerminalCommandRegistry.js +50 -0
- package/runtime/arcane/modules/ThemeBootstrap.js +26 -0
- package/runtime/arcane/modules/ThemeManager.js +131 -0
- package/runtime/arcane/modules/TimeGuard.js +149 -0
- package/runtime/arcane/modules/ToolCallRouter.js +83 -0
- package/runtime/arcane/modules/WaitForComponent.js +102 -0
- package/runtime/arcane/modules/YouTubeMedia.js +16 -0
- package/runtime/arcane/modules/uPlot.LICENSE.txt +21 -0
- package/runtime/arcane/modules/uPlot.iife.min.js +2 -0
- package/runtime/arcane/modules/uPlot.min.css +1 -0
- package/runtime/arcane/security/arcane-network-policy.json +6 -0
- package/runtime/strong-type/index.js +352 -0
- package/runtime/strong-type/licence +21 -0
- package/runtime/strong-type/package.json +45 -0
- package/schemas/arcane-app-bundle.schema.json +125 -0
- package/schemas/arcane-app.schema.json +329 -0
- package/schemas/arcane-lock.schema.json +86 -0
- package/schemas/arcane-package.schema.json +224 -0
- package/schemas/cli-event.schema.json +122 -0
- package/schemas/event-stack.schema.json +152 -0
- package/schemas/native-build-plan.schema.json +176 -0
- package/schemas/target-adapter.schema.json +117 -0
- package/src/app-descriptor.mjs +500 -0
- package/src/cli/main.mjs +561 -0
- package/src/constants.mjs +31 -0
- package/src/dev-server.mjs +718 -0
- package/src/doctor.mjs +315 -0
- package/src/dom-event-instrumentation.mjs +594 -0
- package/src/errors.mjs +75 -0
- package/src/event-manager.mjs +1342 -0
- package/src/event-queue.mjs +138 -0
- package/src/events.mjs +219 -0
- package/src/index.mjs +177 -0
- package/src/integrated-provider-loader.mjs +432 -0
- package/src/native-plan.mjs +698 -0
- package/src/native-provider-loader.mjs +1126 -0
- package/src/packager/core.mjs +2691 -0
- package/src/process.mjs +353 -0
- package/src/release-bundle.mjs +2523 -0
- package/src/repository.mjs +90 -0
- package/src/runtime.mjs +452 -0
- package/src/scaffold.mjs +380 -0
- package/src/targets/index.mjs +436 -0
- package/src/templates/assets/app-icon.png +0 -0
- package/src/templates/workspace-template.mjs +388 -0
- package/src/testing-loader.mjs +9 -0
- package/src/testing.mjs +427 -0
- package/src/toolchain.mjs +1335 -0
- package/src/update-check.mjs +307 -0
- package/src/workspace.mjs +449 -0
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
class Fake{
|
|
2
|
+
//fake class as fallback
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class FakeCore{
|
|
6
|
+
//fake class as fallback
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const brandProbe={};
|
|
10
|
+
|
|
11
|
+
const tryBrand=function(check){
|
|
12
|
+
try{
|
|
13
|
+
check();
|
|
14
|
+
return true;
|
|
15
|
+
}catch(err){
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const methodBrand=function(value,prototype,method,args=[]){
|
|
21
|
+
if(!prototype || typeof prototype[method] !== 'function'){
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return tryBrand(()=>Reflect.apply(prototype[method],value,args));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getterBrand=function(value,prototype,property){
|
|
29
|
+
if(!prototype){
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const descriptor=Object.getOwnPropertyDescriptor(prototype,property);
|
|
34
|
+
if(!descriptor || typeof descriptor.get !== 'function'){
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return tryBrand(()=>Reflect.apply(descriptor.get,value,[]));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getterValue=function(value,prototype,property){
|
|
42
|
+
const descriptor=prototype && Object.getOwnPropertyDescriptor(prototype,property);
|
|
43
|
+
if(!descriptor || typeof descriptor.get !== 'function'){
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Reflect.apply(descriptor.get,value,[]);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const instanceOf=function(value,constructor){
|
|
51
|
+
if(typeof constructor !== 'function'){
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try{
|
|
56
|
+
return value instanceof constructor;
|
|
57
|
+
}catch(err){
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const stringTagCheck=function(value,type){
|
|
63
|
+
try{
|
|
64
|
+
return Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
65
|
+
}catch(err){
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const arrayBufferCheck=function(value){
|
|
71
|
+
return getterBrand(value,globalThis.ArrayBuffer && globalThis.ArrayBuffer.prototype,'byteLength');
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const sharedArrayBufferCheck=function(value){
|
|
75
|
+
const constructor=globalThis.SharedArrayBuffer;
|
|
76
|
+
return getterBrand(value,constructor && constructor.prototype,'byteLength');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const dataViewCheck=function(value){
|
|
80
|
+
return getterBrand(value,globalThis.DataView && globalThis.DataView.prototype,'byteLength');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const arrayBufferViewCheck=function(value){
|
|
84
|
+
try{
|
|
85
|
+
return ArrayBuffer.isView(value);
|
|
86
|
+
}catch(err){
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const typedArrayTagGetter=(function(){
|
|
92
|
+
const prototype=Object.getPrototypeOf(Uint8Array.prototype);
|
|
93
|
+
const descriptor=Object.getOwnPropertyDescriptor(prototype,Symbol.toStringTag);
|
|
94
|
+
return descriptor && descriptor.get;
|
|
95
|
+
})();
|
|
96
|
+
|
|
97
|
+
const typedArrayName=function(value){
|
|
98
|
+
if(!arrayBufferViewCheck(value) || dataViewCheck(value) || typeof typedArrayTagGetter !== 'function'){
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
try{
|
|
103
|
+
return Reflect.apply(typedArrayTagGetter,value,[]);
|
|
104
|
+
}catch(err){
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const dateCheck=function(value){
|
|
110
|
+
return methodBrand(value,Date.prototype,'getTime');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const validDateCheck=function(value){
|
|
114
|
+
if(!dateCheck(value)){
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return !Number.isNaN(Reflect.apply(Date.prototype.getTime,value,[]));
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const mapCheck=function(value){
|
|
122
|
+
return methodBrand(value,Map.prototype,'has',[brandProbe]);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const weakMapCheck=function(value){
|
|
126
|
+
return methodBrand(value,WeakMap.prototype,'has',[brandProbe]);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const setCheck=function(value){
|
|
130
|
+
return methodBrand(value,Set.prototype,'has',[brandProbe]);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const weakSetCheck=function(value){
|
|
134
|
+
return methodBrand(value,WeakSet.prototype,'has',[brandProbe]);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const regExpCheck=function(value){
|
|
138
|
+
return getterBrand(value,RegExp.prototype,'source');
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const boxedBooleanCheck=function(value){
|
|
142
|
+
return typeof value === 'object' && value !== null && methodBrand(value,Boolean.prototype,'valueOf');
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const boxedNumberCheck=function(value){
|
|
146
|
+
return typeof value === 'object' && value !== null && methodBrand(value,Number.prototype,'valueOf');
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const boxedBigIntCheck=function(value){
|
|
150
|
+
const prototype=globalThis.BigInt && globalThis.BigInt.prototype;
|
|
151
|
+
return typeof value === 'object' && value !== null && methodBrand(value,prototype,'valueOf');
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const boxedStringCheck=function(value){
|
|
155
|
+
return typeof value === 'object' && value !== null && methodBrand(value,String.prototype,'valueOf');
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const boxedSymbolCheck=function(value){
|
|
159
|
+
const prototype=globalThis.Symbol && globalThis.Symbol.prototype;
|
|
160
|
+
return typeof value === 'object' && value !== null && methodBrand(value,prototype,'valueOf');
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const plainObjectCheck=function(value){
|
|
164
|
+
if(value === null || typeof value !== 'object'){
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let prototype;
|
|
169
|
+
try{
|
|
170
|
+
prototype=Object.getPrototypeOf(value);
|
|
171
|
+
}catch(err){
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
if(prototype === null){
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if(!Object.prototype.hasOwnProperty.call(prototype,'constructor')){
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const constructor=prototype.constructor;
|
|
183
|
+
return typeof constructor === 'function' && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(Object);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const protocolCheck=function(value,symbol,method){
|
|
187
|
+
if(value === null || value === undefined){
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const key=typeof symbol === 'symbol' ? symbol : method;
|
|
192
|
+
if(typeof key !== 'symbol' && typeof key !== 'string'){
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
try{
|
|
197
|
+
return typeof value[key] === 'function';
|
|
198
|
+
}catch(err){
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const blockedUnionMethods=new Set([
|
|
204
|
+
'constructor',
|
|
205
|
+
'throw',
|
|
206
|
+
'check',
|
|
207
|
+
'typeCheck',
|
|
208
|
+
'instanceCheck',
|
|
209
|
+
'symbolStringCheck',
|
|
210
|
+
'compare',
|
|
211
|
+
'globalInstanceCheck',
|
|
212
|
+
'nestedInstanceCheck',
|
|
213
|
+
'globalValueCheck',
|
|
214
|
+
'nestedValueCheck',
|
|
215
|
+
'union'
|
|
216
|
+
]);
|
|
217
|
+
|
|
218
|
+
const validatorFor=function(target,name){
|
|
219
|
+
if(blockedUnionMethods.has(name)){
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let current=target;
|
|
224
|
+
while(current && current !== Object.prototype){
|
|
225
|
+
const descriptor=Object.getOwnPropertyDescriptor(current,name);
|
|
226
|
+
if(descriptor && typeof descriptor.value === 'function' && descriptor.value.length <= 1){
|
|
227
|
+
return descriptor.value;
|
|
228
|
+
}
|
|
229
|
+
current=Object.getPrototypeOf(current);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return false;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
class Is{
|
|
236
|
+
constructor(strict=true){
|
|
237
|
+
this.strict=strict;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//core
|
|
241
|
+
throw(valueType,expectedType){
|
|
242
|
+
const err=new TypeError;
|
|
243
|
+
err.message=`expected type of ${valueType} to be ${expectedType}`;
|
|
244
|
+
if(!this.strict){
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
throw err;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
check(value,pass,expectedType){
|
|
251
|
+
if(pass){
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const valueType=value === null ? 'null' : typeof value;
|
|
256
|
+
return this.throw(valueType,expectedType);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
typeCheck(value,type){
|
|
260
|
+
return this.check(value,typeof value === type,type);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
instanceCheck(value=new Fake,constructor=FakeCore){
|
|
264
|
+
return this.check(value,instanceOf(value,constructor),constructor && constructor.name ? constructor.name : 'available constructor');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
symbolStringCheck(value,type){
|
|
268
|
+
return this.check(value,stringTagCheck(value,type),`[object ${type}]`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
compare(value,targetValue,typeName=String(targetValue)){
|
|
272
|
+
return this.check(value,Object.is(value,targetValue),typeName);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
globalInstanceCheck(value,type){
|
|
276
|
+
return this.check(value,instanceOf(value,globalThis[type]),type);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
nestedInstanceCheck(value,container,type){
|
|
280
|
+
const constructor=container && container[type];
|
|
281
|
+
return this.check(value,instanceOf(value,constructor),type);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
globalValueCheck(value,type){
|
|
285
|
+
const available=Object.prototype.hasOwnProperty.call(globalThis,type);
|
|
286
|
+
return this.check(value,available && Object.is(value,globalThis[type]),type);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
nestedValueCheck(value,container,type){
|
|
290
|
+
const available=container && Object.prototype.hasOwnProperty.call(container,type);
|
|
291
|
+
return this.check(value,available && Object.is(value,container[type]),type);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
defined(value){
|
|
295
|
+
return this.check(value,value !== undefined,'defined');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
any(value){
|
|
299
|
+
return this.defined(value);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
exists(value){
|
|
303
|
+
return this.defined(value);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
union(value,typesString){
|
|
307
|
+
const types=Array.isArray(typesString) ? typesString : typeof typesString === 'string' ? typesString.split('|') : [];
|
|
308
|
+
const names=types.map(type=>typeof type === 'string' ? type.trim() : '').filter(Boolean);
|
|
309
|
+
if(!names.length){
|
|
310
|
+
return this.throw(typeof typesString,'a pipe-delimited string or array of strong-type methods');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const validators=names.map(name=>validatorFor(this,name));
|
|
314
|
+
if(validators.some(validator=>!validator)){
|
|
315
|
+
const invalid=names[validators.findIndex(validator=>!validator)];
|
|
316
|
+
return this.throw(invalid,'a method available on strong-type');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const weakIs=Object.create(this);
|
|
320
|
+
weakIs.strict=false;
|
|
321
|
+
for(let index=0;index<validators.length;index++){
|
|
322
|
+
try{
|
|
323
|
+
if(validators[index].call(weakIs,value)){
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
}catch(err){
|
|
327
|
+
//custom validators may throw even when strict is false
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return this.throw(typeof value,names.join('|'));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
//values and primitives
|
|
335
|
+
finite(value){
|
|
336
|
+
return this.check(value,Number.isFinite(value),'finite number');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
finiteNumber(value){
|
|
340
|
+
return this.finite(value);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
NaN(value){
|
|
344
|
+
return this.check(value,Number.isNaN(value),'NaN');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
nan(value){
|
|
348
|
+
return this.NaN(value);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
null(value){
|
|
352
|
+
return this.check(value,value === null,'null');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
nullish(value){
|
|
356
|
+
return this.check(value,value === null || value === undefined,'null or undefined');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
boolean(value){
|
|
360
|
+
return this.typeCheck(value,'boolean');
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
bigInt(value){
|
|
364
|
+
return this.typeCheck(value,'bigint');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
bigint(value){
|
|
368
|
+
return this.bigInt(value);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
number(value){
|
|
372
|
+
return this.typeCheck(value,'number');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
integer(value){
|
|
376
|
+
return this.check(value,Number.isInteger(value),'integer');
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
safeInteger(value){
|
|
380
|
+
return this.check(value,Number.isSafeInteger(value),'safe integer');
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
infinity(value){
|
|
384
|
+
return this.check(value,value === Infinity,'Infinity');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
infinite(value){
|
|
388
|
+
return this.check(value,value === Infinity || value === -Infinity,'positive or negative Infinity');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
positiveInfinity(value){
|
|
392
|
+
return this.infinity(value);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
negativeInfinity(value){
|
|
396
|
+
return this.check(value,value === -Infinity,'-Infinity');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
negativeZero(value){
|
|
400
|
+
return this.check(value,Object.is(value,-0),'-0');
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
string(value){
|
|
404
|
+
return this.typeCheck(value,'string');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
symbol(value){
|
|
408
|
+
return this.typeCheck(value,'symbol');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
undefined(value){
|
|
412
|
+
return this.typeCheck(value,'undefined');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
primitive(value){
|
|
416
|
+
const type=typeof value;
|
|
417
|
+
return this.check(value,value === null || (type !== 'object' && type !== 'function'),'primitive');
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
globalThis(value){
|
|
421
|
+
return this.compare(value,globalThis,'explicitly globalThis, not window, global nor self');
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
atomics(value){
|
|
425
|
+
return this.globalValueCheck(value,'Atomics');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
json(value){
|
|
429
|
+
return this.globalValueCheck(value,'JSON');
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
math(value){
|
|
433
|
+
return this.globalValueCheck(value,'Math');
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
reflect(value){
|
|
437
|
+
return this.globalValueCheck(value,'Reflect');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
rawJSON(value){
|
|
441
|
+
const check=globalThis.JSON && globalThis.JSON.isRawJSON;
|
|
442
|
+
let pass=false;
|
|
443
|
+
try{
|
|
444
|
+
pass=typeof check === 'function' && check(value);
|
|
445
|
+
}catch(err){
|
|
446
|
+
pass=false;
|
|
447
|
+
}
|
|
448
|
+
return this.check(value,pass,'raw JSON');
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
//objects and collections
|
|
452
|
+
array(value){
|
|
453
|
+
return this.check(value,tryBrand(()=>{
|
|
454
|
+
if(!Array.isArray(value)){
|
|
455
|
+
throw new TypeError;
|
|
456
|
+
}
|
|
457
|
+
}),'Array');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
date(value){
|
|
461
|
+
return this.check(value,dateCheck(value),'Date');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
validDate(value){
|
|
465
|
+
return this.check(value,validDateCheck(value),'valid Date');
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
map(value){
|
|
469
|
+
return this.check(value,mapCheck(value),'Map');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
weakMap(value){
|
|
473
|
+
return this.check(value,weakMapCheck(value),'WeakMap');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
object(value){
|
|
477
|
+
return this.typeCheck(value,'object');
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
nonNullObject(value){
|
|
481
|
+
return this.check(value,value !== null && typeof value === 'object','non-null object');
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
plainObject(value){
|
|
485
|
+
return this.check(value,plainObjectCheck(value),'plain object');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
nullPrototypeObject(value){
|
|
489
|
+
const pass=value !== null && typeof value === 'object' && tryBrand(()=>{
|
|
490
|
+
if(Object.getPrototypeOf(value) !== null){
|
|
491
|
+
throw new TypeError;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
return this.check(value,pass,'null-prototype object');
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
argumentsObject(value){
|
|
498
|
+
return this.symbolStringCheck(value,'Arguments');
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
promise(value){
|
|
502
|
+
return this.globalInstanceCheck(value,'Promise');
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
thenable(value){
|
|
506
|
+
const pass=value !== null && value !== undefined && (typeof value === 'object' || typeof value === 'function') && protocolCheck(value,false,'then');
|
|
507
|
+
return this.check(value,pass,'thenable');
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
regExp(value){
|
|
511
|
+
return this.check(value,regExpCheck(value),'RegExp');
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
regexp(value){
|
|
515
|
+
return this.regExp(value);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
set(value){
|
|
519
|
+
return this.check(value,setCheck(value),'Set');
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
weakSet(value){
|
|
523
|
+
return this.check(value,weakSetCheck(value),'WeakSet');
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
//boxed primitives
|
|
527
|
+
boxedPrimitive(value){
|
|
528
|
+
const pass=boxedBooleanCheck(value) || boxedNumberCheck(value) || boxedBigIntCheck(value) || boxedStringCheck(value) || boxedSymbolCheck(value);
|
|
529
|
+
return this.check(value,pass,'boxed primitive');
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
booleanObject(value){
|
|
533
|
+
return this.check(value,boxedBooleanCheck(value),'Boolean object');
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
numberObject(value){
|
|
537
|
+
return this.check(value,boxedNumberCheck(value),'Number object');
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
bigIntObject(value){
|
|
541
|
+
return this.check(value,boxedBigIntCheck(value),'BigInt object');
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
stringObject(value){
|
|
545
|
+
return this.check(value,boxedStringCheck(value),'String object');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
symbolObject(value){
|
|
549
|
+
return this.check(value,boxedSymbolCheck(value),'Symbol object');
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
//functions and protocols
|
|
553
|
+
function(value){
|
|
554
|
+
return this.typeCheck(value,'function');
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
callable(value){
|
|
558
|
+
return this.function(value);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
asyncFunction(value){
|
|
562
|
+
return this.symbolStringCheck(value,'AsyncFunction');
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
generatorFunction(value){
|
|
566
|
+
return this.symbolStringCheck(value,'GeneratorFunction');
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
asyncGeneratorFunction(value){
|
|
570
|
+
return this.symbolStringCheck(value,'AsyncGeneratorFunction');
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
generator(value){
|
|
574
|
+
return this.symbolStringCheck(value,'Generator');
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
asyncGenerator(value){
|
|
578
|
+
return this.symbolStringCheck(value,'AsyncGenerator');
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
iterator(value){
|
|
582
|
+
const pass=value !== null && value !== undefined && protocolCheck(value,false,'next');
|
|
583
|
+
return this.check(value,pass,'iterator');
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
asyncIterator(value){
|
|
587
|
+
const symbol=Symbol.asyncIterator;
|
|
588
|
+
const pass=value !== null && value !== undefined && protocolCheck(value,false,'next') && typeof symbol === 'symbol' && protocolCheck(value,symbol);
|
|
589
|
+
return this.check(value,pass,'async iterator');
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
iterable(value){
|
|
593
|
+
return this.check(value,protocolCheck(value,Symbol.iterator),'iterable');
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
asyncIterable(value){
|
|
597
|
+
return this.check(value,protocolCheck(value,Symbol.asyncIterator),'async iterable');
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
//errors
|
|
601
|
+
error(value){
|
|
602
|
+
return this.instanceCheck(value,Error);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
aggregateError(value){
|
|
606
|
+
return this.globalInstanceCheck(value,'AggregateError');
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
evalError(value){
|
|
610
|
+
return this.instanceCheck(value,EvalError);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
rangeError(value){
|
|
614
|
+
return this.instanceCheck(value,RangeError);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
referenceError(value){
|
|
618
|
+
return this.instanceCheck(value,ReferenceError);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
syntaxError(value){
|
|
622
|
+
return this.instanceCheck(value,SyntaxError);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
typeError(value){
|
|
626
|
+
return this.instanceCheck(value,TypeError);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
URIError(value){
|
|
630
|
+
return this.instanceCheck(value,URIError);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
uriError(value){
|
|
634
|
+
return this.URIError(value);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
suppressedError(value){
|
|
638
|
+
return this.globalInstanceCheck(value,'SuppressedError');
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
//typed arrays
|
|
642
|
+
typedArray(value){
|
|
643
|
+
return this.check(value,Boolean(typedArrayName(value)),'typed array');
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
arrayBufferView(value){
|
|
647
|
+
return this.check(value,arrayBufferViewCheck(value),'ArrayBuffer view');
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
bigInt64Array(value){
|
|
651
|
+
return this.check(value,typedArrayName(value) === 'BigInt64Array','BigInt64Array');
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
bigUint64Array(value){
|
|
655
|
+
return this.check(value,typedArrayName(value) === 'BigUint64Array','BigUint64Array');
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
float16Array(value){
|
|
659
|
+
return this.check(value,typedArrayName(value) === 'Float16Array','Float16Array');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
float32Array(value){
|
|
663
|
+
return this.check(value,typedArrayName(value) === 'Float32Array','Float32Array');
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
float64Array(value){
|
|
667
|
+
return this.check(value,typedArrayName(value) === 'Float64Array','Float64Array');
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
int8Array(value){
|
|
671
|
+
return this.check(value,typedArrayName(value) === 'Int8Array','Int8Array');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
int16Array(value){
|
|
675
|
+
return this.check(value,typedArrayName(value) === 'Int16Array','Int16Array');
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
int32Array(value){
|
|
679
|
+
return this.check(value,typedArrayName(value) === 'Int32Array','Int32Array');
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
uint8Array(value){
|
|
683
|
+
return this.check(value,typedArrayName(value) === 'Uint8Array','Uint8Array');
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
uint8ClampedArray(value){
|
|
687
|
+
return this.check(value,typedArrayName(value) === 'Uint8ClampedArray','Uint8ClampedArray');
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
uint16Array(value){
|
|
691
|
+
return this.check(value,typedArrayName(value) === 'Uint16Array','Uint16Array');
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
uint32Array(value){
|
|
695
|
+
return this.check(value,typedArrayName(value) === 'Uint32Array','Uint32Array');
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
//buffers
|
|
699
|
+
arrayBuffer(value){
|
|
700
|
+
return this.check(value,arrayBufferCheck(value),'ArrayBuffer');
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
sharedArrayBuffer(value){
|
|
704
|
+
return this.check(value,sharedArrayBufferCheck(value),'SharedArrayBuffer');
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
anyArrayBuffer(value){
|
|
708
|
+
return this.check(value,arrayBufferCheck(value) || sharedArrayBufferCheck(value),'ArrayBuffer or SharedArrayBuffer');
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
dataView(value){
|
|
712
|
+
return this.check(value,dataViewCheck(value),'DataView');
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
resizableArrayBuffer(value){
|
|
716
|
+
const prototype=globalThis.ArrayBuffer && globalThis.ArrayBuffer.prototype;
|
|
717
|
+
const pass=arrayBufferCheck(value) && getterBrand(value,prototype,'resizable') && getterValue(value,prototype,'resizable') === true;
|
|
718
|
+
return this.check(value,pass,'resizable ArrayBuffer');
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
growableSharedArrayBuffer(value){
|
|
722
|
+
const constructor=globalThis.SharedArrayBuffer;
|
|
723
|
+
const prototype=constructor && constructor.prototype;
|
|
724
|
+
const pass=sharedArrayBufferCheck(value) && getterBrand(value,prototype,'growable') && getterValue(value,prototype,'growable') === true;
|
|
725
|
+
return this.check(value,pass,'growable SharedArrayBuffer');
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
detachedArrayBuffer(value){
|
|
729
|
+
if(!arrayBufferCheck(value)){
|
|
730
|
+
return this.check(value,false,'detached ArrayBuffer');
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const prototype=globalThis.ArrayBuffer.prototype;
|
|
734
|
+
const descriptor=Object.getOwnPropertyDescriptor(prototype,'detached');
|
|
735
|
+
if(descriptor && typeof descriptor.get === 'function'){
|
|
736
|
+
return this.check(value,Reflect.apply(descriptor.get,value,[]) === true,'detached ArrayBuffer');
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
let detached=false;
|
|
740
|
+
try{
|
|
741
|
+
new DataView(value);
|
|
742
|
+
}catch(err){
|
|
743
|
+
detached=true;
|
|
744
|
+
}
|
|
745
|
+
return this.check(value,detached,'detached ArrayBuffer');
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
//Intl
|
|
749
|
+
intlDateTimeFormat(value){
|
|
750
|
+
const constructor=globalThis.Intl && globalThis.Intl.DateTimeFormat;
|
|
751
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
752
|
+
return this.check(value,pass,'Intl.DateTimeFormat');
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
intlCollator(value){
|
|
756
|
+
const constructor=globalThis.Intl && globalThis.Intl.Collator;
|
|
757
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
758
|
+
return this.check(value,pass,'Intl.Collator');
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
intlDisplayNames(value){
|
|
762
|
+
const constructor=globalThis.Intl && globalThis.Intl.DisplayNames;
|
|
763
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
764
|
+
return this.check(value,pass,'Intl.DisplayNames');
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
intlListFormat(value){
|
|
768
|
+
const constructor=globalThis.Intl && globalThis.Intl.ListFormat;
|
|
769
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
770
|
+
return this.check(value,pass,'Intl.ListFormat');
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
intlLocale(value){
|
|
774
|
+
const constructor=globalThis.Intl && globalThis.Intl.Locale;
|
|
775
|
+
const pass=constructor && getterBrand(value,constructor.prototype,'baseName');
|
|
776
|
+
return this.check(value,pass,'Intl.Locale');
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
intlNumberFormat(value){
|
|
780
|
+
const constructor=globalThis.Intl && globalThis.Intl.NumberFormat;
|
|
781
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
782
|
+
return this.check(value,pass,'Intl.NumberFormat');
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
intlPluralRules(value){
|
|
786
|
+
const constructor=globalThis.Intl && globalThis.Intl.PluralRules;
|
|
787
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
788
|
+
return this.check(value,pass,'Intl.PluralRules');
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
intlRelativeTimeFormat(value){
|
|
792
|
+
const constructor=globalThis.Intl && globalThis.Intl.RelativeTimeFormat;
|
|
793
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
794
|
+
return this.check(value,pass,'Intl.RelativeTimeFormat');
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
intlSegmenter(value){
|
|
798
|
+
const constructor=globalThis.Intl && globalThis.Intl.Segmenter;
|
|
799
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
800
|
+
return this.check(value,pass,'Intl.Segmenter');
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
intlSegments(value){
|
|
804
|
+
const constructor=globalThis.Intl && globalThis.Intl.Segmenter;
|
|
805
|
+
let pass=false;
|
|
806
|
+
if(constructor){
|
|
807
|
+
const prototype=Object.getPrototypeOf(new constructor().segment(''));
|
|
808
|
+
pass=methodBrand(value,prototype,'containing',[0]);
|
|
809
|
+
}
|
|
810
|
+
return this.check(value,pass,'Intl Segments');
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
intlDurationFormat(value){
|
|
814
|
+
const constructor=globalThis.Intl && globalThis.Intl.DurationFormat;
|
|
815
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'resolvedOptions');
|
|
816
|
+
return this.check(value,pass,'Intl.DurationFormat');
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
//garbage collection and resource management
|
|
820
|
+
finalizationRegistry(value){
|
|
821
|
+
const constructor=globalThis.FinalizationRegistry;
|
|
822
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'unregister',[brandProbe]);
|
|
823
|
+
return this.check(value,pass,'FinalizationRegistry');
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
weakRef(value){
|
|
827
|
+
const constructor=globalThis.WeakRef;
|
|
828
|
+
const pass=constructor && methodBrand(value,constructor.prototype,'deref');
|
|
829
|
+
return this.check(value,pass,'WeakRef');
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
disposable(value){
|
|
833
|
+
const symbol=Symbol.dispose;
|
|
834
|
+
return this.check(value,typeof symbol === 'symbol' && protocolCheck(value,symbol),'disposable');
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
asyncDisposable(value){
|
|
838
|
+
const symbol=Symbol.asyncDispose;
|
|
839
|
+
return this.check(value,typeof symbol === 'symbol' && protocolCheck(value,symbol),'async disposable');
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
disposableStack(value){
|
|
843
|
+
return this.globalInstanceCheck(value,'DisposableStack');
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
asyncDisposableStack(value){
|
|
847
|
+
return this.globalInstanceCheck(value,'AsyncDisposableStack');
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
//Temporal
|
|
851
|
+
temporalDuration(value){
|
|
852
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'Duration');
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
temporalInstant(value){
|
|
856
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'Instant');
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
temporalPlainDate(value){
|
|
860
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'PlainDate');
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
temporalPlainDateTime(value){
|
|
864
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'PlainDateTime');
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
temporalPlainMonthDay(value){
|
|
868
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'PlainMonthDay');
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
temporalPlainTime(value){
|
|
872
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'PlainTime');
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
temporalPlainYearMonth(value){
|
|
876
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'PlainYearMonth');
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
temporalZonedDateTime(value){
|
|
880
|
+
return this.nestedInstanceCheck(value,globalThis.Temporal,'ZonedDateTime');
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
//URL and text
|
|
884
|
+
url(value){
|
|
885
|
+
return this.globalInstanceCheck(value,'URL');
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
urlSearchParams(value){
|
|
889
|
+
return this.globalInstanceCheck(value,'URLSearchParams');
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
urlPattern(value){
|
|
893
|
+
return this.globalInstanceCheck(value,'URLPattern');
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
textEncoder(value){
|
|
897
|
+
return this.globalInstanceCheck(value,'TextEncoder');
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
textDecoder(value){
|
|
901
|
+
return this.globalInstanceCheck(value,'TextDecoder');
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
textEncoderStream(value){
|
|
905
|
+
return this.globalInstanceCheck(value,'TextEncoderStream');
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
textDecoderStream(value){
|
|
909
|
+
return this.globalInstanceCheck(value,'TextDecoderStream');
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
//fetch and data
|
|
913
|
+
domException(value){
|
|
914
|
+
return this.globalInstanceCheck(value,'DOMException');
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
blob(value){
|
|
918
|
+
return this.globalInstanceCheck(value,'Blob');
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
file(value){
|
|
922
|
+
return this.globalInstanceCheck(value,'File');
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
formData(value){
|
|
926
|
+
return this.globalInstanceCheck(value,'FormData');
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
headers(value){
|
|
930
|
+
return this.globalInstanceCheck(value,'Headers');
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
request(value){
|
|
934
|
+
return this.globalInstanceCheck(value,'Request');
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
response(value){
|
|
938
|
+
return this.globalInstanceCheck(value,'Response');
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
//events and messaging
|
|
942
|
+
abortController(value){
|
|
943
|
+
return this.globalInstanceCheck(value,'AbortController');
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
abortSignal(value){
|
|
947
|
+
return this.globalInstanceCheck(value,'AbortSignal');
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
event(value){
|
|
951
|
+
return this.globalInstanceCheck(value,'Event');
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
eventTarget(value){
|
|
955
|
+
return this.globalInstanceCheck(value,'EventTarget');
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
customEvent(value){
|
|
959
|
+
return this.globalInstanceCheck(value,'CustomEvent');
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
messageEvent(value){
|
|
963
|
+
return this.globalInstanceCheck(value,'MessageEvent');
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
closeEvent(value){
|
|
967
|
+
return this.globalInstanceCheck(value,'CloseEvent');
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
errorEvent(value){
|
|
971
|
+
return this.globalInstanceCheck(value,'ErrorEvent');
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
broadcastChannel(value){
|
|
975
|
+
return this.globalInstanceCheck(value,'BroadcastChannel');
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
messageChannel(value){
|
|
979
|
+
return this.globalInstanceCheck(value,'MessageChannel');
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
messagePort(value){
|
|
983
|
+
return this.globalInstanceCheck(value,'MessagePort');
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
webSocket(value){
|
|
987
|
+
return this.globalInstanceCheck(value,'WebSocket');
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
eventSource(value){
|
|
991
|
+
return this.globalInstanceCheck(value,'EventSource');
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
navigator(value){
|
|
995
|
+
return this.globalValueCheck(value,'navigator');
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
storage(value){
|
|
999
|
+
return this.globalInstanceCheck(value,'Storage');
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
//streams
|
|
1003
|
+
readableStream(value){
|
|
1004
|
+
return this.globalInstanceCheck(value,'ReadableStream');
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
readableStreamDefaultReader(value){
|
|
1008
|
+
return this.globalInstanceCheck(value,'ReadableStreamDefaultReader');
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
readableStreamBYOBReader(value){
|
|
1012
|
+
return this.globalInstanceCheck(value,'ReadableStreamBYOBReader');
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
readableStreamDefaultController(value){
|
|
1016
|
+
return this.globalInstanceCheck(value,'ReadableStreamDefaultController');
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
readableByteStreamController(value){
|
|
1020
|
+
return this.globalInstanceCheck(value,'ReadableByteStreamController');
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
readableStreamBYOBRequest(value){
|
|
1024
|
+
return this.globalInstanceCheck(value,'ReadableStreamBYOBRequest');
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
writableStream(value){
|
|
1028
|
+
return this.globalInstanceCheck(value,'WritableStream');
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
writableStreamDefaultWriter(value){
|
|
1032
|
+
return this.globalInstanceCheck(value,'WritableStreamDefaultWriter');
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
writableStreamDefaultController(value){
|
|
1036
|
+
return this.globalInstanceCheck(value,'WritableStreamDefaultController');
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
transformStream(value){
|
|
1040
|
+
return this.globalInstanceCheck(value,'TransformStream');
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
transformStreamDefaultController(value){
|
|
1044
|
+
return this.globalInstanceCheck(value,'TransformStreamDefaultController');
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
byteLengthQueuingStrategy(value){
|
|
1048
|
+
return this.globalInstanceCheck(value,'ByteLengthQueuingStrategy');
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
countQueuingStrategy(value){
|
|
1052
|
+
return this.globalInstanceCheck(value,'CountQueuingStrategy');
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
compressionStream(value){
|
|
1056
|
+
return this.globalInstanceCheck(value,'CompressionStream');
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
decompressionStream(value){
|
|
1060
|
+
return this.globalInstanceCheck(value,'DecompressionStream');
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
//crypto and performance
|
|
1064
|
+
crypto(value){
|
|
1065
|
+
return this.globalValueCheck(value,'crypto');
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
subtleCrypto(value){
|
|
1069
|
+
const crypto=globalThis.crypto;
|
|
1070
|
+
return this.check(value,crypto && Object.is(value,crypto.subtle),'SubtleCrypto');
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
cryptoKey(value){
|
|
1074
|
+
return this.globalInstanceCheck(value,'CryptoKey');
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
performance(value){
|
|
1078
|
+
return this.globalValueCheck(value,'performance');
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
performanceEntry(value){
|
|
1082
|
+
return this.globalInstanceCheck(value,'PerformanceEntry');
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
performanceMark(value){
|
|
1086
|
+
const constructor=globalThis.PerformanceMark;
|
|
1087
|
+
const pass=typeof constructor === 'function' ? instanceOf(value,constructor) : stringTagCheck(value,'PerformanceMark');
|
|
1088
|
+
return this.check(value,pass,'PerformanceMark');
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
performanceMeasure(value){
|
|
1092
|
+
const constructor=globalThis.PerformanceMeasure;
|
|
1093
|
+
const pass=typeof constructor === 'function' ? instanceOf(value,constructor) : stringTagCheck(value,'PerformanceMeasure');
|
|
1094
|
+
return this.check(value,pass,'PerformanceMeasure');
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
performanceObserver(value){
|
|
1098
|
+
return this.globalInstanceCheck(value,'PerformanceObserver');
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
performanceObserverEntryList(value){
|
|
1102
|
+
return this.globalInstanceCheck(value,'PerformanceObserverEntryList');
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
performanceResourceTiming(value){
|
|
1106
|
+
return this.globalInstanceCheck(value,'PerformanceResourceTiming');
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
//WebAssembly
|
|
1110
|
+
webAssemblyModule(value){
|
|
1111
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Module');
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
webAssemblyInstance(value){
|
|
1115
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Instance');
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
webAssemblyMemory(value){
|
|
1119
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Memory');
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
webAssemblyTable(value){
|
|
1123
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Table');
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
webAssemblyGlobal(value){
|
|
1127
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Global');
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
webAssemblyTag(value){
|
|
1131
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Tag');
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
webAssemblyException(value){
|
|
1135
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'Exception');
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
webAssemblyCompileError(value){
|
|
1139
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'CompileError');
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
webAssemblyLinkError(value){
|
|
1143
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'LinkError');
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
webAssemblyRuntimeError(value){
|
|
1147
|
+
return this.nestedInstanceCheck(value,globalThis.WebAssembly,'RuntimeError');
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
export {Is as default,Is};
|