How to use the @teleporthq/teleport-shared.Constants.ASSETS_IDENTIFIER function in @teleporthq/teleport-shared

To help you get started, we’ve selected a few @teleporthq/teleport-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teleporthq / teleport-code-generators / packages / teleport-uidl-resolver / src / utils.ts View on Github external
acc[styleKey] = styleValue
        return acc
      case 'static':
        const staticContent = styleValue.content
        if (typeof staticContent === 'number') {
          acc[styleKey] = styleValue
          return acc
        }

        if (
          typeof staticContent === 'string' &&
          STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
          staticContent.includes(Constants.ASSETS_IDENTIFIER)
        ) {
          // split the string at the beginning of the ASSETS_IDENTIFIER string
          const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
          const newStyleValue =
            staticContent.slice(0, startIndex) +
            UIDLUtils.prefixAssetsPath(
              assetsPrefix,
              staticContent.slice(startIndex, staticContent.length)
            )
          acc[styleKey] = {
            type: 'static',
            content: newStyleValue,
          }
        } else {
          acc[styleKey] = styleValue
        }
        return acc
      case 'nested-style':
        acc[styleKey] = styleValue
github teleporthq / teleport-code-generators / packages / teleport-code-generator / src / index.ts View on Github external
const projectTemplate =
    projectType === ProjectType.PREACT && publisher === PublisherType.CODESANDBOX
      ? PreactCodesandBoxTemplate
      : templates[projectType]

  if (!projectGeneratorFactory) {
    throw new InvalidProjectTypeError(projectType)
  }

  if (publisher && !projectPublisherFactories[publisher]) {
    throw new InvalidPublisherTypeError(publisher)
  }

  packer.setAssets({
    assets,
    path: [Constants.ASSETS_IDENTIFIER],
  })

  packer.setGenerator(projectGeneratorFactory())
  packer.setTemplate(projectTemplate)

  // If no publisher is provided, the packer will return the generated project
  if (publisher) {
    const publisherFactory = projectPublisherFactories[publisher]
    const projectPublisher = publisherFactory(publishOptions)
    packer.setPublisher(projectPublisher)
  }

  return packer.pack(projectUIDL)
}
github teleporthq / teleport-code-generators / packages / teleport-uidl-resolver / src / utils.ts View on Github external
switch (styleValue.type) {
      case 'dynamic':
        acc[styleKey] = styleValue
        return acc
      case 'static':
        const staticContent = styleValue.content
        if (typeof staticContent === 'number') {
          acc[styleKey] = styleValue
          return acc
        }

        if (
          typeof staticContent === 'string' &&
          STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
          staticContent.includes(Constants.ASSETS_IDENTIFIER)
        ) {
          // split the string at the beginning of the ASSETS_IDENTIFIER string
          const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
          const newStyleValue =
            staticContent.slice(0, startIndex) +
            UIDLUtils.prefixAssetsPath(
              assetsPrefix,
              staticContent.slice(startIndex, staticContent.length)
            )
          acc[styleKey] = {
            type: 'static',
            content: newStyleValue,
          }
        } else {
          acc[styleKey] = styleValue
        }