@promptbook/browser 0.72.0-3 → 0.72.0-30
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 +11 -1
- package/esm/index.es.js +247 -6
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +3 -1
- package/esm/typings/src/_packages/cli.index.d.ts +20 -0
- package/esm/typings/src/_packages/core.index.d.ts +56 -28
- package/esm/typings/src/_packages/documents.index.d.ts +8 -0
- package/esm/typings/src/_packages/legacy-documents.index.d.ts +8 -0
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/node.index.d.ts +18 -6
- package/esm/typings/src/_packages/pdf.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +57 -33
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/_packages/website-crawler.index.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +13 -0
- package/esm/typings/src/cli/main.d.ts +1 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
- package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -6
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +5 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/utils/sourceContentToName.d.ts +11 -0
- package/esm/typings/src/commands/KNOWLEDGE/utils/sourceContentToName.test.d.ts +4 -0
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/TEMPLATE/templateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
- package/esm/typings/src/config.d.ts +35 -12
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +4 -15
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +5 -5
- package/esm/typings/src/{knowledge/dialogs → dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
- package/esm/typings/src/{knowledge/dialogs → dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +3 -3
- package/esm/typings/src/{knowledge/dialogs → dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +6 -6
- package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
- package/esm/typings/src/errors/KnowledgeScrapeError.d.ts +9 -0
- package/esm/typings/src/errors/MissingToolsError.d.ts +9 -0
- package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/execution/{CommonExecutionToolsOptions.d.ts → CommonToolsOptions.d.ts} +1 -1
- package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
- package/esm/typings/src/execution/Executables.d.ts +18 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +35 -9
- package/esm/typings/src/execution/FilesystemTools.d.ts +9 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -2
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -2
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +31 -5
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +6 -12
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +7 -18
- package/esm/typings/src/execution/createPipelineExecutor/{30-executeFormatCells.d.ts → 30-executeFormatSubvalues.d.ts} +2 -6
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -19
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
- package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +4 -0
- package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +13 -0
- package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +2 -1
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +3 -2
- package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/{$llmToolsMetadataRegister.d.ts → register/$llmToolsMetadataRegister.d.ts} +4 -1
- package/esm/typings/src/llm-providers/_common/{$llmToolsRegister.d.ts → register/$llmToolsRegister.d.ts} +5 -2
- package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfigurationFromEnv.d.ts → register/$provideLlmToolsConfigurationFromEnv.d.ts} +3 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +15 -0
- package/esm/typings/src/llm-providers/_common/{getLlmToolsForTestingAndScriptsAndPlayground.d.ts → register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts} +4 -3
- package/esm/typings/src/llm-providers/_common/{createLlmToolsFromEnv.d.ts → register/$provideLlmToolsFromEnv.d.ts} +6 -5
- package/esm/typings/src/llm-providers/_common/{$registeredLlmToolsMessage.d.ts → register/$registeredLlmToolsMessage.d.ts} +5 -2
- package/esm/typings/src/llm-providers/_common/{LlmToolsConfiguration.d.ts → register/LlmToolsConfiguration.d.ts} +6 -5
- package/esm/typings/src/llm-providers/_common/{LlmToolsMetadata.d.ts → register/LlmToolsMetadata.d.ts} +5 -4
- package/esm/typings/src/llm-providers/_common/{LlmToolsOptions.d.ts → register/LlmToolsOptions.d.ts} +4 -1
- package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfiguration.d.ts → register/createLlmToolsFromConfiguration.d.ts} +12 -4
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +5 -5
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +4 -3
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +4 -3
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +7 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +4 -3
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +4 -3
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +4 -3
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/langtail/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -2
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +4 -4
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +2 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +5 -4
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +5 -4
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +16 -7
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +7 -13
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +11 -16
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +24 -9
- package/esm/typings/src/llm-providers/remote/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +3 -2
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +49 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +3 -2
- package/esm/typings/src/prepare/prepareTemplates.d.ts +4 -3
- package/esm/typings/src/scrapers/_common/Converter.d.ts +22 -0
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +59 -0
- package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +11 -0
- package/esm/typings/src/{knowledge/prepare-knowledge → scrapers}/_common/prepareKnowledgePieces.d.ts +5 -4
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +11 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +15 -0
- package/esm/typings/src/scrapers/_common/register/$registeredScrapersMessage.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +13 -0
- package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +13 -0
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +41 -0
- package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +34 -0
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.test.d.ts +4 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +11 -0
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +43 -0
- package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +4 -0
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/document/playground/document-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +43 -0
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +4 -0
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +29 -0
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +40 -0
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +50 -0
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/website/playground/website-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +3 -3
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +3 -3
- package/esm/typings/src/storage/{files-storage/FilesStorage.d.ts → file-cache-storage/FileCacheStorage.d.ts} +7 -5
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +10 -0
- package/esm/typings/src/storage/{files-storage → file-cache-storage}/utils/nameToSubfolderPath.d.ts +2 -2
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +1 -1
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +1 -1
- package/esm/typings/src/storage/{utils → memory/utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/storage/{utils → memory/utils}/makePromptbookStorageFromWebStorage.d.ts +1 -1
- package/esm/typings/src/types/Arrayable.d.ts +1 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +10 -3
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
- package/esm/typings/src/types/Prompt.d.ts +2 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -4
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +27 -20
- package/esm/typings/src/utils/$Register.d.ts +20 -7
- package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
- package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
- package/esm/typings/src/utils/emojis.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +14 -0
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +17 -0
- package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +19 -0
- package/esm/typings/src/utils/execCommand/execCommand.test.d.ts +1 -0
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +10 -0
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.test.d.ts +1 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/esm/typings/src/utils/files/extensionToMimeType.d.ts +8 -0
- package/esm/typings/src/utils/files/extensionToMimeType.test.d.ts +1 -0
- package/esm/typings/src/utils/files/getFileExtension.d.ts +8 -0
- package/esm/typings/src/utils/files/getFileExtension.test.d.ts +1 -0
- package/esm/typings/src/utils/files/isDirectoryExisting.d.ts +14 -0
- package/esm/typings/src/utils/files/isDirectoryExisting.test.d.ts +1 -0
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/esm/typings/src/utils/files/isFileExisting.d.ts +13 -0
- package/esm/typings/src/utils/files/isFileExisting.test.d.ts +1 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +17 -0
- package/esm/typings/src/utils/files/listAllFiles.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
- package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
- package/esm/typings/src/utils/sets/union.d.ts +1 -1
- package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -2
- package/package.json +4 -3
- package/umd/index.umd.js +247 -5
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -40
- package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +0 -37
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -2
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -14
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -15
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +0 -22
- package/esm/typings/src/prepare/PrepareOptions.d.ts +0 -22
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -10
- package/esm/typings/src/utils/files/$isDirectoryExisting.d.ts +0 -15
- package/esm/typings/src/utils/files/$isFileExisting.d.ts +0 -14
- package/esm/typings/src/utils/files/$listAllFiles.d.ts +0 -17
- /package/esm/typings/src/{knowledge/dialogs → dialogs}/user-interface-execution-tools.test.d.ts +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
- /package/esm/typings/src/{storage/files-storage/utils/nameToSubfolderPath.test.d.ts → executables/locateApp.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/files/$isDirectoryExisting.test.d.ts → scrapers/_common/prepareKnowledgePieces.test.d.ts} +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts → scrapers/markdown/MarkdownScraper.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/files/$isFileExisting.test.d.ts → scrapers/website/utils/createShowdownConverter.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/files/$listAllFiles.test.d.ts → storage/file-cache-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
2
|
+
import type { string_mime_type } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Get the file extension from a file name
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFileExtension(value: string_filename): string_mime_type | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
import type { string_dirname } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the directory exists
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDirectoryExisting(directoryPath: string_dirname, fs: FilesystemTools): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
11
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
12
|
+
* TODO: [🧠][📂] "directory" vs "folder"
|
|
13
|
+
* TODO: [🖇] What about symlinks?
|
|
14
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the file is executable
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function isExecutable(path: string, fs: FilesystemTools): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
10
|
+
* TODO: [🖇] What about symlinks?
|
|
11
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the file exists
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function isFileExisting(filename: string_filename, fs: FilesystemTools): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
11
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
12
|
+
* TODO: [🖇] What about symlinks?
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
import type { string_dirname } from '../../types/typeAliases';
|
|
3
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* Reads all files in the directory
|
|
6
|
+
*
|
|
7
|
+
* @param path
|
|
8
|
+
* @param isRecursive
|
|
9
|
+
* @returns List of all files in the directory
|
|
10
|
+
* @private internal function of `createCollectionFromDirectory`
|
|
11
|
+
*/
|
|
12
|
+
export declare function listAllFiles(path: string_dirname, isRecursive: boolean, fs: FilesystemTools): Promise<Array<string_filename>>;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: [😶] Unite floder listing
|
|
15
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
16
|
+
* TODO: [🖇] What about symlinks?
|
|
17
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -30,7 +30,7 @@ export type CodeBlock = {
|
|
|
30
30
|
* @throws {ParseError} if block is not closed properly
|
|
31
31
|
* @public exported from `@promptbook/markdown-utils`
|
|
32
32
|
*/
|
|
33
|
-
export declare function extractAllBlocksFromMarkdown(markdown: string_markdown):
|
|
33
|
+
export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<CodeBlock>;
|
|
34
34
|
/**
|
|
35
35
|
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
36
36
|
*/
|
|
@@ -5,7 +5,7 @@ import type { string_markdown_section } from '../../types/typeAliases';
|
|
|
5
5
|
*
|
|
6
6
|
* @public exported from `@promptbook/markdown-utils`
|
|
7
7
|
*/
|
|
8
|
-
export declare function splitMarkdownIntoSections(markdown: string_markdown):
|
|
8
|
+
export declare function splitMarkdownIntoSections(markdown: string_markdown): ReadonlyArray<string_markdown_section>;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🏛] This can be part of markdown builder
|
|
11
11
|
* Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Semantic helper
|
|
3
3
|
*
|
|
4
4
|
* Keyword is string without diacritics in lowercase [a-z1-9]
|
|
5
|
-
* Words are splitted between multiple keywords @see
|
|
5
|
+
* Words are splitted between multiple keywords @see Keywords
|
|
6
6
|
*
|
|
7
7
|
* For example `"keyword"`
|
|
8
8
|
*
|
|
@@ -15,7 +15,7 @@ export type string_keyword = string;
|
|
|
15
15
|
*
|
|
16
16
|
* @public exported from `@promptbook/utils`
|
|
17
17
|
*/
|
|
18
|
-
export type
|
|
18
|
+
export type Keywords = Set<string_keyword>;
|
|
19
19
|
/**
|
|
20
20
|
* TODO: [🌮] Keywords with weight
|
|
21
21
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { really_unknown } from '../organization/really_unknown';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Keywords } from './IKeywords';
|
|
3
3
|
/**
|
|
4
4
|
* Parses keywords from any object and recursively walks through
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@ import type { IKeywords } from './IKeywords';
|
|
|
9
9
|
* @returns {Set} of keywords without diacritics in lowercase
|
|
10
10
|
* @public exported from `@promptbook/utils`
|
|
11
11
|
*/
|
|
12
|
-
export declare function parseKeywords(input: really_unknown):
|
|
12
|
+
export declare function parseKeywords(input: really_unknown): Keywords;
|
|
13
13
|
/**
|
|
14
14
|
* Note: Not using spread in input param because of keeping second parameter for options
|
|
15
15
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Keywords } from './IKeywords';
|
|
2
2
|
/**
|
|
3
3
|
* Parses keywords from a string
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { IKeywords } from './IKeywords';
|
|
|
6
6
|
* @returns {Set} of keywords without diacritics in lowercase
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
|
-
export declare function parseKeywordsFromString(input: string):
|
|
9
|
+
export declare function parseKeywordsFromString(input: string): Keywords;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Keywords } from './IKeywords';
|
|
2
2
|
/**
|
|
3
3
|
* @@@
|
|
4
4
|
*
|
|
@@ -7,4 +7,4 @@ import type { IKeywords } from './IKeywords';
|
|
|
7
7
|
* @returns
|
|
8
8
|
* @public exported from `@promptbook/utils`
|
|
9
9
|
*/
|
|
10
|
-
export declare function searchKeywords(haystack:
|
|
10
|
+
export declare function searchKeywords(haystack: Keywords, needle: Keywords): boolean;
|
|
@@ -13,4 +13,4 @@ import type { really_any } from './really_any';
|
|
|
13
13
|
* @returns void
|
|
14
14
|
* @private within the repository
|
|
15
15
|
*/
|
|
16
|
-
export declare function keepUnused<TTypeToKeep1 = really_any, TTypeToKeep2 = really_any, TTypeToKeep3 = really_any>(...valuesToKeep:
|
|
16
|
+
export declare function keepUnused<TTypeToKeep1 = really_any, TTypeToKeep2 = really_any, TTypeToKeep3 = really_any>(...valuesToKeep: ReadonlyArray<really_any>): void;
|
|
@@ -3,7 +3,7 @@ import type { number_seed } from '../../types/typeAliases';
|
|
|
3
3
|
* Generates random seed
|
|
4
4
|
*
|
|
5
5
|
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
6
|
-
* Warning: This function is
|
|
6
|
+
* Warning: This function is NOT cryptographically secure (it uses Math.random internally)
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function $randomSeed(): number_seed;
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
|
-
export declare function intersection<TItem>(...sets:
|
|
7
|
+
export declare function intersection<TItem>(...sets: ReadonlyArray<Set<TItem>>): Set<TItem>;
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
|
-
export declare function union<TItem>(...sets:
|
|
7
|
+
export declare function union<TItem>(...sets: ReadonlyArray<Set<TItem>>): Set<TItem>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Additional options for `unwrapResult`
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
type UnwrapResultOptions = {
|
|
5
5
|
/**
|
|
6
6
|
* If true, the text is trimmed before processing
|
|
7
7
|
*/
|
|
8
|
-
isTrimmed?: boolean;
|
|
8
|
+
readonly isTrimmed?: boolean;
|
|
9
9
|
/**
|
|
10
10
|
* If true, the introduce sentence is removed
|
|
11
11
|
*
|
|
@@ -15,8 +15,8 @@ interface UnwrapResultOptions {
|
|
|
15
15
|
*
|
|
16
16
|
* @default true
|
|
17
17
|
*/
|
|
18
|
-
isIntroduceSentenceRemoved?: boolean;
|
|
19
|
-
}
|
|
18
|
+
readonly isIntroduceSentenceRemoved?: boolean;
|
|
19
|
+
};
|
|
20
20
|
/**
|
|
21
21
|
* Removes quotes and optional introduce text from a string
|
|
22
22
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_filename } from '../../../types/typeAliases';
|
|
2
2
|
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
3
|
/**
|
|
4
4
|
* Tests if given string is valid URL.
|
|
@@ -6,4 +6,4 @@ import type { really_unknown } from '../../organization/really_unknown';
|
|
|
6
6
|
* Note: This does not check if the file exists only if the path is valid
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
|
-
export declare function isValidFilePath(
|
|
9
|
+
export declare function isValidFilePath(filename: really_unknown): filename is string_filename;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/browser",
|
|
3
|
-
"version": "0.72.0-
|
|
3
|
+
"version": "0.72.0-30",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"contributors": [
|
|
12
12
|
"Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
|
|
13
13
|
],
|
|
14
|
+
"todo-0": "TODO: [❇️] Make better list of keywords",
|
|
14
15
|
"keywords": [
|
|
15
16
|
"ai",
|
|
16
17
|
"llm",
|
|
@@ -51,9 +52,9 @@
|
|
|
51
52
|
"module": "./esm/index.es.js",
|
|
52
53
|
"typings": "./esm/typings/src/_packages/browser.index.d.ts",
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.72.0-
|
|
55
|
+
"@promptbook/core": "0.72.0-30"
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
|
-
"spacetrim": "0.11.
|
|
58
|
+
"spacetrim": "0.11.59"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/umd/index.umd.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* The version of the Promptbook library
|
|
14
14
|
*/
|
|
15
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
16
|
-
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
15
|
+
var PROMPTBOOK_VERSION = '0.72.0-29';
|
|
16
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
17
17
|
|
|
18
18
|
/*! *****************************************************************************
|
|
19
19
|
Copyright (c) Microsoft Corporation.
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
return SimplePromptInterfaceTools;
|
|
164
164
|
}());
|
|
165
165
|
/**
|
|
166
|
-
* Note: [🔵]
|
|
166
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -182,6 +182,24 @@
|
|
|
182
182
|
return EnvironmentMismatchError;
|
|
183
183
|
}(Error));
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Detects if the code is running in a browser environment in main thread (Not in a web worker)
|
|
187
|
+
*
|
|
188
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
189
|
+
*
|
|
190
|
+
* @public exported from `@promptbook/utils`
|
|
191
|
+
*/
|
|
192
|
+
var $isRunningInBrowser = new Function("\n try {\n return this === window;\n } catch (e) {\n return false;\n }\n");
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Detects if the code is running in a web worker
|
|
196
|
+
*
|
|
197
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
198
|
+
*
|
|
199
|
+
* @public exported from `@promptbook/utils`
|
|
200
|
+
*/
|
|
201
|
+
var $isRunningInWebWorker = new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
|
|
202
|
+
|
|
185
203
|
/**
|
|
186
204
|
* @@@
|
|
187
205
|
*
|
|
@@ -420,6 +438,229 @@
|
|
|
420
438
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
421
439
|
*/
|
|
422
440
|
|
|
441
|
+
/**
|
|
442
|
+
* This error type indicates that some part of the code is not implemented yet
|
|
443
|
+
*
|
|
444
|
+
* @public exported from `@promptbook/core`
|
|
445
|
+
*/
|
|
446
|
+
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
447
|
+
__extends(NotYetImplementedError, _super);
|
|
448
|
+
function NotYetImplementedError(message) {
|
|
449
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
450
|
+
_this.name = 'NotYetImplementedError';
|
|
451
|
+
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
452
|
+
return _this;
|
|
453
|
+
}
|
|
454
|
+
return NotYetImplementedError;
|
|
455
|
+
}(Error));
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @@@
|
|
459
|
+
*
|
|
460
|
+
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
461
|
+
*
|
|
462
|
+
* @private internal function of `$Register`
|
|
463
|
+
*/
|
|
464
|
+
function $getGlobalScope() {
|
|
465
|
+
return Function('return this')();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @@@
|
|
470
|
+
*
|
|
471
|
+
* @param text @@@
|
|
472
|
+
* @returns @@@
|
|
473
|
+
* @example 'HELLO_WORLD'
|
|
474
|
+
* @example 'I_LOVE_PROMPTBOOK'
|
|
475
|
+
* @public exported from `@promptbook/utils`
|
|
476
|
+
*/
|
|
477
|
+
function normalizeTo_SCREAMING_CASE(text) {
|
|
478
|
+
var e_1, _a;
|
|
479
|
+
var charType;
|
|
480
|
+
var lastCharType = 'OTHER';
|
|
481
|
+
var normalizedName = '';
|
|
482
|
+
try {
|
|
483
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
484
|
+
var char = text_1_1.value;
|
|
485
|
+
var normalizedChar = void 0;
|
|
486
|
+
if (/^[a-z]$/.test(char)) {
|
|
487
|
+
charType = 'LOWERCASE';
|
|
488
|
+
normalizedChar = char.toUpperCase();
|
|
489
|
+
}
|
|
490
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
491
|
+
charType = 'UPPERCASE';
|
|
492
|
+
normalizedChar = char;
|
|
493
|
+
}
|
|
494
|
+
else if (/^[0-9]$/.test(char)) {
|
|
495
|
+
charType = 'NUMBER';
|
|
496
|
+
normalizedChar = char;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
charType = 'OTHER';
|
|
500
|
+
normalizedChar = '_';
|
|
501
|
+
}
|
|
502
|
+
if (charType !== lastCharType &&
|
|
503
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
504
|
+
!(lastCharType === 'NUMBER') &&
|
|
505
|
+
!(charType === 'NUMBER')) {
|
|
506
|
+
normalizedName += '_';
|
|
507
|
+
}
|
|
508
|
+
normalizedName += normalizedChar;
|
|
509
|
+
lastCharType = charType;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
513
|
+
finally {
|
|
514
|
+
try {
|
|
515
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
516
|
+
}
|
|
517
|
+
finally { if (e_1) throw e_1.error; }
|
|
518
|
+
}
|
|
519
|
+
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
520
|
+
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
521
|
+
normalizedName = normalizedName.replace(/^_/, '');
|
|
522
|
+
normalizedName = normalizedName.replace(/_$/, '');
|
|
523
|
+
return normalizedName;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* TODO: Tests
|
|
527
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
528
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
529
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
530
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
531
|
+
* TODO: [🌺] Use some intermediate util splitWords
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* @@@
|
|
536
|
+
*
|
|
537
|
+
* @param text @@@
|
|
538
|
+
* @returns @@@
|
|
539
|
+
* @example 'hello_world'
|
|
540
|
+
* @example 'i_love_promptbook'
|
|
541
|
+
* @public exported from `@promptbook/utils`
|
|
542
|
+
*/
|
|
543
|
+
function normalizeTo_snake_case(text) {
|
|
544
|
+
return normalizeTo_SCREAMING_CASE(text).toLowerCase();
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Register is @@@
|
|
549
|
+
*
|
|
550
|
+
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
551
|
+
*
|
|
552
|
+
* @private internal utility, exported are only signleton instances of this class
|
|
553
|
+
*/
|
|
554
|
+
var $Register = /** @class */ (function () {
|
|
555
|
+
function $Register(registerName) {
|
|
556
|
+
this.registerName = registerName;
|
|
557
|
+
var storageName = "_promptbook_".concat(normalizeTo_snake_case(registerName));
|
|
558
|
+
var globalScope = $getGlobalScope();
|
|
559
|
+
if (globalScope[storageName] === undefined) {
|
|
560
|
+
globalScope[storageName] = [];
|
|
561
|
+
}
|
|
562
|
+
else if (!Array.isArray(globalScope[storageName])) {
|
|
563
|
+
throw new UnexpectedError("Expected (global) ".concat(storageName, " to be an array, but got ").concat(typeof globalScope[storageName]));
|
|
564
|
+
}
|
|
565
|
+
this.storage = globalScope[storageName];
|
|
566
|
+
}
|
|
567
|
+
$Register.prototype.list = function () {
|
|
568
|
+
// <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
|
|
569
|
+
return this.storage;
|
|
570
|
+
};
|
|
571
|
+
$Register.prototype.register = function (registered) {
|
|
572
|
+
var packageName = registered.packageName, className = registered.className;
|
|
573
|
+
var existingRegistrationIndex = this.storage.findIndex(function (item) { return item.packageName === packageName && item.className === className; });
|
|
574
|
+
var existingRegistration = this.storage[existingRegistrationIndex];
|
|
575
|
+
if (!existingRegistration) {
|
|
576
|
+
this.storage.push(registered);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
this.storage[existingRegistrationIndex] = registered;
|
|
580
|
+
}
|
|
581
|
+
return {
|
|
582
|
+
registerName: this.registerName,
|
|
583
|
+
packageName: packageName,
|
|
584
|
+
className: className,
|
|
585
|
+
get isDestroyed() {
|
|
586
|
+
return false;
|
|
587
|
+
},
|
|
588
|
+
destroy: function () {
|
|
589
|
+
throw new NotYetImplementedError("Registration to ".concat(this.registerName, " is permanent in this version of Promptbook"));
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
};
|
|
593
|
+
return $Register;
|
|
594
|
+
}());
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @@@
|
|
598
|
+
*
|
|
599
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
600
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
601
|
+
* @public exported from `@promptbook/core`
|
|
602
|
+
*/
|
|
603
|
+
var $scrapersRegister = new $Register('scraper_constructors');
|
|
604
|
+
/**
|
|
605
|
+
* TODO: [®] DRY Register logic
|
|
606
|
+
*/
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @@@
|
|
610
|
+
*
|
|
611
|
+
* 1) @@@
|
|
612
|
+
* 2) @@@
|
|
613
|
+
*
|
|
614
|
+
* @public exported from `@promptbook/browser`
|
|
615
|
+
*/
|
|
616
|
+
function $provideScrapersForBrowser(tools, options) {
|
|
617
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
618
|
+
var isAutoInstalled /* Note: [0] Intentionally not assigning a default value = IS_AUTO_INSTALLED */, scrapers, _a, _b, scraperFactory, scraper, e_1_1;
|
|
619
|
+
var e_1, _c;
|
|
620
|
+
return __generator(this, function (_d) {
|
|
621
|
+
switch (_d.label) {
|
|
622
|
+
case 0:
|
|
623
|
+
if (!$isRunningInBrowser() || $isRunningInWebWorker()) {
|
|
624
|
+
throw new EnvironmentMismatchError('Function `$provideScrapersForBrowser` works only in browser environment');
|
|
625
|
+
}
|
|
626
|
+
isAutoInstalled = (options || {}).isAutoInstalled;
|
|
627
|
+
if (isAutoInstalled === true /* <- Note: [0] Ignoring undefined, just checking EXPLICIT requirement for install */) {
|
|
628
|
+
throw new EnvironmentMismatchError('Auto-installing is not supported in browser environment');
|
|
629
|
+
}
|
|
630
|
+
scrapers = [];
|
|
631
|
+
_d.label = 1;
|
|
632
|
+
case 1:
|
|
633
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
634
|
+
_a = __values($scrapersRegister.list()), _b = _a.next();
|
|
635
|
+
_d.label = 2;
|
|
636
|
+
case 2:
|
|
637
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
638
|
+
scraperFactory = _b.value;
|
|
639
|
+
return [4 /*yield*/, scraperFactory(tools, options || {})];
|
|
640
|
+
case 3:
|
|
641
|
+
scraper = _d.sent();
|
|
642
|
+
scrapers.push(scraper);
|
|
643
|
+
_d.label = 4;
|
|
644
|
+
case 4:
|
|
645
|
+
_b = _a.next();
|
|
646
|
+
return [3 /*break*/, 2];
|
|
647
|
+
case 5: return [3 /*break*/, 8];
|
|
648
|
+
case 6:
|
|
649
|
+
e_1_1 = _d.sent();
|
|
650
|
+
e_1 = { error: e_1_1 };
|
|
651
|
+
return [3 /*break*/, 8];
|
|
652
|
+
case 7:
|
|
653
|
+
try {
|
|
654
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
655
|
+
}
|
|
656
|
+
finally { if (e_1) throw e_1.error; }
|
|
657
|
+
return [7 /*endfinally*/];
|
|
658
|
+
case 8: return [2 /*return*/, scrapers];
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
423
664
|
/**
|
|
424
665
|
* Tests if the value is [🚉] serializable as JSON
|
|
425
666
|
*
|
|
@@ -525,7 +766,7 @@
|
|
|
525
766
|
return makePromptbookStorageFromWebStorage(localStorage);
|
|
526
767
|
}
|
|
527
768
|
/**
|
|
528
|
-
* Note: [🔵]
|
|
769
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
529
770
|
*/
|
|
530
771
|
|
|
531
772
|
/**
|
|
@@ -540,9 +781,10 @@
|
|
|
540
781
|
return makePromptbookStorageFromWebStorage(sessionStorage);
|
|
541
782
|
}
|
|
542
783
|
/**
|
|
543
|
-
* Note: [🔵]
|
|
784
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
544
785
|
*/
|
|
545
786
|
|
|
787
|
+
exports.$provideScrapersForBrowser = $provideScrapersForBrowser;
|
|
546
788
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
547
789
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
548
790
|
exports.getLocalStorage = getLocalStorage;
|